Category Archives: Uncategorized

Using QEMU to emulate ARM devices

This post will show you how to set up a QEMU virtual device to play with your ARM code on an x86_64 host. It is quite simple, and you should be able to simply copy and paste into a terminal and get going relatively quickly.

As an example, we will be installing a debian build (wheezy) into your VM.

First off, we need to install the QEMU packages. I use Ubuntu/Mint, so this post will be somewhat biased towards that.

Let’s start off getting the packages we need:

sudo apt-get install qemu-kvm
sudo apt-get install qemu-system-arm
sudo apt-get install qemu-utils

Now we can check that everything is installed OK and ready to go with:

qemu -version

Make a directory to work with and then grab some files off your local debian mirror. Remember, we need the ARM based distro.

mkdir ~/arm-emul
cd ~/arm-emul

Remember now that depending on your board/device, you may want to check if it supports ARM EL or ARM HF. As you can probably guess from the above filenames, we are working with ARM EL. There are a number of differences between the way (and efficiency) of the two device types, but if you don’t know, then you are probably using an ARM EL device. Also, it is worth checking with your manufacturer if you haven’t built your device yourself, as ARM HF is a way better buy!

Let’s create a virtual HDD now to host the code/OS:

qemu-img create -f raw hda.img 8G

I like to create a drive as big as my devices flash ROM. In this case, it is 8GB. Yours may vary.

Now, lets get the system up and running:

qemu-system-arm -m 256 -M versatilepb -kernel ~/arm-emul/vmlinuz-3.2.0-4-versatile -initrd ~/arm-emul/initrd.gz -hda ~/arm-emul/hda.img -append “root=/dev/ram”

Should get you started with the Debian installer. Do the installation and then close your VM.

Once complete, mount your filesystem, and then copy the relevant files around. You need to do this step as debian will not be able to install the bootloader, so you kind of have to do it manually.

mkdir mount

sudo losetup /dev/loop0 hda.img
sudo kpartx -a /dev/loop0
sudo mount /dev/mapper/loop0p1 mount

cp ~/arm-emul/mount/boot/initrd.img-3.2.0-4-versatile ~/arm-emul/
sudo umount ~/arm-emul/mount

Now you can start up your brand new debian ARM VM with:

qemu-system-arm -M versatilepb -kernel ~/arm-emul/vmlinuz-3.2.0-4-versatile -initrd ~/arm-emul/initrd.img-3.2.0-4-versatile -hda ~/arm-emul/hda.img -append "root=/dev/sda1"

Great! Now off to make your custom OS and flash it to your board! Good luck!

Is SA ready for a “Tech tipping point” in 2014?

TL;DR – No, not unless we work together.

Marissa Meyer posted an article last night about 2014 being a tech tipping point. I would like to outline a few points related to this that I think may be important in 2014 for South Africa, as well as Africa as a whole.

1. At the base of it all is that devs in South Africa (especially really good ones) are few and far between. There are some notable exceptions, however, they do not really talk to each other much and would rather see each other as competition as opposed to peers. This is a poisonous attitude that has been reinforced by the fact that most of them come from a proprietary background and are used to keeping secrets close instead of sharing everything.

Co-opetition would largely solve this. Sure, be competitive as a company (we all need to make a living) but share more. Express yourselves better and seek help. There is no shame in asking, even if you are a top shelf developer! Share issues and successes, so that everyone learns from it and as a community we can improve things incrementally.

2. Consultants are on average paid better than developers. Why? Consultants are supposed to have a very wide knowledge of a number of products that will actually add benefit to the organization. In my experience, consultants in Africa are little more than highly paid salespeople for certain software suites that are installed with a few clicks of a mouse and then “supported” at exorbitant rates.

We need to move away from the consultant based architecture and ensure that software is written or customized for the organizational business needs. Off the shelf software normally comes with a lot of additional bloat (that still needs to be maintained) that is never used and presents a liability to the org in the form of additional security attack vectors, as well as additional expenditure maintaining dead weight.

3. Agility. Are we agile enough to respond to change? Not really. Many organizations have a sense of built in fear when it comes to change. This absolutely hampers growth. Remember that as an organization, your  competitive edge lies in your ideas and the people that can execute them. Any company can hire software people to hack out lines of mundane code, but in order to flourish and gain competitive advantage, you actually need a team of people that can do actual R&D. They will be able to keep up with trends and fashion new trends and pass them into the business, providing a large amount of value. The manner in which this value chain is maintained is another big point, but if those processes are not in place, you will also have a bad time!

4. Working together to ramp up scarce skills. Africa is a big continent. As a continent, we have about as many available developers as any other country, BUT this assumes that we can transgress boundaries and actually work together. If, as a whole, we would collaborate, we could certainly make a global impact (See the AVOIR project as an example), but this requires buy in and actual collaboration.

As it stands, we are simply unable to take advantage of any sort of “tipping point”. How many companies right now are actively doing R&D in areas such as: Semantics and internet of things, bandwidth and compression management, robotics and hardware hacking, big data analytics, and many others? These are the things that will make you stand out!

You need to think to yourself every day as a developer “How can I do something that has never been done before today?” Until that is a reality, we haven’t got a chance.


Google Chromecast in a South African context

I had my Google Chromecast delivered from a local supplier last night, and thought that I would write a quick post on my experiences so far.

Seeing as though I have already had a large number of requests as to where I got it, I will answer that question first. I bought it from on the following URL,29924636

Right, so the first thing that you need to do is plug the chromecast into a free HDMI port on your TV. Great. Easy enough. The box comes with an external power adapter as well as a USB adapter to power the device, but the external power plug is a US plug. Oops. Useless. USB power it is then! I would have liked to use the external power, simply for the fact that the TV does not have to be on for me to queue up online videos to the device, but alas, unless you are willing to screw around with clumsy power adapters and transformers, forget about it. The USB cable plugged into one of the TV USB slots and powered up the device without issue.

You are presented with a beautiful wallpaper and a device name, with the instruction to go and finish setup by connecting to your new Chromecast with an Android device or a laptop.

I tried to complete setup immediately with my Samsung Galaxy S4, having to download the Chromecast app from the Play store beforehand, which failed. I then tried to set up using my laptop computer, and was told by Google that I was using an unsupported OS (Linux), but I could try anyway. That failed too. Hum…

I then had a bit of an idea, and checked that uPnP was enabled on my (admittedly very old) wifi router, and enabled that. It would have been nice if that little caveat was covered in the intro screen, but it wasn’t. I use MAC address filtering to limit wifi access at home to specific devices, and one thing that I really did appreciate is that the Chromecast device displayed its MAC address on the setup page by default.

The setup, once started, becomes somewhat fiddly. My S4 has decided that a wifi connection is unworthy if it cannot reach the internet, and this was a big problem in completing the setup. I resorted to my laptop again, and managed to get through the steps after having to (confusingly) change wifi networks mid way to properly configure the device.

The device will not connect properly to anything but a 2.4GHz wifi network, so keep that in mind too.

I did have to do each of the steps a couple of times in order for the device to recognise my network and install itself properly, but once that was done, it was pretty plain sailing thereafter.

I immediately was able to stream a YouTube video to the TV in full HD without a glitch. The coolest part was that in the Chrome browser, I installed the Chromecast extension and was able to share not only a specific browser tab to the TV, but also my entire screen. There was some noticeable lag (about 500ms) when playing Kerbal Space Program via the network, but for a very graphics intensive app, and on a not-so-great wifi router, it was rather impressive (and still completely playable).

The apps that Google use to sell you the Chromecast (Netflix, Hulu etc.) are great, but not available in South Africa. Sure, I know that you can get a Netflix account (illegally) by spoofing a DNS service to make it look like you are in the US or UK, but the Chromecast has a trick up its sleeve. Google DNS services are hard coded into the device, so, even with a service like that, you would still need some trickery to get it right.

On the other hand, however, DStv BoxOffice works beautifully via a Chrome browser window, and you are able to enjoy the entire Online catalogue at R30 a movie, even if you are not a subscriber! To me, that is well worth the purchase price, as you are not entitled to pay a subscription, and you can rent when you want to. It is way cheaper for a family to grab a BoxOffice movie in this manner than it is to go to the cinema!

Overall, I think that the device is well worth getting (if you don’t already have an XBMC device or similar), although the price could come down a little in my opinion. There is a LOT of potential here, and I do think that we are only seeing the beginnings of something here for TV viewing.

The ultimate best awesome crazy cool killer feature of this device, though completely undocumented, is for people that do a lot of presentations. If you are a regular speaker, you will know that fiddling with projectors and screens on your laptop can quickly become a nightmare. I would suggest getting one of these things to pop into your laptop bag, and carry around with you. When you need to give a talk, simply plug it in and cast your presentation, saving a lot of time and stress!

I don’t normally do reviews like this, so I don’t really know how to end it off, but, yeah, get one of these things, they are OK tending towards good. In the future, depending on the climate, they may be awesome.



Website experiment –

I wanted to challenge myself, and just actually see if you could write an entire website (with a MongoDB backend) just by copying and pasting code from various web resources.

I struggled a little with finding correct variable names and sometimes had to google words to get them, but managed to build an entire site with no coding whatsoever!

The github repository can be found at and you are free to fork it for whatever nefarious means that you may have. The only rule is that if you contribute code to it, you are not allowed to code anything. You need to copy and paste stuff in ONLY!

I started out by registering a new domain on Afrihost ( and chose their “Bronze Home” package, which does not include a database or anything else. It cost me a grand total of R9.00 (which is less than $1 USD) and I was up and running.

I then used a Twitter Bootstrap generator to drag and drop out a simple layout for the site (mostly using LayoutIt interface builder) plus some other examples from around the web.

For the database, I signed up for a free account at MongoLab and chose the Rackspace DFW as my datacentre of choice. I then grabbed my Mongolab REST API key at<yourusername> and set up a user to authenticate with.

Once all of that was done, I then started using a variety of discussion forums, Google, and Stack Overflow, as well as blogs, and mailing lists to get the code that I needed.

99% of the code is pure copypasta, I simply changed some variable names and pasted them in too.

What I found from this exercise is that it is very simple to create a web app in this manner. If I had not been so puritanical about the copy and paste scenario, I could have done this in about 20 minutes. In all, it took around 2 hours.

This simply shows that with a little knowledge and time, you too can do something cool without writing code. It also demonstrates the power of the open web. If so many people had not contributed their knowledge freely and openly, this project would have been impossible!

Think about that a while…

The website, in all its glory, can be found at


Tech4Africa 2013

I delivered my talk at Tech4Africa ( yesterday, on Geospatial MongoDB.
It went quite well, I think, with lots of folks coming to chat to me about it from many different spheres.

If you would like a copy of my talk, as well as the example code and SA data, it is available from

You are more than welcome to download, remix and distribute the stuff with attribution, under a Creative Commons By attribute ShareAlike license.

I do hope that everyone in the room found my talk at least somewhat useful and enlightening!

Thanks to Tech4Africa for giving me the opportunity to speak!

Android video footage encoding on Ubuntu

Reposted from old site – original date: Saturday 21 July 2012
I wanted to encode some footage that I had shot from .avi to h.264 to play on an Android tablet device, but it seems that Android cannot play avi natively without additional app installations.
After some research, I found out that avconv, which is the replacement for good old ffmpeg in Ubuntu these days, does not work with x.264 either. The solution was to download and compile in x.264 support from source. Steps taken below.

In retrospect, I am not sure this is a great way to approach this, and probably grabbing an app is way better. That being said, this may be useful elsewhere too though.

mkdir avconv-source

2.) Download and install the x264 library

Grab yasm from Ubuntu

apt-get install yasm
cd ~/avconv-source
sudo git clone git:// x264/
sudo ./configure --enable-static
sudo make
sudo make install

3.) Download the avconv source

cd ~/avconv-source
sudo git clone git:// avconv/
sudo ./configure --enable-gpl --enable-libx264
sudo make
sudo make install

and you can now execute

avconv -i -c:v libx264 -c:a copy test.mp4


Reposted from old site – original date: Friday 28 October 2011
When you copy someone else’s ideas and roll them as your own, claiming innovation, you are doing it wrong. When it is someone’s ideas or even implementation that you are copying, it is plagiarism, not innovation. Taking ideas from things and creating something new on top of those ideas that will benefit people, that is innovation.

Regarding idea theft. If I help you, it would be nice to at least have a mention. Sometimes. A little attribution goes a long way. If you ask me for help, I will probably help you. I don’t want your money, I don’t want anything like that from you, I would appreciate a thank you or an acknowledgement sometimes though. Your crappy little “startup” is probably going to fail anyway, especially if you treat people that have a lot to give like that. Sorry for the honesty, but you probably need a reality check anyway.

I give away all of my code as Free Software, acknowledge that it is mine at least. Don’t claim it as your own, it isn’t. Should I stop giving away my “Intellectual Property”? I would hate to do that, as I believe that anyone has the ability to think up the same things, but sometimes you may need a seed idea to kick those thoughts off. To me, IP is bullshit, but if I keep on finding people claiming my ideas and text as their own, is it?

I don’t know. Perhaps I just need a break.

Innovation – definitions

Reposted from old site – original date: Friday 28 October 2011

The term innovation derives from the Latin word innovatus, which is the noun form of innovare “to renew or change,” stemming from in—”into” + novus—”new”. Although the term is broadly used, innovation generally refers to the creation of better or more effective products, processes, technologies, or ideas that are accepted by markets, governments, and society. Innovation differs from invention or renovation in that innovation generally signifies a substantial positive change compared to incremental changes.

With that out the way, let us explore the way in which some folks are (ab)using this word.

The part that I would like to point out to the folks that are using the word “innovation” for every stupid project that they crank out would be the “substantial positive change” part. See the word [b]substantial[/b] there? Yeah, didn’t think so. OK, so what is substantial? Substantial is [b]not[/b] doing the same stuff you would do anyway, by means of a mobile app, or a shiny new web site. It means a lot more than that. It means to do something in a new (novus) way in order to really have an impact on how most people would accomplish a task. Banks, you have been doing the same thing for hundreds of years. You are not innovative. Deal with it. A mobile app to do banking is still doing the same boring thing, just on a mobile device. This, to me, is not innovative. Evolutionary, maybe, but not innovative.

When your marketing team gets hold of the word “innovation” please stop them and think before you start spewing nonsense. It annoys people who are trying to actually make the world a better place.

How to write a quick Favourite Tweet backup script

Reposted from old site – original date: Thursday 22 September 2011

Someone asked me to do a quick @twitter “favorites” backup script for them, and the result is that it is very easy to do. I wrote the code in Python, but I guess anything else would probably do as well.

I chose to go the full OAuth route, but I think (I may be mistaken though) that you can do the following with only basic auth involved.

Firts up, you will need a copy of tweepy, which is a python module to work with Twitter. Grab it at It has good support for the latest twitter API, so you should be good there.

Next up, you will need to create an app on twitter for the OAuth dance to interact with. Again, if you are using basic auth, you won’t need to do this, but I did anyway (besides, it gives you a good base to build a bunch of other twitter stuff with)
You need to make your app give up a user secret and key so that you can sign off the requests. You can do that with the following code:

#!/usr/bin/env python

import tweepy

CONSUMER_KEY = 'consumer_key'
CONSUMER_SECRET = 'consumer_secret'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth_url = auth.get_authorization_url()
print 'Please authorize: ' + auth_url
verifier = raw_input('PIN: ').strip()
print "ACCESS_KEY = '%s'" % auth.access_token.key
print "ACCESS_SECRET = '%s'" % auth.access_token.secret

Remember to substitute the consumer_key and consumer_secret with the values that twitter gives you when you register your app.

What the above code will spew out is an access key and access secret which you will need to copy and paste to the next bit of code:

#!/usr/bin/env python
import time
import sys
import tweepy
import csv

CONSUMER_KEY = 'consumer_key (same as above)'
CONSUMER_SECRET = 'consumer_secret (same as above)'
ACCESS_KEY = 'access key generated from the above code'
ACCESS_SECRET = 'access secret generated from the above code'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

# substitute the username here with your own username!
userid = api.get_user(username).id
# Counter is used for reporting purposes only
i = 1
Empty lists are false in Python, so we keep on going in an infinite loop
until the list is empty. Hack? Probably. Works? Yes!
# Initiate an infinite loop, to be broken when we run out of favorites.
while True: 
    results = api.favorites(userid)
    if results:
        favWriter = csv.writer(open('twitterfavs.csv', 'wb'), delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
        print "Page %d exists. Unfavoriting %d tweets." % (i, len(results))
        for r in results:
            tweetdate = r.created_at
            tweet = r.text
            if hasattr(r.user, 'screen_name'):
                name = r.user.screen_name
            else :
                name = "Unknown"
            line = [tweetdate.isoformat(), tweet.encode('utf8'), name.encode('utf8')]
            api.destroy_favorite( # This will unfavourite the tweet too so you are left with 0 favs. Use at your own discretion.
        # Rest for a while. Stupid rate limits...
        print "Script is sleeping for 15 minutes to accommodate Twitter rate limits."
        i += 1        
        time.sleep(900)       # 900 seconds = 15 minutes
        print "No more favorites. Start again!"

As you can see, the code will go through all of your favourites and write them to a CSV file. Remember that I am only grabbing a small subset of the information from a tweet to write, so if you need more, look at the tweepy API docs.
We also need to watch out for rate limits. Twitter limits at 150 an hour (IIRC) so if you have loads of favourites, this could run all night. If you only have a few, go have a bere or some milk and you will be done!

Have fun!

(Again, please excuse the formatting, I will work it out sometime)