Search Results: "dave"

20 November 2005

Matthew Palmer: My First Time Mining Ruby

I'm not usually a grand fan of the latest and greatest fads'' in programming. The only C# I know is the black key next to D#, and I loathe coffee. An IDE in the hands of a poor programmer will still result in crap code. While I do think that agile methods (such as XP) can do well in certain development environments, I certainly don't subscribe to the notion that XP can solve all the world's software production ills. And so on. I do know quite a number of programming languages, and tend to pick up new ones out of intellectual curiousity (although Ada did put a severe dent in that habit) or because a bit of research tells me that the language might be particularly suitable for a particular task (although I've since learned that the actual purpose of PHP isn't dynamic websites so much as bringing the security levels of Linux boxes in line with Windows-led industry standards). I also learn languages because I want to hack on projects written in them, which is motivational, but not a particularly good way to get a deep understanding of a language. Why all of this introspection in a blog? So you have the background to understand how everything about Ruby is different for me, including how I'm getting started using it. I have no interest in hacking on a Ruby-implemented project, and -- although Rails proponents give me an impression similar to that of a horny teenager with a shiny new unlimited broadband account -- I don't have any particular use for Ruby at the moment (I want to write less webapps, FFS, not more!). So, why the hell did I fork out $90 hard-earned South Pacific pesos for a copy of "Programming Ruby: The Pragmatic Programmers' Guide"? A couple of reasons: I'm glad I got "Programming Ruby". The book is superbly organised, reads very easily, and gives you all of the love as and when you need it. Surprisingly for me and a technical book, I read the first section of the book "cover to cover". By the end of it, I came away with a real (if naturally superficial) understanding of the language, and a feeling that I was ready to tackle the world in Ruby. It is a sad state of affairs when the first piece of new programming you can sink your teeth into is some four days after finishing your initial studies into a language, but this afternoon I wrote my first Ruby program in anger. It's quite simple -- just take stdin and rewrite it all on stdout with the lines in a random order. But I wrote it in a new programming language, in about 3 minutes, with nothing more than ri (Ruby's answer to firing up python and typing help(xyzzy), more or less) and "Programming Ruby". I think I also produced a suitably reasonable result:
#!/usr/bin/env ruby
lines = []
while line = gets() do
	lines << line
end
	
while ! lines.empty? do
	idx = rand(lines.length)
	puts lines[idx]
	lines.delete_at(idx)
end
(Any Ruby afficionados out there, feel free to e-mail me and tell me what egregious sins I've committed). I think it looks reasonably neat and clean, it's certainly simple, and the use of real Object Orientation makes for a certain readability (I think the method call lines.empty? is particularly cute, although I did initially consider the use of a question mark in a method name to be a crime against humanity). So, will I be using Ruby more in the future? I think so. There are some features in Ruby which I'm hoping to get a lot more cosy with -- the idea of "blocks" looks particularly interesting, and I don't think the utility of languages that have been designed, top-to-bottom, to really live the OO ideal has been explored enough (you SmallTalk bigots can stop glaring at me now -- really, I mean it -- stop it!). It's far too early to tell whether Ruby will become my "go to" language for random development tasks, but anything that stops the nightmares (where I start thinking about using PHP as a general scripting language) cannot be all bad. And, if I continue to make new webapps, Rails will probably come in handy. Update: HTML <pre> tags don't like having < inside them unescaped. Also, Philipp Kern pointed out that the Ruby documentation browser is called ri (not ir as I originally wrote). Philipp was also kind enough to provide a much shorter version of my original script, which shows the power of Ruby so much better:
 lines = []
 STDIN.each_line    line  lines << line  
 lines.sort_by   rand  .each    line  puts line  
Now tell me that isn't a language worth using!

16 November 2005

Horms: Back from Korea

I made it back from Korea in once piece (several weeks ago), however, sadly, my camera did not. Well, its in once piece, but one not working piece. I took it back to the shop for repair under warranty, they called to tell me it was fixed. But alas when I went to pick it up, it was still not working - though in a slightly different way. I think its an electronics failure. I hope it gets fixed soon so I can take some new snaps. Fortunately Dave's attempts at taking photos were more successful than mine. As an added bonus, his trip with Soyong was around 2 weeks, whereas Chiz and I only dropped in for 2 days. You can read all about it on his blog [Oct] [Nov] which also has links to lots of awesome photos. In semi-related news, by brother sent me a copy of Lee Frost's "The Complete Guide to Night and Low-Light Photography". Mmm, wish I had my camera back...

2 November 2005

Daniel Stone: [tech/x] custard creams

The X.Org security list has a web form, linked off www.x.org, to submit security concerns. Predictably, it gets a lot of spam and weird stuff. However, I'm utterly at a loss to explain this one:
Date: Wed, 2 Nov 2005 10:12:04 GMT
Message-Id: <200511021012.KAA11645@xoneweb.opengroup.org>
To: xorg_security@x.org
From: Dave Custard <davecustard@custardcreams.com>
Subject: X.Org SECURITY CONCERN: Custard Creams
My concern is that the custard creams are going to escape and
kill us all with their sweet custardy filling. I'm scared.
(form_Security)

21 October 2005

MJ Ray: Will the last ex-UEA-er to leave Norfolk please switch out the light?

A surprisingly high proportion of ex-UEA people stay in the area after finishing at UEA. Over 40% want to, according to the local chamber of commerce. Eventually, that number falls: with John and Brett leaving, I think I can now count on one hand those from my Norwich years (1994-1998) who I know are still here. Most left some time ago. Why? Small place syndrome? Underpaid work? Both? Possibly. It feels like only in Norfolk could the train station start to expand its car park to cope with demand and the same week most train services to it are cancelled because a Cambridgeshire farmer drove onto the single line stretch, was killed and it takes at least a day for access and safety checks in this sparsely-populated area. From the BBC's picture, the unit involved was one of the commemorative King's Lynn "picture trains". You seldom hear what happens to the damaged trains and injured drivers. I guess the railways and the media doesn't like to worry passengers. Even the Potter's Bar investigation ending only got brief mentions that I saw. Also at the train station, local police put out a picture of people they would "like to interview" about the spate of recent bike thefts. Possibly as a result, they've charged one man. Someone I know had a bike nicked, which meant a long walk to/from work until it was replaced. Very annoying. The sort of petty bike vandalism/theft which annoyed savs is also on the increase here again. I'd've expected nicked bikes to sell better in summer, but maybe the local crims are thick or there are more easy-to-nick bikes in September. At least it's not Fakenham, (which is one of the most boring places on earth, you may remember - original source ) where the headline story is that the kerbs are too high. I'm sorry someone was hurt, but kerbs here seem tiny compared to the ones in Northamptonshire. Probably they've all been lowered for safety there too now. As a result of adding Dave's blog to Planet ALUG, I noticed BritBlog for the first time. I spent a while browsing the other Norfolk-based blogs on it one evening. Unsurprisingly, I knew about most of the ones I found interesting already, apart from Ztroller who links to me... erm, why? Does he read this? Most listings are from blogspot and I still won't add Atom support to my blogging software - I want to read, not edit, so Atom is mostly extra cache filler. I only added Really Simple Syndication as well as RDF Site Summary because it was fairly cheap to do and I didn't know about the obvious way to get RSS 1 from Wordpress. Finally, in local(ish) concerns, Northern Ireland, from Noodles' emptiness:
"while I'm ranting, why is the adjective for someone from the UK "British"? Britain doesn't cover all of the UK. I wasn't born in Britain yet I'm British. Can't I be UKish or something?"
I'd hate to be called UKish. I don't have any particular affection for this Kingdom's political boundaries. If the UK ended tomorrow, would anyone besides its rulers mourn? I'll not thank you if you call me British. I'm English, a midlander and Towcestrian. British nationality is a side-effect. (And why is it so hard to get .gb domains anyway?) It's odd that there's such argument over England's anthem. So there is imagery or irony involved in Jerusalem, depending how you want to view it: who cares? It's rousing (unlike the UK dirge) and mentions England past. Yikes, I've just discovered I'm agreeing with Billy Bragg of all people. As for the UK, why don't we work together with others when we agree and work independently when we don't agree? Unfortunately, few politicians advocate English self-rule, apart from racist bigots and English imperialists. The really depressing thing is that those sort of people would probably easily get a majority in any English legislature, if backed by the mess media. Maybe Britain is diverse enough that it balances the extreme English... diverse we are or de verse it gets... (ouch)

Next.

Previous.