About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Showing posts with label resize. Show all posts
Showing posts with label resize. Show all posts

Sunday, November 09, 2014

Powershell Profile Setup and Resize script on startup

1)Setup your profile for powershell: 

if (!(test-path $profile )) 
{new-item -type file -path $profile -force} 

2)Open up the profile:
Notepad $profile
 
3)Cut and paste resize into notepad and save: 
 
##
## Author   : Roman Kuzmin
## Synopsis : Resize console window/buffer using arrow keys
##

function Size($w, $h)
{
    New-Object System.Management.Automation.Host.Size($w, $h)
}

function resize()
{
Write-Host '[Arrows] resize  [Esc] exit ...'
$ErrorActionPreference = 'SilentlyContinue'
for($ui = $Host.UI.RawUI;;) {
    $b = $ui.BufferSize
    $w = $ui.WindowSize
    switch($ui.ReadKey(6).VirtualKeyCode) {
        37 {
            $w = Size ($w.width - 1) $w.height
            $ui.WindowSize = $w
            $ui.BufferSize = Size $w.width $b.height
            break
        }
        39 {
            $w = Size ($w.width + 1) $w.height
            $ui.BufferSize = Size $w.width $b.height
            $ui.WindowSize = $w
            break
        }
        38 {
            $ui.WindowSize = Size $w.width ($w.height - 1)
            break
        }
        40 {
            $w = Size $w.width ($w.height + 1)
            if ($w.height -gt $b.height) {
                $ui.BufferSize = Size $b.width $w.height
            }
            $ui.WindowSize = $w
            break
        }
        27 {
            return
        }
    }
  }
}
 
 
4) Change policy for the profile, exit powershell and open a new version "Run as Administrator":
Set-ExecutionPolicy bypass -Scope CurrentUser
 
 
5) Close powershell and open a new version, type resize.

Wednesday, January 30, 2013

Quick Note: Resize canvas to browser

Resize canvas to browser's width/height (at least in IE9+), using jQuery:

Code Snippet
  1. <canvas id="myCanvas" width="1600px" height="1200px" style="border: 1px solid #d3d3d3;">Your browser does not support the HTML5 canvas tag.
  2. </canvas>
  3.  
  4. <script type="text/javascript">
  5.     function resizeFrame() {var h = $(window).height();var w = $(window).width();$("#myCanvas").css('height', h - 100); $("#myCanvas").css('width', w - 50);}
  6.  
  7.     $(document).ready(function () {
  8.         jQuery.event.add(window, "load", resizeFrame);
  9.         jQuery.event.add(window, "resize", resizeFrame);
  10.     });
  11.  
  12.     
  13. </script>