Archive for the ‘Web Development’ category

Overcome Heroku’s “Permission denied publickey” problem

August 29, 2008

Heroku is awesome on paper (or screencast) but after following the directions it never worked for me. I couldn’t figure out why, and the Heroku discussion forum didn’t have any answers. But I think I’ve finally figured it out. (In the very least, I’ve finally gotten it working, which is the next best thing!)

Heroku (before today) would let me do everything except clone my remote apps to my local machine, which is more convenient, and in some cases essential (as when doing Rails apps with Hobo). Observe this:


$ heroku clone hobocookbook [/Data/Rails] [DrTeeth]
Initialized empty Git repository in /Data/Rails/hobocookbook/.git/
The authenticity of host 'heroku.com (75.101.141.116)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,75.101.141.116' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
/usr/local/lib/ruby/gems/1.8/gems/heroku-0.3/bin/../lib/heroku/command_line.rb:37:in `clone': could not clone the app. Is git installed? (RuntimeError)
from /usr/local/lib/ruby/gems/1.8/gems/heroku-0.3/bin/../lib/heroku/command_line.rb:6:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/heroku-0.3/bin/../lib/heroku/command_line.rb:6:in `execute'
from /usr/local/lib/ruby/gems/1.8/gems/heroku-0.3/bin/heroku:36
from /usr/local/bin/heroku:19:in `load'
from /usr/local/bin/heroku:19
$

If I may cut to the chase…it appears that the Heroku setup process assumes that the public key you give it will be your default or only public key, while in fact I made a key pair just for Heroku. So once I added some details to my ~/.ssh/config file:

Host heroku.com
Hostname heroku.com
Port 22
IdentitiesOnly yes
IdentityFile ~/.ssh/id_heroku
TCPKeepAlive yes
User brandon

So far as I know, this solution isn’t listed anywhere else on the web, but I found a tiphere that mentioned changing your default public key, which tipped me off as to what the problem was. (Of course now that I know the solution, I could much more effectively Google to see if anyone else has found it–one of the shortcomings of current search technology as a strategy for finding answers. The keywords you really want to use are the ones in the answer, but of course you don’t know those until you know the answer.)

Anyway, I hope this helps the legions of other people out there who would love to use Heroku but can’t because their use case was overlooked by the set up program.

Advertisements

Coding Standards for CouchDB

April 3, 2008

I’m not sure if this was intentional, but I *almost* laughed out loud:
http://incubator.apache.org/couchdb/community/standards.htmlcouchdb_coding_standards.png

Conceptual Diagram of CouchDB

April 3, 2008

CouchDB looks very cool (and shares a lot of ideas with, of all things, Lotus Notes & Domino, perhaps borrowed from there, or perhaps not), and seems to be getting off to a good start.

I noticed that they have a hand-drawn diagram on their main page. It’s sort of cool in that it carries the implication of getting things done in the most expedient way, which is often on paper. (Sometimes we feel as though we’re compromising our geek credibility if we do anything with technology from four thousand years or so ago. This is a mistake: we should use the right tool for the task, and paper is still outstanding in many cases.)

The yellow legal pad doesn’t really fit well visually into the site, though, and in places the handwriting is hard to read. Also, something that represents the architecture of the whole project, as opposed to a quick whiteboard diagram of an application before its first iteration, should really have a more polished look, at least in my opinion. Quick ‘n’ dirty is not the best image to portray in this case. At any rate, I thought I could whip up something that looked nicer, so I took a shot at it. I’m submitting it to them for their use if they like it.

Conceptual Diagram of CouchDB
conceptual_diagram.pdf

Hobo Cheatsheet, version 0.1

March 28, 2008

Here’s a (very! rough) Hobo cheatsheet, in PDF and HTML formats.

I’m not posting a Markdown version since it mangles source code, and is therefore only useful for natural language text.

Update: The PDF has been updated so that it’s easier to read. I accidentally put two pages of text on each page of the PDF, making it hard to read. I decided that, other than the font size, this was a good thing, so I just upped the font size and left it using a 2-page/sheet layout. Here it is.

The secret is out!

March 21, 2008

For all the millions of people reading my blog, I have a secret to share: the much-anticipated changes in Hobo, that were promised for the end of the month, are now mostly available in Hobo version 0.7.3.

Okay, okay, they didn’t really promise it, but publicly set that as a goal.

And okay, okay, it’s not really a secret—they posted it on their web site, but only in the forums, so only the dedicated few would find it.

And while you’re pinning me down with technicalities, there might not be quite a million…

Fixing iphone4r

March 12, 2008

There’s a very nice looking plugin for Rails to make it easier to develop iPhone versions of web sites and applications, called iphone4r. It is the work Nicholas Schlueter of Simpltry.com, and built on top of work done by (no surprise!) Joe Hewitt.

The only problem I’ve had with it so far is that it doesn’t work! Okay, the problem is quite small, and fairly easily fixed if you have even the slightest understanding of Rails plugins. Since the plugin fails to copy the iui directory to your /public directory, just add a line to install.rb to copy that over. When you’re done, install.rb should look like this:

require 'fileutils'
RAILS_ROOT = File.dirname(__FILE__) + "/../../../" unless defined? RAILS_ROOT
# Install hook code here
def copy_files(source_path, destination_path, directory)
  source, destination = File.join(directory, source_path), File.join(RAILS_ROOT, destination_path)
  FileUtils.mkdir(destination) unless File.exist?(destination)
  FileUtils.cp(Dir.glob(source+'/*'), destination)
end
directory = File.join(File.dirname(__FILE__), "copy_on_install")
copy_files("/script", "/script", directory)
FileUtils.chmod 0755, File.join(RAILS_ROOT, "script", "ibug"), :verbose => true
copy_files("/public/ibug", "/public/ibug", directory)
copy_files("/public/iui", "/public/iui", directory)

A Kinder, Gentler Phone Number Validation

March 12, 2008

Since the very promising phone_validation plugin from Savvica is not yet done, I threw together a validation that is both super simple for the developer and very kind to the user. I’m sick of web sites that require phone numbers (or credit cards) to be entered as numerals only. That’s just not the way we normally write phone numbers (or credit card numbers), so we shouldn’t be forced to enter them that way on a web site.

My approach allows the user to enter a number between 10 and 20 digits (to allow for longer international numbers, and for punctuation) along with hyphens, periods, parentheses, and spaces. So any of the following would be allowed:
7345551212
734-555-1212
(734) 555-1212
734.555.1212
)(73-4-5551212
etc.

Of course the last one mentioned is not something you’d expect, but it’s allowed, since I don’t bother only limiting the punctuation to specific places. I built the regex with North America and the Caribbean in mind, but allowed longer numbers to account for international differences. (I whipped this together in a very short time… if you want to request changes for internationalization, let me know exactly how your needs differ from what this provides.)

Additionally, this allows for an extension to be included in the number, in a variety of ways:
734-555-1212 x 123
734-555-1212 x. 123
734-555-1212 ex. 1235
734-555-1212 EXT. 12
734-555-1212 eXteNsion 12345
etc.

If the full word “extension” is used, the period is not allowed. The letters of the word could be scrambled, although no one is likely to do that.

  validates_format_of :home_phone, :work_phone, 
    :message => "must be a valid telephone number.",
    :with => /^[\(\)0-9\- \+\.]{10,20} *[extension\.]{0,9} *[0-9]{0,5}$/i 

The things you might want (or need) to change are the number of digits accepted (from 20 to whatever), the word for “extension” and the length of the word (currently 9), and the number of digits allowed for an extension.

If you want to disallow extensions, just change it to:

  validates_format_of :home_phone, :work_phone, 
    :message => "must be a valid telephone number.",
    :with => /^[\(\)0-9\- \+\.]{10,20}$/