November 29th, 2009
Last week Michael Neale and I gave a presentation at the 2009 Open Source Developer’s Conference. The topic was effectively a quick and dirty intro to the Scala language, along with some comparisons between Scala and other languages. I’m no Scala expert or even a day-to-day user but I’m a massive fan of what it stands for, which is in Mike’s words “a better Java than Java”. Hopefully that came across in the presentation.
The conference was a lot of fun and there were a lot of familiar faces from last year. I’ll no doubt be back again next time around!
Anyway, now that the presentation is out of the way, you can see our original paper here: On Scala (or: Why Static Typing Doesn’t Have to Suck). The presentation itself was recorded and is due to be put up on the Internet somewhere at some point in time. Will update this post if/when the video becomes available.
Categories: Software Development |
No Comments
June 22nd, 2009
Last night I needed a quick and dirty SHA function for a clojure-based web application. MessageDigest to the rescue!
(ns com.deskchecked.utils
(:use clojure.contrib.str-utils)
(:import [java.security MessageDigest]))
(defn sha
"Generates a SHA-256 hash of the given input plaintext."
[input]
(let [md (MessageDigest/getInstance "SHA-256")]
(. md update (.getBytes input))
(let [digest (.digest md)]
(str-join "" (map #(Integer/toHexString (bit-and % 0xff)) digest)))))
There’s obviously a dependency on clojure-contrib here which you can do away with if you don’t need it. And of course, you can pick a hashing algorithm to suit your needs.
Nothing exciting, but I figure I can’t be the only person in need of this sort of stuff.
Categories: Functional Programming, Software Development |
No Comments
June 1st, 2009
So HTML 5 has been getting a lot of attention recently — in no small part thanks to Google and others. Indeed, reading some of the features planned for HTML 5 are very exciting from a web developer’s perspective. The video and audio elements for standardized web page multimedia, worker threads and of course the canvas element and API.
Since getting excited about HTML 5, it’s been the canvas element that has most immediately grabbed my attention — both for the possibility it opens for a standardized way to render custom user interface components in HTML and for the fact it’s already quite well supported in the more popular alternative browsers (Firefox, Opera, Safari). So instead of studying maths like I should be doing (exams in less than two weeks!), I’ve been tinkering. Nothing exciting except to say that it’s fantastic to be able to render arbitrary graphics without waiting for an applet or Flash to load up.
However, I’ve been bitten by my first quirk in the API — a difference between how coordinates are used for strokes vs fills. Let me explain.
To draw a line using the HTML 5 canvas element, you use code that looks something like this:
var context = $("canvas").getContext("2d");
context.strokeStyle = "#a00";
context.beginPath();
context.moveTo(5, 5);
context.lineTo(100, 5);
context.stroke();
The resulting line looks like this:

Hmm. The line appears to be two pixels wide. Why is that? I figure maybe it was presumptious of me to assume a default of 1 pixel for lines, so I checked the spec. Nope, the spec says the default is 1.0. I read a little about coordinate space vs. bitmap size, it still didn’t really explain the behaviour I was seeing. So I poked around on #whatwg, and was told this:
Philip`: thomaslee: Integer coordinates refer to the positions *between* pixels
Philip`: thomaslee: If you want to draw a line through just a single column of pixels, you have to shift the coordinates by 0.5
snip
thomaslee: Philip`: right, so that would explain why I’m still seeing two pixel lines when reducing line width. But why on earth do integer coordinates refer to the space in between pixels?
Philip`: thomaslee: It’s that way so that fills work like you would expect (with sharp edges), but it has the consequence that strokes don’t quite work like you expect (so you have to shift them by 0.5 to the centers of pixels)
So I adjusted my code:
var context = $("canvas").getContext("2d");
context.strokeStyle = "#a00";
context.beginPath();
context.moveTo(5, 5.5);
context.lineTo(100, 5.5);
context.stroke();
Sure enough, it fixed the issue:

Philip` then went on to explain why this counter-intuitive behaviour is to keep other aspects of the API suffering from similar issues. If you change the stroke behaviour, it breaks fills and vice versa. Without knowing the API for more than the few hours I’ve spent with it, I can’t really comment on it much more than that.
My brain hurts already.
Despite this weird behaviour, the canvas API on the whole seems to be very easy to follow and logical. And HTML 5 is slowly restoring my faith in the future of web development. We’re finally starting to see a move away from the hacks, work-arounds and the mish-mash of technologies that are the norm for modern web applications. Here’s hoping we don’t have to wait too long.
Now, back to the maths …
Categories: Software Development |
2 Comments
March 6th, 2009
So it’s been … oh, about a month or so since the launch of my share accommodation web site, and I’ve just received my first bit of spam via the support email address. I would’ve just deleted the email, except from the fact it’s come from a direct competitor to the site. An apparently Australian competitor at that. Check it out:
G’day!
Have you been worrying about looking for new share mate? Have you been tired of posting rent ads everywhere? Have you been upset about posting your Ad in some forum and soon could not find it again? So, what are you waiting for? Go to PostXDays now!
Have you been worrying about looking for a room for yourself? Have you been spending too much time browsing the forum but hardly find anything useful to you? So, get on to PostXDays right now!
PostXDays is one of the biggest and the most professional classified advertisement website in Australia for rent.
Do you know?
Everyday, PostXDays has more than 1000 visits, and more than 5000 ads be browsed!
PostXDays automatically provides Google map, which will help you to locate your rental property!
You can upload up to 8 photos for your rental property in PostXDays.
PostXDays has more than 30 descriptive items to describe your property, including around condition, furnitures, and so on, to show every feature of the property detailedly.
It takes only 2 minutes to post rental information on PostXDays.
On XYZ, you can search the rental information you want according to suburbs, price, and even more.
Thank you for all your support and we hope you enjoy the service from PostXDays!
www.postxdays.com.au
Now, this bit of spam actually pissed me off a little. There’s a certain level of arrogance required to spam direct competitors (I’m guessing by the nature of their site that this was no accident). So I wrote a bit of a response*:
Hi,
I don’t know why this email has been sent to me — I’ve neither heard of nor contacted any business called PostXDays nor its apparent parent company Tangram Trading Pty Ltd.
In light of this, you should be aware that it’s now illegal in Australia to send an email of this nature without the consent of the recipient (see the Spam Act 2003).
I find it particularly offensive to receive this email in light of the fact I go to certain lengths to obfuscate the email address(es) used on my web site. Even more bizarre is that you’re advertising a service that is in direct competition to the site I run.
Hopefully this is just a misunderstanding, but I’m CCing turboservers.com.au (which appears to be hosting postxdays.com.au) on this email to be sure that you’re not scraping email addresses off sites like mine: I don’t want my users annoyed nor the reputation of my site damaged by garbage like this.
Cheers,
Tom
Unbelievable. I’m *hoping* that this was just a one-off email and he’s not scraping email addresses off the site trying to directly divert users. It sholdn’t be too much of a concern, because ausroomies members communicate with one another using a contact form, so their email addresses are never made public unless they enter it into the listing description field (which some users unfortunately do). Still annoying though.
Anyway, more updates when and if they come.
UPDATE PostXDays was responsible for this spam. The following is a series of emails between myself and the hosting provider of postxdays.com.au which leave me wondering if they’ve got any reason to actually change their practices:
From: Turbo Servers Info
Date: 2009-03-07
Hi,
The email is definately not sent by Net Logistics. Was the sender indicated that the email sent by Net Logistics? Could you please forward the whole message (include the host header for us) to investigate further?
Regards,
Thu Nguyen, Support Technician
Net Logistics Pty. Ltd.
http://www.netlogistics.com.au
<My response to this email has somehow disappeared off the face of the planet, but it was something to the effect of “look at the headers, it came from postxdays.com.au — right down to the path of the PHP script that generated it”">
From: Turbo Servers Info
Date: 2009-03-07
Hi,
It is true that postxdays.com.au is one of our clients. It is violated our Term of Service that client hosted on our servers is sending out spam emails.
I will chase up our client on this matter. Thank you for informing us.
Regards,
Thu Nguyen, Support Technician
Net Logistics Pty. Ltd.
http://www.netlogistics.com.au
From: Thomas Lee
Date: 2009-03-16
Hi,
Do you have a status update? I’m concerned that my own users are still being affected by this, and have no real way to be sure.
Can you confirm whether or not your client’s script was scanning for email addresses on my site? Were other share accommodation sites impacted by this spam?
Cheers,
Tom
From: Net Logistics Support
Date: 2009-03-16
Hi,
I have already contacted our client and given them warning about this issue.
Could you please get back to us if you still receive those spam email?
Regards,
Thu Nguyen, Support Technician
Net Logistics Pty. Ltd.
http://www.netlogistics.com.au
Not exactly comforting.
Mail headers from the original spam:
Return-Path: <nobody@reventon.turboservers.com.au>
X-Original-To: xxx@xxx
Delivered-To: xxx@xxx
Received: from reventon.turboservers.com.au (reventon.turboservers.com.au [122.201.72.110])
by ausroomies.com.au (Postfix) with ESMTPS id B422854173
for <xxx@xxx>; Thu, 5 Mar 2009 02:28:53 +1100 (EST)
Received: from nobody by reventon.turboservers.com.au with local (Exim 4.69)
(envelope-from <nobody@reventon.turboservers.com.au>)
id 1Let4p-0006k8-FP
for xxx@xxx; Thu, 05 Mar 2009 02:32:07 +1100
To: xxx@xxx
Subject: PostXDays -- Advanced Classified Ads Network
X-PHP-Script: postxdays.com.au/_admin/utility/dailyTask.php for 122.201.72.110
MIME-Version: 1.0
Content-type: text/html; charset=utf-8
From: PostXDays <info@postxdays.com.au>
Message-Id: <E1Let4p-0006k8-FP@reventon.turboservers.com.au>
Date: Thu, 05 Mar 2009 02:32:07 +1100
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - reventon.turboservers.com.au
X-AntiAbuse: Original Domain - ausroomies.com.au
X-AntiAbuse: Originator/Caller UID/GID - [99 32002] / [47 12]
X-AntiAbuse: Sender Address Domain - reventon.turboservers.com.au
X-Source:
X-Source-Args: /usr/local/apache/bin/httpd -DSSL
X-Source-Dir: postxdays.com.au:/public_html/_admin/utility
Categories: Life, Linux |
No Comments
January 31st, 2009
Over the past month or so I’ve been working on a site to enable people to find share accommodation here in Australia. I was a big fan of Gumtree’s simplicity but didn’t like how little control I had as a room seeker to really narrow down and organize the listings I’m interested in. I think this is, in part, due to the fact Gumtree is a site for generic classifieds rather than specifically for room seekers — which is totally understandable. However, so far I’ve found other room mate finder services to be over-complicated either requiring me to sign up for a membership (which I hate doing) or to fill out a big scary form in order to find a room. No thanks!
The site was originally written using Merb but a nasty DataMapper bug combined with lacking documentation lead me back to PHP, which sucked. On the plus side, this is my first project using the Symfony framework which really is quite nice as far as PHP frameworks go. I’m a little dubious about the direction in which the framework is headed in the medium to long term, but for this little project it was great.
So that’s how ausroomies came to be. The site’s not perfect and I’m especially worried about whether people will actually stay long enough to play with the search engine to see what it can do. My logs from the first day are indicating the answer is a big, fat “no”. Somewhat predictable I guess. Maybe it’ll become more useful as we get more data. I think the dodgey programmer design currently leaves a lot to be desired, too. I hope to resolve that in a month or so. Outside of that, I can’t convey how much of a relief it is to finally get it live and to finally have something to show for it compared to all the usual throw-away experiments and prototypes I usually play around with.
Anyway, now that this has launched I should hopefully be able to return to a relatively normal sleeping pattern.
I’m keen to hear the good and bad, so please drop me a line if you have any feedback regarding the site.
Categories: Life, Software Development |
2 Comments
December 29th, 2008
I received my shiny new Huawei E160G USB modem from 3 and was desperately hoping that I was just enough behind the curve that it would magically work out of the box with Ubuntu 8.10.
Now, I’m on a prepaid plan because I think contracts are the devil. As you would expect (?), the configuration required for the prepaid accounts is ever so slightly different from the defaults used by Ubuntu. Instead of using 3netaccess as the APN, you’ve got to use 3services.
If you’re running Gnome/Ubuntu, you can set the APN via System » Preferences » Network Configuration » Mobile Broadband, then selecting your Three mobile broadband profile and clicking “Edit”. The field for changing your APN should be in the “Advanced” section. Aside from that, you shouldn’t need to change anything more to enjoy your prepad Three account.
I’ve just sent off a patch to the upstream provider of the service data included with Gnome. I hope this saves somebody out there the two hours I just lost!
UPDATE: This patch was applied upstream on the 19/01/2009.
Categories: Software Development |
1 Comment
December 17th, 2008
The title of this post is probably a little bit flamebait-ish, but I’m actually genuinely interested to get the Internet’s opinion on the following:
Pick any three aspects of PHP that makes you feel dirty as a developer, and post them as a comment here.
For me it’s:
- The standard library is a huge, monolithic mess. This has been covered before, so I won’t beat a dead horse. I’d love to see the standard library reorganized and some sanity introduced around the naming of certain aspects.
- Superglobals because they behave weirdly in certain scenarios and make unit testing a pain in the ass.
- omg\namespace\separator\is\Backslash, which has effectively killed this long-awaited feature for me.
Again, I don’t intend for this to be about hating on PHP or its developers (read: comments that don’t contribute anything meaningful to the discussion won’t see the light of day). Instead, I want to formalize what causes people pain when working with PHP today. Who knows — maybe somebody, somewhere will listen?
Categories: PHP, Software Development |
2 Comments
December 10th, 2008
Last week I gave a presentation in Sydney for the Open Source Developer’s Conference on the internals of the Python compiler. Now that the conference is over, I figure there’s no better place for the original paper than right here on my blog.
Thanks again to my employer, Shine for all their wonderful support with this. Thanks too to the folks who reviewed my paper before it was submitted and my colleagues at Shine who endured a painful test run that ran well over time!
OSDC 2008 was a whole lot of fun. If you happened to miss the conference, I strongly recommend you make it along next year. It’s well worth the trip.
Download Python Language Internals: From Source to Execution, and a corresponding patch against Python 2.6 beta 3 implementing the “unless” statement. If you want to test the patch, you also be aware of the nasty little circular dependency that may cause you some grief — apply the latest (non-review) patch from the tracker before you start the build and you should be fine.
Categories: Compilers, Python, Software Development |
1 Comment
November 25th, 2008
The “code” section of the website has been updated to reference most of the code I’ve uploaded to this blog over the past year or so. Enjoy!
Categories: Software Development |
No Comments
October 19th, 2008
As you may have noticed in the last week or two, the web site has undergone a bit of a rebranding process. deskchecked.com will still continue to work for at least another year, but I’ll slowly be moving everything over to this new domain: deskchecked.com.
It probably seems like a trivial issue, but I’ve longed to get rid of the hyphen in the deskchecked domain. However, every time I went looking for a new domain name I was never happy with the alternatives I came up with. At long last, I’ve finally settled on this one. Unfortunately, this decision has already taken its toll on my Google rank but I’m sure as new content rolls in I’ll see that pick up again over time.
Again, I must apologise for the lack of posts. In addition to the OSDC paper, I’ve been busy actually writing code rather than just writing about writing code.
Categories: Software Development |
5 Comments