users_by_name = {}
users.each { |u| users_by_name[u.name] = u }
Which is of course silliness now that we know about index_by.
users_by_name = users.index_by(&:name)Slick.
writing code between lawsuit threats.
Thursday, November 20, 2008Method of the Day: index_by
Just stumbled on to this one. I can't tell you how many times I've wanted this functionality.
You have an array, but you want a hash keyed by an attribute of the items in the array. Typically, you'd do something like this:
users_by_name = {}
users.each { |u| users_by_name[u.name] = u }
Which is of course silliness now that we know about index_by.
users_by_name = users.index_by(&:name)Slick. Thursday, November 6, 2008Pushing to multiple user accounts on GitHub
Here at Avvo, we've started to use GitHub for publishing some of our internal libraries that might be useful to the programming community. Although we have a company account, it's nice to have a personal account, too. Unfortunately, github doesn't allow multiple accounts to share the same SSH key. This makes sense, because all communication with github works using the same ssh user account. From my perspective, it can get kind of annoying.
The key to being able to check code into multiple github accounts is setting up multiple ssh keys and using ssh aliases to use the correct key for the correct repo. First, I created a company-specific key:
Then I set up an SSH alias in ~/.ssh/config:
Next, I copied the id_rsa.avvo.pub key into the avvo github acccount.
Finally, when creating the clone of whichever repo I was using, I didn't use the clone path that github gave me, I translated it to use the alias I created. For example, a clone URL like
becomes
Now, when pushing to the central repository, it will pick up the id_rsa.avvo key that I tied to the avvo github account, and send the code to the right place.
Subscribe to:
Posts (Atom)
|
Who we are...
A handful of ruby on rails developers. We like ruby, rails, seo, and other developer type things. We work at avvo.com.
Other Stuff |