Search Results: "Matthew Palmer"

23 December 2006

Matthew Palmer: Miss Manners' Guide to Porn at the Office

A few little style tips, provoked by a recent observation. In general, it's not a good idea to view porn at work. There's a very large ick factor there. If you must, however, please observe a few simple guidelines. Specifically, don't view porn:
  1. while the office is still populated with people who may not share your tastes;
  2. if your monitor is visible to most of the rest of the office;
  3. if your monitor is visible from the main corridor for the office;
  4. on your giant 24" widescreen Dell monitor.
The only thing I'm thankful for is that the computers at this place don't come with external speakers.

14 December 2006

Matthew Palmer: Could You Pass the 8th Grade in 1895?

In case anyone is in doubt about the degradation of educational standards over time, I present to you the 8th grade "final" exam for Saline County, Kansas, for April 1895.

11 December 2006

Matthew Palmer: We Are Living In a Computer Simulation

Or, more accurately, this is what you get when you watch The Matrix while sucking down bottles of Nitrous Oxide. (Thanks to Two Second Memory for the link)

6 December 2006

Matthew Palmer: I Have Problems With REST

Not being one to stick with what I know, over the last few days I've been trying to put a RESTful sheen on a small app I'm toying with. It's quite simple -- there's really only one type of resource I need to deal with, and I've got a solid URI structure to refer to it all. So far, so good. I've read all the theoretical stuff about how URIs should be nouns, and the HTTP action should be the verb -- and I agree with the sentiment, at least for this system I'm writing[1]. I can even (I think) model all of that stuff using my framework of choice, the ever-hyped-but-good-despite-that Ruby on Rails. There's even fairly explicit support in Rails for a lot of what I want to do, with automatic Content-Type: and Accept: handling logic built-in. But this thing is, primarily, a web app, not a web service. I want the RESTful thing so I can interact with the app programmatically, but at the end of the day, I expect most interactions will be via the good ol' HTML. How, then, do I implement my HTML interface so that my user's browser does the right thing with my resources? My REST resource http://example.com/widgets/1337 will do the right thing if an appropriately-credentialled user issues a DELETE /widgets/1337 request, but how do I tell a browser to do that? The "traditional" way I've done that sort of thing, in Rails, is to encode the verb in the URL, like so: /widgets/delete/1337, but I completely agree with the idea that a GET request shouldn't modify data[2]. So I'm completely sold on the idea of not encoding actions into the URI itself. I'm also a DRY[3] kind of guy, and one of the things that has always slightly irritated me about web services is that, when you write them alongside a HTML-oriented webapp, you often have to duplicate logic (even if it's not very much) to get both versions working. Considering that both the webapp and the REST service are using URLs in pretty much the same fashion, it seems very wasteful to have to design two subtly different schemes to handle the two nearly-identical sets of requirements. So, having written this article without managing to figure the answer for myself, I invite comment (sent to mpalmer@hezmatt.org, and I'll summarise later). How do I tell a user's browser to issue a DELETE or PUT against a URL? Am I being overly idealistic to expect the two access methods to be somewhat comparable? Should I just give up and encode the action I want in my URL, or maybe the parameters to the POST request? Am I even completely misunderstanding REST, and trying to find answers in it that just aren't there?
1. I have some slight qualms about the idea that every possible interaction with any possible system could be modelled using an unlimited noun set and four verbs, but I'm happy to leave that debate alone for the moment, as I don't have anywhere near enough experience to speak intelligently, and I have more basic problems at the moment anyway. 2. I remember the common story of the website where the 'delete' hyperlinks are regular GET requests, and the first Google spidering of the website causes everything to be deleted, resulting in a very bare database. This is a result I'm keen to avoid. 3. Don't Repeat Yourself -- a phrase that should be tattooed on the inside of every developer's eyelids.

4 December 2006

Matthew Palmer: Automatic Ordering Systems

Reading about Jamie Zawinski's problems with purchasing plumbing parts (look for 'side-outlet elbows' and read until 'Construction'), I started wondering about the automatic ordering system that shop used. To compensate for the obvious stupidity in the staff, I wondered whether their ordering computer might have a system of automatic adjustments for stock re-ordering quantities. Then I wondered what the thresholds might be to increase the per-restock quantity. Finally, I entertained myself with the idea that, just maybe, jwz's rampant purchases triggered the stock computer to put in an order for some huge number of 4-way pipe joints, which then sat in stock for years and years, because the average consumption rate for those pieces is probably a hell of a lot less than the 10-per-week that the computer saw over the month in question.

1 December 2006

Matthew Palmer: The Patron Saint of Modern Computing

Piero Manzoni should be canonised as the patron saint of modern computing. "Who the hell is Piero Manzoni?" I hear you all say. Well, he was an Italian artist whose work included the act of producing and selling cans of "Merda d'Artista". The Tate gallery bought one of the cans a few years ago, for more than the cost of the same weight of 24 carat gold. According to the above article, "At least 45 of the original 90 cans have exploded, however. This is exactly what Manzoni intended.". As Bill Harzia puts it (in a forum which will not be named), "He was the first to sell overpriced shit, of no practical value, that could fail at any moment, to unsuspecting suckers." That really sums it up, doesn't it?

28 November 2006

Matthew Palmer: You Know That Sinking Feeling You Get...

... when you suddenly realise that you've done something really dumb and there's probably no way to fix it? I just got that feeling, big time, reading today's DailyWTF. And I had nothing to do with the problem whatsoever. My commiserations to the poor sods actually involved in the story.

Matthew Palmer: VLAN adventures

Have you ever had a need for a large number of "real" network interfaces on a Linux box? For security reasons, you don't just want to hook everyone up to a single switch and use virtual interfaces (because it's too easy for one of the connected devices to play silly buggers with his neighbours). Up to a certain point, you can stuff more NICs into a box, and when it fills up you can switch to those outrageously expensive 2- and 4-port NICs. But eventually you're going to run out of space[1] or money. At that point, you need something more interesting. For me, this week, that "more interesting" has been Ethernet VLANs. Linux Journal has a good intro to the technical aspects of how to setup VLANs and Linux. VLANs are some crazy stuff. They're implemented by wrapping a little number around every Ethernet frame indicating which VLAN the packet is "on", and the switch (you need a higher-end device, appropriately configured) makes sure that packets don't roam onto ports they're not meant to be on. For a single switch, this isn't very interesting, and you don't really need an IEEE standard to make it work -- just a lot of little jumpers. However, VLANs are mostly useful on larger networks, which tend to use more than one switch. So you need a way for your VLANs to roam amongst your switches -- hence the packet tagging. You stick the tag onto the packets and fling them off to another switch, and packets coming in with the tag are corraled into their VLAN. Naturally, you don't want end-user devices whacking their own VLAN tags onto packets (untrusted data, and all that), so you define most of your ports as being "untagged". Packets that come in on these ports are treated as regular ethernet frames and tagged with the appropriate VLAN ID, and packets that go out have their VLAN IDs stripped before being sent. (This implies that you can tunnel VLANs in VLANs, and I'm pretty sure that is doable in most switches, modulo some nasty problems that can, and probably will, occur). The ports that aren't designated "untagged" spit out tagged packets -- and this is where my interest lies. Like most every other computer-related standard, Linux can decipher and work with VLAN tags (the 8021q module is what you're looking for). You just load up the module, hook your NIC into the appropriate port on your very expensive switch, define your VLAN tags with vconfig, and suddenly you've got vlanN interfaces, which map to real RJ-45 ports, and you can hang network devices off these and get lots and lots of "real" network interfaces on your Linux router. It's all so simple, right? Nothing ever is, of course. The trials and tribulations I've had over the past two days have included: Thankfully, once all those dramas were done, the whole thing just kind of fell into place, and now I've got a machine which has up to 2048(ish) network interfaces (with huge, glaring caveats on that upper bound, of course). With a bit of luck, the live installation in a couple of days will go smoothly. You can stop sniggering now.
1. In this case, there wasn't a lot of space to begin with, as it's a 1RU box I'm working on, and the 4-port NIC didn't want to place nice with me for some reason anyway.

Matthew Palmer: A Very Creepy Story

Some of the 365 Tomorrows stories are a bit lame, but when they get a good one, it's really good. "Best Friends" is definitely in this latter category.

26 November 2006

Matthew Palmer: When Open Classes Attack

(... or "Why Cut-and-paste coding is a bad idea", part $bignum) I've just spent an embarrassingly long time debugging a problem in an app that I'm converting from single-threaded to multi-threaded operation. As a nice first step, I wrote a new test suite, and put it in a new file threading_test.rb. This file was created by copying another, similar test suite from another file. I've since been having a lot of trouble with the new functionality, as it was throwing a lot of spurious errors. I've only just realised that this is because I defined a teardown method for my new test suite, which kinda depended on the corresponding setup method I defined. Except that I screwed up the file copy a bit, and didn't rename the test suite class name, so I was defining a teardown which was running alongside a completely unrelated setup method (the one from the original class). Kaboom! Of course, a large part of the reason it took me so long to track the problem down is that the reported exception was vaguely threading related, and since I'm no threading guru (or even wet-eared novice, truth be told) I'd spent a long time faffing around in my threading code wondering where the problem was. Then I read the exception information really closely and suddenly all was revealed...

15 November 2006

Matthew Palmer: Severe Discomfort's "The Joy of UDP"

(For the grammar Nazis out there: no, that apostrophe is not misplaced)
There are times when a connectionless protocol almost doesn't seem worth the hassle. Take, for instance, the troubles of a round-trip communication, using UDP, where the initial request is sent to a secondary IP address on an interface. Your code, on the server, might look like this:
 s = UDPSocket.new
 s.bind('', 12345)
 loop   data, remote = s.recvfrom(65535); s.send(data, 0, remote[3], remote[1]  
This is a pretty simple Ruby fragment which just reflects your UDP packets back at you. It really doesn't get much simpler than that. Connect to this thing from somewhere else (using nc -u remoteip 12345) and you can reflect packets back and forth to your heart's content. Or so you'd think... When talking to a regular IP address, your packets probably look something like this (when viewed using tethereal):
 192.168.0.1 -> 192.168.0.2 UDP Source port: 35716 Destination port: 12345
 192.168.0.2 -> 192.168.0.1 UDP Source port: 12345 Destination port: 35716
Fantastic -- I send a packet, and get one back. In netcat, you see whatever you typed printed back out again. But, what if I add a secondary IP address to the server's interface (ifconfig eth0:1 192.168.0.5, for instance) and try sending packets to that IP address (with nc -u 192.168.0.5 12345)? I get this insanity:
 192.168.0.1 -> 192.168.0.5 UDP Source port: 35772 Destination port: 12345
 192.168.0.2 -> 192.168.0.1 UDP Source port: 12345 Destination port: 35772
And of course, no self-respecting network stack is going to accept a packet back from a totally different IP address, even if it did manage to get the ports right. Hence, the client never sees the return packets, and thinks that the server is snubbing it. What's happening here seems insane, but it's actually just a regular artifact of a connecntionless protocol like UDP. You see, we've bound our socket to the "any" address (the empty string in the call to #bind tells UDPSocket to bind to the "any" address -- no, I don't know why either, it's not a particularly intuitive interface). When we get the packet into our app via #recvfrom, we get no information on what address the packet was actually sent to, only that the OS decided that the packet was for us (yay for encapsulation). The only information we get is where the packet was coming from -- and due to the fact that the kernel keeps no connection-related information around for the socket (the kernel figures it'll hold us to our connectionless pledge), when the time comes for us to send a packet back, we have to explicitly say where we want that packet to go -- that's the remote[3], remote[1] arguments in the #send call. The brain-leakage starts when we work out where to say the packet is coming from. When we send the packet, a source address needs to calculated -- again, the kernel keeps no information on source or destination because we're connectionless. Because our socket is bound to the "any" interface, the OS thinks it has carte blanche to set whatever source address it likes. In Linux, the behaviour appears to be to pick the IP address set on the primary alias for the interface that will be used to send the packet out on. So for the common case (one IP address per physical interface) everything is fine. But those corner cases, gee, they're awfully sharp and pointy... The solution, of course, is to send the packet out through a socket that is bound to the particular address you want to use as the source address -- then the kernel knows what source address you want, and there's no confusion. Seems pretty trivial, right? Surely every sensible network application does that already, right? So obviously Ruby's UDPSocket implementation just sucks. That's what I thought, and I don't blame you if you think so too. But before you raise pitchforks and storm the gem-covered castle, try repeating our little experiment with some other widely-used UDP-based applications, such as net-snmpd or your ntp server. (The NTP server is a little different, in that to trigger the problem you need to start it and then setup the interface alias, for reasons I'll explain later). Both net-snmpd and ntpd exhibit the same behaviour as our trivial UDP echo service -- at least, the versions present in Ubuntu Breezy do, although I can't imagine everyone's suddenly cottoned onto this problem in the last 12 months or so and come out with a rash of fixes. So, basically, everyone seems to be suffering from the same malady. For values of "everyone" that equal "some UDP servers". There's some services that don't seem to have such troubles with alias interfaces -- the Bind DNS server comes immediately to mind, and ntpd works fine if you start the NTP server after you setup the interfaces. Why the difference? These services are clever and bind to each IP address on the system separately, like so:
 $ netstat -lun  grep :53
 udp        0      0 192.168.0.1:53          0.0.0.0:*                          
 udp        0      0 192.168.0.5:53          0.0.0.0:*                          
 udp        0      0 127.0.0.1:53            0.0.0.0:*                          
This is very cool, and solves the problem, except that if you add another interface after you start Bind, it doesn't pick up the new address, and you're boned until you restart the daemon. It also increases code complexity a bit, since you need add a select into your request handling loop (instead of just blocking on the #recvfrom call, like I've been doing thus far). Whilst I'm never happy about unnecessary complexity, I'll deal with it where I have to, but the real killer for this application is the "you can't change your interfaces after starting the daemon" rule -- my particular need is to make requests to a virtual service IP address, and restarting my service after each IP address change is going to suck hard. I mentioned ntpd earlier because it has some extra trickery at work. It's list of bound interfaces looks like this:
udp        0      0 10.6.66.6:123           0.0.0.0:*                          
udp        0      0 192.168.250.6:123       0.0.0.0:*                          
udp        0      0 172.14.16.6:123         0.0.0.0:*                          
udp        0      0 172.31.62.1:123         0.0.0.0:*                          
udp        0      0 192.168.37.179:123      0.0.0.0:*                          
udp        0      0 10.64.64.64:123         0.0.0.0:*                          
udp        0      0 127.0.0.1:123           0.0.0.0:*                          
udp        0      0 0.0.0.0:123             0.0.0.0:*                          
It listens to every IP address explicitly plus the "any" interface. I'm not quite sure why, either -- just listening to the specific addresses works for Bind, and if you add an interface alias after starting ntpd, it exhibits exactly the same problem as the trivial UDP echo service, so I don't think that listening on "any" is really gaining it anything. Listening on "any" does make ntpd behave differently to Bind: with Bind, if you send packets to an interface that wasn't available when Bind was started, it just completely ignores you (because it lacks a socket listening for packets to that address), while with ntpd the packets hit the "any" socket and suffer from the wrong-source-address bug. At the moment, my best chance of a solution appears to be to follow Bind and ntpd's lead and hook onto every address, but with the extra twist inspired by ntpd -- listen on the "any" address as well as all of the specific addresses. If I use any packets that arrive on the "any" socket as a trigger to rescan the available addresses (to add any new addresses that have been created since the last scan), that should solve all my problems. Now I only need to make it work (and deal with the insanities that will no doubt result). Wish me luck. The screams of pain and frustration you hear (no matter where you are in the world) are probably mine.

7 September 2006

Matthew Palmer: Bruce Schneier, You're my hero

The article of interest, Microsoft and FairUse4WM, starts with this:
If you really want to see Microsoft scramble to patch a hole in its software, don't look to vulnerabilities that impact countless Internet Explorer users or give intruders control of thousands of Windows machines. Just crack Redmond's DRM.
And just gets better from there, covering the economic realities of software patches for vendors and the user community, and makes (yet another) call for taking some of those externalities that dodgy software vendors love to exploit and internalising them again. Possibly the best sentence in the whole article, and a fantastic soundbite, is this one:
[Microsoft] is not a public charity, and if the internet suffers, or if computers are compromised en masse, the economic impact on Microsoft is still minimal.
The unasked question is, of course, how we can make the economic impact of enabling abuse of the Internet through shoddy security practices a little larger? Making Linux a more compelling option for all consumers is a nice long term one, but lawsuits and legislation would make them take notice a bit quicker. The funniest (or saddest, depending on your perspective) part of the DRM patch is that Microsoft released the patch out of it's normal "Patch Tuesday" cycle (which is guaranteed to garner more-than-usual interest), and then an updated version of the DRM-smasher is released a few days later getting around the "fix". I highly recommend everyone to read this article. It's a nice piece, full of talking points and thoughts to ponder.

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

Next.

Previous.