auckland code fields of gold flat games humour itunes linkin park mae movies music nakedbus paintball philosophy project frozen flame qemu random silverstripe site vcs
Just a quick tech note here - I've been playing round with OpenGL a little bit recently, and managed to figure out how to do some basic 2D graphics with it. Chucking my code here in case it helps anyone - this is just for basic drawing image to the screen.
First things first, you need to create your window and OpenGL context. I use SDL to do most of the hard work for me.
We use SDL to set up OpenGL for us, being careful to enable double buffering. The gluOrtho2D sets up a 2D coordinate system for us. Here I've made (0,0) the top left of the screen. Then I enabled textures (which we use to draw images) and alpha blending.
Before we can draw an image, we need to load it into a texture. I used the DevIL library to do this, as it is written specifically to work well with OpenGL. It provides some utility functions to do things quicker than I did it here, but I found the textures lost of a lot quality if I used them, so I stuck to the basics.
Pretty straight forward - use DevIL to load the image, and then convert the image to a display friendly format and copy it into a texture. The final step is to actually draw the image on the screen. We do this by drawing a four sided polygon and binding the texture to it.
Care must be taken here to make sure you draw your points clockwise, to make sure you get a front facing polygon. Texture coordinates are always from (0.0, 0.0) to (1.0, 1.0), regardless of the size of the image.
That's it! Tuck that away behind some abstraction so you don't have to deal with it, and you have nice hardware accelerated 2D drawing. I've been playing round with creating a 2D graphics library/engine with OpenGL, so I'll probably chuck that online in a little while. :)
Edit: Sorry about the lack of spacing in the code - SilverStripe appears to have a bug with line breaks in code blocks with bbcode. I'll fix this at some point - syntax highlighting might also be nice! :)
For a long while I have been using subversion as my main version control system (VCS). This was due to a few factors - firstly it's probably the most popular VCS out there, and secondly since I use it at work I know it like the back of my hand. While it is most definitely a momentus improvement over CVS, it always seemed like a bigger hassle than it needed to be - firstly I start and stop and then pick up little personal coding projects all the time, and its quite an effort to set up a repository. Then there's the question of where to keep it - having it online is definitely useful, but sometimes I want to code without a net connection, particularly on one of my trips back to visit family and friends in Blenheim. That's a three hour ferry trip each way, and the time I am there is spent with only a dialup connection, which is more hassle than it's worth. The other thing that is irritating is occasionally people want to help code something (ok, that doesn't actually happen that often, but it does happen :P). So I have to give them access to subversion, which one is a pain, two it means I have to trust their code since it's committed before I get to do it, and three, maybe, just maybe, more people would send code my way if there wasn't that annoyance (okay, that's probably just wishful thinking). So with distributed version control systems (DVCS) being all the rage these days, I decided to give them a try.
The difference between a distributed VCS and a centralised VCS is really just a matter of different assumptions. A centralised VCS assumes that all developers working on a project at any given point of time will have access to the VCS server, and that all code is stored in a central repository on this server. It also assumes that branches are rare, and that while you might have a development, stable, and a few feature branches lying around, branches are the exception, not the rule. Anyone who has worked on a project with more than a handful of developers knows this is definitely not the case. On the other hand, a distributed system lends itself to a much more flexible system of development - each 'checkout' of a project is it's own branch, and in fact it's own repository. While this initially sounds like it might be a nightmare - that's a lot of branches, DVCS's have very good support for tracking merges and handling conflicts, so it ends up being more hassle free than a centralised system, which generally have very poor support for these things.
When deciding to give a DVCS a go, the first program that popped to mind was, of course, git. Git has generated a decent amount of hype behind it, as it was originally developed by Linus Torvalds, the guy who was the original programmer for the Linux kernel, and still plays a large role in its ongoing development. He wrote git to manage the source of the linux kernel, after a disagreement between the kernel guys and the BitKeeper guys meant the kernel developers' free license for the proprietary BitKeeper system was revoked. Git has also been picked up by few prominent open source projects other than the Linux kernel - notably X.org and Ruby on Rails. So I decided to give git a try for a while and see how I like it.
I spent quite a while reading the documentation on git - it's a complex piece of software. After reading the introductory and basic usage a few times over, I felt I had grasped some of the basics, and so started to use it. The first thing I noticed about git was it is blazing fast - after using subversion for so long, which while not being horribly slow, does feel a little bit sluggish at times. Using a lightning fast application like git reminds you what responsiveness really is - you press enter and the text scrolls faster than you can read it. It is also very easy to set up your own git repository - just run a command in your working directory and git does all the hard work. So while initially everything looked good, after a few weeks I found myself beginning to dislike git. The reason for this is simple - it's written by a kernel developer, for kernel developers, and it shows. While it is blazingly fast, it is also pretty darn unintuitive to use. Part of this I put down to Linus' development of "take CVS as an example of what not to do", which for users coming from a CVS/subversion background is very confusing. The rest of it I just put down to kernel developers being the target market, which don't really have a reputation for being people who concern themselves with such trivial things as user friendliness. Git also tries to force you to do things its way - which is very orientated to how the kernel developers work. Sure, being able to handle having hundreds of developers in some sort of crazy web of trust is useful to a lot of people, but there is very little support for making it easy for old Joe Bloggs (aka me) to handle his little projects, or for a small group of deveopers to work on a project together with little hassle. I'm sure these things are easily possible with git - but with the complexity of git I'll be darned if I can figure out how.
So feeling a little disillusioned, I started to hear about another DVCS more and more commonly through the tubes of the blogosphere - bazaar. While initially I didn't pay it much attention - in my mind the only reason git was popular was because of the backing of the kernel crew, and the buzz about bazaar all seemed to come from the Canonical/Ubuntu crew, as Canonical sponsor the development, I just brushed it aside as more irrelevant hype. After seeing a few more blog posts of what seemed to be some cool features (a avahi branch sharing plugin in particular), I decided to take a closer look.
The first thing that struck about bazaar was it has a completely different focus than git - git was designed to be fast, but bazaar was designed for usability. That's not that to say that git can't be usable (well, one day ;)), or that bazaar can't be fast, but it is a different mindset. Bazaar is coded in python, which from what I read is less of a concious design decision, but was originally being used for a prototype, when they discovered their prototype was quickly outgrowing the software it was designed to be a test bed for. Being developed in python, the language everybody loves to love, there are a large number of plugins written for it. I think an extensible plugin system is a brilliant idea - it beats the screen scraping and data peeping tools that have historically been used for VCS integration.
Bazaar is a breeze to use, particularly if you've come from a subversion background. All the basic commands are there, and act pretty much as they do in subversion. Bazaar is also very flexible - it lets you choose if you want a centralised repository or not - when you do a 'checkout', whenever you commit a change, the changeset will be pushed to the repository you checked it out from. If instead of doing a checkout, you use the 'branch' command, all your commits are made locally, and can easily be pushed to the repository you got them from (or another repository) whenever you need to. And to answer the speed question - bazaar feels more responsive than subversion, and is more than fast enough for everyday use. It's not the lightning that git is, but it's still a snappy piece of software.
Add to this the wide range of useful plugins, and the ease of setting up a web accessible repository (bazaar can use http, ftp and rsync in lieu of not having bazaar installed on the server), and you have a winning DVCS in my mind. I use the bzr-gtk plugin, which gives some nice gui integration (accessed via commandline, eg to get a nicer gui diff, i use bzr gdiff instead of bzr diff), the avahi plugin to make sharing branches on local network easier, and the svn plugin to let me read from svn repositories (this is mostly just playing around!). All in all, I think I've found the VCS for me!
Today marked my return to university for my final semester of undergraduate education. I'm taking three papers – Concurrent & Distributed Systems, Introduction to Artificial Intelligence, and Discrete Mathematics. I had my first lecture for each of these, but the one that has proved most interesting thus far (to be fair, 'thus far' is a single lecture), is Artificial Intelligence.
In particular, we were discussing a debate in the field of AI – strong AI versus weak AI, or in layman's terms, whether or not a machine can possess true intelligence, a mind. For starters, it is useful to establish exactly what constitutes a mind, a conciousness, or the soul. The concept of a soul is something that is universal across all human cultures – the part of a person that makes them distinct and separate, the part that thinks, that feels. The question is then whether the soul is a simply the manifestation of the physical make up of the brain, or something separate and non physical. In both cases this raises the question of how do you model such a thing with a machine, and can it even be modelled? Although it seems much more feasible if the soul is a result of the physical happenings in the brain, there is still little understanding of how the brain actually works. Also, if the brain is merely a machine, albeit a complex one, then how is it we have the feeling of choice – that given a set of inputs, we not only rationalise, but we also act on impulse, on feeling. The concept of free will does not fit well with the idea that the mind is a machine, mapping inputs to outputs.
A slightly less philosophical point (although only slightly less), is what it means to comprehend something. Sure, given the word 'tree', a picture of a tree, or a description of a tree, a machine may be able to correctly associate it with a tree – but does the machine truly have comprehension of what a tree actually is? It understands all of these symbols as pointing to the same object, but does it understand what a tree is? Another way to put this is to think of it in language – given the word 'horrifying', a machine could learn about its definition, where it is appropriate it should be used, when it does or doesn't make sense. But is knowing about 'horrifying' the same as knowing 'horrifying'? Can a machine know what it is to be horrified? John Searle points out this difference in his thought experiment, the Chinese room. Although I will probably fail at trying to explain this, and you are better reading it elsewhere, it basically says the following: given a question in Chinese, and a 'program' of sorts in the form of a book written in English, an English speaker like you or me could follow this program and produce the correct answer in Chinese. The point made here is this – although given the input, an 'intelligent' output is given, the Chinese characters are still just nonsensical squiggles to the uninformed. We have returned the correct output, without actually comprehending what either the input or the output actually mean. It is in this way we have exhibited what seems to be intelligence, but without actual comprehension.
For me, the idea of strong AI is something that is unachievable, but like many unachievable goals there is much to be gained in the process of trying. I'm looking forward to my first chance to dabble with AI in these coming months.
A beautiful storm is raging outside - the crash of thunder, the brilliant flashes of lightning, the sound of rain on the roof, of wind through the trees. I'm quite the fan of storms, and I thought I would take the opportunity to relax, and mayhap update that blog I've been neglecting for far too long.
Firstly, I've decided to try and learn Japanese. The motivation for this I'm not sure - I guess I've always been kinda interested in the country (it's a prerequisite of being a geek I think..), my good friend Mat knows a bit and offered to help teach, and of course the lovely Emma (or えっちゃん as I fondly call her) is pretty much a Japanese genius, so I've got lots of smart people to help me along. Matt (not to be confused with Mat) has loant me his Japanese textbook; he started an introductory course at University but dropped out pretty early. Progessing alright thus far - I've got most of the hiragana down, and am starting to work my way through memorising the katakana. Learning some basic grammar and vocabluary as well, although I think I'm learning some words in a bit unconvential order, Emma teaches me how to say lots of useful stuff that I haven't got up to in the textbook quite yet.
A few months back I finally decided to do that which most of my peers had done long before me - get my driver's license. After studying up the New Zealand road code, I went in for the test to get my learners license. I passed - just. Seriously, why would I need to know the amount of tread that should be on my tires? Or how far something is allowed to stick forward from a roof rack? Well, I passed, and I guess that's the important thing. Mat took me out for a few lessons (geez I have nice friends!), and um, I wouldn't trust me on the road just yet. Or any time soon. Lanes are for losers. Guess ya gotta start somewhere though, right? The lessons are on hold at the moment - petrol isn't cheap and I'm pretty poor during term time. Now that university is over (yuss), I might try get a few lessons in, Mat willing, although work and life in general has been keeping me pretty busy.
Earlier this year, me and my buddy Hamish decided that we wanted to get a flat together come end of year. We signed up Mat as flatmate number three, and began a flat hunt as university neared its closing for the year. We've looked at quite a few flats, seen a few we liked, loved even, but has thus far been unsuccessful in securing a flat for ourselves. Hamish moved into a friends place when his lease ended, so he has somewhere to stay until we find somewhere. The issue of when we need to find a flat has been further complicated by the moving out of my old flatmate - he moved out last Saturday. He gave me a good few hours notice, but he's going to continue cover rent until I find a place, and then discuss with the landlord about terminating the lease early (it doesn't end til early January). I don't have any Internet access or a phone line at the moment (both were under my old flatmates name), which makes it difficult to continue flat hunting; it's all in Mat's capable hands now. I'm confident that we're gonna find a great flat, and with us three guys it's gonna be the most awesome flat ever - I'm just praying that we find it soon.
I've spent most of my time at work recently preparing the SilverStripe 2.2.0 release - it's gonna be fairly fantastic. We managed to get the first release candidate out today - if you're at all into web development you should definately check it out - http://www.silverstripe.com/assets/rc/silverstripe-v2.2.0-rc1.tar.gz. It is such a gigantic improvement over the 2.1 series that I'm not even gonna bother listing the improvements - lucky Sig is pretty good at that kinda thing, and will be covering them on the SilverStripe blog these next few weeks.
In the world of university, I've finished up for the year. Not sure how well I did on the two papers I did last semester - I didn't work nearly as hard as I should have, so I won't be too suprised if my grades are rather poor. I'm considering changes to a BSc in Computer Science, rather than the BIT in Software Engineering that I'm doing at the moment. There are a few reasons for this - first the BIT has been discontinued, so although I still have the chance to finish my degree, how well it will be recognised I'm not sure. Also, as I'm only studying part time now (work part time and studying full time did not bode well for me) it would take me another two years to finish my current degree. Changing to a BSc means I would be able to finish next year if I picked up a few math papers. I'm fairly over university at this point - I'm sick of doing papers that don't interest me because I have to, and I'm confident that I am ready for the workforce already. As fun as studying for studies sake is, I want to get out there and use what I've learnt, and I feel I'm at the stage when I'm going to learn more useful skills out in the big wide world than I would in a lecture theature. I'm pretty sure I'm going to change degrees, but I am going to wait till the new year before I make my decision.
It is growing late, so I feel I should get some sleep. The rain seems to have subsided, but the thunder and lightning continues to rage - I'm not sure I've heard thunder this loud in a long time, it's literally shaking the house. Sleeping to the sound of rain makes me happy :). Until next time..
A while back me and my sister discovered that Linkin Park was coming to play in New Zealand. Being long time fans, my sister had sworn years ago that if they came she HAD to go, even if it was a thousand dollars (her words, not mine). I quite wanted to go as well and saw it as a good excuse to have a holiday.
Being students on a budget, we decided to travel on the cheapest option available - nakedbus.com, $18 from Wellington to Auckland. I had traveled on this bus service previously, and while they aren't really buses, more refitted vans, and you tend to get some interesting characters on the service (both travelers and bus drivers), you can't pass up an $18 trip.
This time however, things didn't turn out quite so well. On dragging myself out of bed at a ridiculous hour, travelling through the pouring rain to get to the bus stop in town, the bus had yet to arrive. So we waited.
And it rained.
And we waited.
And it rained some more.
And we waited some more.
There were six of us unexpecting vagabonds. Me and my sister, the emo couple, the van girl, and the loner. Emo couple moved around a bit, trying to find shelter at a stop that had none. Loner, well, he was lonesome. Van girl, although sitting in her van was the warmest of all of us, offered us no shelter. She was also the most impatient. After about fourty minutes of waiting, she grew tired, and came over to converse with us. After careful investigation, we found the bus companies number - 0900 NAKED. I thought it was quite checky of them to have an 0900 toll number in the first place, and it sounds a bit like a pr0n number, but the number itself wouldn't work. It seemed it no longer existed. Upon discovering this, van girl decided to turn in and find alternate transport, and so her van escorted her away.
We had a little more paitence, but not much. It wasn't long after that loner went on his lonesome way. After waiting over an hour, we too decided to give up. We were soaked, cold, shivering and tired. We decided the best course of action would be to head to the train station and seek alternate transport. Emo couple gave us a strange inquiring look as we left, as if we had some idea why the bus wasn't there, but we headed off to the train station. Along the way though, Teresa thought the information centre might be able to help us. A kind girl there booked us seats on the overnight bus (although at four times the price of our original nakedbus ticket).
I am now sitting in my sister's bedroom, trying to dry out all my clothes which got soaked in my bag from the rain. We have attempted several times to lay a complaint at nakedbus' website, however they seem to elude all forms of contact. Their contact form doesn't seem to want to submit - it requires you to fill in the 'optional' booking reference. However even once we fill it in, it still doesn't work, in either IE or FireFox. It doesn't provide any form of email address, only a postal address, in which they promise to respond within a month or so.
Let's just say i won't be travelling naked again.
I shot Mina. It was fun!
Over the last two days I've been experimenting with virtualisation - running one operating system inside another. The motivation was twofold - firstly Internet Explorer testing at work is a real pain. I normally have to upload all my changes to a test server, remote desktop into an IE test box and then make any changes via ssh - not particularly productive. The second objective is I have yet to find a way to be able to use the iTunes store in Linux! So off on the virtualisation adventure I went.
My friend Matt had managed to get Windows XP running on his work machine on Ubuntu at decent speeds using VMware. While VMware looks very cool, I didn't particularly feel like forking out any money, so I decided to see what the open source options were like. My first stop was Xen - it's built into the kernel and sits very close the the hardware, so is supposed to be very fast. Unfortunately for me it sits too close to the hardware - I'd need either a modified version of XP (which while exists isn't actually available to anyone due to licensing restrictions), or for my CPU to support virtualisation. A quick check on wikipedia showed that my CPU was just a few models too late.. gutting :(.
Next stop was QEMU. QEMU is a bit different - it sits on a much higher level, the software doing more work. Unfortunately this meant it was very slow. Recently, though, someone had developed a kernel module that allowed the hardware to do much more of the grunt work; the module is called KQEMU. I managed to get this all set up (ArchLinux had it all packaged up nicely), however as soon I tried to install XP with KQEMU enabled, I was greeted with a lovely big BSOD. Oh no..
Not willing to give up hope, I ran the installer without the kernel module - this tooking pretty much forever (like hours and hours forever). I don't advise it. After the installation was complete, it booted into Windows... very, very slowly. At that point I shut down the virtual machine. I reenabled KQEMU and rebooted - voila! Windows XP at fairly decent speeds - not native speeds for certain, but it does run faster than a lot of XP machines I've used. And as I plan to only be running a single application, it is more than adequate for my purposes. I have also since found that the problem with the BSOD on install was due to QEMU's less than perfect implementation of ACPI, and that disabling acpi on the commandline would've fixed the issue - doh, wish I had known earlier, would've saved me a lot of time! Lesson learnt - QEMU by itself = horribly slow, QEMU with kQEMU = victory!
After letting Windows do it's update thing, I made a backup of my machine - this is where virtualisation comes in handy. I then proceeded to install Internet Explorer 7 on one copy - so I now have an easy way to test both IE6 & IE7. I was slightly scared about trying to set up networking with QEMU, but I was pleasantly suprised - not only could I access the Internet without configuring anything, but my real linux machine was avaiable at 10.0.2.2, so my web server was all ready to go! :)

My final task was to install iTunes - this ran without a problem. Unfortunately most of the music available on iTunes store is DRM protected, and as I don't plan to boot up a virtual machine every time I want to listen to music, and I have yet to find a way to remove it, I won't be buying any DRM music. Fortunately all EMI music can be bought DRM free (for a slightly higher price, but thus is the price of freedom). While initially I didn't think I listened to a whole lot of EMI music, I discovered that a number of labels with lots of bands I listen to are actually owned by EMI - most importantly Tooth & Nail :). So after setting up a iTunes account, I took for a test run and bought Mae's The Everglow EP, which, btw, I highly recommend (well I highly recommend anything by Mae in general).
The last piece of the puzzle was figuring out how to transfer my newly purchased music from my virtual machine to my actual machine. First I tried Windows file sharing with [url=http://www.samba.orgSamba</a> - however I had a few problems with authorisation - I don't think I'll ever understand how to configure Samba properly. So I took an easier road - downloaded WinSCP on my virtual machine, and used ssh to transfer the files. Result - Mae on Banshee! Excellent!

Today I discovered a new addition to the dairy down the road - classic indian dishes in tasty pie form! I had a butter chicken pie - pure genius! :)
I just went to update my computer and I guess I typed the wrong password, which isn't very suprising considering my severe lack of touch-typing</a> skills. What is suprising is that instead of the general 'incorrect password' message (or something to that effect), my computer decided to insult me. Slightly confused, I deliberately got the password wrong a second to see what would happen:

It seems that the maintainer of the sudo package on Arch Linux recently decided to enable insults. I personally don't mind - I like my computer having a bit of personality! I'm not sure everyone else would think the same though.