Ever since I moved to Santiago, Chile in July, I’ve asked myself “What time is it in San Francisco?” multiple times a day. Sometimes it’s for something practical (knowing whether or not I should be on a conference call) and sometimes it’s for something stupid (figuring out whether or not it would be a good time to tweet because the majority of my followers won’t even see it). Either way, I need to know.
I tried to find an application that runs in the OS X Menubar and displays the time for a different time zone and I did find a few programs that sort of did that:
Unfortunately, they didn’t do just that. I couldn’t figure out how to prevent World Clock Deluxe from opening up a floating clock in addition to the menubar and iStat Menus wanted me to click the clock every time I wanted to see the alternate time.
Today I decided to just write it myself. Armed with a vague recollection of iOS development experience and the power of Google, I took the shell of a menubar demo and extracted some code from Menubar Countdown and tweaked it until it worked. Then I slapped an icon from Glypish onto it and called it a day.
Unzip the file and drag Hipster into your Applications folder. Run it.
If you want it to run on startup, go to:
System Preferences -> Users and Groups -> Login Items
and hit the [+] and select Hipster from your Applications.
Customization
You may notice that there is no Preferences option. In fact, the only option is Quit Hipster. I realize the ridiculousness in a menubar application that only displays the time for San Francisco and my only defense is that this is my first Cocoa Mac Application and I have no idea how to create a Preferences pane.
Source code is available on github - if you are able to create a basic Preferences pane that lets you specify a time zone, I will happily accept a pull request.
You can change the time zone by opening up StatusBarAppAppDelegate.m and looking at line 41. Change America/Los_Angeles to whatever you need it to be and hit Build in Xcode.
sushi-motd
The other night I logged into our dev server to check something and got tired of seeing our standard banner, so I wrote a small bash script called sushi-motd.
sushi-motd displays a random piece of sushi ASCII-art whenever you SSH into your server.
I had to set-up a new MacBook Pro last week, a replacement for my laptop that was stolen a few weeks ago. If you count the interim laptop that I was using while waiting for my electronics mule to get back to Chile, that will make four Macs this year that I’ve had to get into a state where I can use them. I’ve decided to document this process, mostly as a personal reference but hopefully beneficial to you as well.
Install
The Basics
iTerm2 – I spend a lot of time at the command line. iTerm2 makes that time more pleasant and productive. Two features I particularly like are split panes and full screen mode.
Scroll Reverser – I hate change and so should you. I’ve mostly gotten used to the trackpad scrolling in Lion but I can’t handle the mouse wheel going the opposite direction.
Right Zoom – This makes the green button in the top left of every window actually do something.
Caffeine – Sometimes you don’t want your Mac to go to sleep
Google Chrome – For better or worse, my browser of choice. I’ve given up on the dev builds, however, that way lies faster Javascript engines but madness.
Firefox – Because, well, Firebug. When I put on my frontend hat, I usually switch to Firefox. When the Net tab in Firebug doesn’t do what I need it to do, I use Charles.
Github for Mac – Streamlines the checkin process of selecting files for checkin, viewing diffs, and writing commit messages
Macports – Homebrew doesn’t set my CPU on fire but sometimes your legs need to be heated up. Install XCode first.
EC2 Tools – All those instances aren’t going to manage themselves. Unzip and copy bin and lib directories to ~/.ec2/. Symlink in the master key from the Dropbox folder.
Productivity
Evernote – Notes in the CLOUD, syncs to my iPhone. Good for doing research.
Skitch – Take screen captures, annotate and show them to people.
Parallels Desktop – Run a Ubuntu VM for testing package installation (although lately I’ve just been creating AMI’s of existing EC2 instances and spinning up clones), run a Windows VM for testing IE and playing old games
Non-productivity
Twitter – Tweetie is still the sexiest Twitter client around.
Adium – Necessary evil. By default only connects to company Jabber account and then I manually connect the other services when I want the possibility of being distracted. Disable all sounds and disable Growl. Nothing you need to know has ever appeared in a Growl notification.
Calibre – For managing my Kindle. Install DRM removal plugin to make backups of the books I’ve purchased and put them in Dropbox.
VLC – For all the non-standard video files that do not exist from USENET, which does not exist.
Connection sharing will ultimately make your uploads to dev server faster as long as you keep an SSH window open to it
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
Host aliases are your friend. For example, alias dev.yourcompany.com to dev and then bash alias the command dev to ssh dev.
iTerm2
I use the Pastel (Dark Background) color scheme.
Scrollback buffer – check Unlimited scrollback.
Allow word movement in iTerm2, add ~/.inputrc
"\e[1;5D": backward-word
"\e[1;5C": forward-word
Dropbox
Dropbox will take a while to sync, log-in to their website and download a zip file of 1Password.agilekeychain and unzip it in the Dropbox folder so we can at least login to websites while it’s syncing.
Pastels on Dark is the only way to go. Ackmate for faster global searches. If you don’t have an upload to dev server script, this one is a quick substitute.
Macports
After installation:
sudo port -v selfupdate
Packages I usually install:
imagemagick – CLI tool for manipulating images
watch – run the same command over and over again while monitoring changes in output
Personal Stuff – Passwords – Never save passwords (All passwords are handled by 1Password)
Extensions
Pinboard – The only real functionality I want out of a pinboard extension is to be able to hit ⌘D and have it open a bookmark dialog. In the options, check Enable Keyboard Shortcuts, set Bookmark Page to meta-d and Browse Bookmarks and Read Later to shortcuts you’ll never hit, e.g. alt + ctrl + meta + shift + b. This is to compensate a conflict with the 1Password extension.
1Password – Install from 1Password itself by selecting Install Browser Extensions
Screen Capture – Useful for taking whole page screenshots of webpages.
Window Resizer – Use in conjunction with Screen Capture for taking demo snapshots of webpages
This is a side-project that I’ve been working on for a while.
Like most people, I have a large collection of digital music, which is awesome, but sometimes I miss the process of physically choosing an album. Also, when you have friends over, it’s a little weird to hand them a laptop and say “Pick an album!”. When you have thousands of artists to choose from, the paradox of choice kicks in and it’s a bit like asking them to pick a 401k plan.
This is an early prototype of it working in action:
The small vinyl records are Christmas ornaments that I embedded RFID tags into and then pasted their album art that I downloaded from discogs and had printed on quality photo paper at a print shop. The record player is simply a photo of a record player I found on Flickr with an RFID reader underneath.
Assembling a record
I start with a Christmas ornament of a vinyl record.
Then I peel off it’s label and clip the string and plastic loop.
The RedBee RFID reader reads the RFID tag and wirelessly transmits it to the XBee module attached via USB to my wireless router, which then replays the RFID tag to my Popcorn Hour, which finally selects the corresponding album and plays it.
Software
Asus RT-N16
The XBee wireless module is attached to the router via USB. I’ve flashed the router with DD-WRT, which includes an implementation of the FTDI Virtual COM Port drivers.
Thus, we just need to read from the virtual COM Port and send the RFID tag to the Popcorn Hour via netcat:
cat /dev/usb/tts/0 | nc 192.168.1.135 3333
Popcorn Hour A-100
Starting from a stock Popcorn Hour, I modified it to allow telnet access and then used the NMT Community Software Installer to install mpd.1
I found mpd when researching mp3 player daemons that could be accessed via the command line. It’s an amazing project that’s worth checking out if you’re interested in running a music server. They have free clients available for almost every platform, including iPhone and Mac OS X.
The Popcorn Hour reads data from the router via netcat and then passes the RFID tag to our play.php script.2
nc -l -p 3333 | while read x ; do /mnt/syb8634/server/php /opt/sybhttpd/localhost.drives/HARD_DISK/RFID/play.php "$x" ; done
And play.php simply does an array lookup against the RFID -> Artist/Album hash and launches mpc, the command-line client for mpd. It also checks if the RFID tag it just read is the same as the one currently playing.
<?php
$albums = array(
'128 208 4 44 154' => array('A Tribe Called Quest', 'The Anthology'),
'128 208 248 94 105' => array('Broken Bells', 'Broken Bells'),
// etc...
);
$line = $argv[1];
$line = preg_replace("/>?T:NACK /", "", $line);
$line = trim($line);
// Sometimes the RFID reader likes to send junk data
if (!preg_match('/[0-9 ]*/is', $line)) {
exit();
}
$currently_playing = '';
if (file_exists('/tmp/currently_playing.txt')) {
$fp = fopen('/tmp/currently_playing.txt', 'r');
$currently_playing = fread($fp, filesize('/tmp/currently_playing.txt'));
fclose($fp);
}
if ($line != '' && $line != $currently_playing) {
if (array_key_exists($line, $albums)) {
exec('mpc stop');
exec('mpc clear');
exec('mpc search artist "' . $albums[$line][0] . '" album "' . $albums[$line][1] . '" | mpc add -');
exec('mpc play');
}
$fp = fopen('/tmp/currently_playing.txt', 'w');
fwrite($fp, $line);
fclose($fp);
}
?>
That’s pretty much it! When I make new albums, I just transfer them to the Popcorn Hour via SMB, add the corresponding RFID tag to the array, and update the music database.
Cool, how do I make one?
The hardware choices I’ve made here were mostly based on stuff I already had. The Popcorn Hour could easily be replaced by any computer with a sound card that can run mpd and the ftdi drivers, but if you don’t have a spare netbook or PC lying around, the Popcorn Hour seems to be the right price point (especially the refurbished A-110 at $105) for a dedicated RFID mp3 player.
The RedBee RFID reader is slightly more expensive that most RFID readers, but that is because it can use XBee wireless modules. If you don’t need wireless, you can get away with cheaper USB RFID readers.
The only tricky thing to find is probably the Christmas ornaments that look like records. I bought these from Restoration Hardware’s online store a few years ago during an after Christmas sale, but I haven’t been able to find a cheap source for them. If you do, let me know. One alternative that I was thinking of would be to remove the disc inside of 3.5” floppy disks.
If you decide to try making one, please let me know (bertrand@fan.net) how it turns out!
It’s worth noting that the ftdi_usb drivers are also available for the Popcorn Hour, thus you could theoretically bypass the wireless router altogether by attaching the XBee wireless module directly to the Popcorn Hour, but I found the drivers to be too unstable - perhaps due to the memory limitations of the unit.
Why do we have a daemon running in a loop that calls php? PHP daemonizes poorly and leaks memory like a sieve. Why not use a language other than PHP? Well, for one, I work at Flickr and write PHP all day long, so it’s the language I’m most familiar with. When all you have is a hammer, everything looks like a nail. Also, it’s already on the Popcorn Hour, albeit an old CGI version of PHP 4.
Yelp Success Story
A few years ago, I found myself living in Cambridge, MA. I went to a laundromat and put my clothes in and decided to look for restaurants in the area, when I stumbled across this review:
After reading it, I had to see what he was talking about, so I walked over there, had a terrible meal, and then took a photo and uploaded it to Yelp.
Today, I got this!
This, my friends, is social media at work.
Hi, I'm Bertrand Fan. I'm the co-founder of Recollect. I've previously worked on Flickr, MyBO and TED.