Thomas James Just a geek.

Technology, Gadgetry, Photography and Software Development

 

Latest Posts

DocPad & a new layout

by

I've been wanting to redesign the layout & theme of this blog for quite some time. It was dated. With the task of developing a custom wordpress theme ahead of me, I looked at other options. Static site generators that use existing templating libraries & markdown sounded like a good way to go, and allowed me to avoid having to learn to create a wordpress theme at the same time. The frontrunners I considered were Jekyll, Octopress & DocPad.

I decided to go with the following:

Although I chose not to use Jekyll, I found Hadi Hariri's article Migrating from WordPress.com to Jekyll quite helpful in planning out the move to docpad. It gave me a number of things to consider, much of it applying to docpad, including migraing existing content to markdown, which can be consumed almost as-is by docpad. Some manual cleaning up of the html to markdown converted text was required.

Overall the move to docpad was a pretty smooth one, plugins are required to achieve much of the like-for-like behaviour with the wordpress blog that I desired. This included clean URLs with the publish date in the path, tag/category listing pages & generating RSS feeds. Most plugins work as expected with varying options for customising to your liking.

Tweeting links to posts has become a manual task for the moment though... all in good time

Game of Life as an i386 kernel

by

I wrote this; Game of life implemented as an i386 kernel.

After reading through the excellent Kernel 101 – Let’s write a Kernel post by Arjun Sreedharan, I was motivated. I thought it would be interesting to see how difficult it would be to implement Conway's Game of Life simulation as an extension to what I'd already done as part of the tutorial.

I set myself some goals; that it needed to be interactive & visual.

The kernel implements screen writing, cursor position updating and polling IO for the keyboard.

The screen is updated using the mapped memory method outlined in the tutorial, while the cursor position and the keyboard use C inline asm to read/write to the necessary ports.

I didn't go to the extent of implementing an IRQ based keyboard driver as I just wanted do the minimal to get a working interactive simulation. The simulation also uses a fixed size array thats allocated as part of the program rather than attempting to allocate and manage memory. This certainly limited the data structures available to use and forced me to really think about the most basic algorithm to get the job done.

It's not pretty, efficient or bug free, but it was a fun (re)learning exercise for a weekend. Taking me back to my uni days learning assembler, although much of what I learnt back then I had clearly forgotten.

Some thoughts on where it could go next:

  • interrupt driven keyboard driver
  • scancode to key events & translation into ASCII
  • memory management
  • user driven initial game state (eg using the arrow keys to mark squares as initially live then triggering the simulation run)

Doing the kernel development on a mac also posed some additional challenges in being able to successfully compile and link the kernel, as it was proving imposible to get the GNU linker on the mac. I found that setting up a Vagarantfile and running ubuntu in a virtual machine to perform the build was the easiest way to get around the limitations I ran into.

Create a windows base box for vagrant

by

Using puppet on windows, one thing has been missing for me, being able to iterate quickly with vagrant. There are a number of articles out there that detail a the steps required to create your own windows base box for vagrant, but unfortunately they're a whole bunch of manual steps, which doesn't gel too well with working with an automated environment. So this is my attempt to distil down the steps into as few manual ones as possible.

This has all been tested using the publicly available Windows Server 2008 R2 evaluation VHD for Hyper-V.

The end goal being a vagrant base box that:

  • Includes puppet
  • Has all the necessary setup performed via powershell
  • vagrant up works as expected

You will need the latest versions of the following installed as well:

The Hyper-V VHD unfortunately doesn't work as-is with the default VirtualBox setting used when creating a new VM, so use the following bash script to setup the needed VirtualBox VM. The main change required is connecting the VHD to an IDE Controller not the default SATA one the wizard will create.

Save the gist locally as virtualbox.sh in the directory you want to use as your working folder, the gist will do the following:

  • Boot VM via ./virtualbox.sh script (note, only tested on a mac)
  • Login as Administrator/Pass@word1
  • Allow installation to complete, consent to the reboot
  • Login as Administrator/Pass@word1
  • Set the Timezone
  • Install the VirtualBox Guest Additions
  • Run the vagrant_prepare.ps1 gist from the command shell
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://gist.github.com/tvjames/6750255/raw/33f3a553663b6b6ace77f1eb11ee23d4c58449fd/vagrant_prepare.ps1'))"

Once the preparation script is complete:

  • Activate Windows for 180 days of use.
  • Reset password expiry on administrator
  • Shutdown the VM so that a vagrant base box can be created

Back in the terminal window where virtualbox.sh was run from, execute the following, it will take a while:

NAME=$(basename -s .vhd *.vhd)
VBOX=$(VBoxManage showvminfo "$NAME" | grep "Config file" | cut -d : -f 2 -s | sed 's/^ *//g')
vagrant package --base "${VBOX}" --output windows-server-2008-r2-eval.box
vagrant box add windows-server-2008-r2-eval windows-server-2008-r2-eval.box

If you are rebuilding an earlier box, you'll need to remove the exiting one before running the above commands:

vagrant box remove windows-server-2008-r2-eval

To create your new windows vagrant instance:

vagrant init windows-server-2008-r2-eval
# alter Vagrant file according to https://github.com/WinRb/vagrant-windows
vagrant up

You now have a fully functioning vagrant controlled windows box for the next 180 days, with the puppet provisioner baked in.

Enjoy!