The Lumber Room

"Consign them to dust and damp by way of preserving them"

Archive for August 2009

To Be or Not to Be

leave a comment »

(Not about the excellent film or the excellent animated short.)

Bit off more than my mind could chew,
Shower or suicide, what do I do?
— Julie Brown, “Will I Make it Through the Eighties?”

If you are of the opinion that the contemplation of suicide is sufficient evidence of a poetic nature, do not forget that actions speak louder than words.
— Fran Lebowitz, “Metropolitan Life”

Razors pain you, Rivers are damp,
Acids stain you, And drugs cause cramp.
Guns aren’t lawful, Nooses give,
Gas smells awful. You might as well live.
–Dorothy Parker (several tentative suicide attempts, died of a heart attack at 73)

No one ever lacks a good reason for suicide.
– Cesare Pavese (who committed suicide, WTF?)

And of course no mention of suicide is complete without Maddox’s How to kill yourself like a man.

Written by S

Wed, 2009-08-26 at 14:10:15 +05:30

Posted in quotes

Tagged with , ,

Smith? and other names

with 2 comments

As I, like many South Indians, don’t have a surname, and have been forced to adopt one for my life in the US, I have some things to say about surnames, and there will be a post about them someday, probably. (There was a draft lying around which had “tyranny” in its title, but nothing much good besides.) In the meantime, someone very bored might be able to amuse themselves with related news I’ve been collecting, such as this latest one from a BBC article on zombies:

In their study, the researchers from the University of Ottawa and Carleton University (also in Ottawa) posed a question: If there was to be a battle between zombies and the living, who would win?

Professor Robert Smith? (the question mark is part of his surname and not a typographical mistake) and colleagues wrote: “We model a zombie attack using biological assumptions based on popular zombie movies. [..]

Some paragraphs later:

Professor Smith? told BBC News:

(Apparently he’s an Australian citizen and got his name changed while living in the US… quite an achievement. His major complaint seems to be that Facebook won’t let him use his name.)

Written by S

Wed, 2009-08-19 at 15:45:00 +05:30

Posted in Uncategorized

Tagged with ,

Flashing the screen on Mac OS X

leave a comment »

Here’s one way. There’s a C program to adjust the screen’s brightness written by Nicholas Riley, also available from this blog post by Matt (Danger) West. Get it. The rest is obvious. For instance, here’s a Python script, which should have probably been written in Perl:

import os, re, time

s = os.popen('./brightness -l').read()
ob = re.findall('brightness (\d.\d+)', s)[0]

w = 0.2
for i in range(10):
    os.system('./brightness 0'); time.sleep(w)
    os.system('./brightness 1'); time.sleep(w)
    if(i==4): os.system("say beep")

os.system('./brightness ' + ob)

Tune parameters to avoid epileptic seizures.

Read the rest of this entry »

Written by S

Mon, 2009-08-17 at 16:07:05 +05:30

Posted in compknow

Tagged with , , , ,

Eugene Curtain and Max Washauer

with 7 comments

If you came here because you were reading Peter Winkler’s “7 Puzzles You Think You Must Not Have Heard Correctly”, the names are supposed to be Eugene Curtin and Max Warshauer, and the paper is called “The locker puzzle”, published in The Mathematical Intelligencer, Volume 28, Number 1 (March 2006), pages 28ā€“31.
[If not, you should read the amazing "7 Puzzles You Think You Must Not Have Heard Correctly", spend several days trying the first problem, read the brilliant solution, and then come back here if you're interested in learning why no other solution can do better.]

The paper is available here if your institution has access. If not, here’s a sketch of the proof that the strategy cannot be improved upon. [Update 2010-01-06: Oliver Nash has a post about the puzzle, explaining both the original solution and the proof of optimality, here. Just the original solution is also worked out by David MacKay here.]

First, let us modify the rules slightly so that each prisoner must continue looking in boxes until he finds the box containing his name. The prisoners win if no prisoner opens more than 50 (i.e., n/2) boxes. This change obviously makes no difference to the outcome. Let’s call this (modified) game Game 1.

A different game involves all the prisoners being in the room at the same time, and is played as follows. The first prisoner opens boxes until he finds his name (i.e., the number “1”). Then, the lowest-numbered prisoner whose name hasn’t been revealed starts opening boxes until he finds his name. Then the next lowest-numbered whose name hasn’t been revealed opens boxes, and so on. The prisoners win if no one opens more than 50 boxes. Call this Game 2.

Let’s say we observe the prisoners as they play Game 2, and record the order in which boxes were revealed. This completely specifies what happened. For example, (with 10 prisoners instead of 100) if we record the list 2,6,1,4,9,7,10,8,3,5, we know that the first prisoner revealed boxes containing 2, 6, 1, then the third (lowest unrevealed) prisoner opened boxes with 4,9,7,10,8,3, then prisoner 5 opened 5, and they lost because the third prisoner opened 6 > 5 boxes.

  • Prove: No matter what strategy the prisoners follow, each permutation has the same probability (1/n!) of being the list recorded.
  • Prove: “The classical records-to-cycles bijection”. It sends 2,6,1,4,9,7,10,8,3,5 to (2 6 1)(4 9 7 10 8 3)(5), for example.
  • So the probability of the prisoners winning Game 2 (no matter what strategy they follow) is exactly the probability that a random permutation has no cycle of length greater than n/2.
  • Prove: Any strategy for Game 1 corresponds to a strategy for Game 2 with the same probability. (Trivial: the only change is that you don’t have to open boxes you’ve already seen opened.)

This proves that the pointer-chasing strategy is optimal for Game 1.

Here’s the puzzle as it was originally considered, still open: suppose there are n prisoners and 2n boxes, half of them empty. The prisoners can each examine n lockers. The pointer-chasing strategy doesn’t work as empty boxes point nowhere. Does the probability of winning go to 0 as nā†’āˆž?

Written by S

Mon, 2009-08-10 at 23:45:25 +05:30

The procrastinator’s nature

with 7 comments

I just started using LeechBlock yesterday, and already I know why “How can I block Google’s cached versions of sites as well?” is in the FAQ.


LeechBlock is wonderful. (Install)

There are no results on Google for “LeechBlock saved my life”, but there are testimonials like “Leech block has changed my life”, “Leechblock just saved my life”, and “This application is saving my thesis, and improving my social life”.

If LeechBlock isn’t working for you, you can try more extreme solutions like (on Mac) Freedom and SelfControl. (Found via this post.) But for me, right now, with my current level of work and self-awareness and other devices being employed, LeechBlock seems to be just about sufficient. (Although I do wish Safari were an even worse browser than it is.)

Semi-unrelatedly, also worth reading is Aaron Swartz’s experiment involving one month offline: Before/After.

Written by S

Fri, 2009-08-07 at 23:51:05 +05:30

Firebug “console is undefined”

with 2 comments

If you’re using Firebug and don’t want to bother removing or commenting out all the console.log debug messages for users who aren’t, put this at the top:

if(typeof(console) === "undefined" || typeof(console.log) === "undefined") 
    var console = { log: function() { } };

This reminds me of the trick I use for C/C++ of putting debugging statements inside a macro:

D(cerr<<"The number is "<<n<<endl;);

where the macro D is defined as

#define D(A) A

when you want the debugging code to run, and

#define D(A) 

when you don’t. :-)

(The final semicolon after the D() is for Emacs to indent it reasonably.)

Update: Of course, the above are just hacky hacks to save typing. The “right” way for conditional C code is usually to use #ifdef DEBUG and the like, and the right way around the Firebug problem is to use something more general like this code at metamalcolm.

Written by S

Wed, 2009-08-05 at 14:32:15 +05:30

Follow

Get every new post delivered to your Inbox.

Join 75 other followers