Author: Matt

  • Another Personal Test

    There are 3 different things you can do to affect your weight.

    • Exercise changes
    • Dietary changes
    • Take drugs

    It is possible to take any weight management strategy and estimate percentages of effectiveness to each of these 3 categories.  You can lose weight by just exercising more, or just eating less, or doing both.

    I have tested various diets – vegetarian, meatatarian, low carb, slow carb etc. I have also tried doing more exercise.  They all met with varying amounts of success.

    So far I have not really tried very much in the way of dietary supplements or drugs for weight management.

    For the next month I’m going to try taking the EC stack to see it’s effects.  It’s 25mg Ephedrine and 200mg Caffeine taken 3 times a day.  These two compounds taken together have proven to be effective at increasing metabolism and burning fat according to scientific reports I’ve read on Examine.com.

    We’ll see how it goes.

  • Lines of Code Per Day Performance

    There are few arguments with programmers that can elicit such passionate hatred as a debate about measuring a programmer’s performance by tracking the number of lines of code they write per day.

    There are far too many variables at play which can affect a programmers ability to type code – how well they understand the problem, the language being used, familiarity with libraries, and distractions in the workplace.  Because of these extra variables it becomes unfair to compare LOC productivity between programmers or between projects.

    However I do believe it has merit as a personal metric.

    I am a believer in mastery through practice.  You deliberately practice a musical instrument by playing the same song over and over until the performance is good.  You learn your multiplication tables by practicing on 1000’s of example problems in primary school.  You master Jujitsu by repeatedly doing the same throws over and over until they become instinct.

    For mastery to occur the practice must be deliberate and focused on improvement.  You wouldn’t get better at playing piano if you just mash keys – no matter how many hours you did it for.

    Software programming is a skill like these others which takes experience to become proficient with.  For the vast majority of programmers I’ve met proficiency comes naturally through years of 9-5 coding.  I’m not happy with that level of performance for myself.

    Measuring yourself in terms of time to code a solution to a given problem is a valuable metric to have to identify what areas you need to focus on.

    For example if you took a standard example such as implement a merge sort algorithm – and tested yourself on that over time and against different languages you would be able to measure a meaningful change in your programming performance.

    You might first find that you don’t know the algorithm well enough to type it out off the top of your head and turn to Google for a description of it (a detour that takes valuable time).  If it’s a new language you may find points that the syntax throw you back to a book.  Over time if you continued to learn you could reduce the time it takes to type out a solution.

    It’s not that typing out merge sort once per week is going to be code that you would even want to keep.  Just like you don’t record your drum practice and post it up in an album on iTunes.  The point is to identify places in your process for improvement by asking could I have typed out this code better or faster if I was more familiar with the syntax, or knew of some extra libs to use that would cut down on lines of code.

    Then once you’ve perfected that song (algorithm) move onto something new.  Practice it until there is no room for improvement in your time to solve or code quality.

    I believe that practice like this should improve your personal day to day Lines of Code Per Day metric to be 2x to 5x what it would have been without the deliberate practice.

  • Great App Challenge of 2013

    wecandoitThis year myself and a friend have taken up the challenge of releasing a new iPhone/iPad game every 2 weeks to hopefully have 20-25 finished games by the end of the year.

    The strategy is to build upon 3 different game platforms for all the games.  Each game will add one new feature to the platform and completely replace all the art assets to create a unique and fun game.

    The first game was submitted to Apple last week.  It was an update to the first game I did for iPhone called UFO Invader.  It will form the base platform for the next 8-10 games.  The second game, called Air Barons, was finished up and submitted to Apple last night.  The next game is an 8-bit styled space fighter and will add tile-mapped levels and designed coin/power-up layouts to the platform.

    The goal of this challenge is 4 fold:

    1. Learn how to create better and better games through fast iteration of the entire process – design, art, programming,  and marketing
    2. Reduce the risk of focusing on one big game by producing many games that each may resonate with different players
    3. Start generating a small cash flow quickly that will grow with each game release
    4. Build out a network of games to cross promote each other

    It is not going to be easy to do working just in the evenings and weekends but 2013 is the year to do it!

    I’ll be blogging about the work I’m doing here on this site as I go.

  • The Great App Challenge of 2013

    UFO Invader version 2.0 is submitted to the iTunes App Store for review.  It should be published in about a week.

    That marks the first app for what I’m calling the Great App Challenge of 2013.  The goal is to release 20-25 Apps this year between myself and Colum.  That’s one app every 2 weeks!

    The second game is called Air Barons and should be ready to submit tonight or tomorrow.  It is essentially the same game as UFO Invader except all the art assets have been replaced and we’ve managed to add a few new animations and effects to give the game a bit more life.

    The strategy for the Great App Challenge of 2013 is to iteratively improve the on 3 different game platforms focusing on one key feature to implement for each new game.  No doubt that most of the effort will be going into creating the art assets for all these games but by the end of the year we should have streamlined our production of new games to the point where both myself and Colum have a tremendous amount of experience creating and releasing some fun games.

    When successful,  these games will cross promote each other to build an even bigger audience.  It shouldn’t be hard to have all these games generating a healthy second income for both of us by the end of the year.

    Game #3 is going to be an 8 bit space fighter again based on the UFO Invader code.  It will feature a new tile based parallax background and the layout of coins in the game will be designed rather than randomly generated.   Target completion date for that game is February 20th.

  • Hiking to the inkpots

    20130203-180028.jpg

    We’re spending a night in banff and we went on a 5 hour hike along a river and then into the mountains to some interesting coloured springs.

  • Why you should use Celery and Django

    Celery is something that I kept hearing about but took me a while to wrap my head around.  Why is it important? What is it good for?

    With a couple of big Django websites under my belt it has become more obvious where something like Celery fits and why it’s useful.

    The first thing you need to know is what problem Celery solves for you.  It allows you to do things asynchronously so that you can perform longer running tasks in the background and quickly return a page to website visitors.  It also provides a means for running and scheduling tasks that might have before been managed by crontab.

    It is good for things that could result in long wait times like sending emails.  In the case where the code to send an email could potentially timeout if the mail server is down then putting the send email code into a view function could result in a long frustrating wait for the user.

    The biggest issue with cron is that in a multi-server environment it is difficult to manage what is going to run where, and balance your resources.  It’s also a bit of a pain to deploy changes to the schedule without pushing configuration files to your servers.  You lose control over any load balancing and it becomes difficult to manually kick off processes.

    Celery also provides some neat methods for delaying code to run in the future.  For example, lets say you want to send an email to users who haven’t logged in to your website in the last 7 days to remind them of your awesome service.  To optimize it further you’d like the email to be sent at a time of day when there’s a good chance they’re sitting at their computer (the same time of day as their last login).  Using a cron job you’d have a script that queried the database for all users who met the criteria and then send out all those emails at once – and run it every few minutes.  The risk there is that an error in the DB query could result in spamming a lot of people with the wrong email.

    Using Celery it’s possible to schedule the code to send the email 7 days into the future.  The task code will be much simpler – check that the conditions are still valid and send just one email to the one user.  It also scales up nicer – since it’s only going to query the DB when there is a likely chance that it actually will have some work to do.

    Setting up Celery takes a bit of work.  Actually,  getting it to work is relatively easy,  deploying it to production is a bit more involved since it requires a bunch of other tools you may not be using yet.

    There are two celery tasks that need to be demonized – the Celery workers and the Celery beat (for scheduled tasks).  Celery tasks are queued up by either the celerybeat program or from scheduling them in your app.  The queue that all these are persisted into is some sort of message queue service or database.  It can be RabbitMQ, Amazon SQS, Redit, Mongo, or a Django DB.  Workers listen to the queue for things to do and pick up work when they can.

    Demonizing the workers and celerybeat can be done with Supervisord.  It simply makes sure that if the programs crash they get restarted, and that they continually run in the background.

    Monitoring what tasks are in the queue, what is running, and the results of past tasks is through an app called Flower.

    Ensuring that everything stays up and running can be handled by Monit.

    Once the infrastructure is in place having Celery really does simplify a lot of the code you write.  Simpler code make me happy.

  • Home Music System

    A while ago I set up a music system above the fireplace.  It uses an AirPort Express as a destination for playing iTunes music from my computers, iPhone or iPad.  The audio out channel from the AirPort Express feeds into a small amp that I found on Amazon for $20 which powers a pair of good bookshelf speakers.

    To control the music I have a spot where I can attach my iPad to the wall with velcro.

    It’s been a pretty good system.

    The Raspberry Pi is going to be making itself part of the system eventually as a podcast downloading alarm clock.  The plan is to write a simple script to download CBC podcasts in the morning and auto-play them with a bit of smarts regarding holidays and weekends.  I’ll have  simple web front end to control and configure the system.  Should be nice to have a little something to wake up to.

  • Finding Focus

    Programming is a task that requires long stretches of uninterrupted time to be productive.  A simple 15 second “How’s it going?” will almost inevitably lead to a 15 minute delay in work getting done.  A scary but true fact.  Programming, like design, and engineering tasks are most productive when you get into the “flow” or “zone”.  They are high momentum tasks that take time to ramp up to full speed.

    Task switching and multi-tasking kill the flow and are therefore detrimental to being productive.

    There are many tips out there for how to prevent disruptions.  Headphones have worked for me during late night coding sessions to help me forget how late it is.  Using full-screen apps is helpful as is turning off new email notifications.  Learning to use my editors keyboard shortcuts so that I don’t have to use my mouse is surprisingly effective – the mouse is a gateway to browsing reddit.

    I’m still looking for new tips all the time.  Anything that can help me chip away at the mountain of code yet to be written makes a difference.

  • Migrating from Apache to Nginx + Gunicorn

    I was never really sure why people opted to swap out the heavily tested, widely deployed Apache web server for alternatives other than those trying to eek out a little bit more performance.  Finally I found a good reason to change my setup.

    When trying to enable Celery for asynchronous tasks on my web server I ran into some unexpected errors with imports.  Eventually I tracked the problem down to mod_wsgi was compiled and running against an old version of Python rather than the newer version in the apps virtualenv.

    The bigger problem with Apache outside of any performance issues is the coupling of Apache, mod_wsgi and python.  Upgrading python becomes complex and running multiple django apps on different versions of Python is non-trivial.  The other issue I found is that Apache takes several minutes to reload which is enough time to disrupt users.

    Nginx acts as a trivial reverse proxy.  Once it’s configured and running it will probably never need to be restarted.  It directs incoming requests to a free standing python application that is running and listening at localhost:8000.  Gunicorn is used to run the django app on port 8000.  It can be run from the command-line all within the virtualenv’s copy of python and gunicorn.  This way the django app is nicely isolated and it operates without tying itself to too much of the OS.

    Making the gunicorn process a daemon so that it runs in the background and starts after a system reboot is handled by having Supervisor running.

    The real day to day benefits to getting rid of Apache is that deployments are faster and there’s less downtime when restarting the server.  It also gives more flexibility for upgrading python rather than using the system installed version.  In the end it was easier to switch to Nginx + Gunicorn + Supervisor rather than fixing the Apache config to work with Python 2.7.3

  • Biting Off More Than You Can Chew

    If there is one fault that I have it is that I continually make ambitious plans and take on every little project that someone suggests.  The big iOS game that I was working on for the last month is looking like it’s too much for one person to complete in a reasonable amount of time.

    Lesson learned:  If a company of 50 is developing an application and it takes them 6 months to complete then it will not be possible to do something similar on my own in half the time.

    God.  That is actually hard to admit.

    So the big project is going in storage for a while and I will focus on smaller deliverables.  More easy to build games and build up the infrastructure, code libraries, and cross-promotion network of apps needed to push a good game to higher heights.

    There are two factors I have found to being able to be productive:

    1. Setting small goals and short timelines seems to be the best way for me to make progress on things.  I love to ship products and updates.  Give me just a handful of features to add to an application and I’ll be able to hammer it out quickly and deliver the update.  Too big of a change makes me nervous that I’m going to break too many things.
    2. Headphones.  Removing distractions and getting into the zone with my code is crucial.  With the headphones on I can work for hours without getting distracted by people or what might be on TV.  It’s amazing how often you forget to go to bed or eat when you can maintain your focus on the task at hand.