Docker on CrunchBang

Was just trying to get docker installed on CrunchBang Linux waldorf without much success and came across this post by Wil Tan. Basically…

echo deb docker main | sudo tee /etc/apt/sources.list.d/docker.list
sudo apt-key adv --keyserver --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sudo apt-get update
sudo apt-get install -y lxc-docker


Yeoman Angular Bootstrap SASS compilation error

I’ve recently been doing some front-end-focused web development on a jMVC-style project which has lead me to have a look at some of the more recent front-end technologies that are abounding at the minute. After some experimentation and reading I decided that AngularJS looked to be a very cool way to go. So after a little reading on the Angular site, I hunted out a ‘Getting Started’ tutorial which would include some decent workflow (I went with Kickstart Your AngularJS Development with Yeoman, Grunt and Bower), which opened me up to Yeoman and friends.

All was looking good – I’d even managed to sidestep a few issues (these things move incredibly fast). Then I came to actually getting something in my browser…

grunt serve

But I was met with the following:

error app/styles/main.scss (Line 121 of app/bower_components/sass-bootstrap/lib/_mixins.scss: Invalid CSS after "...-shadow($shadow": expected ")", was "...) {")

Googling this error (at least when I did it) really didn’t help, though happily the solution turned out to be fairly reasonable – it would appear my sass was a bit out of date. I tried doing a

sudo gem update

but that didn’t work, so it occurred to me I might have installed my distro packages for sass and compass a while back (I don’t do that much front-end dev :)). I found the procedure to remedy the situation in this answer on In a nutshell:

sass --version # Sass 3.1.19 (Brainy Betty)
which sass # /usr/bin/sass
apt-get remove ruby-sass ruby-compass
apt-get install ruby-full 
gem install sass 
gem install compass
sass --version # Sass 3.2.7 (Media Mark)
which sass # /usr/local/bin/sass

Now I can

grunt serve

with no errors. Nice!

Powerful raw data viewing with “od”

I remember a few years ago using a command line tool called hexcat, which gave a great view into raw file data when you were suspicious of stray bytes or just curious as to exactly what a file contained. It turned out that this wasn’t bundled in standard distributions and, for one reason or another, I never got round to finding a substitute.

Recently, by chance, I came across the exact thing – “od” (think “octal dump”, because that’s it’s default output format). You can do a lot of cool things with this tool. Output hex and char stacked…

$ echo 'Hello World!' | od -t c -t x1
0000000   H   e   l   l   o       W   o   r   l   d   !  \n
         48  65  6c  6c  6f  20  57  6f  72  6c  64  21  0a

or get a 4 byte random unsigned int :)

$ dd if=/dev/urandom count=4 bs=1 2>/dev/null | od -A none -t u4

Converting Unix Timestamp fields in a Log File from the Shell

I recently wanted to get a view on the date/times of entries in some Nagios logs I was working with in the shell, e.g. when did their entries start and end, etc. The logs are tab-delimited with a Unix timestamp in the first field. Googling around led me to the following nifty technique using awk:

$ head service-event.out | awk '{print strftime("%c",$1)}'
Thu, Jan 31, 2013  9:49:20 PM
Thu, Jan 31, 2013  9:51:23 PM
Thu, Jan 31, 2013 10:21:03 PM
Thu, Jan 31, 2013 10:23:03 PM
Fri, Feb 01, 2013 10:07:55 AM
Fri, Feb 01, 2013 10:09:55 AM
Fri, Feb 01, 2013 10:36:18 AM
Fri, Feb 01, 2013 10:38:18 AM
Fri, Feb 01, 2013 11:40:58 AM
Fri, Feb 01, 2013 11:41:19 AM

Low Widescreen Resolution in Lubuntu

I recently installed Lubuntu on my old laptop and got around to addressing something that has bugged me for a while – the lack of available low widescreen resolutions.  I understand that for most people, this isn’t an issue and most people tend towards the higher resolutions, but limited eyesight is never more a problem than when you’re trying to use a laptop.

I was able to drop my resolution to 640×480 without much difficulty using the Display Settings GUI, but of course that pillar-boxes on my widescreen display, so I set about looking into whether I could force the issue and get a widescreen resolution working.  Some Googling led me to the xrandr and cvt tools.

Creating and testing new screen resolutions

With my screen at 480 pixels high, I wanted to figure out how wide it would be to fill my display, so using the mathematics and the fact that my system detected a WXGA+ 1440×900 resolution, I got 480*(1440/900) = 768. Putting these figures through cvt, we get the following modeline:

brendan@ubuntu:~$ cvt 768 480
# 768x480 59.90 Hz (CVT 0.37MA) hsync: 29.95 kHz; pclk: 28.75 MHz
Modeline "768x480_60.00"   28.75  768 792 864 960  480 483 489 500 -hsync +vsync

We then make the new resolution available using xrandr, copying the data from the modeline above…

brendan@ubuntu:~$ xrandr --newmode "768x480_60.00"   28.75  768 792 864 960  480 483 489 500 -hsync +vsync
brendan@ubuntu:~$ xrandr --addmode LVDS1 768x480_60.00

… and switch to it:

brendan@ubuntu:~$ xrandr --output LVDS1 --mode 768x480_60.00

Ah, glorious lo-res! Let’s create another out of interest using the same technique – this very low res looked pretty dreadful but it’s nice to know it can be done.

$ cvt 320 200
$ xrandr --newmode "320x200_60.00"    5.00  320 336 360 400  200 203 209 212 -hsync +vsync
$ xrandr --addmode LVDS1 320x200_60.00
$ xrandr --output LVDS1 --mode 320x200_60.00

Making the new resolutions persistent

All our hard work in the terminal won’t survive a reboot, so we must do a bit more to make the changes permanent. While there are various ways of doing this, such as scripting the above to run at login, consensus seems to be that it’s best to do this at the X config level, as the new resolutions will be available earlier in the startup process.

It’s been a while since I looked at an xorg.conf file, so I was surprised to see that it no longer exists by default in *buntu. However, there are a set of conf files at /usr/share/X11/xorg.conf.d/ so I created a file there called 10-screen.conf and added the following:

Section "Monitor"
    Identifier    "Monitor0"
    Modeline "320x200_60.00"    5.00  320 336 360 400  200 203 209 212 -hsync +vsync
    Modeline "768x480_60.00"   28.75  768 792 864 960  480 483 489 500 -hsync +vsync
    Modeline "960x600_60.00"   45.25  960 992 1088 1216  600 603 609 624 -hsync +vsync
    Option "PreferredMode" "768x480_60.00"

Section "Screen"
    Identifier     "Screen0"
    Device         "Card0"
    Monitor        "Monitor0"
    SubSection "Display"
        Modes       "320x200_60.00" "768x480_60.00" "1440x900"

Section "Device"
    Identifier    "Card0"
    Driver        "i915"

The main things to note are the Modeline directives in the Monitor section – these are just the output given to us by cvt. As you can see I added another slightly higher resolution at 960×600. Also the PreferredMode option in the same block, which will be the default resolution. Also the Driver directive in the Device section. If you’re not sure which driver your using, you can obtain this by doing:

$ lshw -class display | grep driver

Now you can logout or reboot and have the X server restart with the new resolutions available. Enjoy the lo-res goodness!

The Move To WordPress

Hi, and if Google Analytics are anything to go by, noone is reading this.

So I’ve waved a fond farewell to the old – a woefully neglected site powered by Pivot, and moved into the bright new future of WordPress.  I wonder if I’ll post any more than on the previous site?  I think on average it was a post every 2.7 years.

Shouldn’t be hard to beat…