Saturday, April 04, 2015

Installing Source Code Pro true type fonts for Raspbian

As programmer you need good fonts, and I highly recommend Source Code Pro. To install Source Code Pro font for single user account do the following:
  • Download latest release of Source Code Pro fonts
  • Unzip the fonts into the directory: ~/.fonts
  • Update the font cache: fc-cache -vf

I was having problem working out what the semi bold font name was, the following one liner was useful:
fc-list :fontformat=TrueType -f "%{family}\n" | sort -u | less

Add the folllowing in ~/.Xresources to use Size 11 of Source Code Pro semi bold font for xterm:
XTerm*faceName: Source Code Pro,Source Code Pro Semibold
XTerm*faceSize: 11

For the changes in ~/.Xresources to take effect without restarting X, you can do the following:
xrdb -merge ~/.Xresources

And to verify that the changes have took effect, you can do the following:
xrdb -query -all

Saturday, March 07, 2015

Burning RASPBIAN Linux image onto micro sd card

Recently I got Raspberry PI 2 and I got around to burning RASPBIAN image onto micro SD card.

Here is a step by step guide what I did:

Please note that the use of the dd tool can overwrite any partition of your machine. If you specify the wrong device in the instructions below you could delete your primary Linux partition. Please be careful.
  • Run df -h to see what devices are currently mounted.
  • Insert the micro sd card into your computer
  • Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card.On my machine it was listed as /dev/sdb1 . The last part (i.e. 1) is the partition number.
  • Run umount /dev/sdb1 
  • In the terminal, write the image to the card with the command:
sudo dd bs=4M if=2015-02-16-raspbian-wheezy.img of=/dev/sdb
  • Run sync to ensure the write cache is flushed and that it is safe to unmount your SD card.
  • Remove the SD card from the card reader.

I did this all in Virtualbox VM, therefore did not have hard disk space in the VM to dd-ing from the micro SD card back to another image on my hard disk.If I had the hard disk space in the VM I would have done the following to check what had be writtten to the SD card:
sudo dd bs=4M if=/dev/sdb of=from-sd-card.img
sudo truncate --reference 2015-02-16-raspbian-wheezy.img from-sd-card.img
diff -s from-sd-card.img 2015-02-16-raspbian-wheezy.img


diff should report that the files are identical.

Sunday, March 02, 2014

Installing Node.js on Ubuntu 12.04

Download the source of Node.js for Linux. Make sure you have the Ubuntu package 'build-essential' already installed before building Node.js.

You can check if Ubuntu package 'build-essential' is already installed by issuing the following command on the terminal:

suleman@devbox:~$apt-cache policy build-essential 
build-essential:
  Installed: 11.5ubuntu2.1
  Candidate: 11.5ubuntu2.1
  Version table:
 *** 11.5ubuntu2.1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64

The above Installed line indicates, which version of  'build-essential' is installed, if it was not installed then you would have seen something like the following:
build-essential:
  Installed: Installed: (none)
  Candidate: 11.5ubuntu2.1
  Version table:
 *** 11.5ubuntu2.1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64

If you don't have package 'build-essential' installed then please install it:
suleman@devbox:~$sudo apt-get install build-essential

Issue the following commands in the terminal to build Node.js for local use as opposed to system wide use:
suleman@devbox:~$tar xzf node-v0.10.26.tar.gz
suleman@devbox:~$cd node-v0.10.26
suleman@devbox:~/node-v0.10.26$./configure
suleman@devbox:~/node-v0.10.26$make
suleman@devbox:~/node-v0.10.26$mkdir ~/local
suleman@devbox:~/node-v0.10.26$./configure --prefix=~/local
suleman@devbox:~/node-v0.10.26$make && make install

Then  I would add the following in your ~/.bashrc:
export PATH=~/local/bin:$PATH

Either open new terminal or source ~/.bashrc in current terminal and check you have node installed successful:
suleman@devbox:~$node -v
v0.10.26

I installed Node.js for tutorial I was doing on AngularJS, once I have finished this tutorial I am hoping to have look in anger at Node.js for server side programming.

The book Node: Up and Running looks good for Node.js server side programming.