I’ve had something strange occur when attempting to commit changes to a Git repository located on a flash drive. A pre-commit hook, which is a script Git runs before the git commit command does its thing, prevents me from committing files until I’ve removed whitespace characters from the ends of all the lines in the files. Cleaning out such whitespace is good practice if you’re working on a project and you submit your changes as patches; the patch mechanism has a tendency to barf on lines that contain trailing whitespace.
My problem is that not only am I not working on a project where I submit patches, some of the Rails generators create files that contain trailing whitespace (I’m looking at you, RSpec). When I found that the rake db:migrate task adds trailing whitespace to the schema.rb file, I nearly went ballistic. I’d be okay with keeping the whitespace out of my own code, because I’m just OCD enough to enjoy the exercise, but having to fix code generated by automation tools just pisses me off.
Read More »
March 21, 2009 – 11:32 am
I’ve been down with the flu and confined to the couch for the last couple of days, so what better way to pass the time than learning a new web framework and deploying it to Dreamhost? Only a brain cooked by fever would think something like this might qualify as fun, but my grey matter is pretty close to hard-boiled by now, and I can only play so much WoW before wanting to shoot myself. So I fired up Google and a text editor and started hacking away.
Read More »
The Helipad Ruby interface is now available on GitHub in addition to its original home on RubyForge.
There’s no difference at all between the two, apart from the GitHub copy bearing my name, which is GitHub’s convention for preventing collision between identically-named gems. If you wish to install the gem from GitHub instead of RubyForge, you can do the following:
> gem sources -a http://gems.github.com
> sudo gem install lonnon-Helipad
February 20, 2009 – 1:58 am
Earlier in the week I posted about making dynamic RESTful routes in Rails. At the end of the article, I mentioned that the method I was using might not work in a production environment, and after searching Agile Web Development with Rails for the word “restart,” I confirmed my suspicions. Generating routes on the fly from data runs afoul of caching, requiring the server to be restarted to pick up changes to the routing. That rules it out as a reliable way to generate pretty URLs.
To recap, I’ve already used map.resources to generate the usual http://example.com/sections/1 style of REST URL. I want to be able to route a URL like http://example.com/about to the show method of my Sections controller, as well, to improve human readability (and SEO) of the URL.
Read More »
February 18, 2009 – 6:17 pm
After generating a table of contents for a multi-document InDesign book, I tried to export the book to PDF. Adobe InDesign CS3 fell right over, presenting me with the friendly “please tell our developers what the hell you were doing that crashed our fine software” dialog.
When generating the table of contents (Layout > Table of Contents), I selected the Create PDF Bookmarks option. If I omitted the bookmarks, InDesign was able to export a PDF without any trouble, but of course, the PDF was missing the bookmarks. Because the book is nearing 100 pages, having functional bookmarks in the sidebar of Adobe Reader, as well as working hyperlinks in the table of contents, is a necessity for navigating this beast.
Read More »
February 16, 2009 – 8:02 pm
I’m slowly becoming a convert to the RESTful routing model in recent versions of Rails, largely because it builds a pile of useful named routes with a tiny amount of code. If I put map.resources :sections in my routes.db file, I instantly get sections_path, edit_section_path, and all their friends. When coding a controller, it’s a lot nicer to write redirect_to section_path than redirect_to :controller => :section, :action => show.
The only difficulty I have with default routes created by map.resources is that, in some cases, they’re ugly and show too much of the application’s internal workings. For example, the application I’m working on now has a Section model, which describes a major section heading in the site (things like About, FAQ, and Help). Instead of having weird routes like /sections/1, I want human-readable URLs like /about. They look nicer, and they’re better for SEO.
Read More »
February 11, 2009 – 3:48 pm
There’s something extraordinarily wrong about this. I just discovered, through Barry Hess’ blog, that TextMate has a blogging bundle. It hooks up to the ubiquitous XML-RPC interfaces sported by modern blogging software (Wordpress, Movable Type, Typo, what-have-you) and lets you use your text editor to create and edit weblog posts.
This is a far more comfortable interface for composing blog articles than any I’ve encountered, including the feature-rich web interface in Wordpress itself. I don’t use the embedded WYSIWIG editor widget in Wordpress, preferring to format my posts with Textile so I can just keep typing instead of trying to figure out what all the little buttons are supposed to do. TextMate does a great job with highlighting Textile, providing just enough coloring and styling to let you know that you’re doing the markup right without getting in the way of the writing.
On top of that, I’ve got the security of knowing that my prose isn’t going to disappear if the browser crashes or my network connection flakes out. Need more time to compose a lengthy article? Just save it locally, as a simple text file, and come back to it later. This is the very definition of “no muss, no fuss.”
Now to see if this bundle works as well in TextMate’s Windows cousin, e, so I can get the same great feature on my laptop that I have on the iMac at work.
UPDATE (2009-02-11 21:03): Yes, indeed, this same power exists in e. I am one happy camper.
January 8, 2009 – 2:25 pm
Spurred by my need to upload a bunch of notes from the now-defunct Stikkit to my account on Helipad, I wrote a Ruby wrapper for Helipad’s XML-over-HTTP API. The interface takes care of all the XML magic, letting you concentrate on the fun stuff: playing with your documents on Helipad.
hp = Helipad.new("lonnon@example.com",
"password")
source = File.read("cake_recipe.txt")
response = hp.create(:title => "Cake",
:tags => "recipe",
:source => source)
puts "Recipe saved" if response.saved?
The Helipad Ruby interface can be installed through rubygems:
gem install Helipad --remote
Documentation is available here:
If you’re interested in the source code and current state of development, you can find the Helipad Ruby interface over on RubyForge:
November 24, 2008 – 7:19 pm
- Grab the book nearest you. Right now.
- Turn to page 56.
- Find the fifth sentence.
- Post that sentence along with these instructions on your LJ.
- Don’t dig for your favorite book, the coolest, the most intellectual. Use the closest.
Armadillos: This witty description of the armadillo was produced by the descit environment.
Alas, the nearest book to me is Leslie Lamport’s ??LATEX User’s Guide and Reference Manual??.
October 28, 2008 – 5:05 pm
I encountered a weird web problem today when adding images to the company website. The new images I’d added wouldn’t appear on their page, and when pointing the browser directly at them, I received a 403 Forbidden error.
After insuring that the permissions and filenames were all correct, I sat down with the sysadmin to see if a second pair of eyes and a root login could find anything amiss. After spending half an hour of finding nothing in the logfile or permissions settings, we both gave up.
I returned to my desk, and on a whim, performed the following commands:
cp image-file.gif foo.gif
rm image-file.gif
mv foo.gif image-file.gif
I can’t imagine why this would have solved the problem, but it did. The implications–that something might be messed up deep within the innards of Apache or the Fedora filesystem–make me worry what other bizarre behavior I can expect from the webserver in the future.
This isn’t the first time machines have had odd behavior in my presence, which I’ve been able to dispel by performing seemingly unrelated actions. I’m obviously in the wrong business. I should pack my bags and hit the road as a traveling computer faith healer.