• 03 APR 2012

    Moving hosts

    It's been a good run with Hostgator, but since I've been using Django for more projects, it's been frustrating working with only v1.2, as well as issues with performance.

    My new host of choice is WebFaction, who so far are so far above any other shared hosting packages. The big difference is that you get to install apps to your home directory yourself, rather than relying on a shared instances. Not only that, but you get access to Apache config files, proper error logging, and a lot more. If you're looking for somewhere to host your projects as a developer, definitely give them a look.

    Django-debug-toolbar


    As a result of changing hosts (i.e. actually having an up-to-date version of Python and Django) I've been able to try out Django debug toolbar which was recommended to me. It's almost been worth the switch in web hosts purely to use this, and I already uncovered a mistake that was slowing down a site by a factor of 10. (I was counting objects with len(Thing.objects.all()) rather than Thing.objects.count() - silly mistake, but with the toolbar it pointed it out right away)

    I've got a busy few weeks coming up, but after that regular updates should resume.

  • 24 FEB 2012

    Django bits-and-bobs

    I've spent the last week or two working on a new Django site, and learning a lot at the same time. I thought I'd post a few small little tips on how to do a few things that people still getting into Django may not work out so easily. The documentation is generally very good, but sometimes it's not clear on which method or combination of methods to use to achieve something.

    (Note: I'm stuck back on Django 1.2 so some of these things have changed in 1.3 and dev)

    Getting current URL


    To get the current URL you need to reference the request object, but you'll find this isn't available by default in your templates. To have access to this, be sure to add django.core.context_processors.request to your TEMPLATE_CONTEXT_PROCESSORS setting.

    You can get the current URL with request.build_absolute_uri

    Moderate comments by default


    The built-in comments framework is great, and even better when I found it had the capability for moderation. However I found it strange that once enabled, comments weren't hidden by default. You're supposed to be able to specify auto_moderate_field and moderate_after settings to make them require moderation after a set time since the post was written, but it had no effect. So the solution, override the moderate() method as below (moderate() in docs)

    class BlogPostModerator(CommentModerator):
    email_notification = True
    enable_field = 'can_comment'

    def moderate(self, comment, content_object, request):
    return True

    I'll add a few more later and hopefully they'll help some Django newbies out there.

    The game


    I've not had much time to work on anything with the HTML5 game lately, but I still intend to - right now I'm in the middle of getting NPC movement and map scrolling working well, somehow between all the ideas of loot and inventory screens and baddies, you forget about the less-fun maths part of game programming.

    Here's a screenshot as of a week ago. You can see the random map generation, using Binary Space Partitioning to split into sections (indicated with the shades of ...

    Read more
  • 09 FEB 2012

    New toys

    So it's been a while since my last post, been a little busy the past few months, but now I'm getting settled and should be able to start some regular updates again.

    After my last blog post, I did eventually go ahead and sell the Mac Pro and just this week I've been setting up my new PC and happily using Ubuntu. Linux in general has come a long way for home use in the last few years, and I've had no issues whatsoever through installation, getting various bits of software installed (Chromium for browsing, Sublime Text 2 for coding, Crashplan for backup, and many others), and getting used to the differences between OS X and Linux (mostly keybindings, but getting there). I even found a great replacement for Visor ('Quake' style dropdown terminal for OS X) called Tilda.

    I'm still slowly working on my HTML5 Canvas-based game, and hopefully I can start more regular posts about that soon too. Ultimately I'd love to finish something and get it up on the Chrome web store, but finding the time is difficult just now.

  • 28 NOV 2011

    Bye-bye Mac Pro, Hello Ubuntu?

    In preparation for moving, I'm selling my trusty Mac Pro that's served me well since late 2008. Initially, I was going to replace this with an iMac - much cheaper than a new Pro, and after using a 27" version at work for a while, I'd gotten used to the large screen that would otherwise cost a fair bit to match. I do still use Windows occasionally via dual-booting, mainly for IE testing and gaming. I still have a Macbook Pro to use as well in the interim, but I much prefer having a desktop as my main machine.

    As a bit of background, I went through a phase many years back of trying out Linux at home, but I have this bad habit of not sticking with one route and so I was reinstalling a different distro every week. I went through the big three at the time - Fedora, Mandrake (before the rename), and Suse, and then had a play with Slackware for a while. I think at that point I got my first Mac, and to me Linux didn't really seem ready for the desktop yet. I've been happy using the Mac for a number of years; the software in particular kept me on the platform, and I was still able to use the command line to keep some of that feeling of when I used Linux.

    After some exposure to recent versions of Ubuntu at work, I decided it was time to see if a modern Linux distribution, running on higher spec hardware (cheaper than a new iMac) could meet my day-to-day needs. I started by grabbing the newest version of Ubuntu and installing it onto a VirtualBox image, and I was definitely impressed. With new additions like an App Store ('Ubuntu Software Center') and native versions of software I use (Sublime Text 2, Crashplan) the hold that OS X had on me was dwindling.

    Ubuntu screenshot

    So after playing around a little and testing out just how easy it is to get setup with a LAMP stack, and even getting Minecraft running inside the ...

    Read more
  • 15 NOV 2011

    Random bits

    Already slacking with the updates here, I should start trying to be a bit more regular with these posts. So a few random unrelated things today:

    South on Hostgator
    My site has been up working for a bit of time now, and the fact there's django (and Rails) hosting as part of the cheap shared hosting package on Hostgator still impresses me, but one little problem I encountered was using South.

    Now, on this page they list support for it, and it is indeed installed available to add to your INSTALLED_APPS in your settings.py. The problem is the shared hosting severs run Python 2.4, and so the second I ran a migration I hit this bug. Despite several attempts to let the folks at Hostgator know that it wouldn't work for anyone, they were being a little over-cautious and didn't want to update South at all.

    Thankfully I found a nice simple solution to work around the problem. Download your own copy of South and stick it inside your django project folder and add the path inside your .fcgi file - sys.path.insert(0, "/home/tomc/djangoapps/south"). Then in your settings.py, rather than just adding 'south' to your INSTALLED_APPS, add '<project>.south' (djangoapps.south in my case) and you'll have a correctly working copy of south good to go.

    Minecraft 1.0 and Minecon
    For you gamers, a reminder that Minecon is happening next weekend, and IGN are going to be streaming various things during the event. For those of you who've not picked up Minecraft, I really would give it a try - it's a great thing to relax with in the evenings.

    More posts soon, honest...

  • 23 OCT 2011

    Some new shiny tools

    I've been using a few new bits of software lately that deserve some love so I thought I'd share a few links (sorry Windows fans, they're for mac)

    Sublime Text 2
    After being an avid Textmate user for a while now, a bunch of us at work recently switched over to using Sublime Text 2 instead, and so far it's doing the job perfectly. A few features I like: split column views, 'distraction-free' mode, the autocomplete addon which scans your JS library to autocomplete your own objects, and generally it seems more stable when dealing with large files and projects.

    Sublime text 2 screenshot

    Sequel Pro
    For a long time I used web-based MySQL admin systems - PHPMyAdmin at first, then SQL Buddy - but recently I've switched to using a native application - Sequel Pro - and it has some very nice features, and also has the nice addition of being free to download. It does everything you'd expect in a database admin tool so I won't list the obvious features, but it's a very polished app and well worth a look.

    Sequel Pro screenshot

    Crashplan
    Not quite a dev tool, but I bought a Crashplan subscription quite a while back now, and although I've (thankfully) never had to restore a dead computer, it's been doing a great job of silently backing up all my worldy digital possessions onto their remote servers, ready for the day when my Mac Pro has had enough. Sure, Time Machine is good, and it'll give you a simple way to restore a dead drive, but I get very paranoid about my data, and if the Time Machine drive got stolen, or broke, then it's gone. Crashplan gives you a way to backup everything remotely without that worry. They do a 10GB plan as well as Unlimited (yes, actually unlimited).

    At some point I'll add commenting to this blog so anyone reading can actually contribute, as there's probably a whole lot of apps I've never even heard of that some of you can't live without.

  • 22 OCT 2011

    ...and done

    Finally got around to sorting this out, so here be a new site. I'll probably vary blog topics between tech things and general day-to-day stuff, so lets see how that goes.

    So what am I up to? I've been trying to expand a bit from the comfort of PHP lately, both with django (which this site uses) and Ruby on Rails, which I'm starting to get involved with (from a frontend point of view) at work. So far I'm preferring django, I think partly due to the syntax of Python vs. Ruby, but time will tell.

    I'm doing less in the way of gaming at the moment, mostly holding out for Diablo 3 (even a beta key would do) and in the meantime Minecraft is keeping me entertained - definitely recommended for any gamers who've not discovered it yet.

    I'm still trying to create something resembling a game myself, but I'll save that for another post.

  • 02 OCT 2011

    A new site

    So after switching to the excellent Hostgator for my web hosting a few months back, I thought it was about time I put a site back up. I thought I'd use the chance to pick up django rather than my usual familiar PHP, and while I've built up a pretty good framework over the years, django is certainly making some things easier - still plenty to learn.