Sorting transform function in PostgreSQL

August 3, 2006
5 comments Work

A database table that I've had to work with has a something called identifiers which are humanreable names of questions. There's a HTML template where the question designer can place the various questions in a human-sorted order. All questions get identifiers in the form of <something><number> like this: Head1 or Soma3 or Reg10 where Head, Soma and Reg are sections. Changing the nameing convention from Head1 to Head01 is too late because all the templates already expect Head1 not Head01. Initially I sorted the identifiers like this:


SELECT id, identifier 
FROM questions
WHERE section=123
ORDER BY identifier 

The result you would get is:


Head1
Head10
Head2
Head3
...

The human readable sort order should have been this:


Head1
Head2
Head3
...
Head10

Truncated! Read the rest by clicking the link below.

Exploding Dell laptops

July 31, 2006
0 comments Misc. links

Dell laptop number 3 This just in on Engadget, Dell number 3 explodes That's right. Explodes! Yep, you heard right, third explosion.

That can't be good for business. But most importantly, security. Imagine if you're sitting with the laptop and it explodes in your face, whilst it also explodes in your lap when you're on an airplane!! The amazing thing is, Dell hasn't yet started recalling laptops. That means that somewhere sometime someone will be the unlucky owner of the fourth exploding Dell.

Here's number 1 and number 2

Truncated! Read the rest by clicking the link below.

slim in ruby

July 26, 2006
0 comments Linux

Just figured out how to call my slim web service via XML-RPC using Ruby. It's as easy as in Python.

Here's the code:


require "xmlrpc/client"
# Make an object to represent the XML-RPC server.
server = XMLRPC::Client.new( "www.peterbe.com", "/")
# Call the remote server and get our result
result = server.call("slim", "h1 { font-family: Arial;}","css")
puts result
result = server.call("slim", 
  "function add(var1, var2) { return var1 + var2; }","js")
puts result

And when you run this on the command line this is what you get:


$ ruby dummy.rb
h1{font-family:Arial}
function add(_0,_1){return _0 + _1;}

slim, a new free web service for white space optimisation

July 25, 2006
1 comment Python

If you have some code that you need to optimise, like some Javascript code that is well commented but costs too many bytes of download for your users then you might want to use my slimmer web service. I'll let a Python example speak for itself:


>>> import xmlrpclib
>>> s=xmlrpclib.Server('https://www.peterbe.com/')
>>> css='h1 { font-family: Arial, Verdana; }'
>>> s.slim(css)
'h1{font-family:Arial,Verdana}'

Truncated! Read the rest by clicking the link below.

Spaceinvaders with real people

July 22, 2006
1 comment Misc. links

Space invaders This is such a cool idea. They've "re-enacted" the retro game Space Invaders with real people sitting in a theatre. You have to see it to believe it. Very impressive.

Is it just me or do they repeat the first game once again around half way through the clip?

This inspired me to look if anybody has done something similar with other games. Of course they have. Pacman I tried looking for a re-enactment of Pong but with no luck. Instead I found this wall clock that I would pay good money for.

Trout Mask Replica - Captain Beefheart

July 19, 2006
5 comments Music

Trout Mask Replica - Captain Beefheart The last couple of days I've been listening to Trout Mask Replica by Captain Beefheart & His Magic Band. It's a strange experience and the more I listen to it the more it gets to me. The reason I got this album was because I saw an old documentary about Captain Beefheart and there's this special album that they talk about that was meant to be so special.

I've never been a huge fan of Captain Beefheart. The only other album I've been listening to is Clear Spot where the song Big Eyed Beans From Venus can be found. Probably one of the best songs I know. Like with Trout Mask Replica, it took me a long time to appreciate Big Eyed Beans From Venus. It wasn't until I actually listened to the song that I realised why it was so fantastic.

Truncated! Read the rest by clicking the link below.

Nice stats added to RememberYourFriends.com

July 15, 2006
0 comments Python

Nice stats added to RememberYourFriends.com I've just added some nice stats to RememberYourFriends.com. It's basically two line charts. One of how many reminders have been sent that week and one of how many reminders have been sent, ever up to a particular week from the very start.

To do this I use the wonderful CharDirector package for Python which is really fast and very easy to implement. These graphs are created on the fly and apart from generating the image it obviously needs to generate the data. Pretty fast I'd say. Will be interesting to see how it will fair when the load starts to get interesting.

Once I get a bit more users I'll start thinking of other funky charts to draw. It's fun.

GMapEZ - Google Maps API too complicated for you?

July 12, 2006
1 comment Web development

gmapezlogo.png If you've used Google Maps API to put a map on your site the javascript work you need to do can get quite hairy. GMapEZ puts an end to that. With GMapEZ, controlling google map on your site is as easy as writing HTML. I'm really impressed.

However, the usage in the grand scheme of things has to be taken with a pinch of salt. If you do want a Google Map on your site and do stuff with it, perhaps GMapEZ is not for you unless you want quick results. Simplifying APIs or other convenient libs are really only useful if it's not important. If it is important to you, in most cases you'll have to get ready to roll up your sleeves and get in there and do it yourself. GMapEZ does add more HTTP download for the user and additional javascript rendering time as well. So, if you have 1,000 users a day to view your Google Map app the time you save with being lazy with GMapEZ is paid by your users having to wait a long time extra for the overhead if you sum it all up.

But, like I said, if you think the Google Map API is too complicated sometimes then GMapEZ is definitely worth considering.

UPDATE

This tool looks really hot too. Worth remembering.

Oil, gas and stupidity

July 10, 2006
0 comments Politics

dilbert21046950060710.gif Today's Dilbert comic is brilliant.

For the uninitiated, Elbonia in the Dilbert comic is a returning made up country. Here's what Wikipedia has to say about Elbonia:

"It is an extremely poor, fourth-world Eastern European country that has recently abandoned Communism. Most of the nation is covered with waist-deep mud, which the residents use to build houses. Much of the economy is also mud-based."

What's funny about this strip is that it's so true in our world today.

Desired Firefox extension

July 9, 2006
1 comment Web development

I want an extension for Firefox that measures the speed it takes to download a webpage. I'd like a total time and the time for the individual constituents.

For example, it could look like this:


screen.css took 0.5 seconds
core.js too 1.0 seconds
index.html took 2.0 seconds
foo.png took 0.5 seconds

total page took 4.0 seconds

Does anybody know of a solution to my problem? Can it be done?

UPDATE I just discovered lori which does a decent job. It could be more detailed but so far it's looking quite promising.