Microblogi: A very long article Wikipedia article on the orientation of toilet paper [7. kes klo 22:52] [V]

Lauantai, 21. maaliskuuta 2009

No for, no if

Käännös: [ Google ]

Kategoriat: [ ATK ]

The mission: write a program that iterates over a list and asks the user, on every item, if he wants to change the current number, or quit (and keep the rest of the list unchanged).

Here's a possible python implementation.

def loop(data, index):
  return decide(index == len(data) - 1, 
                lambda: quit(data), 
                lambda: run(data, index+1)
def decide(condition, iftrue, iffalse):
  return (iffalse, iftrue)[condition]()
def choose(selector, choices, default):
  return choices.get(selector, default)()
def change(data, index, new_value):
  data[index] = new_value
  return loop(data, index)
def run(data, index):
  print data[index]," Change? [n/q/]",
  reply = raw_input()
  return choose(reply.lower(),
                  "n": lambda: loop(data, index),
                  "q": lambda: quit(data)
                lambda: decide(reply.isdigit(),
                               lambda: change(data, index, int(reply)),
                               lambda: run(data, index)
def quit(data):
  return data
data = range(10)
print run(data, 0)

[ Postattu 21. maaliskuuta 2009 klo 18.09 | 2 kommenttia | ]

Tiistai, 17. maaliskuuta 2009


Käännös: [ Google ]

Kategoriat: [ Valitusta ]

Pour la Saint Patrick, la Chartreuse (verte, évidemment) c'est plus adapté que la Guinness, non ? Donc, en attendant de me lancer dans la glace à la Chartreuse, un petit verre de Chartreuse.

[ Postattu 17. maaliskuuta 2009 klo 19.49 | ei kommenttia | ]

Maanantai, 16. maaliskuuta 2009


Käännös: [ Google ]

Kategoriat: [ Askartelu ]

Yesterday late evening I went to the kitchen, switched the light on and… nothing, except a slight buzzing from the switch. I ran to the fuse board and removed a couple of unlabeled fuses (until I found the one for the kitchen, which bore a label). Of course, the fridge is on the same circuit as the light, so I had to pull it out of its corner to grab its power cord, and connect it to one of the sockets in the kitchen (which are on a grounded circuit).

After that, I removed the cover, I took a look at the inside of the swith. It was full of cooked ants… We've been having ants in the kitchen (they came with the house, they visit us at the end of the winter, and should leave when the weather is warmer outside), but I never expects the buggers to walk into the electric switch. Damn stupid animals (which they are, of course, taken individually). So I vacuum-cleaned the switch, then used canned air to spray the last pieces of ant out. But the switch was still not conducting electricity.

The problem was that cooked ants don't conduct electricity very well (I measured about 60 Ω through the switch) and the switch was still buzzing. After a bit of thinking and scratching the contacts with a flat screwdriver (too big for the job), I thought of using a piece of sandpaper, stick it between the contacts, close the switch, and pull. After a couple of times, the switch was better than new (with a resistance of under an Ohm).

Lights are working fine now. But why does this always happen at night, when you have to work with a flashlight in your mouth?

[ Postattu 16. maaliskuuta 2009 klo 21.33 | 5 kommenttia | ]

Keskiviikko, 4. maaliskuuta 2009

Last.fm Datamining

Käännös: [ Google ]

Kategoriat: [ ATK ]

Interesting article about how personal profiles on different systems can be linked together by datamining:

“If your username isn't your real name, your Last.fm account may seem to be anonymous, but the facts it contains probably tell the world who you are.”

“even a small amount of information about other pseudonyms you've friended on Last.fm has a high probability of allowing a data miner to match you based on the friendship graphs from other sites”

“There are only 7 billion people on the planet, and only about a billion on the Internet. Every fact about a person (are they male or female? Where they live? Do they listen to Brian Eno?) slices that number down by a significant fraction. If you have enough facts about a person, (33 bits of independent facts, it turns out, because log2 7,000,000,000 = 32.7) you can determine who they are.”

[ Postattu 4. maaliskuuta 2009 klo 14.05 | 2 kommenttia | ]