That's a Spicy Meatball!

Apr 13

We built this tool to help people quickly download an archive of their Instagram photos.

We built this tool to help people quickly download an archive of their Instagram photos.

Apr 04

My Twitter social graph visualized by Recollect

My Twitter social graph visualized by Recollect

Dec 26

Introducing Hipster

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:

World Clock Deluxe ($19)

iStat Menus 3 ($16)

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.

Hipster looks like this in your menubar:

screenshot

Get it

You can download it here.

Installation

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.

Dec 10

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.

screenshot

You can download it here.

Oct 26

Reboot

Introduction

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

Development

Productivity

Non-productivity

Photography

Configure

System Preferences

Desktop and Screen Saver

Minimal wood wallpaper

Keyboard – Keyboard shortcuts

Most of this is to ensure that ⌥⌘→ and ⌥⌘← are the universal keyboard shortcuts for Next Tab and Previous Tab.

Mission Control
Disable Move left a space
Disable Move right a space
Application Shortcuts
iTerm2 - Select Next Tab - ⌥⌘→
iTerm2 - Select Previous Tab - ⌥⌘←
Google Chrome - Bookmark This Page… - ˆ⌥⇧⌘D

The reason Google Chrome’s Bookmark This Page keyboard is so weird is so that we don’t conflict with the Pinboard extension’s keyboard shortcut.

Trackpad

Secondary click – Click in bottom right corner

.bash_profile

Usually I just symlink this to a file in my Dropbox folder, but for reference:

Colored LS output in iTerm2:

export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

Environment variables for EC2:

# Setup Amazon EC2 Command-Line Tools
export EC2_HOME=~/.ec2
export PATH=$PATH:$EC2_HOME/bin:/opt/local/bin:/opt/local/sbin
export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/

~/.ssh/config

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.

Github

Generate SSH keys:

mkdir .ssh
cd .ssh
ssh-keygen -t rsa -C "bertrand@fan.net"
cat id_rsa.pub | pbcopy

Github SSH public keys – Add another public key – ⌘V.

git config --global user.name "Bertrand Fan"
git config --global user.email "bertrand@fan.net"

Textmate

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:

Google Chrome

Bookmarklets
Preferences
Extensions

Feedback

And that’s pretty much my working environment. There’s a lot of room for improvement and I’m open to suggestions.

Jun 12

[video]

Jun 04

Apr 18

This is pretty much what I stare at all day long. It’s hard getting the photos exactly straight and we’re running out of scotch tape.

This is pretty much what I stare at all day long. It’s hard getting the photos exactly straight and we’re running out of scotch tape.

(Source: backofawebpage)

Apr 11

Almost certainly the best lighthouse log entry on Flickr.

Almost certainly the best lighthouse log entry on Flickr.

Feb 28

RFID Record Player

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.


This is a disc RFID tag.


I stick the disc RFID onto the album.


Then I place the album art on top of the RFID.


Hardware

The components are a RedBee RFID reader with XBee wireless modules, a wireless router running DD-WRT, and a Popcorn Hour A-100.


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!


  1. 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.

  2. 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.