The Irish Penguin Watching Open Source unfold across Ireland

18Sep/0910

Open Letter to the Irish Government on Open Source Driven Innovation

"Recent years show that openness and collaboration is essential to the generation of innovation in the software sector. Technology increasingly means software. In Ireland, we can see that the production of hardware technology in many, but not all, cases is providing ever diminishing returns. Here we outline some key policy recommendations that are crucial to the fulfilling the vision of making the Irish Smart Economy a reality for the software industry through the adoption and encouragement of Open Source technologies."

The above extract is from a paper we are submitting to the Innovation Taskforce as requested by the Department of Taoiseach. The draft paper is available at Positioning Ireland as an International Innovation Hub

Please note, we are submitting the paper ahead of the deadline which is Friday the 18th of September. We appreciate any feedback, support or criticisms you may have. Please post them as comments below.

16Sep/090

Simple straight up caching for pages served by Heroku

So you've got an app that's ticking along nicely; being served up a good steak in a 5 star restaurant - but you'd like to boost it's performance with some caching. For those who develop their apps on the Heroku platform, a great way to do this is to cache a dynamic page using Varnish. This means that your page is served up super fast without hitting Rails/Sinatra/whatever. And best of all it requires no extra gems or anything, just a well placed one-liner in your controller.

Firstly, you can only use this technique if all users that visit this page expect to see the exact same content - in other words you have no 'per user' customised content on a page. To help understand how this type of caching works, imagine that the first time your page (let's say an Events index page) is hit it is turned into a static html page for a pre-defined amount of time (let's say 60 seconds). Anyone else who visit this page (ie. anyone else who visits this particular controller action) during the next 60 seconds gets that static html page. After the 60 seconds the static html page is removed from the cache. Thus the next hit will cause your underlying dynamic page to be invoked; then the caching process kicks off again lasting another 60 seconds. And so on and so fourth.

With the increasing amount of web applications that call APIs, such as Twitter's API, this is a really easy way to ensure that you do not end up spamming a service provider with an unreasonable number of calls per hour. This is the technique we use on www.thelisbontweety.com to keep our API overhead down.

So how do you do this? Simply put something along the lines of

response.headers['Cache-Control'] = 'public, max-age=60'

as the first line of your action for the page you wish to cache. The max-age setting means that this will be cached for 60 seconds. After you put this in your application and redeploy to Heroku, you can see if it's working by using http://hurl.it

Just enter theĀ  URL for your action and click Send. You should see something like "Cache-Control: max-age=60, public" in the output if it's working.

And that's it! No need to install anything. Just cache your little heart out with Varnish. Top marks to chaps at Heroku for making this so easy to use out of the box at Heroku. For more on this technique check out their HTTP caching docs at http://docs.heroku.com/http-caching

9Sep/090

Packaging Ruby Apps for Ubuntu: Dissecting an existing Ruby Ubuntu Package

One of the best ways to learn about how a Ubuntu package is put together is reverse engineer the package into it's constituent components. We are going to take a look at how to do this for the chef application and it's related libchef library is packaged as a Debian package.

* Visit the page http://packages.ubuntu.com/karmic/ruby/chef
* Under the Download chef section, download the package via the 'All' link into a directory called chef
* Visit the page http://packages.ubuntu.com/karmic/ruby/libchef-ruby1.8
* Under the Download libchef-ruby1.8 section, download the package via the 'All' link into a directory called libchef1.8

From the following guide (http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages) you can learn how to 'unzip' a Debian package. This is easy as they are pure ar archives. Here's what we need to do

* In the chef directory, run the commands

ar vx chef_0.7.8-0ubuntu2_all.deb
tar -zxvf data.tar.gz

* In the libchef1.8 directory, run the commands

ar vx libchef-ruby_0.7.8-0ubuntu2_all.deb
tar -zxvf data.tar.gz

Now you can study the layout of the of the data payload of the package (this is where to look in order to study the anatomy of the application as it was being packaged). This layout is what will be of most interest to you.

If you have an application in a particular programming language that you wish to package, pick a similar application for which a package already exists and dissect it as shown above. Then bend your app into a similar shape in terms of directory layout before attempting to package it. To find out more about how to create your own Ubuntu packages check out this great video by Horst Jens Ubuntu: Making a .deb package out of a python program. It's worth the effort of watching it to the end!

Happy packaging!

26Aug/090

Bringing Back the Spirit of the Amateur Programmer

In a blog post this month, Richard Dale (the man behind Qt/KDE's Smoke bindings) eloquently phrased a noble goal,

"In the 1980s there were lots of computer magazines that used to publish programming articles with BASIC code, that everyone could input and run on their own computers. However, in the 1990s such large scale end user computer programming pretty much died out - tweaking the odd web page isn't quite the same thing. One of the assumptions that the Free Software movement makes is that every user is also a programmer of some sort, who is able to tweak the software on their computers. I hope we can get back to that spirit, and change the way that people think about KDE programming, because at the moment there is a tendency to think it is hard and that only the 'C++ gods' like David Faure or Thiago Macieira can do it. In fact it is pretty easy to write small Python and Ruby apps and plasmoids, or to write a little script to message an app over DBus. We just need to get communities of like minded people together who write tutorials on TechBase, create blog entries with code (like the 1980s BASIC articles), and help beginners get started. These ubiquitous end user programming environments in Kubuntu (and other distributions I hope) will make it possible to do that."

This really sums up something that would be fantastic to see over the next few years. There's so many gadget lovers and technology geeks out there - the type of people who would've probably punched those BASIC tutorials into a Commodore 64, an Amstrad CPC464 or ZX Spectrum back in the good old days - that feel left behind as they perceive professional programmers to have blazed ahead a path that cannot be caught. But in many ways nothing could be further from the truth. For any programmer, there's always some guy or gal that's coding something more challenging or doing cleverer(er) stuff on the next machine. It's all relative. And since software turned into a mainstream industry over the last couple of decades, it's been the programmers doing the simplest tasks that have made the megabucks whilst the hardcore wizards of machine code and assembly have seen their demand dimish.

So next time you think there's no point in picking up a few programming skills give a language like Ruby or Python a shot. Hopefully, with the continuing progress of Kubuntu and other distro's to make programming more accessible, you'll have the perfect environment to do so!

22Jul/0914

HOWTO: Add a secondary hard drive for Windows via VirtualBox 2.1.4 OSE

Sometimes one disk just isn't enough. In fact most times! Here's how to add an E Drive to your Windows Guest OS

  • In VirtualBox, go to the File->Virtual Media Manager
  • Click the New button to create a new hard disk and create a new hard drive file via the wizard (a .vdi file)
  • Ensure Windows Guest OS has been shut down
  • Click on the Settings button for your Windows Guest OS, and choose the Hard Disks tab
  • Add the .vdi file you just created to be a hard drive for the Guest OS by clicking the Add Attachmenticon on the right and selecting your .vdi file in the file explorer from the drop down list that appears, here is the typical order of drives on a system
    • IDE Primary Master: this is the main drive onto which your Guest OS is installed (very important!)
    • IDE Primary Slave: this is the first additional drive you add on (ie. the E: drive)
    • IDE Secondary Slave: this is the second additional drive you add on
  • Once your done start up you Virtual Machine Guest OS
  • Visit the Control Panel in Windows
  • If you're using XP elect to 'switch to classic view' on the left of Windows Explorer
  • Visit Administrative Tools->Computer Management
  • Under the storage node on the left, there should be a Disk Management node
  • A wizard should instantly popup to help you add the drive as soon as you click on this, agree to its demands
  • After the wizard, you should see a drive displayed as 'unallocated' as you scroll down the list of drives
  • Right click, select New Volume and before you know it you should be done!
  • Now go and open Windows Explorer and experience the joy that is an extra drive!
Filed under: Linux 14 Comments
9Jun/090

A Breath of Fresh Air – The Well Grounded Rubyist

After a tough day in the office you want to catch up on the news, so you look at the ticker on a TV channel or tune in your car radio. Other days you'll want to sit down with a meaty broadsheet and really take in the detail of what lies behind the headlines. This is a book about Ruby which which triumphs at walking the line between these two styles. The Well Grounded Rubyist aims to appeal to a developer that has been exposed to some Ruby coding and take their knowledge to the next level. And it succeeds brilliantly.

This is not a book about Rails or any other web frameworks; purely Ruby. Though much of the material will also apply to the 1.8.x series of Ruby, this is a book about the 1.9 version of the Ruby language. It's broken into three parts - Ruby foundations, Built-in classes and modules and finally Ruby dynamics. But don't let the title of Ruby foundations fool you for part one - this is not some remedial rush through the basics of Ruby in six chapters. Rather, after a couple of warm-up chapters, it moves quickly to clarify the key aspects of how classes and module inter-relate, as well things such as crystallising what 'self' really means in different contexts in a Ruby program. The author sets out his stall early - what makes Ruby different from other languages is it's focus on objects rather than classes. Everything else stems from this and by the end of the section you feel like you have an understanding of Ruby's design and focus.

Part two of the book is Built-in classes and modules. Now that you know what makes Ruby tick, it's time to get seeped in all aspects of the core library that ships with it. One of the problems when learning a language is that becoming familiar with all methods of a particular core class is a tedious task. It's much more interesting to learn about concepts such as meta programming than memorising lists of methods by rote. But if you don't take the time to familiarise yourself with the dusty corners of a language's API then you're less likely to think of those handy methods when a problem they would elegantly solve presents itself. At this point the book shifts gear to a more reference style of text. However, it still gives the reader an interesting story to follow as it documents arrays, hashes and other classes - throwing in the occasional golden nugget of information that will be a valuable additional to the toolbox of even experienced Rubyists. One side effect of the change in style is that this section is probably the most accessible to beginners. Again it's broken down into six chapters. In addition to collections, it also covers topics such as regular expressions and file handling. Each topic takes a zero-to-hero approach meaning that you can bring little regular expression knowledge to the table yet still walk away learning an immense amount about the subject.

The final part of the book, Ruby dynamics, returns to the book's roots from part one - a focus on imparting a deep knowledge of Ruby's design. Before you even pick up this book you have an inkling that procs and lamdas are going to make a guest appearance at this late stage. And they do not disappoint. Extending the behaviour of objects takes centre-stage and meta-programming based techniques move quickly to the fore. Any block/proc/lamda confusion you may have will be a distant memory by the time you finish this section. Threading is also covered here - though a detailed discussion of 1.9's new native OS threads vs green threads is left to one side to focus on the usage of threads regardless of which underlying type you use. Lots of material is also provided on querying objects; which is not only useful for program design but also invaluable as a debugging aid. The book really shines in this section because a lot of other texts make the mistake of going into 'super-boffin' mode at this point, leaving the reader lost, whereas the author here continues to provide patience and context to get you round that final lap on you way to becoming a Well Grounded Rubyist!

This book cannot be all things to all people. Because it is catering for a wide range of intermediate to advanced Rubyists, it will feel like it's moving a little too slowly for some. By the author's own admission, this is in order to make it accessible to a wider audience and no doubt it will make it easier for developers of all levels to digest - your humble reviewer very much included! Ruby first-timers would be best off having some straight-to-the-point tutorials or entry-level text to hand in order to get some instant gratification - as part one of the book, by it's very nature, is a little more abstract than a complete beginner would expect. But all in all, this book is a great way to learn just how Ruby crams so much expressiveness into such a simple clean framework. Whenever I read a book like this I keep a list of new things learned along the way. For The Well Grounded Rubyist it is a very long list! Well done to David A. Black and Manning for producing a book that fills those gaps in many Rubyists' understanding of the language while at the same time delivering an absorbing readable book that would sit proudly on any Ruby programmer's bookshelf.

11May/090

Optimising Apache serving Ruby on Rails via Passenger

An unusual blog post this in that I have such little value to add other than pointing you at two great links. The first is a wonderfully useful post on tweaking Phusion Passenger when running some Rails apps on a 256MB Slicehost VPS and the other link is a no-nonsense explanation of tweaking Apache config options to cut down on your swap memory usage. Thanks so much to these folks!

27Mar/094

VirtualBox and Running a Virtual Ubuntu Image within an Ubuntu Host

"What?" you say, "that's a lot of Ubuntu going on! Why would you want to do such a thing?" The answer - for testing applications, replicating environments or perhaps running a few servers on one box.

This guide should work pretty well for any Linux distro, though you may need to replace the aptitude commands with the package manager of your choice. Here we'll install a Hardy Heron guest inside an Intrepid Ibex host. Afterwards, we'll also use dselect with apt in order to clone the packages on a machine we wish to replicate onto our guest OS. Oh ho the fun! Here goes...

We'll start from scratch on your developer (host) machine with no prerequisites. Here are the steps
* Install the VirtualBox program
sudo aptitude install virtualbox
* Install 7zip, needed to extract downloaded image
sudo aptitude install p7zip
* Download Ubuntu 8.04 Hardy Heron iso image from http://virtualbox.wordpress.com/images/ubuntu/
* Make a new folder called my_temp
Move the downloaded file into my_temp
cd into my_temp
* Extract image
p7zip -d downloaded_imagefile
This should yield a folder called something like ubuntu-8.04-x86.
cd into this directory and run
- 'mv VDI/ubuntu-8.04-x86 ~/.VirtualBox/VDI'
* Create a new virtual machine
- Run VirtualBox (should be in Accessories under the Applications menu or just type 'virtualbox' at the command line)
- Click the New button to create a new virtual machine
- Create a name for your Virtual Machine and set it's OS Type
- Set the base memory to 256MB
- Elect to add an 'Existing Hard Disk', you the Add button and choose the ubuntu-8.04-x86.vdi under the ~/.VirtualBox/VDI directory
* Run and customise new virtual machine
- You should now have a new Virtual Ubuntu machine at your disposal. Start it up by clicking the Start button.
- Log in with ubuntu/reverse as username password. Double check that this is correct by looking at the site you downloaded the image from
- Once logged in change the password through the System/Administration/Users and Groups menu
- Install 'Guest Host Additions' from the Devices menu of the running window of you virtual machine. GHA allow you to copy and paste between the host and guest OS's, along with a raft of other improvements. Tip: If your mouse gets stuck in the virtual machine window then use the right control key to let it escape.
If the GHA install does not work (due to a timeout) then you will need to install the Guest Host Additions manually, as follows
i) On your real Ubuntu machine (ie. the host) download the file that was specified as a URL in the popup that was displayed when you previously tried to install Guest Host Additions - if you forget the URL try to download the GHA again from the Devices menu and when the URL appears copy and paste it into FireFox running on your host machine. Note: The GHA are installed onto your host machine.
ii) Once downloaded, move the file to /usr/share/virtualbox on your host machine and create the following symlink (as virtualbox won't recognise the file if it has the revision number in the filename)
sudo ln -s /usr/share/virtualbox/VBoxGuestAdditions_2.0.4.iso /usr/share/virtualbox/VBoxGuestAdditions.iso
iv) Once again try to install 'Guest Host Additions' from the Devices menu of the running window of you virtual machine. This time it will pick up the local file you downloaded.
* Create a shared folder - to swap files between your host and your VM
- On your host machine create a directory you will use for sharing
- On your running virtual machine create a directory you will use for sharing
- From the Devices menu of the running VirtualBox windows select Shared Folders and set the 'folder path' to the folder you just created on your host. Give it a friendly name in the 'folder name' field and elect to make it permanent. Then on your VM run
mount -t vboxsf the_friendly_name /path/to/folder/on/virtual/machine

Note: That vboxsf is the filesystem type that VirtualBox is using for shared folders

Now you should be ready to go with your VM. Congratulations!

As a final step you may want to take this vanilla Ubuntu machine update it so that it has the same packages as another machine, in the case where you are looking to replicate an environment. Use dselect and apt to do this as laid out in the following guide Restore Packages using dselect on Kevin von Zonneveld's blog.

As a final step you may want to install any other software that is not covered by aptitude packages - such as programs for which no debian package exists or for things like Ruby on Rails gems. It shouldn't take you long to put these on your new virtual machine and "hey presto!" you're ready to rock!

9Mar/090

Blackout Ireland – Not Condoning Piracy but Criticizing Coporate Internet Censorship

One of the key points of the Blackout Ireland campaign is that letting individual companies control the Internet is not acceptable. This article at OpenWriters.org says why.

5Mar/090

Blackout Ireland Campaign Begins – No to Irish Internet Censorship

The battle for control of the Internet has begun within Ireland. In the red corner, Eircom has sided with the Big Four record companies - Sony-BMG, Universal and Warner and EMI - who are seeking to control the Irish Internet using coporate censorship and civil law techniques. In the blue corner, the Blackout Ireland campaign is looking to highlight the dangers of this censorship and has used social networking tools such as Twitter and Facebook to build support to protest this decision. A similar campaign was succesful in New Zealand, will it work again here?

Read more on OpenWriters.org.