Random Thoughts
wrong argument type Hash (expected Data) - Merb json
I was having a heck of a time with .to_json in Merb. Turns out, it was because Merb’s to_json implementation doesn’t work the same as ActiveRecords.
In order to get it working, I had to disable the Merb one by placing the following code at the top of my init.rb file:
Merb.disable :json
Just thought I’d share. :)
How much has ModRails made in donations?
So, after totally falling in love with ModRails (Phusion Passenger) a few months back, I was looking at their “Enterprise Edition” and began wondering how much they had made so far with their free software…
Luckily, I had Ruby and Hpricot handy. I opened up IRB and ran the following code:
require 'hpricot'
require 'open-uri'
doc = Hpricot(open('http://www.modrails.com/enterprise.html'))
(doc/"tr/td").collect { |td| td.inner_html.scan('USD').empty? ? nil : td.inner_html.sub('USD ','').to_i }.compact.inject { |s,n| s + n }
To date, they have made $20,700 in donations! Not bad for two guys and some “free” software.
Setting up a remote server to access my git repository
I host all of my Git repositories on a box that has a different port than normal SSH connections use, which causes git checkouts to be a bit of a pain in the butt.
So, in order to deal with this, any computer I plan on continually using for Git access, I add to the git user’s authorized_keys list. Here is the step by step I use to make it easy.
All of these commands are performed on the computer I want to grant permission to.
First, make sure I have a public ssh key.
cat .ssh/id_rsa.pub
Now, lets copy that public key to the Git server.
scp -P 8888 .ssh/id_rsa.pub git@YOUR_SERVER_ADDRESS:~
Using a remote SSH command, lets append our id_rsa.pub file to the authorized keys list, and then delete the file since we won’t be using it anymore.
ssh -p 8888 git@YOUR_SERVER_ADDRESS "cat id_rsa.pub >> .ssh/authorized_keys; rm id_rsa.pub"
Test the connection to make sure we can connect without a password. Just ssh and then exit immediately if it worked.
ssh git@YOUR_SERVER_ADDRESS -p 8888
Alright, so once that works, you have permission… but it still doesn’t deal with the port problem. To do that, we will create a .ssh host in the config file.
vi .ssh/config
You want to add something that looks like this:
host myserver
hostname YOUR_SERVER_ADDRESS
user git
port 8888
Once you’ve done that, save the file and exit.
Now, you should be able to clone your git repo without any problems. No more passwords, no more long git urls. Just beautiful simplicity.
git clone myserver:commentize.git
