12/30/10

Happy New Year!

Translations by Google Translate API.

LanguageTranslationPhonetic Pronunciation
AfrikaansVoorspoedige Nuwe Jaar!
AlbanianGëzuar Vitin e Ri!
Arabicسنة جديدة سعيدة
ArmenianՇնորհավոր Նոր ՏարիShnorhavor Nor Tari
BelarusianЗ Новым годам!Z Novym hodam!
BulgarianЧестита Нова Година!Chestita Nova Godina!
CatalanFeliç Any Nou!
Chinese Simplified新年快乐Xīnnián kuàilè!
Chinese Traditional新年快樂Xīnnián kuàilè!
CroatianSretna Nova Godina!
CzechŠťastný Nový Rok!
DanishGodt Nytår!
DutchGelukkig Nieuw Jaar!
EstonianHead uut Aastat!
FilipinoMasaya Bagong Taon!
FinnishHyvää Uutta Vuotta!
FrenchJoyeux Nouvel An!
GalicianFeliz Ano!
GermanGlückliches Neues Jahr!
GreekΕυτυχισμένο το Νέο Έτος!Ef̱tychisméno to Néo Étos
Haitian CreoleKontan Ane Nouvo!
Hebrewשנה טובה
Hindiनया साल मुबारक हो!Nayā sāla mubāraka hō!
HungarianBoldog Új Évet!
IcelandicGleðilegt Nýtt Ár!
IndonesianSelamat Tahun Baru!
IrishAthbhliain faoi mhaise daoibh!
ItalianFelice Anno Nuovo!
Japanese明けましておめでとうございますAkemashite omedetōgozaimasu
Korean새해 복 많이saehae bog manh-i
LatvianLaimīgu Jauno gadu!
LithuanianLaimingų Naujųjų Metų!
MacedonianСреќна Нова Година!Sreḱna Nova Godina!
MalaySelamat Tahun Baru!
MalteseSena l-ġdida Kuntenti!
NorwegianGodt Nytt År!
Persianرسید سال نوی خوشی
PolishSzczęśliwego Nowego Roku!
PortugueseFeliz Ano Novo!
RomanianAn Nou Fericit!
RussianС Новым годом!S Novym godom!
SerbianСрећна Нова година!Srećna Nova godina!
SlovakŠťastný Nový Rok!
SlovenianSrečno novo leto!
SpanishFeliz Año Nuevo!
SwahiliFuraha ya Mwaka Mpya!
SwedishGott Nytt År!
Thaiสวัสดีปีใหม่S̄wạs̄dī pī h̄ım̀
TurkishMutlu yıllar!
UkrainianЗ Новим роком!Z Novym rokom!
VietnameseChúc mừng năm mới
WelshBlwyddyn Newydd Dda!
Yiddishגליקלעך ניו יאָר

12/5/10

SQL Server Command Line Utility - SqlCmd

http://msdn.microsoft.com/en-us/library/ms162773.aspx
path: c:\program files\microsoft sql server\100\tools\binn\sqlcmd.exe

powershell examples
- execute command-line query, connect using SQL Server Authentication
  &sqlcmd -S SERVER -d DB -U LOGIN -P 'PASSWORD' -q 'select getdate()'

- execute command-line query, connect using SQL Server Authentication, password prompt
  &sqlcmd -S SERVER -d DB -U LOGIN -q 'select getdate()'

- execute command-line query, connect using Windows Authentication
  &sqlcmd -S SERVER -d DB -E -q 'select getdate()'
    
- execute sql script file
  &sqlcmd -S SERVER -d DB -E -i x:\sql\script1.sql

- execute all sql script files in a folder
  gci x:\sql\ *.* | %{ &sqlcmd -S SERVER -d DB -E -i $_.fullname }
  
- exit or quit

- command-line options
  [-? show syntax summary]
  [-a packetsize]
  [-A dedicated admin connection]
  [-b On error batch abort]
  [-c cmdend]
  [-C Trust Server Certificate]
  [-d use database name]
  [-e echo input]
  [-E trusted connection]
  [-f <codepage> | i:<codepage>[,o:<codepage>]]
  [-h headers]
  [-H hostname]
  [-i inputfile]
  [-I Enable Quoted Identifiers]
  [-k[1|2] remove[replace] control characters]
  [-l login timeout]
  [-L[c] list servers[clean output]]
  [-m errorlevel]
  [-N Encrypt Connection]
  [-o outputfile]
  [-p[1] print statistics[colon format]]
  [-P password]
  [-q "cmdline query"]
  [-Q "cmdline query" and exit]
  [-r[0|1] msgs to stderr]
  [-R use client regional setting]
  [-s colseparator]
  [-S server]
  [-t query timeout]
  [-u unicode output]
  [-U login id]
  [-v var = "value"...]
  [-V severitylevel]
  [-w screen width]
  [-W remove trailing spaces]
  [-x disable variable substitution]
  [-X[1] disable commands, startup script, enviroment variables [and exit]]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-z new password]
  [-Z new password and exit]

11/15/10

PInvoke SetWindowText PowerShell Script

P/Invoke examples for the SetWindowText Windows API Function.
These examples set the window text/title for Notepad.exe.
#get notepad window handle
$notepad = get-process notepad
$notepad.mainWindowHandle //100000, intptr structure

$pinvoke::setWindowText($notepad.mainWindowHandle, "a")

#auto-convert int to intptr
$pinvoke::setWindowText(100000, "b")

#create intptr
#out-null to suppress bool result
$pinvoke::setWindowText((new-object intPtr(100000)), "c") | out-null

$pinvoke::setWindowTextCustomWrapper(100000)

Implementation #1 simply exposes the SetWindowText method, the member definition uses C# syntax.
$pinvoke = add-type -name pinvoke -passThru -memberDefinition @'

[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern bool SetWindowText(IntPtr hwnd, String lpString);

'@

Implementation #2, same as #1 but written on one line.
$pinvoke = add-type -name pinvoke -passThru -memberDefinition '[DllImport("user32.dll", CharSet = CharSet.Auto)]public static extern bool SetWindowText(IntPtr hwnd, String lpString);'

Implementation #3, SetWindowText is private, add custom wrapper method.
$pinvoke = add-type -name pinvoke -passThru -memberDefinition @'

[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern bool SetWindowText(IntPtr hwnd, String lpString);

public static void SetWindowTextCustomWrapper(IntPtr handle)
{
string customText = string.Format("handle: {0}", handle);
SetWindowText(handle, customText);
}

'@


11/3/10

Git Custom Difftool Configuration

Original solution by David Tchepak: Setting up Git difftool on Windows

This example shows the configuration for ExamDiff Pro.
Tested on Windows 7 and msysgit version 1.7.3.1

1. Set the path environment variable to include "c:\program files\git\cmd\;"
2. Create a shell script wrapper file, note the forward slashes in the executable path
#c:\program files\git\cmd\diff.sh
#!/bin/sh
"c:/program files/examdiff pro/examdiff.exe" "$1" "$2" | cat

3. Edit the .gitconfig file
#c:\users\john\.gitconfig
[diff]
tool = examdiff

[difftool "examdiff"]
cmd = diff.sh "$LOCAL" "$REMOTE"
...

4. Verify it works, run the difftool command: git difftool --no-prompt


Setting Windows Path Environment Variable with PowerShell

#get all environment vars
gi env:
(gi env:) | sort name

#get path value
gi env:path
(gi env:path).value
(gi env:path).value.split(';')
(gi env:path).value.split(';') | sort

#set path value (note the "$" prefix)
$env:path = 'c:\windows;c:\windows\system32;'

8/20/10

Visual Studio 2010 Keyboard Shortcuts

v5-11

ctl + R, ctl + R         refactor rename

ctl + alt + R            view web browser

ctl + R, T               run tests in current context
ctl + R, ctl + T         debug tests in current context
ctl + R, A               run all tests in solution
ctl + R, ctl + A         debug all tests in solution

ctl + \, ctl + M         tfs team explorer
alt + V, E, I            tfs view history
alt + V, E, H            tfs view pending changes
alt + V, E, S            tfs view source code explorer

ctl + M, ctl + G         goto mvc view/controller

ctl + I                  incremental search
ctl + shf + I            reverse incremental search
ctl + F3                 find using current selection
ctl + ]                  match braces, opening & closing
ctl + shf + ]            select code between braces

ctl + M, ctl + H         hide selection
ctl + M, ctl + U         unhide selection
ctl + M, ctl + O         collapse to definitions
ctl + M, ctl + T         collapse tag - htm, aspx
ctl + M, ctl + M         toggle outline expansion, current section
ctl + M, ctl + L         toggle all outlining
ctl + K, ctl + K         toggle bookmark
ctl + E, ctl + W         toggle word wrap

ctl + K, ctl + C         comment selection
ctl + K, ctl + U         uncomment selection

ctl + K, ctl + X         code snippet
ctl + K, ctl + B         code snippet manager
ctl + shf + U            uppercase selection
ctl + U                  lowercase selection

ctl + alt + O            output window
ctl + alt + C            call stack
ctl + alt + I            immediate window
ctl + alt + A            command window

ctl + alt + T            document outline window, use w/htm files
ctl + alt + U            modules window

ctl + \, E               error list window
ctl + \, ctl + E         error list window

ctl + alt + V, A         autos window
ctl + alt + V, L         locals window
shf + F9                 quick watch
ctl + alt + W, 1         watch 1 window (1-4)
ctl + alt + B            breakpoints window
ctl + F9                 toggle enable breakpoint
ctl + shf + F9           delete all breakpoints

ctl + K, ctl + W         bookmark window
ctr + \, D               code definition window

ctl + -                  navigate backward
ctl + shf + -            navigate forward
ctl + F6                 navigate open windows forward
ctl + shf + F6           navigate open windows backward

ctl + tab                select open windows dialog
ctl + shf + tab          select open windows dialog backward
ctl + alt + down arrow   list open documents
ctl + alt + P            attach to process

shf + alt + enter        toggle full screen
alt + U                  restore from full screen
ctl + f2                 focus on navigation bar
alt + W, W               show windows window
alt + -                  show float/dock window menu

F5                       start debugging
ctl + F5                 start without debugging
shf + F5                 stop debugging
alt + num + *            show next statement
ctl + shf + F10          set next statement
ctl + F10                run to cursor
shf + F10                context menu, popup

ctl + shf + B            build solution
alt + B, R               rebuild solution
alt + B, U               build current project
alt + B, E               rebuild current project
alt + B, G               build webform page/user control
ctl + break              cancel build

ctl + alt + L            view solution explorer, highlight active file
alt + enter              show file properties/property pages for active item in solution explorer
shf + F4                 show property pages for active project/solution in solution explorer
F4                       show file properties for active item in solution explorer

ctl + F4                 close active code window
F9                       toggle breakpoint
F10                      debug step over
F11                      debug step into
shf + F11                debug step out
f12                      goto definition
ctl + alt + J            object browser
ctl + alt + S            server explorer

//command window (ctl + alt + A)
File.Close               closes currently selected window, including solution explorer
File.TfsHistory          tfs history for currently selected file
View.F#Interactive       f# interactive

//F#
ctl + alt + F            f# interactive
alt + enter              send selected code to f# interactive

//SQL
ctl + shf + E            execute sql
ctl + F5                 validate sql syntax
ctl + shf + alt + R      show/hide sql results pane, toggle
ctl + T                  show results as text
ctl + shf + E            show results as grid

5/18/10

Blocking Websites with the Hosts File

#v5-12
#http://blog.expressionsoftware.com/2010/05/ad-block-host-file-entries.html

#mac
#  path: /etc/hosts
#  ls -1alt /etc/hosts*
#  head -20 /etc/hosts

#windows
#  path: C:\windows\system32\drivers\etc\hosts
#  gci C:\windows\system32\drivers\etc\hosts* -force
#  gc C:\windows\system32\drivers\etc\hosts | select -first 20

127.0.0.1 spam.com
127.0.0.1 f.ads.com
127.0.0.1 www.msn.com