Skip to content

Tranquil Checkers 1.0 Released!

April 23, 2009

I finally released the 1.0 version of tranquil checkers. You can grab it (all platforms) at I’ve got a lot of studying to do for a differential equations test this afternoon, but I’m going to post a full update about this later.

A Lack of SelfControl

March 31, 2009


Just read a Wired piece about a new mac app called SelfControl. In a nutshell, it allows you to blacklist specific domains (and IPs) for a given time, allowing you to remove the distractions that keep you from your actual work (that’s the plan at least).

It’s a fun little app, with an interesting premise. While I was skimming its website this sentence caught my eye:

“Once started, it can not be undone by the application or by restarting the computer – you must wait for the timer to run out.”

Now, I see the reasoning behind not allowing the user to renege on his/her commitment to actually get work done, but there’s no way this little app was going to tell me what to do.

Ok, ok, I admit that’s a little over the top. The app isn’t meant to be fort Knox (it’s open source), and the developer’s goal was to make the casual user keep a promise to themselves. But at the same time, my interest was piqued. (From here on, some things get a bit technical. I encourage you to keep reading, but if you just want the solution you can skip down to the bottom. I won’t tell anyone.)

I looked around on Activity Monitor, but couldn’t find a daemon that was keeping me down. Dead end.

Two minutes and a git repository later, I’m elbow deep in source code, looking around. My eye gets drawn to IPFirewall.m.

The first declaration: NSString* const kIPFirewallExecutablePath = @"/sbin/ipfw";

Very suspicious. As I had no idea what ipfw was at that point, I decided to investigate. A quick man revealed that ipfw was an “IP firewall and traffic shaper control program.” Bingo.

Salient points from the man file:

An ipfw configuration, or ruleset, is made of a list of rules numbered

from 1 to 65535.  Packets are passed to ipfw from a number of different

places in the protocol stack (depending on the source and destination of

the packet, it is possible that ipfw is invoked multiple times on the

same packet).  The packet passed to the firewall is compared against each

of the rules in the firewall ruleset.  When a match is found, the action

corresponding to the matching rule is performed.

Rules can be added with the add command; deleted individually or in

groups with the delete command, and globally (except those in set 31)

with the flush command; displayed, optionally with the content of the

counters, using the show and list commands.  Finally, counters can be

reset with the zero and resetlog commands.

Sounds easy enough. I added ( to my SelfControl blacklist, and pushed the start button. My attempt to reach YC returned the expected “Safari can’t connect to the server” message. Back in Terminal, I gave sudo ipfw list(list all current ipfw rules) a shot:

02500 count ip from any to any // BEGIN SELFCONTROL BLOCK

02501 deny ip from me to

02502 count ip from any to any // END SELFCONTROL BLOCK

65535 allow ip from any to any

Looks easy enough, especially since Mr. Lambert was able to comment the block of rules that SelfControl is using (which could be helpful if you’ve got more ipfw rules than I do). I tried entering sudo ipfw delete 2501, and again attempted to connect to Success!

But was there any way to remove all of the rules? I went back into the app, and dug around in the source code a bit. Again I quickly found what I was looking for (kudos to Mr. Lambert for the clear code):

- (int)clearSelfControlBlockRuleSet {

NSArray* args = [NSArray arrayWithObjects:



[NSString stringWithFormat: @"%d", kIPFirewallRuleSetNumber],


NSTask* task = [NSTask launchedTaskWithLaunchPath:kIPFirewallExecutablePath


[task waitUntilExit];

int status = [task terminationStatus];

return status;

For those not completely fluent in code, the above method is the one SelfControl uses to remove the access blocks. It basically removes a set (a group of rules) from the ipfw list. Specifically, it removes the set at the index kIPFirewallRuleSetNumber.

A quick check to see what kIPFirewallRuleSetNumber was set to (19) and I was ready to go.

Without further ado, I present the simple command to resume your time-wasting ways (Note: You must enter your administrator password when you’re asked for this to work):

sudo ipfw delete set 19

Yup, it’s that easy. There goes my productivity again.

UPDATE: Uh oh. As Charlie Stigler pointed out, there’s a problem with this approach. Turns out SelfControl will reactivate the ipfw blocking after a time. Petard pointed to a better solution, which is to find the SelfControl helper and remove it. The command is then
sudo /Library/PrivilegedHelperTools/org.eyebeam.SelfControl `id -u` --remove
This resets the app quite nicely.

Genetic Algorithms

March 31, 2009

I have very little understanding of genetic algorithms, other than their ability to produce some rockin’ pictures of the Mona Lisa and Lena.

The plan, therefore, is to build a genetic algorithm to determine the optimum Fourier series of a given signal. I realize that this is easily calculated, and a giant waste of cycles, but I figure the best starting place is an easily verifiable solution.

I’m also interested in seeing if my optimum solution will exhibit the Gibb’s phenomenon, or some other type of artifact.

Wish me luck.


Listen to this post: