Saturday, July 26, 2008

Just Saying

Amazon has released information about the cause of the recent S3 outage and what they are doing to ensure that their "performance is statistically indistinguishable from perfect":
Here are the actions that we're taking: (a) we've deployed several changes to Amazon S3 that significantly reduce the amount of time required to completely restore system-wide state and restart customer request processing; (b) we've deployed a change to how Amazon S3 gossips about failed servers that reduces the amount of gossip and helps prevent the behavior we experienced on Sunday; (c) we've added additional monitoring and alarming of gossip rates and failures; and, (d) we're adding checksums to proactively detect corruption of system state messages so we can log any such messages and then reject them.
Except for (d), these actions don't really address the cause, but only mitigate the effects.

Thursday, July 24, 2008

Quicksort in Lisp

Version #1:
(defun generate-lt (value)
(lambda (x) (and (< x value) (list x))))

(defun generate-eq (value)
(lambda (x) (and (eq x value) (list x))))

(defun generate-gt (value)
(lambda (x) (and (> x value) (list x))))

(defun quicksort (list)
(if (<= (length list) 1)
list
(let ((pivot (nth (truncate (/ (length list) 2.0)) list)))
(append (quicksort (mapcan (generate-lt pivot) list))
(mapcan (generate-eq pivot) list )
(quicksort (mapcan (generate-gt pivot) list))))))
Duplication of code in the 'generate-' functions. Need a macro.

Version #2:
(defmacro generate-comparator (value fn)
`(lambda (x) (and (,fn x ,value) (list x))))

(defun quicksort (list)
(if (<= (length list) 1)
list
(let ((pivot (nth (truncate (/ (length list) 2.0)) list)))
(append (quicksort (mapcan (generate-comparator pivot <) list))
(mapcan (generate-comparator pivot eq) list )
(quicksort (mapcan (generate-comparator pivot >) list))))))
Looks elegant, but can we make this even more concise?

Version #3:
(defun quicksort (list)
(if (<= (length list) 1)
list
(let ((pivot (nth (truncate (/ (length list) 2.0)) list)))
(append (quicksort (mapcan (lambda (x) (and (< x pivot) (list x))) list))
(mapcan (lambda (x) (and (eq x pivot) (list x))) list)
(quicksort (mapcan (lambda (x) (and (> x pivot) (list x))) list))))))
Seven lines of condensed confusion. Not to mention wreaking havoc with the layout of the blog.

(Blog post inspired by a) a rekindled interest in Lisp and b) a sudden urge to share the joy of having found a non-gratuitous use for macros)

Update: Version #4:
(defun quicksort (list)
(if (<= (length list) 1)
list
(let ((pivot (first list)))
(nconc (quicksort (remove-if #'(lambda (x) (>= x pivot)) list))
(remove-if #'(lambda (x) (not (= x pivot))) list)
(quicksort (remove-if #'(lambda (x) (<= x pivot)) list))))))

Saturday, July 19, 2008

Who Moved My Chees(y Distro)?

[Warning: boring post about Linux distros]

Kubuntu has been my distro of choice for more than a year; I had reached a point where the download-new-distro-spend-a-week-tweaking-it was no longer appealing. Every once in a while the urge to go distro-hopping would hit, but the comfort zone of status quo would prevail.

But the cheese did move one day: KNetworkManager would drop connections at random, not remember the wireless router's SSID, and so on, and things got fairly annoying. Not to mention the fact that things were, on the whole, not as zippy as they used to be. Time for a change.

I decided to give OpenSuse 11.0 a try. After a few false starts with the ISO download (see problem with KNetworkManager above), SuSE was up and running, but no go. What with my peeves with KDE 4.0 and the problems with the Java plug-in (1.5 would crash Firefox while 1.6 would make the applet disappear after one or two operations), I quickly abandoned it.

I have tried out MEPIS in the past, and except for the sound problem found it to be very good. True enough, 7.0 turned out to be equally good, but the sound problem seemed to have been carried over from 6.5. But this time a quick modprobe snd_hda_intel took care of it (Did I try this before? Not sure), and so here I am, with SimplyMEPIS 7.0 as the distro de jour (well, not exactly a day -- I plan to use it for at least six months).

Good things about MEPIS:
  1. Very zippy

  2. Comes with a lot of stuff already bundled, so you don't have to look beyond the CD for things like the Java Runtime, Skype, etc.

  3. Better handling for wireless (KNemo in place of KNetworkManager)
The not-so-good things:
  1. Some of the bundled packages are slightly outdated (Firefox, Postgres)

  2. I found some random weirdness with the mounting of other partitions. For some reason I couldn't get them to mount on a directory I had created in the root partition. Instead, I had to allow them to be mounted as /mnt/sda*, and then create a symlink to this directory.

Sunday, July 13, 2008

Put a Shark in Your Tank

There's this story about how Japanese fishermen put small sharks in their fish tanks to keep the fish fresh and better-tasting till they reach the shore. A Google search for the title of this post will give you the full story.

I have nothing against this story -- kudos to the Japanese fishermen for solving their problem in an innovative manner. What I do take exception to is holding up this story as motivational lesson:
Instead of avoiding challenges, jump into them. Beat the heck out of them. Enjoy the game. If your challenges are too large or too numerous, do not give up. Failing makes you tired. Instead, reorganize. Find more determination, more knowledge, more help. If you have met your goals, set some bigger goals. Once you meet your personal or family needs, move onto goals for your group, the society, even mankind.

Don't create success and lie in it. You have resources, skills and abilities to make a difference." So, put a shark in your tank and see how far you can really go!
That's all very well, but there's another -- admittedly pessimistic -- way of looking at it, from the perspective of the poor fish: no matter what you do, nothing matters in the end; you will end up getting eaten anyway, so you might as well surrender to the shark and get it over with ("Oh, these poor humans will end up with not-so-great-tasting fish? Bite me").

Also, just because the fish taste better, it doesn't mean that they had a hoot, trying to save their asses from the %^&# shark.

Sunday, July 06, 2008

Something to Think About

"Have you imagined commodities like steel, crude oil, red chilli, pepper and gold is [sic] a highly potential [sic] investment option. Read on to see why? [sic]" begins an ad in The Times of India today. It goes on to quote figures like 47.58% for cardamom, 25.22% for gold, and 23.80% for crude as the returns in the derivatives market for these commodities, and pitches for a training course on derivatives.

Two points:
  1. Per a report by a United States Senate subcommittee entitled "The role of market speculation in rising oil and gas prices", a speculator 'does not produce or use the commodity, but risks his or her own capital trading futures in that commodity in hopes of making a profit on price changes.'

  2. The folks who enroll for the above mentioned course are already suffering from the actions of people whom they are trying to emulate ("I guess I'll have to take the public transport to attend the classes because petrol is so expensive these days. Those ^&*$ speculators!").