Archive for the 'Madness' Category

IRC Quote (2)

Zeus WPI has an IRC channel which at any one time contains two dozen geeks discussing a myriad of topics ranging from the latest XKCD to the physics behind not being able to reach absolute zero.

Such a cornucopia of madness wouldn’t be complete without a bot for certain administrative tasks such as keeping stats on each user.

The “riddle” I posted last year is a question we pondered about for a few days back then:

We keep a log-file of all that is said on our IRC channel. What’s the fastest way to extract one random line said by a specified person from that file, with every line having equal chance of being picked.

This we would use to implement a “quote”-command in our custom-made bot, which returns a quote for the named person.

To keep the problem interesting, no “persistent” data can be kept in memory over multiple queries, such as an index or a counter.

Adhemar was the only person to propose a solution, but we also asked our professor for Datastructures & Algorithms, Gunnar Brinkman. As it turns out Adhemar’s solution was very close to the one Prof. Brinkmann suggested.

Brinkmann’s Algorithm

This is the algorithm we were using:

totallines = 1
while not eof(logfile) do
   currentline = readline(logfile)
   if (rand() mod totallines) == 0 then
      currentqoute = currentline
   totallines++
done

In plain English:

For every line i, pick that line with chance 1/i.

Adhemar’s Algorithm

Adhemar’s solution however, is a tad faster on a real-life system because it does not need the relatively expensive mod-operation for every line:

currenthighest = 0
while not eof(logfile) do
   currentline = readline(logfile)
   currentrand = rand()
   if (currentrand >= currenthighest)
      currentquote = currentline
      currenthighest = currentrand
done

Or:

The player who rolls the highest dice gets picked.

Emperical data suggests the second algorithm is about 1% faster than the first. It’s obvious that this problem is an I/O-limited one, so these algorithms are probably as good as it gets without storing any data in memory.

Although the problem is relatively simple, the interesting thing to remember here is how to randomly pick an item from a set with an unknown amount of items.

How-To: Wrap a romantic present using Schamper

So you need to wrap a romantic present, but you’re all out of wrapping paper. Or you never had any. As a student, I face this situation constantly, and have become quite adapt at surviving it.

The Victims
Here are the victims. I’m going to scavenge an old issue of Schamper, our university’s awesome student magazine, for wrapping paper.

My Favorite Article
Rip out your favorite or most romantic articles to use as wrapping material.

Two articles fused together
Use tape to paste every page together to make a long enough string of mind-blowing literature.

Wrap around
Wrap the string around the present. Use tape to paste the two ends together.

Cornered
There’s supposed to be a certain technique to do the corners neatly, but let’s face it: you’re wrapping her present using an old magazine. She’s not going to care about the corners. Also, I forgot.

Use tape vigoriously to make sure the enlightening wrapping doesn’t fall apart.

Missing side
If you missed a side, a common error, just paste a page on top.

FixedThat’s the beauty of this method: you can screw up and she’s never going to notice.

Nice Wrappings
Nothing says I love you like a big bald face on top of her present.

A job well done, another potentially problematic situation solved. You can tell her you custom-made the wrapping paper yourself, because that’s how much you love her!

Good Luck Phoenix!

2 hours and 30 minutes before humanity’s newest mars lander will touchdown - hopefully unharmed. One of the highlights of the mission is the search for past lifeforms in the polar ice. Some nice links if you’re interested:

Let’s hope Phoenix will fare better than his predecessor. Sleep tight tonight, because we just might awake to a whole new world.

1.30192108E+94K

A year ago, while drunk, a friend and I were discussing temperature scales. Turns out Fahrenheit used his body temperature to define 100°F, which is totally ridiculous from a scientific point of view. Fahrenheit was actually having a little fever when he developed his scale, which is why 100°F is slightly higher than the normal human body temperature of 98.2°F.

One could say Celsius was more sane, using the boiling-point of water to define 100°C. If you think about it, though, this isn’t optimal either. Water boils at differint temperatures depending on the atmospheric pressure. Seen through the alien eye it really doesn’t make any sense at all: why H²O? Why bound by the conditions of one planet (Earth)?

Mind you, we were drunk.

So off we went and created a new temperature-scale. We figured Kelvin was spot on with defining 0K as the absolute zero, so we used that in our scale. Furthermore, using probably bogus science, we calculated the highest temperature possible in our universe, which turned out to be 1.30192108E+94K, and used that to define 100°.

Out came Astix, including basic HTML-page explaining the calculations done and Kelvin-To-Astix converter. Enjoy our crazy brainfart.

Sarcasm

Sarcasm
As seen on reddit (submitted).

Atwood Strikes Again

Some of you probably follow Jeff Atwood’s Coding Horror. I used to look forward to reading his articles, but his content is increasingly starting to bore and annoy me. Many times it’s him quoting large pieces from some guy’s blog that does have original content, while trying to give some insightful comments. Except, they’re not insightful. They’re just plain wrong.

His latest entry, What’s your backup strategy, is another one of those monsters. Here’s a snippet:

The rsync command is more than a simple copy; it actually does a block-by-block comparison, only copying the differences. So instead of backing up the entire contents of your hard drive (again), you only back up the parts that changed since your last backup. This is commonly known as incremental backup.

Sorry Jeff — I can call you Jeff, right? — although your introduction to rsync is correct, rsync is definitely not “incremental backup” software. If he’d actually read the Wikipedia article he links to, he’d notice that the first line of it goes like this:

An incremental backup is a backup method where multiple backups are kept (not just the last one).

(Emphasis’ mine) rsync doens’t keep multiple backups. rsync will indeed only transmit the differinces between the last backup and the current original, but the result will be one backup: a complete mirror of the current original one.

The advantage of an incremental backup is not that it’s fast to do, like Jeff implies, it’s that you can pick a backup from before your last backup. This way you can restore the one you need, which is not necessarily the last one. Handy if you need a file you deleted 2 weeks ago, but your last backup was last week.

Even better, at the end of the article he throws up this God-awful piece of advice:

You don’t even technically need a second or third hard drive; if you have a large enough primary drive, Acronis will allow you to create a new, hidden partition to store a complete backup image.

If you store a backup on the same drive as the one you’re backing up, what the fuck — excuse my french — is the point in backing it up in the first place? If your drive dies, dear Jeff, your backup dies with it. Guess he didn’t got the message Jamie was trying to spread anyway.

It’s not that I hate Jeff. I guess I’m just disappointed that his articles have decreased in quality so much. There are some real gems on his blog, so you really should check it out. Just watch out for his Microsoft-centered ideas ;) .

Religion and Programming Languages

One Michael Kimsal put up a survey to determine the correlation between what religion you believe in and what programming language is your favorite. Although of little real use, and probably not to be taken seriously, it’s going to be interesting to see the results.

At the time of writing, there are 1003 entries. Why not put in yours? It’ll make the world a better place… (not really ;) )

I bet Scientologists will love LOGO. Har Har.

Das Klock

Seth Godin writes how Alarm Clocks are deprived of features and intelligent design because everyone involved in the business of Alarm Clocks aren’t hired to make it better, rather they’re hired to sell it.

Here’s my idea for a superior alarm clock:

Verbarius

Display the time in words like Art Lebedev’s Verbarius (displayed). Take hints from Verbarius’ design - sleek, black, like a jewel. You should be proud to have it on your nightstand, but it shouldn’t attract much attention when you enter the room. It’s an alarm clock, not a 1952 Jaguar Roadster.

Add a light-sensor: dim the brightness when dark, so it doesn’t to hurt your eyes when you wake up at 3am.

Use high quality audio components. No one likes waking up to static-ridden audio. You want the best listening experience that fits in the tight package. Just an AM/FM tuner, too. No MP3 player functionality, no CD-player. Yes, it’s fun to wake up to something of your own choosing. It gets less fun after waking up for the tenth time to the same song. Adding it would force your users to upload new songs every week. Don’t add stereo controls: it’s an alarm clock. You want the least amount of buttons.

Automatically update time and date using radio-transmission. Allow the user to disable any alarms (or set different ones) on weekends. Add a “holiday”-switch: disable all alarms. Disabling alarms doesn’t make it forget what time it’s set at.

Add touch-sensitivity to the casing of the clock as the “shut the fuck up”-button. The lesser you need to search for it while morning-drunk the better. Make sure the touch-sensor works in any possible bed-circumstance. Test it with a used condom thrown on it. If you’re buying an expensive alarm clock, you don’t want to wonder if it’ll wake you up in the morning just because you had a fantastic, drunk night.

Add a feature to turn off the next alarm clock. Useful if you wake up 5 minutes before the actual alarm goes off, or for the night before a random day off. Possible method: tap the casing twice (”doubletap to skip one”). Add Unskip.

Use the touch-sensitive screen for settings. Yes, this will scare away grandmas and grandpas. They’re not our target market. Make the menus huge - don’t force the user to squint. I don’t have any statistics on near-sightedness, but if I had to pull one out of my ass, I’d say 50% would suffer from small text 50cm away.

Market it as the best alarm clock ever. Price it as the best alarm clock ever. You don’t want people to think it’s an alternative to those cheap alarm clocks you get free with your magazine subscription. You want people to think the cheap alarm clocks aren’t worthy of being on your nightstand, doing the most honourful job of waking you up in the morning. Use a name people will associate with good ol’ German/Swiss quality, like “Das Klock”.

Give supreme warranty - 10 years at a minimum. Make a tiny, portable version, with the ability to sync alarms with its big brother. Don’t segment - why would anyone buy anything less than Das Klock, the best alarm clock ever?

And then go bankrupt because no one wants to buy a €400 alarm clock without a Hello Kitty on it. It doesn’t even play MP3’s, *gasp*!

Recipe to blog.crowdway

Bring a large pot of lightly salted Wordpress to a boil. Cook K2 in the boiling Wordpress for 8 to 10 minutes. Drain.

Meanwhile, prepare the sauce: Cook Potsie for better cellphone mail blogging until brown. Disable Wordpress Widgets and configure the K2 Aside Module with some Parmesan. In a bowl, stir together the Scrobbler Plugin and half a tablespoon of K2 Scrobbler Module. Simmer uncovered for 30 minutes.

Serve preferably with a light Sauternes. For 1 person.