Oct 26, 2013

Fixing Home and End keys for both Terminal and Vim in Mac OS X (Snow Lion)

Multiple posts on the Internet describe ways to fix Home, End, Page Up and Page Down buttons in OS X Terminal application, which don’t work there by default. While this particular post helped me fix these shortcuts for the Terminal itself, Home and End still didn't work in Vim, especially in the INSERT mode. After going through several  posts and comments I found the sequence that worked for both. Here are my results.

First, follow these steps to fix Home, End, Page Up and Page Down in the Terminal itself. Below are the codes you should end up with for the Terminal:

Home \001
End \005
Page Up \033[5~
Page Down \033[6~


Next, add the  following lines to your ~/.vimrc file:

" End
map <C-E> <End>
imap <C-E> <C-O><End>
" Home
map <C-A> <Home>
imap <C-A> <C-O><Home>

Restart all Terminal and Vim instances, and Home and End buttons should work in both.

Aug 3, 2013

Merging .NET assemblies into one executable with ILMerge (and why do it)

At my start-up we’ve built our own installer for the Windows desktop part of our application. The goal was an ability to push silent updates with no user disruptions (i.e. similar to Google Chrome). In fact, we treat out desktop app as web app - it’s always of the latest version, and the process of updating it is an irrelevant detail from the user’s perspective. After all, our users don’t care how we update our web app – do we use file copy, pull from Git, or some other process? Nobody cares as longs as it works.

To achieve this goal we used an excellent open source project DDay Update as a starting point. It works in a simple fashion. The user downloads a single EXE file – a bootstrapper. The bootstrapper then connects to our server and downloads the rest of the app and launches it. For auto-updates, the bootstrapper regularly checks our web site for new versions. If there’s one, it repeats the steps above. The installation and auto-updates are essentially the same process.

Which brings me to the subject of this post. The bootstrapper project consists of a primary app (EXE) and several assemblies (DLLs). But, in this configuration it wouldn’t work for us since we want the user to download a single executable file to run. ILMerge solves this problem.

ILMerge is a free command line tool from Microsoft Research. Its syntax is simple:

   1: ilmerge /target:winexe /out:SelfContainedProgram.exe Program.exe ClassLibrary1.dll ClassLibrary2.dll

ILMerge doesn't ship with Visual Studio or any Microsoft SDKs, so you need to manually download it from the Microsoft Research web site. For additional details and examples I recommend this article on Code Project.