Search Results: "mpalmer"

5 September 2006

Matthew Palmer: Stripping Away Unnecessary Detail

I think that concept may have been taken a little too far in this job ad I just found:
DATABASE ADMINISTRATOR To administer company databases. Respond by resume only to ...

3 September 2006

Matthew Palmer: One Sentence Review Of Babe 2: Pig in the city

If you've never seen "Babe 2: Pig in the city", now you'll never have to. My wife just came up with the ultimate review of it:
"It's very dark, like Moulin Rouge with pigs."

Matthew Palmer: Music To Hack To -- The Belated Summary

Back in the embarrassingly early part of this year, I wrote a blog entry on music that I liked to listen to whilst cutting code. I solicited feedback, and promised a followup. Technically, I didn't say when I'd be posting a summary, so I don't feel quite so bad about leaving it for 9 months before posting this followup. Firstly, Matthew Davidson gave a lengthy treatise on The Fall, whom I'd never heard of before, and actually haven't gotten around to listening to yet, either (shaaaaame!). It certainly must do the trick for him, though, because he says:
I try to avoid programming wherever possible -- I know how it's done, and really appreciate it when it's done well, but I generally find doing it as much fun as a trip to the dentist. However, put a bit of the Fall on, and I find myself settling into a pretty productive groove without much trouble.
Next up, Decklin Foster pointed me to where I could do my own research -- the Debian Developers group on last.fm. Although I've glanced at last.fm now and then, I've never really gotten into it much. I suppose I should harness the hive mind and find more music similar to that I already like -- you can only listen to your old favourites so many times in a row before they start to wear out. Apparently, my tastes in coding tunes isn't unique -- Roger Barnes shares my preference for the quick-paced abstract:
When I'm coding though, I prefer something fast and electronic. I think this is for two reasons, one is the rhythm tends to get my mind going, and the lack of vocals means that there are no words disrupting my thoughts.
As does François Beausoleil, who says:
I have the same need as you for loud, fast and driving music. Personally, I've been listening to Born to be alive, the first Matrix's theme song, Confusion from New Order of the Blade soundtrack.
Since the original Music To Hack To post, I've been listening primarily to the Chillits 2005 sets whilst coding. In the words of Boing Boing (where I originally found out about Chillits), "Every fall in Northern California, the Chillits music festival brings together a stunning line-up of DJs who spin mesmerizing sets of ambient and downtempo music under the sun and stars." The key word there is "ambient"; I'm not looking for something to listen to so much as I want backdrop to my other activities. The collection of laid-back and thumping tunes keeps a nice work/relax rhythm going while I'm coding. There are some immensely funny bits in some of the mixes, too, like the (hopefully) mock ad for speed ("The little blue diet pill you don't have to be overweight to need!"). Sometimes the tracks go into some area that bugs the shit out of me, which is when I exercise the skip feature of my music player, but most of it is pretty good at blocking out the world and letting you concentrate on the code at hand.

Matthew Palmer: I think someone didn't get the memo...

Pop quiz: what is strange about this path fragment?
 pool/breezy/i386/non-free/<package>

2 September 2006

Matthew Palmer: Tarballing

So, what do you do when you want to make a tarball of a local filesystem, but with the result on a remote machine, taking up minimal space, but you just don't have a lot of CPU grunt on the local machine? That's right, you delegate the compression step to the far end. On the destination machine, you run:
 nc -l -p 31310   gzip -c > zaurus_hdd3.tar.gz
And on the source machine, you run:
 tar cf - -C /hdd3 .   nc hussy 31310
And then watch the data roll by. This post brought to you by the "Matt Has His Zaurus And Is Neglecting The Rest Of His Obligations To Play With It" Foundation.

29 August 2006

Matthew Palmer: Public vs Private Enterprise

I just read the best explanation of the whole privatisation issue (currently a hot topic, what with the Australian government trying to sell off the rest of the currently Government-owned telco):
Private enterprise is more efficient than the public service, by definition. [...] Of course, private enterprise [...] works by ignoring unprofitable tasks, while the public service exists to serve everyone.
From a comment on Random Acts of Reality. It's a good blog all round, I highly recommend it.

25 August 2006

Matthew Palmer: I'm So Excited!

I ordered a Zaurus SL-C3200 from Conics.net a little while ago, and overnight I received an e-mail reporting that it's been shipped, and giving the parcel tracking number. I think the F5 key is going to get a heavy workout over the next few days as I watch my newest little toy slowly move through the bowels of the international shipping system, and finally into my eager little hands. Mmmmm, ultra-portable Linux computing. <drool />

23 August 2006

Matthew Palmer: That's one way to put it...

This pretty much accurately expresses my gut feeling of what Ruby is:
... pretty much a Perlized dialect of Smalltalk... from http://c2.com/cgi/wiki?SmalltalkLanguage

30 July 2006

Matthew Palmer: Shell Scripting: Good; Sane Tools: Better

While David Gibbons' little shell snippet to add unknown files to an SVN repository is nice:
 svn status   awk '/\?/  print $2 '   xargs svn add
You can do better if your revision control system can answer the questions you really need answered:
 bzr add $(bzr unknowns)

11 July 2006

Matthew Palmer: It's All So Simple When You Know How

As a followup to my Dapper is teh suck entry, it appears that my egregiously slow system is known bug. Of course, it'd be better if it were a fixed bug, but at least it's trivially work-aroundable (echo 1 >/sys/module/processor/parameters/max_cstate -- down from it's default, on my system at least, of 8). Apparently there's some "issues" with the SMP-compiled kernel on uniprocessor systems, and hitting that tunable down masks the problem, whatever it is. It's funny -- just the other day I was having a chat with the other sysadmin at a place I'm contracting at about the vagaries of SMP kernels on non-SMP machines, and he was amazed that you could have a modern system that didn't play nice with an SMP kernel. Now, it seems, I'm a walking, cursing example of the issue. I don't mind, though -- I'm playing Oolite at full speed again, so I'm happy.

Matthew Palmer: User Interfaces as Slideshows

Backstory: I recently found a new game. It's called Oolite, and is (probably unsurprisingly) a clone of that great old spacefaring game, Elite (for BBC Micro and C64, amongst others). This game (unlike the original!) uses OpenGL and hardware rendering, so it was a good motivation to get accelerated rendering going on my laptop (never bothered before; it's unlikely that DRI is going to make an Xterm run any faster, after all). The problem with DRI under Ubuntu Breezy on my laptop is that it makes the machine unstable. Every couple of hours, my screen would freeze, and I'd get a lovely collection of randomly-coloured 80x25 text-mode characters on my screen, flashing madly at me. That's the signal for "game over", apparently, and I'd have to reboot. Incidentally, this used to happen, but very rarely, before I turned DRI on, so it's not really DRI-specific, but it went from occasional irritation to regular irritation. End backstory.
So it was time to upgrade. "Dapper's Out", thought I. "May as well see what all of the fuss is about". I think the phrase "oops" correctly describes the result. For reasons which I have not fully determined yet, my system is now Dog Slow. (That's the technical term, anyway; I've got a few more colourful phrases for it that I'm using privately). What was, previously, a nice quick Xterm launch is now a slowly progressing set of concentric rectangles culminating in the eventual, lacklustre, appearance of a terminal window. Oolite, my new obsession, is like playing Quake3 (the last OpenGL game I really got into, many years ago) on a P-II 300 with no 3d graphics card -- here a frame, there a frame, oh, by the way, you died a couple of minutes ago. (And yes, before you ask, glxinfo says "direct rendering: Yes".) This isn't an old machine -- it's a Thinkpad T43, with gobs of RAM and a 1.7GHz processor. It ran Breezy like a charm. Now, my machine looks like a powerpoint presentation. I've got to put something onto my wife's "new" (P-III 700) laptop -- lord only knows what it'll think of Dapper. Other strangenesses I've noticed so far include: Ultimately, I think that the cause of my problem may be closely related to that last point. I need to find out what's chewing my machine's CPU and kill it dead. Oh won't that be fun. Well, enough moaning. Time to find the cause(s) of these problems and nail it/them to the floor.

3 July 2006

Matthew Palmer: Shittyrail does it again!

(Caution: Rant ahead. At least it's short.) It's obvious that they're putting the extra funds they're getting from yesterday's ticket price hike to good use -- this morning, my train was cancelled. These trains are pretty packed by the time they get to the city anyway, and now we're going to have twice as many sardines in the can. You'd think that, for at least this week, they'd try that bit harder not to piss people off too much. Or perhaps they're just packing it all into one chunk, figuring that there's some sort of upper-limit on people's irritation and it can't get worse beyond a certain point of irritation.

8 June 2006

Matthew Palmer: [Ruby] Blocks as Resource Management

One of the really neat things about Ruby is the extensive use of blocks (closures, I think the rest of the world calls them) in the standard library to control the allocation and deallocation of resources. Take the following snippet:
 File.open('something.txt') do  fd 
   # Manipulate the file through 'fd'
 end
 # File handle is now closed
There's no way that you can escape from that block without the file being closed (well, in theory, you could lose the file handle if there was an exception thrown in the block, but the File::open method can take care of that internally by catching, closing, then rethrowing). I've loved this feature since I first saw it -- "holy crap!" I thought to myself, "I never have to call close again!". And I was pretty well right -- I think I can count (in unary, not binary!) on one hand (well, I'd use grep wc) the number of times I've used IO#close in my Ruby code. The funny thing is, though, that I don't think I've used this pattern in my own code enough. But I just had an epiphany whilst waiting for a train home -- and I think I'm cured. Take this hideous piece of test code I had laying around in an app I'm working on at the moment:
 def test_something_funny
   faux_path_on
   d = Domain.new('127.0.0.1', 'somethingfunny.com')
   faux_path_off
   
   # assert writ large
 end
Domain::new calls out to a shell command (dig(1) to be precise -- take a guess at what I'm writing <grin>, and yes, it will be released shortly) but for test purposes I can't run dig (because I'm not guaranteed to have all the infrastructure available for a real dig to succeed). So I have a flimsy mock of dig in a directory in my test suite, which is where faux_path_on sets ENV['PATH'] to look at. This is, of course, pretty untidy, because when (not if!) I forget to call faux_path_off, everything goes to complete poop, and my children will have two heads or something. The much cleaner version is like this:
 def test_something_funny
   d = faux_path   Domain.new  
 
   # Assert ahoy!
 end
And my faux_path method (I've even saved a method!) is as simple as simple can be:
 def faux_path
   realpath = ENV['PATH']
   ENV['PATH'] = my_fake_path
   rv = yield
   ENV['PATH'] = realpath
   return rv
 end
I also have a trickier faux_* method, which sets a couple of environment variables which tell my mock nsupdate(8) where to write the data it gets sent from my application -- again, it's a block-taking method that sets the environment, yields, reads in the data from the temporary file, cleans it up, and returns the contents of the aforementioned file. The power of the Ruby is growing within me, I can feel it. And I like it.

Matthew Palmer: A Fool And His Money are soon parted...

... but not nearly soon enough. The Daily WTF is almost always worth a read -- it makes me feel better about my lot in life. Today's entry, though, shocked me more than a little. How do people this dumb even breathe? Certainly, they don't deserve to be in control of a business.

Matthew Palmer: Inadvertantly Appropriate

Seen on the way to work this morning (for some sort of art show):
From the affordable... to the collectable!
I'm not sure that what they meant was "the stuff you can afford isn't worth keeping", but I'm pretty sure that it's the truth.

24 May 2006

Matthew Palmer: Testing the Testing of Your Tests

I'm writing an application in Ruby that makes heavy use of XMLRPC (the application of XMLRPC-over-Unix-socket fame), and so I'm using Mock Objects to mock out the XMLRPC client proxy and provide an interface that doesn't involve having a whole other infrastructure running on my laptop so I can run my test suite. For those who don't know, mock objects are objects which look and superficially act like the real objects you might use to communicate with an external service, but don't actually do the communication -- instead, they return canned responses to your calls. Why is this useful? Well, imagine that the real object talks to a SOAP service on the 'net (such as the Google search API). It means that every time you run your test suite, you need access to the Internet. The external service may also cost something everytime you talk to it -- or it may be impossible to use to test, since there's statistics generation or something going on that means that hammering it for test purposes is just impractical. In addition to returning values to your application, mock objects will usually record what has been called, so that after your test run is complete, you can also verify that all of the methods you wanted called have actually been called. This means that you can have a good idea that what you wanted to happen to the service actually would have been done. Handy. Some people have a (justified) ditrust of Mocks, because it's easy to make a mock object that doesn't perform like the real one (and hence invalidate your tests), but they provide a necessary evil in cases where you just can't use the real object when running your test suite. The XMLRPC proxy I'm using has a bit of a quirk. Everything runs through one method on that object -- XMLRPC::Client#call(). This seems really limiting, especially in a wonderfully dynamic language like Ruby. In reality, it's not too bad -- it makes the object interface easier to mock, and you couldn't emulate the whole thing with method_missing anyway, because you can have various Ruby-illegal characters in XMLRPC method names. The downside to this all-in-one-method thing, though, is that simply verifying that #call() has been invoked a dozen times doesn't really tell me much about whether the mock was used the way I wanted it to be used. My chosen mock object suite, Test::Unit::MockObject, whilst otherwise excellent, is (or rather, was) missing the ability to verify the arguments that are passed to your calls -- you can say "I need methods x(), y(), and z() called", but you couldn't say "I need the call y('foo', 'bar', 42) made". Of course, this change the mock object class is non-trivial, and needs to be tested itself (it'd be pretty lame if a class intended to facilitate automated testing lacked a test suite of it's own). I added a bunch of tests to the test suite, and got some good results. I had a couple of false starts, where I wasn't checking most of the corner cases (where bugs lurk in the shadows), but eventually I got a test suite that was fairly complete, which drove the new features I needed to a good place. So I carted my newly enhanced mock object class across to my production project, and off I went. Except that I was getting some downright weird failure messages when my code wasn't invoking the mock object the right way. Why? Because I hadn't tested that my failure messages were appropriate. Why was that? Because the assert_raise assertion in Test::Unit doesn't have a facility to make sure that you're passing back the right exception message, only that you're passing back the right exception class. Whisky, Tango, Foxtrot? Over. (This space intentionally left blank for me to insert the correction to this claim that the lazyweb is sure to provide) So I had to write a new assertion (assert_exception_message) which checked that both the right class and the right message came back. This code, of course, needs to be tested too, because otherwise you can't be sure that your test code is performing right. At this point, I was writing test code to test a new assertion I'd written so I could test the mock object class I had modified so I could test my application. At this point, things got a bit "meta". It got a bit difficult to separate out the tests from the tests' tests. But I fought through the brain melt, and shortly thereafter came out the other end with a properly working piece of actual application, and all was well in the world. By now, a certain Mr. Tendys is probably rubbing his hands with glee, as he gets ready to espouse at length about how this whole post just proves how utterly useless test-first programming (or even testing in general) is for producing economically-viable software. Let me analyse what I "spent" on getting all this functionality, though -- about 3 train trips home -- maybe 4 hours of time total, including writing the extra tests in my application to use the wonderful new features I'd made. That's not much, in the grand scheme of things. I've wasted that much time in a day skiving off work in the past because I was frustrated with what I was trying (and failing) to program, usually because I was swamped with bugs. What did that four hours of my time buy me? Heaps. I can now better verify my software works as anticipated. I have confidence that my software is a lot more robust than it was before. My tests identified several issues that passed my eyeball check, but blew up when I tried to actually use them in a particular way. But with the help of my tests, I identified the problems quickly and went on my way. Since I was working in a localised area of the application, I was immediately familiar with the code, and could stomp the bug almost immediately. If I'd only done end-to-end testing at the end of development (or worse, released it with the bugs still in there), the debugging would have been much harder because I'd forgotten little details about the code. I reckon that benefit, alone, has probably saved me 4 hours already, since I've spent whole days hunting down little bugs in an ad-hoc fashion in the past. I'm fairly sure most any programmer can empathise with me there.

Matthew Palmer: Trains: Inverse Hibernation

So it would appear that, now that the hot weather is over and blessed winter is upon us, the air-conditioned trains that I dreamed of so much and so rarely saw over summer are now out in force. Such a cruel, cruel world we live in.

14 May 2006

Matthew Palmer: Curious Perversions in Software Engineering

I've been ill with flu the last few days, so I've been doing very little other than sitting huddled in my recliner, with a large, warm blanket over me, and my hot water bottle (AKA the laptop) to work on. As a result, I've been doing a fair amount of random coding, and I've come away with a larger-than-average amount of... weird shit. It maybe the flu, the strong drugs I've been taking to keep the symptoms under control, or maybe just the phase of the moon, but I haven't coded up this much madness in quite a while. Let me take you through them. The Proctologist I've been writing some software which has to talk to an XML-RPC server. Not so weird. However, because the system lacks any inherent security, the (strongly) preferred method of communicating with this server is via a Unix socket. That's right, I'm doing XML-RPC over HTTP over... a Unix socket. That, you may think, is weird. Well, it is, but it isn't the curious perversion in and of itself -- for a start, I didn't write that monster, and I'm only blowing my own trumpet in this article. No, the perversity is in how I wrote *my* software to deal with it. See, I'm using Ruby for this software, and the standard Ruby XML-RPC client uses the built-in Net::HTTP library that comes with Ruby (which is a killer little HTTP library, BTW). Because the authors of Net::HTTP were lacking in imagination (or crack pipes) they didn't think to include the native ability to talk to Unix sockets. I mean, really -- isn't that the most important feature in a HTTP library? I think we all know the answer to that. Anyway, despite the lack of forward planning (and crack pipes) on the part of the Net::HTTP authors, I needed to get it to talk to a Unix socket. I could have done the long-winded thing and spend a pile of time putting in handling of pipe:// (crack or otherwise) URLs, but then I would have also had to add support for it to the XML-RPC client library (which did URL validation before passing it on -- good for it). And really, I don't think I could have handled the guffaws of laughter when I attempted to submit the patch upstream. Instead, I put Ruby to it's perfectly-suited use. I simply created the XML-RPC client object (which created the Net::HTTP object internally), then inserted my gloved finger and replaced the default TCP socket object in the Net::HTTP object with a specially crafted Unix socket object pointing to the correct place. "Dear god almighty!" I hear the practitioners of good software engineering practice exclaim. "Doesn't Ruby have protection against such atrocities?" Why, yes, it does. All of the objects I had to play with are private instance variables of their parents, and I can't get access to them normally. However, classes in Ruby are never closed, so I just reopened them and added accessor methods (which, in Ruby, is as simple as attr_accessor :http) so I could do my nasty little thing. I'm quite happy to take the heat for doing what I did. It breaks encapsulation, and makes everything that little bit more complex. But, on the other hand, it let me get the job done -- the language gives you full protection until you say "may I?" and then it gets out of your way. Personally, I reckon that's a nice tradeoff between C-style full control (where even the best programmers blow their foot off on a regular basis) and B&D; languages where you'll never shoot yourself in the foot, but instead you'll gnaw your leg off in frustration. Russian Dolls I'm doing a bunch of interesting things with the Xen hypervisor for work. Of course, you need to have a way to test all this stuff, and despite a number of hints, work still hasn't gotten me that fully-kitted out dual-core Opteron that I want to test (and transcode all my video <grin>) on that I always wanted. So, instead I've installed Linux in a qemu image, and then put Xen on that. Surprisingly, it's worked really well -- I've got Xen running quite happily in the virtual machine, and I can create and run Xen domUs (the guest VMs) in the usual fashion. Now all I need to do is install UML in a Xen domU, and then run some vservers inside that UML, and I'll have the full collection...

11 May 2006

Matthew Palmer: The Pain of CFEngine

So it seems that Steve Kemp is finding out that, whilst being a brilliant idea in theory, CFEngine is just plain weird in practice. I was the person who originally encouraged Steve to look at Puppet when he was originally talking about this stuff about a month ago. I was arguing from a position of weakness then, as I'd never tried Puppet then (although I was already eminently familiar with CFEngine and it's issues). Since then, I have started using Puppet on a project for a client, and let me just say that it is "all that and a bag of potato chips". Luke Kanies, the main man behind Puppet, is immensely supportive, quick to work up new features when suggested (< 24 hour turn around, in some cases) and really knows his systems-management stuff. The configuration language itself is quite easy to learn, it's wonderfully extensible, and the system as a whole doesn't have nearly the same number of "WTF?" moments as CFEngine (and Luke has already, in the week or so I've been using Puppet, fixed up two of them based on my suggestions). There's only one thing in CFEngine that I use that Puppet doesn't have, and that's editfiles. This is by design, apparently -- there is no consensus, even within the CFEngine diehards, that editfiles is a good thing, and Luke isn't really keen on implementing it (it's a big feature, and there's known better ways of solving most of the problems that editfiles solves anyway). I still feel that it's useful to use editfiles in some circumstances, but not having it certainly hasn't cramped my Puppet style excessively so far. Oh, Steve -- about Ruby being "un-perl" -- that's not a bug, it's a feature!

2 May 2006

Matthew Palmer: I think it's time for #wimbledon...

Between myself and new DD Ben Hutchings, I think we have enough wombles to make a fair showing. <grin>

Next.

Previous.