Archive for March, 2011

Code snippets in VIM

Abbreviations in VIM can save some typing when writing texts.

A simple example of a normal abbreviation looks as follows:

:ab foo foobar

Now when you type foo followed by a Space, Enter or Esc key the the text will automatically be expanded to foobar.

When coding it is often desirable to insert a structured piece of text with some placeholders between which we can cycle.

The snipMate plugin for VIM lets you do just that.

For example the if snippet in c++ allows us to type if followed by Tab and produce something like:

if ( ... )

The cursor is automatically placed onto the condition and when we’re done with the condition we can press Tab to jump to the code.

If you want to define your own macros for your own language this is also quite easy. Create a file mylang.snippets in $VIMFILES/snippets and put in something like:

snippet if
	if (${1:/* condition */}) {
		${2:/* code */}

The ${1} means that the cursor will be initially placed here. When pressing tab the cursor will move to ${2} etc.

The values behind the colon are default values which can be accepted when pressing Tab or overwritten by typing something else.

Wednesday, March 16th, 2011 Uncategorized No Comments

Play YouTube videos in VLC

The new VLC allows playing youtube videos with a much lighter load on the resources than flash. To quickly launch a video in VLC from firefox you can map the following AutoHotkey script to a hotkey:

IfWinNotActive, YouTube
  Send, ^l
  Send, ^c
  Send, {Esc}
  Run, C:\Program Files\VideoLAN\VLC\vlc.exe -f %clipboard%

This works best when using together with the FlashBlock plugin to prevent the flash player from starting.

Wednesday, March 9th, 2011 Uncategorized No Comments

stash/unstash with subversion

The following two scripts make it possible to stash (remotely resembles the git stash command) changes and unstash them again.



cd `dirname $0`

if [ "$1" == "" ]; then
svn diff > stash.svndiff
svn diff > $2.svndiff



cd `dirname $0`

if [ "$1" == "" ]; then
patch -p0 -i stash.svndiff
patch -p0 -i $2.svndiff

Wednesday, March 9th, 2011 Uncategorized No Comments

Dell Latitude E6510 with Ubuntu 10.04


  • Press F4 in the install menu and then escape. Add nouveau.modeset=0 after the — on the kernel param line.

Booting first time after installation

  • Before GRUB pops up, keep pressing shift. Once you see GRUB, choose the kernel you want to boot from and then press e. Find the line that says quiet splash and add nouveau.modeset=0 at the end of the line.

Fixing up the nvidia driver

  • Once you booted for the first time, type the following to fix up your nvidia driver:

sudo apt-get --purge remove xserver-xorg-video-nouveau

sudo apt-get install nvidia-current

Fixing up the touchpad

  • Enable the backports repository in synaptic
  • Download the newest 2.6.35 kernel
  • Then do the following:

cd /tmp/
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
apt-get source linux-image-$(uname -r)
cd linux-2.6.35/src/drivers/input/mouse/patch -p0 < /tmp/patch-dell-e6510
make -C /lib/modules/`uname -r`/build M=`pwd` psmouse.ko
sudo rmmod psmouse
sudo cp psmouse.ko /lib/modules/`uname -r`/kernel/drivers/input/mouse/
sudo modprobe psmouse


Friday, March 4th, 2011 Linux, Ubuntu 10.10 1 Comment

Subversion diff and patch

Store the (versioned!!) local changes of your working tree to a file localchanges.diff in your home directory:

svn diff > ~/localchanges.diff

Restore the changes back to your tree:

patch -p0 -i ~/localchanges.diff

Thursday, March 3rd, 2011 Linux, Versioning No Comments