Can haz source?

Recently I've decided to make better use of my GitHub account by putting some of my work out there for others to see and contribute to, if they feel the need. It's also been a chance to read through a lot of my old code and tidying it up (plenty of WTF was I thinking? moments).

I've put some of my Mozilla add-ons up there and some javascript bits and pieces. I may later add the rest of my add-ons, some of my PHP code (although mostly that is gathering dust) and possibly the CMS that runs my website (already on BitBucket).

So here you go, DarkTrojan on GitHub.

Bugs I've fixed for Firefox 4

  • Posted: Feb. 20, 2011, 12:03 a.m.
  • Last updated: Feb. 20, 2011, 12:04 a.m.
  • Tags: frontpage mozilla code

With Firefox 4 just around the corner, I thought I'd see how many Firefox bugs I've fixed since 3.6. There's 21 of them. Granted, I caused a few, but I do try to clean up after myself.

There's also a few cool patches that are sitting in someone's review queue somewhere, and have been for some time. Maybe at some point before Firefox 5 they'll get there.

Identifying yourself online sucks

  • Posted: Nov. 16, 2010, 12:25 a.m.
  • Last updated: Nov. 16, 2010, 12:26 a.m.
  • Tags: frontpage code web

Here's a picture of a website I'm working on. I'm trying to offer the user ways to prove their identity online - basically when they come back I'm saying "how do I know you're the same person who was here before?".

Here's the options I've created and the big problem with each:

Email - if email was even reasonably reliable, this would be a good option. But it isn't. I want users to be able to do this without having to remember another username and password. The email address option requires a password, because I'm not going to send the user an email every time they want to log in, only to be caught in a spam trap and then have the user complain.

OpenID - even though plenty of people have one or more OpenIDs, 99% of the population would say "what the heck is OpenID?". Aside from that, I think it's a good option. Code-wise, the LightOpenID library is particularly good.

Google - is actually OpenID in disguise, but I think sending the user to a website to log in more intuitive. If there weren't dozens of providers, I could link to them all this way. Yeah, right.

Twitter, Facebook - I've created Twitter and Facebook apps solely for the purpose of collecting the user's identification number. Sucks a bit, but it works. How can I convince the user that I'm not up to funny business with their account? I like that Twitter apps can be 'read-only', but that fact is not very prominent on the authorisation page.

I think it's safe to say the only easy way to do this is to create usernames and passwords. That sucks.

5 reasons I like Python

  • Posted: Sept. 1, 2010, 11:11 p.m.
  • Last updated: Sept. 1, 2010, 11:15 p.m.
  • Tags: frontpage code python

I've been faffing about in Python for about a week now and I quite like it! Here are 5 reasons why:

  1. It's functional. I hate having to write classes when they're unnecessary.
  2. The interpreter is really handy. I like that I can test out code snippets and get instant feedback without opening a text editor.
  3. There are plenty of built-in libraries, including for odd things like reading and writing the config-file format (extremely easily!). And yet, they all come pre-packed and the download is still small. All except MySQL, that is, but it's easy enough to get.
  4. References to dead parrots in the documentation. I also recommend the tutorial.
  5. It's simple enough that it could (and should) be taught in COMPSCI 101. When I did 101 (9 years ago), we learned Java, and it was far too complicated for teaching the basics of programming. I still hate it.

I hope you try Python and like it too. Maybe soon I'll create something funky and post it here with all the C# and the Javascript and PHP.

PHP portability lessons

  • Posted: Aug. 29, 2010, 3:24 p.m.
  • Last updated: Aug. 29, 2010, 3:52 p.m.
  • Tags: frontpage code php

I want my code to be able to run in as many different environments as possible, so last week I upgraded from PHP 5.2 to 5.3. I also installed it on my sister's Mac, which is really poorly configured (this is handy). Here's what I learnt:

  • 5.3 introduces some new types of errors (E_DEPRECATED and co.) and since my code wasn't set up to ignore them, I got error messages everywhere. For portable code it's a bad idea to take E_ALL and subtract the errors you don't want to see, especially as you can't use E_DEPRECATED in code when it's not defined (5.2). I'm now using error_reporting(1015), which is the sum of all the errors I do want to see.
  • Sometimes PHP ignores settings in .htaccess files, and sometimes it ignores your code if there's an .htaccess setting. This is particularly irritating if you can't figure out what's going on.
  • ereg and friends are deprecated in 5.3. I don't know why, and I'm sure there's a good reason, but I use ereg a lot. Still going through one's code and removing uses of a commonly used function is good for code review.
  • PHP has a function called idate. I did not know that.
  • Mac Finder is a pain in the behind. And I thought Windows Explorer was bad.
  • If it works fine in one place, that's not an indication that it'll work fine in another.

Apart from that (and only the first two actually required me to do anything), my code is actually in really good shape. I must be getting better at this.