Save your productivity with Chrome’s StayFocused extension


“You sit down at the computer, and you swear you’ll be productive. Next thing you know, it’s twelve hours later. You’ve checked your email, updated your Facebook status, browsed the trending topics on Twitter, read your RSS feeds, [read Reddit, my drug of choice,] looked up your favorite band on Wikipedia, vanity googled yourself, cyber-stalked your ex, looked at all your high-school crushes’ Facebook photos, watered your plants on Farmville, and lost a week’s pay playing online poker. 

What you haven't done is WORK.
StayFocusd is a productivity extension for Google Chrome that helps you stay focused on work by restricting the amount of time you can spend on time-wasting websites. Once your allotted time has been used up, the sites you have blocked will be inaccessible for the rest of the day."

Of course, you have to be running Chrome.

Three great new tools

Task management: Toodledo,  Different than Remember The Milk, maybe better.  I’m trying it out and may switch permanently.

BetterTouchTool:  Lots of gestures for your Mac.
BetterSnapTool:  A subset of the gestures in BetterTouchTool, but in addition allows you to move a window by pressing a modifier key and moving the mouse.  If you use a touchpad, this is actually just a modifier key and dragging your finger.
All are free.

Unintended consequences

Problem: Editor creates “backup” files.  Solution: create a script to find all “*.bak” files and delete them.  Run it manually whenever appropriate.

Problem: Files are too big.  Solution: Use the “split” command to split them into 10k line chunks.  Files are big enough that the “split” default (foo => foo.aa, foo.ab, etc) needs to be changed to a 3 character extension, thus foo =>, foo.aab, etc.

Solutions collide: foo.bak gets deleted the next time I clean up my backup files.  Oops.

QFTD, 5/17/11

“Life is too long to know C++ well.”  — Erik Naggum, via Peter Seibel

Interesting factoid: I coulda sworn that said “too short”.  To the point that I half-suspected it’d mutated in my cut-and-paste buffer and went back to check.  It’s weird when you mis-read something consistently.  It’s like those experiments where you can read short to medium length words, even if they’re scrambled, as long as the first and last letters remain the same.  I didn’t see “long”, I saw “life is too X” and filled in the blank.

Random tidbits

  • VirtualBox’s “seamless” mode is really cool.  Make sure your guest additions are installed and working correctly.
  • EPUBReader for FireFox is my favorite ePub reader on my Mac (and the only ePub reader on the Linux VM running on my Mac :).  Prefer it highly over Stanza Desktop or Sony’s ebook reader.  Stanza on the iPhone rocks, though.
  • Land of Lisp is cool, as is Modern Perl
  • The airport at Detroit is really big.  Or maybe it’s not.  But certainly my plane taxied for what seemed like a very long time before takeoff.

I hate it when … invalid models

I hate it when my internal model of a program doesn’t quite match its actual behavior.

So I’m tailing a file: “tail -f file”.  Tail recognizes when a file’s been truncated and starts rereading it.  BUT, even if you say “-n +0” it still starts rereading from the new end, not from the beginning.  So if you have

# Terminal 1
date > file
tail -f -n +0 file

# Terminal 2
date > file
date > file
date > file

You’ll never see anything new from tail, because the length of the file never actually changes.

More subtly, say you have

# Terminal 1
date > file
date >> file
tail -f -n +0 file

# Terminal 2
date > file

Here the tail will see that you truncated the file, but it won’t show you the new line, because the file length changed from 58 to 29, not from 58 to 0 to 29.

All that’s fine and maybe even “obvious” when laid out like that.  But you can get the same behavior like this:

# Program 1, pseudo-Perl
open LOGFILE, “>file”;
while (my $request = get_request()) {
    print LOGFILE “the requestn”;
    process( $request );

# Terminal 1
tail -f -n +0 file

When you restart Program 1, you won’t see the first request in the log file, because just as above, the file length went from (say) 100 to 50, not 100 to 0 to 50.

But if you cat the file, there it is.

Anyway, I hate it when that happens.

(The answer, by the way, is to unlink the file before you start writing to it again, and tell tail “–follow=name”.)

A few things I’ve learned about time synchronization in VirtualBox

These comments may be specific to running a Debian Linux guest on a Mac OS X host.
  • Time synchronization is briefly documented in the manual in chapter 9, Advanced Topics.
  • Time synchronization is performed by an in-guest daemon called VBoxService
  • You can tune VBoxService (on the guest) by running VBoxManage on the host.  As near as I can tell, you must restart VBoxService for any changes to take effect.  (In Debian, /etc/init.d/vboxadd-service restart.  To kill it, replace “restart” with “stop”.  To start it after you’ve killed it, replace “restart” with “start”.)
  • You can watch what VBoxService does by killing the daemon (see above) and running it from the command line in verbose mode, in the foreground (as root), “VBoxService -v -f“.
  • By default, VBoxService wakes up every 10 seconds and adjusts the time.  If the time is off by less than 20 minutes, it adjusts the time by (very roughly) 0.005 seconds.  (Put another way, if your clock is slow by a whole second, it may take half an hour to catch up.)  If the time is off by more than 20 minutes, VBoxService just sets the time.
  • If you want VBoxService to just set the time when it’s off by more than 1 second (1000 ms), instead of adjusting it gradually every 10 seconds, you can say
    • VBoxManage guestproperty set <vm-name> "/VirtualBox/GuestAdd/VBoxService/--timesync-set-threshold" 1000
  • The “--” in the documentation and in the command above is not a typo.
  • Remember to restart VBoxService for your changes to take effect.

VirtualBox doesn’t suck

I wanted to run Linux on my Mac laptop, but didn’t want to pay $80 for VMWare Fusion if I could avoid it.  It turns out, I could!  I’m not actually done installing Linux yet, but VirtualBox seems pretty nice so far.

I wouldn’t bother, since Mac OSX is a Unix variant, but I recently got the hankering to run my Lispworks for Linux on my laptop, so that’s what this is about.
Update: Finished installing Linux with KDE.  Worked out of the box.  Currently running konsole exported to the regular Mac X11 server.
Update 2: Hit a bit of a speed-bump on VirtualBox: networking.  The default NAT networking is great: it will take packets from the guest and put them on the host’s network.  But … what if you’re currently unplugged?  Then your machine has no network, and no IP address.  Sure, your guest can’t get to the outside world, but here’s the thing: It can’t get to your host, either.
So, try bridged networking.  As near as I can tell, the network you’re bridging to has to be up and active.
Then there’s host-only networking.  The guest can talk to the host even if the host is not currently attached to a larger network … but even if it is, the guest can’t talk to said larger network.
You can switch between the two, but only if you reboot the VM.
I shall attempt to enquire at the VirtualBox forum.
Update 3: While typing in my question at the VirtualBox forum, I thought of a possible solution, which I tried and it works: Add a 2nd NIC to the guest.  One NIC is NAT’ed to the outside world, the other uses “host-only” networking to talk to the host.  Still curious if there’s a better way, though.  My VB forum question here.