March 09, 2010 | categories: Me, Programming

During the last week, I finally did something I've been meaning to do for the last while, and bought myself a VPS as up until now, I've been on shared hosting. On the advice of compwhizii, I went with Linode. While there was nothing wrong with my previous web host, Web Hosting Buzz, they were a full $5 a month dearer for their entry level VPS packages, and unlike Linode, did not give you a choice of a UK data centre. My site, and most of it's visitors are in Europe, so that was quite helpful.

So, after purchasing the VPS, I set it up with the basics: DNS, Apache, MySQL, PHP (my blog runs on Wordpress which uses PHP, which is why it got in ahead of Python). Very simple, just use the package manager and Control Panel to set it up. There was a slight mishap where my DNS changes were propagated before I fixed them, leaving my blog not set up yet. But that was soon resolved.

After about a day, I noticed Apache was getting random segfaults serving static pages. Rather than spending ages to debug the problem, I decided to try out nginx, which I had heard good things about. It was quite simple to set up, with Linode providing a guide with most of the steps. All well and good. Until, about two days later, nginx started reporting a 502 bad gateway error. A problem with a new web server? Nope. The fault lies with php-cgi, and it was compwhizii's blog to the rescue again. His post about using nginx provided a link to this page explaining how to solve it. The short version? Set the  PHP_FCGI_MAX_REQUESTS environment variable, so the php-cgi process gets restarted every so often.

The VPS is, unsurprisingly much better than the shared hosting. SSH is much better for administration than the old Control Panels. The first project I'm doing to really make use of that, is something I have planned using Django. More on that later, if it comes to anything.


February 28, 2010 | categories: Programming

On the advice of Sirupsen, I have been trying out vim during the last few weeks. Up until now, my editor of choice has been gedit on Linux, or Notepad++ on Windows for most stuff. I have also used VS on Windows, which while good for C#, it doesn't really help writing multi-platform programs. And I've used Eclipse a bit, back when I used Java for a while. But, most of my programming is done in languages such as Python, PHP and Javascript, and for the small size of my projects, IDEs tend to get in the way, and they also aren't quite as good for dynamically typed languages anyway.

So first of all, to quote one of my tweets:

After using it a while, I apologise to vim users. It isn't weird and crap, it's just weird.

I haven't exactly been the most positive of vim. After all, as a Linux user, it's nigh impossible to use many of them without one of them using vim or a vim-like interface for something. And while nano manages to be relatively easy to understand, vim does not. Because vim is weird.

But after a while of using it, I realise it's weird for a reason. Want to get rid of a line? In other text editors it's:

  • Left arrow to start of line
  • Hold shift
  • Hold right arrow to end of line
  • Press delete

In vim it's:

  • Type dd

Don't like that 13 line function anymore, and want to delete it?

In normal editors it's:

  • Up and left arrows to start of function
  • Hold shift
  • Down and right arrows to end of function

Vim is:

  • Type 13dd

Weird, obtuse, but once you learn it, it's far more efficient. A final example. Suppose you want to rename that variable from $car to $vehicle:

A normal text editor?

  • Edit
  • Search and Replace (somethings this is part of search anyway and under Ctrl-F, other times it's its own menu, under Ctrl-H)
  • Type in $car.
  • Type in $vehicle


  • Type :%s/$car/$vehicle/

At this stage, I'm still not getting the most out of vim. After all, I only know a few basic commands (and even then I'm missing a few. Any vim users care to tell me how to Select All?). Yet I'm already finding it easier and faster than I did in other editors. vim is also cross platform, unlike the Windows-only Notepad++ and Linux-only gedit, which means I can use the one editor across all OSes. For that matter, it's even available on my jailbroken iPod touch.

Another useful feature of it is it's huge styling and plugin community. Again, Sirupsen pointed me to BusyBee. I didn't quite like that, so I found Mustang, the theme it was based on. I haven't yet found plugins that I'd reccomend, but the choice is huge. One of the inbuilt ones, allows you to set different options per language. I'm doing a project in Ruby atm, and in any other editor I'd have to change my settings to and from my personal preference of tabs and Ruby style of double spaces. With vim, I can set it to do tabs with all other files, and just do the silly double space thing with Ruby.

You know, I kind of liked Vista

February 21, 2010 | categories: Pcs
Still doesn't make this any less funny.
<Snakeman^Engineer> Do I sense some hatred towards Windows Vista originating from your direction?
<Chrysalid^Revenge> Oh no, not at all
* Chrysalid^Revenge stands up in a medieval recitation pose
<Chrysalid^Revenge> "OS X for the Mac users, pretentious in their coffeeshops
<Chrysalid^Revenge> Gentoo for the nerd-lords in their mother's basement
<Chrysalid^Revenge> XP for the everyday user, bound to muck around with bloody settings and registry values they should damn well leave alone
<Chrysalid^Revenge> Then Vista from the Dark Lord behind his desk
<Chrysalid^Revenge> In the Microsoft office, where crappy programming is performed
<Chrysalid^Revenge> One OS to eat your RAM, One OS to spy on your digital media
<Chrysalid^Revenge> One OS to screw them all, and in frustration bind them
<Chrysalid^Revenge> In the Microsoft office, where crappy programming is performed"
<Sectoid^Authopsy> Whoa!

The wi-fi doesn't work. I give up. I'm going back to... Linux

February 16, 2010 | categories: Gaming, Pcs

Linux and wi-fi. They normally go together like a square peg and a round hole. Every wireless adapter I've had the past few years has had at least some problems running under Linux. Ranging from my USB WPN111 putting an end to my first foray into Linux ("screw this - no internet, it's too much effort, I'm going back to Windows"), about 2 years ago, to my current laptop's random DNS failures when I used WPA2.

So, I was pleasantly surprised when my new TP-Link WN821N worked straight away on Linux on my desktop PC. Given that is was a €20 Wireless N adapter, I didn't expect it to. All well and good. Then it came to Windows. Expecting it to be simple as usual, I installed the driver. The wi-fi thing showed up, I used Connect to a Network, and... No network.

Several minutes of googling later reveals there is no Windows 7 driver (which is what Server 2008 R2 normally uses). Instead there is a Vista driver, which is no good in this case. So I've either:

  • Ran into one of those edge cases where the difference between Windows 7 and Windows Server 2008 R2 actually does matter.
  • Ran into one of those edge cases where the difference between Vista and 7 does matter


  • Both

Which really sucks. Especially when the majority of what I do on that desktop using Windows is gaming. (Yeah, yeah, gaming over Wi-Fi, tut tut...). Gaming sans multiplayer is kind of limited. I mean, sure I can play Fallout 3, and Oblivion fine, but what about Team Fortress 2? Oh, hold on, that works on Wine. Actually, so does Fallout 3. And openTTD. And that's basically all I play in PC games lately.

Right, so why am I running Windows on this machine? My copy of Visual Studio is from DreamSpark (as is my copy of Windows, which is why I'm using Server 2008 R2 in the first place - it was that or XP, I've no Windows 7 yet, and my Vista disc is a Dell OEM disc), which I'm fairly certain can only be installed once, and it's already on my laptop. uTorrent and Paint.NET both blow away their nearest competitors on Linux, but uTorrent is useless without an internet connection, and Paint.NET is only one program at the end of the day.

So, screw this - no internet, it's too much effort, I'm going back to Linux1. And that is something I never thought I'd say when I first started experimenting with Linux. Of course, most of this is TP-Link's fault. If some random outsider can write a working driver for Linux, I don't see why they shouldn't be able to write a driver for Windows 7. I won't be buying from them again.


On this desktop at least, on my laptop I still dual-boot to have VS for programming Windows languages, and iTunes for syncing my iPod Touch.

First projects

February 05, 2010 | categories: Programming

One of my online friends has started learning programming in C++ and Python a few months ago. While he seems fairly competent in it, he was complaining that he feels he hasn't acheived anything worthwhile in it. He said he just can't think of anything useful to make.

This reminded me of when I was starting out (and again when I was starting out with Javascript, and again with PHP, and again with... you get the picture). Like him, I also struggled to think of something to make. My first trivial program was a Java clock applet when I was 13. I saw one on another site and decided to make one for my own. My first non-trivial program was a social network, written in PHP when I was 15. Two years to think of an decent idea that I could keep working on until completion.

I think the problem with beginners projects by self-learners is one of overreaching. I've certainly done it a lot. If they try to write a social network, they want to write Facebook. If they write a forum, they want to write vBulletin. If they write a game, they want to write Fallout 3. All of these were written over a significant amount of time by large groups of people.

My advice is this: Start small. Reduce whatever you plan to build to it's basics. A social network can be reduced to users who can add friends, edit profiles and leave comments on other's profiles. A forum can be reduced to users creating threads and posts. A game can be something like Pacman. Implement these basics. When you have them done, you will have enough motivation to get the rest of the stuff done (login, logout, etc.). While you can't assume designing a successful product is as simple, as the linked blog post shows, designing a beginners project to practice your coding is easier than designing a product to base a business around.

Despite not being quite that simple, many successful products are based on simplicity. Compare Twitter to Facebook, punbb to vbulletin, Google Chrome to Firefox. Simple and fully-featured are two equally valid design strategies (although I tend to favour simple products myself), but simple ones are much easier to get going.

Once you have your basic program written, you can then add features to it. You could add image uploads to your social network, bbcode to your forum or extra enemies to your game. Further again, you can add groups to your social network, tagging to your forum, and new level types to the game. Since you already have a working base to start from, it's much easier to look at it feature by feature, instead of waiting ages until you have anything that works.

« Previous Page -- Next Page »