bellyphant → page twoFeed

composed_of getting you down?

Trying to use composed_of for something? Realising that it’s not quite working for you — you need to be able to enter things on forms and actually get them into the database?

You need the Composed Of Conversions plugin. Basically it lets you write a converter block with your composed_of declaration. This means that (to take a wildly relevant example — I’ve been trying to get this to work for a little while now) you can put “AU” in a text box on a form (or a <SELECT>), have that converted to a Country object, then write that to a string column in your database. Seems like a roundabout way of doing things, but it suits what I’m doing at the moment.

Interestingly, the author of that plugin submitted it as a patch to core Rails, but it’s basically been ignored (it seems?). Which is strange, since without it, composed_of is more-or-less useless. (If your attribute has a UI, that is.)

Weird symbol gotcha in ActiveRecord

Perhaps you already knew this, but here’s my (first) hint for the day: don’t store Symbols (you know the ones — :my_symbol etc) in your database. It would seem that ActiveRecord doesn’t to a to_s on them. Instead it seems to do Mystery Operation X. This seems to basically convert:

:my_symbol

to something like

---- :my_symbol

Which could be fine. Possibly even useful — hey, I might actually want Symbols stored in the DB like that (assuming I never want to store strings like that…) Unfortunately it doesn’t seem to be paired with Mystery Operation Un-X. In that when it comes back out of the database, nothing is done; you just get a String (with garbage characters chucked in), not a Symbol, and it’s totally useless. My advice: don’t store symbols in the DB.

This could be due to my use of the Composed Of Conversion plugin (which I’m just about to write an entry about), but if so, since it happens one way but not the other, it’s an/yet-another example of deep-embedded Rails code cruftyness.

(Incidentally, if someone can explain this, that would be great. That whole explaining process would probably be made easier if I had comments on this blog… Oh well.)

Lunchtime walk: Clerkenwell

Being that it’s technically spring, and today is actually sunny, I decided to go for a walk to “the other side of the tracks” — those tracks being the tracks of the Circle Line. Work is to the south, and Clerkenwell is to the north (here is a map — “ec1r 4pf” is work, Clerkenwell is near the middle). I’d never really thought about which side of the tracks was the wrong side; now I’m starting to think that I work on the wrong side, and Clerkenwell is the better side.

It’s now my new “I wish I worked here” area — it’s really quite nice. Nice looking pubs and cafes, a park (the grounds of St James Church, I think) — what more could you want? At least it’s nearby, so I can go and hang out there in the sun (when there is sun). Perhaps at night-time it turns into some sort of weird zombie-fest, but given how nice it looks during the day, I’m willing to ignore that possibility.

PS: Sorry I’ve been slack updating this (exciting) blog, lots of work to do… I think I may also split the blog into “tech” and “life” sections — similar to what I’ve seen done elsewhere. I’m reasonably sure that it’s a tiny minority of my readers (which are already a tiny minority in themselves) who’d like to read both, and perhaps I’d put more about living in london if I had a blog/section devoted to it.

Data URL format

Well, I never — never knew about Data URLs, that is. This is probably old news for a lot of people, but it’s something I missed; I have no idea when they came about. Data URLs lets you encode random data into URLs — essentially the URL is the data, rather than a link to it. Here’s an example:

data:text/plain,hello world

If you follow that link in Opera or Firefox, you’ll get a “hello world” document. Obviously you can also do HTML:

data:text/html,<html><body><h1>hello world</h1></body></html>

And you can use Base64 encoding (this is the same as the previous HTML example):

data:text/html;base64,PGh0bWw+PGJvZHk+PGgxPmhlbGxvIHdvcmxkPC9oMT48L2JvZHk+PC9odG1sPg==

Clearly by using Base64, you can actually encode anything you like. Such as this example from Mozilla.org:

data:image/png;base64,... long Base64 bit here ...

Lots of fun! You can also save your HTML <CANVAS> tag drawings to this format, using toDataURL(). Now I just have to think of some way to use this stuff. Note that (naturally) it doesn’t work in Internet Explorer.

Welcome to Britain: please pay now

It’s a strange feeling living here in the UK. There’s a strange sense that almost everywhere you turn, someone is trying to rip you off. Not in a “gimme all your money or I’ll stab you” type way — although in some neighbourhoods perhaps that’s the case. It’s more in a “thanks for being a customer, by the way, may we steal your money?” kind of way. Tonight we received our water bill from Thames water. “Please pay £254.65.” Yep, that’s right — Thames Water has decided to stop billing in six-months in advance (!) cycles, and has now decided it would be better for everyone (i.e. them) if we were billed yearly. So much for saving water — apparently Thames Water already know how much we’ll use.

I thought the whole BT bill pay three months in advance thing was rude; this reaches new heights. (Just to explain to British readers, in Australia you get billed for what you’ve used; you aren’t expected to basically extend credit to large companies. Or at least all the companies I dealt with were like that.) British Gas bills you in arrears (they have to, it’s actually user-pays; half the time it’s based on an “estimate” of course), but says “pay now” — there’s no “please pay by X” type arrangement. Just “pay up little-person, we’re here to screw you!”

Anyway, my immediate reaction was to call up and ask if we could get a bill for less than a year in advance; the only way was to get a Post Office payment booklet. So we’ll be doing that; I’m sure it costs Thames Water far more than billing us every three months ever could. Non-violent protest and all that; I’m sure Thames Water will be impacted massively (or not). Is there an open market for water in the UK — I wonder how I switch water provider?

Just to make my point more clear: big companies should never ask for money in advance; and the least often they should bill is quarterly. They should be easily able to absorb the cost of billing people for services they’ve used. I like my money to stay in my account; if I wanted to invest in big companies, I’d buy shares.

More snow!

Well, it would appear that all forecasts about snow were correct. Today we woke up to a nice fluffy (frozen) blanket of snow covering everything. I decided cycling was probably not an option — it looked like the cycle lanes were pretty snowfilled. So, as if to prove the ridiculousness of most of the ideas I have, I decided that walking would be better. (Public transport in the UK seems to pretty much stop; or at least slow to a crawl. Even the underground, which you would expect might not — in fact you might assume they put the trains underground in order to make them weatherproof. Apparently you’d be wrong.) Also, I wanted to get some more photos than I did last time :)

Out the windowThe streetUp close, imgp8283 On the way to Regent's Park, around St John's Wood

So yes, I started off on my one-and-a-half hour trek to work. (I didn’t think it would actually take that long; I guess I didn’t factor in the snow…) I decided Regent’s Park might look nice, and it’s on the way, so I walked through there. It was pretty cool; I also wasn’t alone in thinking that — the park amply populated with Australian’s etc taking photos of themselves in the snow…

Regent's CanalRegent's ParkPlayground in Regent's ParkSome of the walking was hard work...Bridge in Regent's ParkRegent's ParkBy the end of the walk, I was covered in snow!

(That last shot is about all I could get self-portrait-wise; My coat was pretty well snow covered by the end of the walk. And I’m fairly sure my hair was frozen…) So yes, another ridiculous adventure, of sorts. It was pretty fun!

Bill Gates, you are…

… a moron. Or at least deluded. Or perhaps just brainwashed by the strength of your own marketing. Or trying to make up for the fact that Microsoft (as it currently exists) is headed straight for the toilet. Or perhaps a misunderstood genius? Whichever way: I don’t understand.

I don’t normally blog about random things like this (since there’s no doubt more than enough coverage out there), but this is just so bizarre that I had to. Today Engadget highlighted highlighted the following amusing section of an MSNBC interview with Bill Gates:

Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine.

Obviously he’s referencing (or perhaps just thinking of) the Month of Apple Bugs, but come on, seriously: we’ve had about seven consecutive years of Windows bugs and serious exploits. (And many before that as well, but people didn’t try so hard.)

I don’t want to come across as some sort of Apple fanboy: I’m really not. This is just stupid. Some of the other things he says (or implies) in the interview are pretty ridiculous as well (like the bit where Apple actually took all its interface design ideas from Microsoft). I think Bill may need to learn to pick fights he can actually win.

Flickr geolocation view

Flickr has a map view of the photos that have geolocation data on them. If you want to see photos from around the bit of London where I live, it’s pretty useful. If only I hadn’t sold my GPS! (And if only it wasn’t totally annoying to try and link the data up with photos…) Maybe I’ll have to buy another one, this time one that has better battery life.

Viewing Microformats with Operator

I installed the Operator plugin for Firefox a few hours ago, and have been wandering about the web seeing what places have embedded microformats (not many). There’s a blog post that describes better than I could, but I’ll give it a go: it’s an interesting idea — basically it adds a toolbar that lets you do things with the little chunks of information embedded in microformats on the page you’re looking at — storing contacts, resumes, geolocations; that sort of thing.

Microformats seem to be catching on, I’m not sure they’ll totally change the face of the internet. For certain types of information though, they are pretty effective. I’ve already got XFN happening here, I need to add a few more things I think.

Small laptops

So I’ve been thinking about travelling again (as in, my thoughts have returned to travelling, not I’m about to head off again), and I’m thinking I need a smaller laptop. I found having my Asus W5F really handy; mainly for the photos, but also because I was able to get free internet around the place. The main problem was the size — it’s pretty small, but everything seems huge when you’re trying to live out of a backpack. (The camera is something else I’m thinking of downsizing…)

Anyway, Sizeasy makes comparing sizes a lot easier than trying to imagine what a difference of 10mm means. Here’s a picture I made of the laptops I’m looking at (none seem like a great choice at this point, but they’re the best options around):

Sizeasy is pretty cool; it’s a nifty idea. In terms of the laptops, the Kojinsha SA1 seems a little underpowered, and the rest a little scarily pricey. The OQO Model 02 should be on there as well — it’s tiny and awesome, but even more expensive. I’m thinking I should try and go a little cheaper… I’ve no idea how much the US702 will cost, it won’t be out for a while. Details (in English at least) are a little hard to find, but it looks pretty nice. In the diagram I’m assuming the Flybook v5i will be a similar size to the v33i — it hasn’t been released yet.

← newer stuff older stuff →

Simon Russell is a software developer from Canberra currently living in London.

Links

Me in other places

Photoblogs

Friends' blogs

Stuff I read

I have to check my RSS reader to finish these links...

Recently del.icio.us links >>

del.icio.us tags