Skip to content


Goals, 2010

Apparently, Goals suck too. Or at least I suck. Reviewing the goals I set for myself last year, I see that I didn’t really do too well.

1. Lose 30 lbs. I don’t want a perfect body, but I do want to get rid of this spare tire I’m lugging around. Getting down to 195 would do most of that.

FAIL. I weigh as much as last year at this time, almost to the pound.

2. Exercise 3x weekly, for at least 30 minutes. I’m going to keep a journal and everything.

FAIL. I lasted until early February.

3. Launch BillOnSite. There’ll be more on this later, but I think I have a real winner (or at least some real potential) here.

WIN! I actually launched the site! That said, I haven’t really developed it into a winner yet.

4. Pay off my PC Financial Mastercard. My strategy here is that every non-rent paycheque is used to reduce it a further $500 from last time. So if it’s at $2000 and I spend $40 in the intervening time, I have to put $540 on it to “catch up”. I don’t know how well that will work, but even if it doesn’t, I should still be able to pay the whole thing off this year.

FAIL. Though getting laid off sure didn’t help.

New Goals for 2010

  1. Lose 30 lbs. This one I’m carrying over, since it’s pretty worthwhile.
  2. Develop Bill On Site into something at at least pays its own bills.
  3. Pay off my PC Financial Mastercard. Again, I’m carrying this over. Hopefully this year I won’t be laid off halfway through it and I can afford to throw money at it until it’s dead.
  4. Have a playable demo. I’m working on a game now – name unknown, but it goes by “Zombie Fortress” until I can dig up a better one – and I want to have something I can actually show someone so they understand how the game plays. It’s one of those sandbox games where the attention to detail really makes the game, so I’m not planning on finishing it this year, but I want to be able to load it up and say “So look, the survivor goes over here and he picks up the gas can, but there’s a zombie there and he’s a cowardly survivor, so he drops the gas can and runs. Neat, huh?”

Unachievable goal: Rig the lottery so that Stephen Harper wins six times in a row, even though he’s not playing, and he undergoes an embarassing investigation. The scandal loses him the Prime Minister’s seat.

In other news, while not a goal or a resolution, I do plan on blogging more. It occurs to me that more things of note happened to me in ‘09 than are reflected on this blog, and that’s kind of a shame. I mean, nowhere on here does it say how I’m now working for The Hill Times in downtown Ottawa, and loving it. I mean, what the heck’s the point of that?

Posted in Life.

It’s Programmer’s Day!

Apparently, in Russia, on the 256th day of the year, they now celebrate Programmer’s Day.

I propose that this is an excellent idea, and we should celebrate it with all the pomp, circumstance, and rigamarole that we celebrate Mother’s Day, Father’s Day, and Talk Like a Pirate Day.

Speaking of, Talk Like a Pirate Day is coming up, too.

Posted in Uncategorized.

The Colony

So I found this new reality show. I know what you’re thinking – “Man, fuck reality shows. Those are for bored housewives who do nothing but sit around eating bonbons all day.” Well fuck, aside from the “bored”, “housewife”, “bonbons”, and “nothing but sit around”, that’s me to a T.

(For those of you playing the home game, that makes me a “who do eating all day”. That’s fucked up.)

Anyway, the show is called “The Colony”, and it’s about a group of people who are herded into an abandoned industrial lot, told that the world has ended, and they must survive this post-industrial wasteland with nothing more than what they can scavenge, build, or steal.

Considering I just got through playing Fallout 3, I am in exactly the right frame of mind to enjoy this show. I basically scavenged and stole the entirety of Washington, DC.

Here, let me give you a little excerpt from the wikipedia page about episode one:

Episode 1

Phase Context Description
Phase 1: Sleep Deprivation Shock and Fatigue To simulate the stress survivors experience in the aftermath of a disaster, the volunteers are kept awake for thirty hours with almost no food or water.
Phase 2: Looting Scarcity of Supplies Mentally drained, the first six volunteers were given fifteen minutes in an abandoned department store to scavenge as many resources as they can carry.
Phase 3: The Marauders Resource Competition Ten minutes into scavenging, a gang of looters are sent in to steal the volunteer’s supplies.
Phase 4: River Walk Search for Shelter Before arriving at the colony, the volunteers haul their 200 pounds of looted supplies eight miles down the Los Angeles River.
Phase 5: Arrival and Survival Rebuilding Begins The six colonists arrive at an 80,000 square foot warehouse on a three and a half acre plot of land. They are supplied with rudimentary materials, tools, and a small supply of food and water. How they use these resources is up to them.

Now tell me that doesn’t sound badass. I’m sure it’ll be fucked up by the normal reality-show drama nonsense that the producers seem to love putting in regardless of how cool the concept is, but this is such a cool concept that I’m going to have to give it a try.

Hopefully I can catch Episode 1 tonight and report back.

Posted in Raw Entertainment.

The Game Crafter – Cafe Press for Board Games

I just saw this and fell directly in love:

The Game Crafter – Your game REALIZED

So basically you can design your own board game, upload it to them, and then start selling it from their site. How freaking cool is that?

I wish I had an extra 24h in each day so I could work on a board game in addition to Bill On Site

Posted in Games.

The Naked Else – How I Hate Thee

I cannot express my frustration at seeing code like this:

if (isset($modifier)) {
    // Do some things.

    // And some more things.

    // Still more
    // things
    // to be done here.

    // There's a whole lot of things here!

    // Last bunch of things
}
else {
    // Do totally different stuff
}

People. Comment your elses! I shouldn’t have to scroll up to read the if again just to figure out what a branch of logic does. This is a maintenance code nightmare, and simply adding a simple “// If validation has failed” will save all kinds of time and frustration.

Posted in Coding.

Got Laid Off Today

I always figured that when I got laid off next, I’d write a scathing missive about how the company that did it was full of blundering morons, savagely incompetent noncompoops, and how I hoped they’d fail miserably without me.

Okay, rather, I figured I’d have the fortitude to resist writing such a post, but I at least figured I’d want to.

But see, I got laid off earlier today and frankly, I’m not upset at all.

I’m not upset with the company – I wish them the very best. They have some neat technology and if it pans out (and it looks like it will), then they’re going to clobber the marketplace. I’m not upset with anyone left behind – these things are usually as hard on them as they are on those that got laid off, and everyone still working there is good people that I just don’t wish this on. And I’m not upset with the management either – they were faced with a tough decision. They’d cut every non-staff expense they could (we watched and noticed and were grateful), but this economy is brutal and people are loathe to commit to purchasing decisions, which affects their bottom line.

And it’s not like I’m going to be in dire straights or anything. Since I was laid off, I can get EI for Quite Some Time, or even better, Ontario offers a Self-Employment Grant that you can get if you’re otherwise eligible for EI. Since I wanted more time to work on Bill On Site, then this may actually work out to my benefit.

Ultimately, I’m choosing not to think of this as a setback, but rather as a hell of an opportunity.

Posted in Bill On Site, Life, News.

Super-useful Komodo Plugins

Komodo Edit is Awesome and has Plugins

Komodo Edit is awesome and you should all use it.

Seriously. I don’t know how much more I need to go on about this point, but the productivity benefits of a good IDE are astounding, and if you’re still using Notepad or gedit or the like like, then you are Doing It Wrong.

If I had to recommend a good IDE, I’d recommend Komodo Edit. I have before. Hell, I’m still their go-to quote, a fact that I find puzzling, yet rewarding.

Anyway. The guys at Activestate switched to using the Mozilla codebase a while ago, which means that anyone who can write a Firefox extension can (in theory) write a Komodo extension. And so they have! And I have found three that I have fallen absolutely in love with.

They are:

TODO Helper

The TODO Helper plugin is great if you leave all kinds of little “TODO:”s scattered through your code as mental bookmarks. This plug-in can quickly search your entire project for all TODOs listed and display them in the bottom panel.

It’s a little frustrating when the framework you’re using leaves TODOs in their releases, but it’s not hard to take those suckers out anyway.

kJSLint

A long while ago, I blogged about how to integrate jslint into Komodo Edit, but I guess that’s not really strictly necessary these days. Since there’s a plugin that integrates jslint into a menu command.

Sure, you lose out somewhat on the ability to control exactly what version of jslint you use, but the version included is rather up-to-date, and saves you the trouble of having to install an interpreter just to run it. A definite win.

(Also, the “Crockford says no.” message it spits out when you fail validation makes me smile every time.)

Source Tree

Though not as slick as Komodo IDE’s code browser, at least the Source Tree plugin is free and does what it says on the tin. Having the entirety of the file’s functions and classes available and easy to navigate is very handy. Shame this isn’t in the free version of Edit to start, but they’ve got to have some features to differentiate the two enough to encourage people to buy the “pro” edition.

And in Conclusion

Komodo Edit. It’s good. Komodo Edit with Plugins. Even better.

Now get coding.

Posted in Coding. Tagged with , , , , , .

Clean Code: Nested conditionals

Ugly code is everywhere. Inside that copy of Microsoft Office 2007, behind that latest Linux kernel, and in the dozens and dozens of web 2.0 MicroISV tools you use day-in and day out. Lurking.

But there are those of us who fight! Who rage against the dying of the light! Those who are more than happy to share our solutions to cleaning up ugly code, in the hopes that up-and-coming programmers will notice and apply said solutions. This… is one such solution.

Take, for example, nested conditions. They look like:

if (thing) {
    [CHUNK A]
    if (thing) {
        [CHUNK B]
        if (thing) {
            [CHUNK C]
        }
    }
}

It’s not THAT ugly, but try extending that out into five or more chunks, or if you’ve already indented a couple of times, you will notice just how ugly this looks. Since each chunk is only executed based on the result of a boolean test (the if statements), and each chunk is directly dependant on the previous chunk (and oughn’t be run if the previous chunk fails), we can take advantage of short-circuit operators and rewrite this section of code to be much cleaner.

Instead, rewrite each chunk into its own function, have that function return a boolean, and you can rewrite the original code like:

$success = do_chunk_a();
$success = $success && do_chunk_b();
$success = $success && do_chunk_c();

This is a huge win in terms of readability, and therefore in terms of maintainability. Especially so if you name your new functions descriptively, like “send_invoice()” or “update_client_list()”. It’s far easier to look at the descriptive name of the functions instead of having to read through the entirety of each chunk, just to find out what the code is supposed to do.

Posted in Coding.

The Micropreneur Academy

As some of you may know, I began working on a side-project back in December – a business I want to launch this year. Thankfully, to a large degree I know what I don’t know, and I’ve been reading as voraciously as possible, trying to fill the gaps. I’ve read books by Guy Kawasaki, I’ve subscribed to blogs for entrepreneurs, and participated in discussion forums for software business owners.

But just today, I decided to sign up for The Micropreneur Academy, by Six Figure Software. Run by a fellow named Rob, who has experience creating, launching, and running not one but many super-small businesses, it looks to be a very interesting resource. Two main things attracted me:

  • It’s not free. Actually, it’s rather pricey. The benefit here is that it keeps out the riff-raff. The only people here are the people who really want to learn how to launch a super-small business and succeed, not just some shmoe who wants to dream of doing constantly without ever achieving. Signing up to something that costs serious dollars at least signifies some intent.
  • The forum. I waffled on signing up for a bit, wondering if the information imparted would really be worth the money, when I realized that it didn’t matter. The course could be a total wash, teaching me nothing that I didn’t already know or couldn’t already find on the internet for free. But it would provide a guided discussion of all the varied aspects of running a super-small business, and all those people on the forums with intent and businesses, who are currently putting it on the line will be there, taking part in that conversation. That, in and of itself, is worth it.

Today was the first day the Academy was open, and the forum is already lively. There’s the seemingly-mandatory introduction thread, there’s a few threads about very specific questions that are returning some interesting answers, and there’s an entire sub-section dedicated to people announcing goals each week and how well they followed through on the previous week’s goals, a brilliant little feature that I immediately participated in. It’s good to have people keeping you honest.

And honestly, I’m really looking forward to the coming weeks and the lessons learned therein.

Posted in Bill On Site.

New in PHP 5.3

PHP is approaching another important release, version 5.3. The release candidate is already available, if you’re interested in trying things out early. I thought I’d take a moment however, and highlight four really interesting new features we can expect in this new release.

1) Namespaces

Adding namespaces solves, in a stroke, a great many conflicts that developers tend to run into with PHP. For example, if I write a database layer class called db and YOU write a database layer called db, and I try to include another library that you’ve written that references your database layer, I’m boned. Since they’re both declared globally, this attempt at code re-use fails.

However, if I write a database layer and I decide to put it in the “danhulton” namespace, and you put yours in the “anotherlibrary” namespace, we’re fine. I refer to “danhulton\db” and you refer to “anotherlibrary\db” and all is right in the world.

Sadly, the namespace delimiter they’ve chosen is the backslash, which to my eyes just looks ODD, and also can run you into issues if you ever have to put your namespace in a string (with backslash being the escape character). Still, this is a net win for writing shareable PHP code.

2) Anonymous Functions

I got into the habit of using anonymous functions liberally in javascript, and have come to sorely miss them in PHP. Sure, you can emulate them with create_function(), but the syntax is awkward and the resource cost prohibitive. As of PHP 5.3, we’ll be able do do something a little like this:

$escaped = array_map(function($value) {
    return "'" . $value . "'";
}, array('sql', 'parameters', 'that', 'need', 'escaping'));

I’m very much looking forward to the cleaner code this will allow me to produce.

3) Ternary (?:) Operator

The ternary operator already exists in PHP, and I use it frequently. It allows you to do something like this:

$colour = ($balance > 0) ? 'green' : 'red';

Or, if you need to ensure a value is set before using it, you can write:

$entries = isset($entries) ? $entries : array();

In PHP 5.3, you’ll be able to simply write:

$entries = $entries ?: array();

Which means you can also write:

foreach ($entries ?: array() as $entry) {
    // some stuff
}

This change is excellent because, again, it leads to cleaner code.

4) Native MySQL library driver

This should be a huge win for many applications which value efficiency. (Although, isn’t that all of them?) The MySQL native driver is a full replacement for the currently-used driver written my MySQL AB. It is more efficient in terms of memory usage (storing all rows only once instead of twice), and should be just as processor-friendly, if not more. Further, there are a host of performance statistics calls that should ensure that performance debugging is much easier, and they include a function I wish had been there from the beginning: mysqli_fetch_all(). No more having to write a big while() loop with mysql_fetch_assoc(), this baby will take care of you in one line.

Now, since I’ve switched to the Kohana framework, my database functions are a lot friendlier already, so the latter function won’t specifically change how I code. But the decreased memory costs, especially for queries that return many rows, will be fantastic.

Conclusion

PHP 5.3 is going to be an excellent addition to the language, one I can’t wait for. I expect a fair amount of grumbling as we get adjusted to all the new features, and I’m rather curious to see what Kohana and other frameworks decide to do with regard to support (ideally for Kohana, IMHO, is keep KO 2.3 compatable with PHP 5.2.9, but require PHP 5.3 for KO 2.4 and 3.0). However, in the long run, we’ll have the ability to write cleaner, clearer, and less code, and that will be a fantastic advantage.

Posted in Coding. Tagged with , , , , , .