You need to have svn installed, of course. If you want to improve it, here’s the gist.

#!/bin/bash
tmsupportpath="/Library/Application Support/TextMate"
bundlepath="$tmsupportpath/Bundles"
if [ ! -d "$bundlepath" ]
  then
  echo "First time, eh?  Making $bundlepath..."
  mkdir -p "$bundlepath"
fi
 
if [ ! -d "$tmsupportpath/Support" ]
  then 
  cd "$tmsupportpath"
  echo "Checking out the most recent Support folder..."
  svn co http://macromates.com/svn/Bundles/trunk/Support
fi
 
cd "$bundlepath"
svn co http://macromates.com/svn/Bundles/trunk/Bundles/$1.tmbundle
svn up *.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
 
cd "$tmsupportpath/Support"
svn up

Andrew and I were recalling BBC’s The Box today when I wondered if people have tried living in shipping containers.  I know there have been many efforts to sell prefab homes based on shipping containers as low-cost, eco-friendly housing solutions, but I’ve never heard of someone living in one while it was shipped around the world.

I thought this might be a cool idea for a story: who lives in shipping container communities on boats and at port?  What kind of relationships and norms form under such fleeting conditions?  Could this ever be economically feasible if shipping a container from China to the US costs $8000?  Any ship carrying house containers could carry freight beneath them, but I guess the only way it could work is if passengers were willing to pay as much or more than their weight in freight was worth.

I also started thinking about how this might work in space.  Rotating container bays for simulated gravity?  Completely self-sufficient shipping container space homes?

Deleting Unversioned SVN Files

Here’s a silly bash trick that will delete all unversioned SVN files

svn st | grep "^?" | sed s/?[[:space:]]*// | xargs rm -rf

Use with care, obviously. If there’s a more concise method, please let me know.

And here’s how you might use similar commands to apply fmresolve to all conflicted files, and then resolve them.

for f in $(svn st | grep "^C" | sed s/C[[:space:]]*//); do fmresolve $f; done
svn st | grep "^C" | sed s/C[[:space:]]*// | xargs svn resolved

Active Record Model Adapters

I recently refactored some code in iNaturalist that fetches taxon names from external name providers like uBio and the Catalogue of Life. They return names and classification data that are similar but (of course) not identical to ActiveRecord models we use in iNat, so I figured I’d write adapters for them, and I thought a really smart solution would be to subclass the models themselves, simply overriding the attributes with getters that mined a private instance variable holding an XML response from one of the web services. Big mistake. ActiveRecord mixes in all kinds of magic into the models that doesn’t necessarily get passed on to child classes. I ran into all sorts of fun errors and problems until I remembered the Adapter implementation described here, which takes a much more sensible approach: don’t sublcass, and instead hold an internal copy of the adaptee, passing calls to anything you don’t want to override to the adaptee.

Read the rest of this entry »

Git Cheatsheet

It’s small, fast, and github is rad. So I am trying to learn it.

# Setup
git config --global --list
git config --global user.name "Ken-ichi"
git config --global user.email "fortinbras@norway.net"
 
# The colors, children.  Mm-hey
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
 
# Getting Info
git remote -v # Display the remote repository URL
 
# Committing
git add .
git commit -a
 
# Pushing to another repos
# could be local like /path/to/somewhere 
# or ssh://me@there.net/path/to/repos
git push path/to/repos

GoodReads iPhone App

This may already exist in some form, but here’s an imaginary feature list:

  • adds to GoodReads library based on a photo of a bar code and/or ISBN
  • page-based annotations based on photo or entry of page #, including word-lookups, favorite words, or just random notes
  • maybe you could print out a bookmark with a barcode for a given book, and when you want to leave a note for the book your reading, you use your iPhone to scan the bar code first

I usually have a bookmark and pen by my side as I read, and I keep note of cool or unknown words, choice quotes, or whatever thoughts occur to me while reading.  I don’t think the iPhone can really serve as a replacement (too thick, too expensive), but it might make for an interesting way to enhance social reading sites like GoodReads, Shelfari, or LibraryThing.

There is a small, seasonal creek that runs through the Temescal Farmer’s market.  As far as I can tell, it runs above ground from around Frog Park, under CA-24, down to around 51st St.  It only seems to run in the summer, and kids at the market play poohsticks and splash around in it.  I have found this stream confusing for a while and have a few questions

  • where does it come from?
  • why does flow in summer?
  • is it really safe for children?

My Ubuntu Cheat Sheet

Looks like I’m maintaining an Ubuntu server these days…

Package Management

# Finding Installed Dependent Packages
apt-cache rdepends --installed packageX
 
# Installing Individual .deb Packages
sudo dpkg -i package_file.deb

Trust not to aptitude…

Sometimes aptitude does silly things, like install X11 when all you wanted was ImageMagick. Try apt-get as well to see if it doesn’t have a different set of deps (this is true of ImageMagick as of December 2008).

Someone asked this among a group of perfectly intelligent UC Berkeley staffers and no one had a good answer, so I think this is a good exscuse to start using this blog in one of the ways I originally intended it: answering my own questions.  More to come…

Answer

First of all, not all of California has a Mediterranean climate. A Mediterranean climate is one in which summers are hot and dry and winters are mild and rainy, similar to the regions bordering the Mediterranean Sea. These conditions exist in CA from about Cape Medocino south to Baja, and east to the Sierra Foothills.

Read the rest of this entry »

I’m just getting started with git.  Turns out if your git binaries are in a path specified in something like .bash_profile on your remote machine, something like git clone ssh://you.com/~you/repos.git will fail with an error like bash: git-upload-pack: command not found because sshd ignores .bash_profile, so git won’t find its binaries. So you need to alter the PATH env var in .bashrc instead. Fun.  The git-clone-pack man page is worth a look.