Changing the Default Encoding of SQL files in SSMS


The default encoding for SSMS sql files is UTF-16, more specifically, either Western European (Windows) - Codepage 1252 or Unicode - Codepage 1200. These encodings play havoc with a git diff as these encoding appear as binary files.

The preferred encoding is Unicode (UTF-8 with asignature) - Codepage 65001

Steps to resolve

  1. From within SSMS, open the sql template file named SQLFile.sql, by default in one of these locations: –
    1. %ProgramFiles%\Microsoft SQL Server\[Sql Version]\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\
    2. %ProgramFiles(x86)%\Microsoft SQL Server\[Sql Version]\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\
    3. %ProgramFiles%\Microsoft SQL Server\[Sql Version]\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql
    4. %ProgramFiles(x86)%\Microsoft SQL Server\[Sql Version]\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql
  2. Resave using correct encoding:
    1. File => Save As
    2. Click the arrow next to the Save button
    3. Choose the relevant encoding: Unicode (UTF-8 with asignature) - Codepage 65001

All new query windows will default to UTF-8 files

Cortana not working after Windows 10 Anniversary Edition update

For all of you out there that have struggled to get Cortana and the Start Menu searching to work after installing Windows 10 Anniversary Edition update, there is hope!

My environment

  • Mac OS – Sierra 10.12.2
  • Parallels 12.1.12
  • Windows 10 Pro x64 – 10.0.14393 N/A Build 14393
  • Hotfixes:-
    • KB3176935
    • KB3176936
    • KB3176937
    • KB3199209
    • KB3199986
    • KB3214628
    • KB3213986

The solution

This may sound strange, and I do not claim to know what the root cause is, but this is a sure-fire fix that I have proven to work on multiple machines.

Simply create two dummy User Accounts, and log into each of them. Yes, you heard/read correctly, two accounts, no less. You must log into each one to establish their profiles. Once you create and log into each one, you can log out and back into your main account, and hey presto! Cortana and your Start Menu search will be full functional again. I know – it’s weird – but it works!

You can safely remove the two dummy accounts and their home directories.

Post Mortem

I am sure someone out there can explain the root cause, and why it takes no less than two dummy accounts to resolve the issue. Honestly, you would think that one dummy account might reset a pointer/setting/registry entry/file/????? somewhere and that would be enough. I don’t know, and frankly, I am not sure I have the time or energy to work out why.

Hope that helps someone!

Force single user mode from the Terminal command line

Taken with thanks from this StackOverflow post:

Open and enter:

sudo nvram boot-args="-s"

In the future your Mac will always boot to single user mode until you remove (sudo nvram -d boot-args or sudo nvram boot-args="") or replace the boot-args.

Other boot-args directly modifying the boot mode:

sudo nvram boot-args="-v": verbose
sudo nvram boot-args="-x": safe mode

git Cheat Sheet

Command line tools

Download git command line tools for Windows:

Command line tips

Create a branch and switch to it

git checkout -b branchname 

Switch branches

git checkout branchname

Push to remote repo

git push origin branchname 

Merging branches

Be sure to commit and push branch to remote repo first for completeness
git checkout master
git merge branchname

Delete local branch

git branch -d branchname

Delete remote branch

git push origin :branchname  (watch for the colon)

Undo a branch merge

git reset --hard SHA1__Commit_Prior_to_Merge

Sync all remote branches

git remote update
git fetch --all
git pull --all
If that fails, do it one-by-one manually:
git checkout -b <local branch> <remote>/<remote branch>

Saving Credentials

git config credential.helper store

Cloning a Remote Git Repo

git clone <remote_git_url>

Cloning from SVN with Commit History

git svn clone <svn-url>
git remote add origin <remote_git_url>
git push origin master
Remember to add a .gitignore file

Reverting the current repo back to a previous commit

git reset --hard <commit-id>
(reset without –hard only resets the history. –hard also resets the files)

Reverting a single file from a known specific commit

git checkout <commit-id> <file-path-to-restore>

Reverting a specified single file or all files in the path back to the last commit

git checkout -- full-file-path-to-restore>
git checkout -- full-path-to-folder-restore>
To revert ALL uncommitted changes:
git checkout -- . CheatSheet


See also:

Accessing a Remote Git Repo from behind a Proxy Server

It is quite tricky accessing a remote Git Repo when you are stuck behind a corporate HTTP Proxy Firewall. The proxy requires authentication to access the outside world.

Here is how to specify the proxy server settings for Git to negotiate its way out to the remote repo using Windows Authentication:

Git Proxy Server Configuration

git config --global http.proxy http://DOMAIN\\USERNAME:PASSWORD@PROXY_ADDRESS:PROXY_PORT

Mac OSX – Installing a password protected certificate from the command line

This was taken from a very helpful article over at I develop on a lot of machines and transferring Apple developer certificates is an absolute pain! — Thanks Jay! You saved me heaps of time!

If you ever need to install a certificate into the OS X Keychain on a remote machine in such a way that Xcode can sign a build with it, then this command is for you.

security import /tmp/MyCertificates.p12 -P MyPassword

This allows you to not get that annoying “Always Allow” dialog the first time you try to use the cert to sign a build.

Handy .gitignore file for Visual Studio on GitHub

git doesn’t exactly play nicely with Visual Studio (or maybe it’s the other way around).  It probably doesn’t matter who’s fault it is. Fact is, if you add a Visual Studio solution to a git repo, you are bound to end up with a tonne of files you don’t really want in there. Cache files, build files, and all the other VS bloat.

So I went searching for a “prepacked” .gitignore file so I didn’t have to guess all of the file types myself.  So I Googled and got this page on GitHub.

Many thanks to the 240+ contributors to-date for compiling this great resource.



Recover from a lost password on Mac OSX

This article has been copied from ( only to preserve it!   Thank you Paul Horowitz!

This very article saved me after upgrading to Mac OSX Mavericks Preview 4.  The install went fine but then after the reboot, it wouldn’t let me login.  I didn’t forget my password – it just wouldn’t accept it.  After keying in my password, it would think about it for a while and then go back to the login screen.  Even resetting my password on my normal account didn’t help – same result.

Using this article, I was able to create a new admin account using the section titled “Reset Mac Password – without a CD or Boot Drive”.  The new admin account logged in and out just fine, but not my normal user account.  This article ultimately allowed me take back control of my system!  I logged in with the new admin account, ran the software update to Preview 5 and hey-presto! My normal account worked again.  Did I say “thank you Paul Horowitz”?


Forgot Mac Password? How to Reset Your Mac Password (with or without CD)

So you forgot your Mac password… uh oh. Don’t worry, it happens and you aren’t out of luck. You’ll need to reset the forgotten password and there’s several ways to do this, we’ll focus on the three best methods; the first is dirt simple and will utilize the Apple ID (yes, the same on you use for iTunes and App Store purchases), the second method is a hack of sorts and does not require a Mac OS X recovery drive or CD and is guaranteed to be effective, and the third trick is fairly simple but it requires either a Mac OS X DVD, boot disk, or Recovery mode partition to use. Use whichever method works for your situation, but whichever method you choose you will have your password reset and gain access to your stuff again.

forgot mac password

Resetting Lost Mac Passwords with Apple ID

This is the best approach for Mac users running new versions of OS X (Mavericks, Mountain Lion, and Lion) because it’s extremely fast and simple. The only requirements are that you must have tied an Apple ID to a user account, and you must have internet access so that the Mac can contact Apple to initiate the reset procedure.

  • From the Mac login or boot screen, enter any wrong password three times to summon the “Password Hint” box and a message saying “If you forgot your password you can reset it using your Apple ID”… click on that (>) arrow icon to start the Apple ID based reset
  • Enter the Apple ID credentials, this is the same information used to log into the App Store, iTunes, and iCloud, then click “Reset Password”
  • Confirm the new password and let the Mac boot as usual

That was easy, right? Indeed, the Apple ID password option is the fastest and simplest method available to Mac users, and when that option is available it’s the preferential method. But what if you don’t have an Apple ID attached to the Mac account? Or what if you don’t remember that password either, or if there’s no internet access? If you find yourself in a situation where the Apple ID approach is not possible, don’t worry, because that’s what we’ll cover next.

Reset Mac Password – without a CD or Boot Drive

reset mac passwordUsing a pretty nifty trick you can reset a forgotten Mac password without a Mac OS X installer CD/DVD or any kind of boot drive or recovery partiton, and without having an Apple ID. This is basically the be-all-end-all approach if nothing else works, because it’s guaranteed to get you back into a Mac when the other options are available, and it works in literally all versions of OS X. The steps may seem a little intimidating at first but I assure you it’s easy if you follow them exactly, here is exactly how to do this in three stages:

Stage 1) Boot into Single User Mode and remove a setup file

    • Restart the Mac holding down the Command+S keys, this will take you into Single User Mode and it’s Terminal interface
    • You’ll need to check the filesystem first:

               fsck -fy

    • Next, you must mount the root drive as writeable so that changes will save:

               mount -uw /

    • Now, type the following command exactly, followed by the enter key:

               rm /var/db/.applesetupdone
reset forgot mac password

  • After removing the applesetupdone file, you need to reboot, type ‘reboot’ and hit enter

Stage 2) Create a New User Account upon System Boot
You aren’t finished, but the hard part is now over – no more command lines, you’ll now be in the familiar Mac OS X GUI to finish the password reset process. In this step we just create a new user account as if you just got a new Mac:

  • Upon reboot, you will be presented with the traditional “Welcome Wizard” startup screen just like when you first get a Mac
  • Follow the welcome wizard and create a new user account – making the account name different from the account whose password you want to recover
  • Continue on and boot into Mac OS X with this newly created user account, this new user account is an Administrator and has administrative access

Stage 3) Reset the Forgot Password via System Preferences
You are almost done, now you just need to reset the forgotten user account password using the Accounts control panel:

  • Once you are booted into Mac OS X, click on the Apple logo and then navigate down to “System Preferences”
  • Click on the “Accounts” icon in System Preferences
  • Click on the Lock icon in the lower left corner of the “Accounts” preference window and enter the newly created user credentials, this enables you to change other user accounts and reset other users passwords
  • On the left side user panel, select the user account containing the forgotten password
  • With the user of the forgotten password account selected, click on the “Reset Password” button
  • Enter a new password for that user, be sure to include a meaningful hint so you don’t forget it again!
  • Close System Preferences and reboot the Mac
  • You can now login to the previously inaccessible user account using the newly reset password! All user files and settings are maintained as before the password was forgotten

Optional: If you’d like, you can delete the temporary account you created to reset the users password. This is wise for security purposes.

Here’s how this works: by deleting the .applesetupdone file, you are telling Mac OS X to re-run the setup wizard, which by default creates a new user account with Administrative abilities, which can then reset the forgotten password of any other user on the Mac. This is a great trick and excellent troubleshooting technique if you don’t have a Mac OS X installer CD/DVD laying around, which is pretty much the norm as many people tend to lose or misplace the installer disks that come with their computers. I have used this exact method multiple times to restore various Macs with forgotten/lost passwords.

Reset Mac Password – with installer CD/DVD, boot drive, or Recovery Mode Partition

reset forgotten mac passwordResetting a forgotten Mac password is pretty easy if you have an installer disk, drive, or the recovery partition handy, which method you use here will depend on the version of OS X the Mac is running.

For OS X Mavericks (10.9), Mountain Lion (10.8), and Lion (10.7) with Recovery Mode:

  • Boot into the Mac OS X boot loader menu by holding down the OPTION key at system start
  • Choose the Recovery drive to boot into recovery mode and wait until the “Utilities” screen appears
  • Pull down the “Utilities” menu and choose “Terminal”
  • At the command line, type “resetpassword” without the quotes
  • Confirm the new account password, then reboot the Mac as usual

For Mac OS X Snow Leopard (10.6), Leopard (10.5), and before with install DVD/CD:

  • Insert the bootable DVD into the Mac and restart or start the computer
  • Boot the disk by holding down the “C” key at system start
  • Select your language preferences and then under the “Utilities” menu select “Password Reset” (it may say “Reset Password” instead, depends on the version of Mac OS X)
  • Select the hard disk that the forgotten password is on, then select the username of the forgotten password, you’ll then be asked to select a new password
  • Reboot as usual from the hard drive, using your newly reset password as the login!

This older trick is borrowed from our article on how to reset a lost password with a CD.

These boot menu methods are obviously easier than the #2 manual trick, but whether or not they will work for your depends on if you have a recovery partition (all new Macs do), or with older Macs, if you have a DVD installer laying around. Because we’ve covered solutions for every possible situation though, one of these options will work for you to reset that password and be using the Mac again.

Lazy unix command line script

I don’t know about you, but as a developer, I can’t count how many times a day I use the command on my Mac Terminal command-line:

ls -al directoryname

By definition, as a developer, I am lazy and I’m tired of typing that command. So I came up with an easy alternative:-

l directoryname

Back in the early 90’s, one of the flavours of SCO Unix had this command and I kinda miss it, so I recreated it very easily here:-

sudo echo "ls -al $*" > /bin/l
sudo chmod +x /bin/l

You’re done. Now you can simply use l directoryname or any other variation on the ls command to list your files.