SSH for Snow Leopard -- don't forget to turn your agent forwarding back on, if you need it

To make a long story short, Snow Leopard ships with key forwarding disabled by default and you will have to modify the file /etc/ssh_config to get it working.

Just change the lines

# Host *
# ForwardAgent no

into

Host *
ForwardAgent yes

and you are good.

Posted

Trying to install rvm and you're getting an error "usage: dirname path"? Here's the fix

So my home directory is on my secondary volume, so it's actually at /Volumes/Secondary HD/Users/me -- unfortunately the RVM install script when you run "bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)" will output this annoying error "usage: dirname path". It's maddening. I checked the chat logs and Google didn't come up with a fix. 

Luckily I busted out my bash-fu to debug the RVM install script. Pro tip -- run bash -x scriptname.sh and it will give you the line number things fail on. I saw that it was failing on line 318. A little digging and I noticed that what was happening was since my directory name has a space, it was borking one of the commands.

So you came here for a fix right? Here's the simple fix.

  1. Use curl to download https://rvm.beginrescueend.com/install/rvm by running curl https://rvm.beginrescueend.com/install/rvm > rvm_install.sh
  2. Edit that file you just downloaded. Change line that says rvm_prefix="$(dirname $rvm_path)/" instead to say rvm_prefix="$(dirname '$rvm_path')/"
  3. Now you can run bash rvm_install.sh and it'll work on your weirdo setup with a space in your home directory.

EDIT: Oops, it looks like RVM doesn't support home directories with spaces in them at all. So, even if you do the crossed out steps above, you'll run into problems. 

According to RVM docs though, you can install as root (run sudo bash to get a root shell)  and it will install to /usr/local -- so even though that's not the recommended way to do it for dev users, this seems to be the best way to get it to work if you have a space in your home directory.

Posted

Google's 174 web fonts in one convenient downloadable tarball for your Photoshopping enjoyment

Media_httpwwwelatedco_cvghh

Google’s Font Directory and API for web fonts could have a transformative effect on how we read the web. The only problem is, Google has made it very difficult to download all of the actual font files.

Web designers must be free to experiment with these new fonts, to sketch, comp and get to know these typefaces in browser and non-browser applications. This is why I’m providing this archive. 

Download Google’s Web Fonts
38.9 MB on disk (38,869,231 bytes)*
Updated 2011-03-15

You can use it in web pages, but until I found this, I couldn't design with it. Now I can. EPIC WIN.

I found the packaging still vaguely annoying since each ttf file was in a separate directory, so I ran this on the command line (cd to the untarballed directory first):

mkdir all; find . -iname '*.ttf' -exec cp \{\} ./all \;

Then I had all the ttf files in one directory at the root (./all) and I could drag and drop that into OS X fontbook.

Posted

Node.js beginner links

This is the minimal list of links that I think you need to get up and running with node, express, and a fully functioning node site.

Node.js homepage
This is the beginning. Node.js actually runs your javascript file. It's the interpreter runtime. 

Express.js
Express gives you Sinatra-like routing. It gives you the baseline to be able to run a functioning web app.

Mongoose ORM
Mongoose gives you pretty syntax for accessing MongoDB models. It can be your data layer. 

Jade
The default HAML-like template format for express 

NPM
it's a package manager like gem or CPAN for the node universe -- install, compile, update all from one command line. 

NPM module listing
listings of useful NPM projects, super useful.


Tutorials

How to Node.org
Great up-to-date blog, thanks for the suggestion @DShankar!

Nodepad: An in-depth tutorial
How to write a full app, In 15 parts...


For Rubyists

Node JS for my tiny ruby brain
via technoweenie of github


Advanced Topics

socket.io - easy realtime long polling library

coffeescript - beautiful syntax for javascript -- you can write an entire node project in coffeescript. Worth +10,000 elegant hacker points.

Node Inspector - debugging for your server

nvm - node version manager, kind of like rvm but for node -- cleanly lets you switch between node.js interpreter versions

Filed under  //  javascript   node.js  
Posted

Netflix has a Chaos Monkey: A process to randomly kill things so as to engineer for failure

One of the first systems our engineers built in AWS is called the Chaos Monkey. The Chaos Monkey’s job is to randomly kill instances and services within our architecture. If we aren’t constantly testing our ability to succeed despite failure, then it isn’t likely to work when it matters most – in the event of an unexpected outage.

On the face of it, it seems insane. Why would you intentionally kill parts of your site? Yet in practice, being able to handle failure consistently means you are never ever surprised.

Edit: My friend Vinny Magno writes:

Automobile assembly lines started doing the same thing (I think Ford was the first, though I might be wrong).

A single line can produce multiple models back to back. So for example, a Focus may be followed by an Explorer and then an Escape. At one point, the chassis and body are aligned and welded together. Obviously welding a Focus body to an Explorer chassis would be a problem, but the automation is so good that the defect rate was incredibly low. Since such a defect happened so infrequently, operators became complacent and failed to catch it the times that it did occur. To solve the problem, Ford purposefully upped the error rate to keep the operators sharp.

Turns out there's precedence!

Posted

ActiveRecord Table Transform (or, how to write to the db 27,000 times in 24 seconds instead of 9 minutes)

I implemented my new scheme and running time went from 9 minutes to 24 SECONDS. I liked this approach so much I decided to generalize it as ActiveRecord::Base.transform. Sample usage:

# if users don't have names, give them a random one
NAMES = ['Adam', 'Ethan', 'Patrick']
User.transform(:name, :conditions => 'name is null').each do |i|
  i.name = NAMES[rand * NAMES.length]
end

Really interesting use of temp tables here.

Filed under  //  Ruby on Rails   activerecord  
Posted

Gruber's URL Regular Expression Explained

While America threw on its eating pants and combed the Thursday circulars for deals, John Gruber spent Thanksgiving preparing to unveil his regular expression for finding URLs in arbitrary text.

\b(([\w-]+://?|www[.])[^\s()]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))

Pretty dense. Let’s be that guy and break it out, /x style (ignoring white space, with comments)

\b                          #start with a word boundary
(                           #
    (                           #
        [\w-]+://?                  #protocol://, second slash optional
        |                           #OR
        www[.]                      #a literal www. 
    )                           #
    [^\s()]+                  #non-whitespace, parens or angle brackets
                                #repeated any number of times
    (?:                         # (end game)
        \([\w\d]+\)                 #handles weird parenthesis in URLs (http://example.com/blah_blah_(wikipedia))
                                    #won't handle this twice foo_(bar)_(and)_again
        |                           #OR
        (                           #
            [^[:punct:]\s]              #NOT a single punctuation or white space
            |                           #OR
            /                           #trailing slash
        )                           #
    )                           #
)                           #

Amazing writeup by Alan Storm on Gruber's autolinking regex.

Update: Gruber updated this with an even more awesome regex, with breakout explanation

Filed under  //  regular expressions  
Posted

How #newtwitter uses shbangs (#!) to let Google crawl AJAX content

If you're a Twitter user, logged-in, and have Javascript, you'll be able to see my profile here:

However, Googlebot will recognize that as a URL in the new format, and will instead request this URL:

Sensibly, Twitter want to maintain backward compatibility (and not have their indexed URLs look like junk) so they 301 redirect that URL to:

(And if you're a logged-in Twitter user, that last URL will actually redirect you back to the first one.)

seomoz.org, dependable as usual.

Filed under  //  ajax  
Posted