Archive for June, 2007

Be a Good Mac Laptop Guest

Friday, June 22nd, 2007

I frequently use my wife’s Macbook because it always seems to be handy when my own laptop is in the other room. I gave myself a user account on the machine, but she started complaining that I’d often forget to switch back to her user account when I was done.

Being a lazy git, I sought out for a technical solution for this problem. The solution I came up with will automatically switch the active user to one of your choice each time the laptop is put to sleep (the lid is closed):

Step 1: Install SleepWatcher

SleepWatcher is a very simple daemon that adds new wakeup, sleep, and idle event triggers to your mac. At the time of this writing, SleepWatcher 2.0.4 can be downloaded here.

Open the .DMG file and install “sleepwatcher.pkg” then “SleepWatcher Startupitem.pkg”.

Step 2: Install SwitchUser

I have crafted a small command line application called SwitchUser to facilitate easily scriptable fast user switching.

Download and install SwitchUser 1.0.

Usage: switchuser

Step 3: Configure the Event

Open terminal and type the following line:

sudo nano /etc/rc.sleep

This will prompt you for your password. Once that is done, enter the following line at the end of the file:

switchuser 'target_user

Remember to replace target_user with the short user name of the account you would like to switch to. If you don’t know that name, it can be found in /Users/.

To exit the editor, press CTRL + o then CTRL + x.

Step 4: Enjoy!

At this point, you should be able to close the lid of your laptop and the computer will automatically switch to the specified account.

House: Check!

Monday, June 18th, 2007

My wife and I have just sealed the deal on our first house! It’s a very nice little three-bed two-story semi-fixer in northern Seattle. We’ve already generated a two page remodeling project list that we sure hope gets done in a reasonable time frame. Thanks to the magic of Google Sketchup, I have a fantastic CAD layout of the entire place that should greatly help us along the way.

Despite taking nearly 500 pictures of the insides of the house and the back yard, I don’t have a single house front photo to share with you.
However, if you’re interested in more updates, check back to this blog every now and then.

Oh, and we’re getting some chickens. The city limits us to the lesser of 20,000 chickens or one per square foot of property space, but I think we just need two or three. We’ll keep you posted on how that goes after we move in.

If you know the name of any really good and really inexpensive architects, interior designers, or contractors, let us know!

Hello Again, Zend Certified Engineer!

Tuesday, June 12th, 2007

Last year, I tested and passed the Zend PHP 4 certification. Once again, I have overcome great adversity and climbed the highest figurative mountains in order to qualify and quantify my bountiful PHP skills.

Ladies and gentlemen, I would like to announce my acceptance of Zend Certified Engineer: PHP 5.

Tune in this time next year for my PHP 6 hat trick.

The Science of Luck

Saturday, June 2nd, 2007

I’ve heard a lot of people claim not to believe in luck. Allow me to demonstrate that this belief, while psychologically satisfying to some, is tantamount to disbelief in Pi or milkshakes.

Luck is not some sort of ethereal faith-based system of wish-granting priority. Luck is the result of a simple calculation and luckiness is the sum of a series of luck calculations.

The Formula


Luck = Benefit / sqrt(Probability)

The basic unit of luck measurement is under some debate, but for our discussion, we will refer to the unit as Л or “El.”

You can see the formula in action with my online luck calculator.

Benefit:

A numeric value with min and max centered about 0 and range set to an arbitrary scale (ex.: winning a free bagel = 0.8 and getting a lethal papercut on the giant novelty check handed to you by Ed McMahon = -99). For our purposes, the benefit scale ranges from -100 to 100, inclusive.

Note: The benefit value is subjectively determined value on a scale where -100 is the worst possible, 0 is neutral, and 100 is the best possible outcome. Refer to table 1a for some examples.

Probability:

A ratio of the number of times an event will happen over a number of attempts. This value will always range from zero to one, inclusive.

Formula In Action

Assuming your assessed benefit value of finding a $20 on the street is 5 and the odds of doing so are 1:400 (1/400 = 0.0025 = 0.25%), the formula would work out like this:
Л = 5/sqrt(0.0025)
Л = 5/0.05
Л = 200

Homework

Everyone loves story problems, so here’s one for you:
Lucy values her life more than anything in the world except for that of Mr. Turtle, her cat. She places the benefit of losing her life at -99. After a friend of a friend perished in a tragic futon accident, Lucy found out that the odds of such a thing happening to her are 1:4,473. Aside from the toilet, Lucy owns no furniture with a seat or table top higher than 18 inches because she feels this will ensure her safety. However, a fateful visit to Sears nullifies all of her protective efforts as she trips over a footstool and suffers a fatal concussion.

Calculate the Л for Lucy’s untimely death. Show your work.
Hint: Surprisingly, the value is negative.

Luck Calculator

Use this simple tool to quantify the luck for a particular event.


Benefit (range: -100 to 100)

 

Probability (range: 0 to 1)

 

Л:

 
Table 1a.: Example relative benefits

Event Benefit
Senseless death -100
Identity stolen -50
Broken tailbone -25
Fender bender -10
Goldfish dies -5
Paper cut -1
It’s Thursday the 12th 0
Two toys in your happy meal 1
Flowers from an admirer 5
No cavities 10
No red lights for a whole day 25
Bowl a 300 50
Save Oprah’s life 100