Category Archives: code

Learning Bash by Building a Game

Many years ago (summer of 2010) while learning the Bourne Again Shell (Bash) on Linux I decided to build a game for fun. This made learning the cryptic syntax more enjoyable and the hangman game is kind of fun to play.

Today I uploaded the hangman game to Github.

Code Academy has a nice tutorial that teaches one how to use Bash. There’s also a great tutorial here by Mike G on The Linux Documentation Project website. Learn something new!


Using Photoshop and Netflix on Ubuntu 13.04 *Updated*

Update: The following also works on Ubuntu 14.04.

My favourite operating system to use is Ubuntu. Like most people, I grew up using Windows, but seven years ago I started experimenting with Linux while trying to build a webserver. I had an old machine that could manage Debian 3.0 or 3.1 (can’t remember which) and set up Apache on it without the ability to use a GUI. Since building the webserver, I have been moving closer and closer to independence from Windows.

My laptop and desktop computers currently dual boot Windows 7 and Ubuntu 13.04, but I only really logged in to Windows to use Photoshop or to watch Netflix. Recently, thanks to the wonderful work of some excellent people in the Linux community, it is possible to  completely switch from Windows to Linux without sacrificing the use of Photoshop or Netflix!

Netflix on Ubuntu/Debian

This is actually very easy to do so I won’t elaborate much here. Basically you can just go here and follow the instructions. TL;DR installation amounts to:

sudo apt-add-repository ppa:ehoover/compholio
sudo apt-get update
sudo apt-get install netflix-desktop

and then you are done! Wooo!

Photoshop CS6

There are a number of resources online that explain how to install Photoshop in Linux, but my experience trying to install a legitimate copy of CS6 was difficult at best. After a few hours of fiddling, I managed to get it to work. Hopefully my guide will save some time for someone else. Before we start keep in mind that I have only tried this on Ubuntu 13.04 and I will be assuming that you have not installed wine before. I am also assuming that all commands are executed in your home directory.

Installing Wine

First we must install wine. You can do this on the command line via the commands:

sudo add-apt-repository ppa:ubuntu-wine/ppa
sudo apt-get update
sudo apt-get install wine1.5

This should also install a little handy tool called winetricks. You can double check with a:

sudo apt-get install winetricks

Configuring Wine

Next we need to configure wine to emulate Windows XP in 32 bit mode. We do this by running the command:

WINEARCH=win32 WINEPREFIX=~/.wine winecfg

and then change the windows version to “Windows XP”.

Change the windows version to "Windows XP".Make sure that the dnsapi library is set to "Builtin then Native".


Next we must use winetricks to install many different libraries and programs required to run Photoshop. Use the following commands on the command line:

winetricks -q amstream cc580 directx9 d3dx11_42 d3dx9_43 d3dx11_43 dinput dinput8 gecko vcrun2005 vcrun2008 vcrun2010 xact
winetricks -q atmlib gdiplus ie6 vcrun2005sp1 vcrun2008 fontsmooth-rgb corefonts msxml3 msxml6 winhttp wininet

odbc32.dll and odbcint.dll

Next we need to place 2 .dll files in the system32 folder of our wine installation. The .dll files can be downloaded here. Assuming we are in the home directory, we use the following two commands:

cp ~/odbc32.dll ~/.wine/drive_c/windows/system32/
cp ~/odbcint.dll ~/.wine/drive_c/windows/system32/


After copying the .dll files, the next thing to do is the make sure that the correct version of dnsapi.dll is used. To do this we must once again enter the wine config:


Navigate to the “Libraries” tab and look for “*dnsapi”  in the list of libraries. Once found, click edit and then make sure to set the “Builtin then Native” radio button.

Installing Photoshop

Finally, we can now install Photoshop. Insert your CD and then execute the “Set-up.exe” file on the CD. Follow along the instructions on the installer window. Once you get to the installing process, it should fail, but have no fear, because for some strange reason, Photoshop will still install in the background in spite of the error window. Do not close the error window until you are absolutely sure Photoshop has had enough time to install (for me this took almost 10 minutes). You have not installed Photoshop on Ubuntu!

This is the first post

This is the first post for my blog. I will update this later…

And I am now. This blog space will be used for sharing photos, code snippets, and whatever else I feel would be useful to share. For a start, here’s a useful little python script for resizing a directory of images:

def resizeAll(files,maxDim):
    from wand import image
    if isinstance(files,str): files=[files]
    for f in files:
        print "Resizing " + f

The script requires a list of files and the size of the largest dimension to resize the images to. It preserves aspect ratio and saves the resized images to the same directory as the original image was in. Resized images have the same name plus a “_resized” added to the name. This script of course requires the ImageMagick library and the wand python library.