Erik A. Hanson's Weblog

Archive for the 'Howto' Category

Testing File Uploads To A Rack Server

Posted: Saturday, March 28th, 2009    Tags: Howto, Ruby

I wrote a web app on top of Rack that includes the ability to accept file uploads. It took some time to figure out how to successfully test the file upload using Rack::Test.
The trick was to encode the file exactly correctly, and then post it with the correct headers. I wrote a simple post_file [...]

WordPress 2.7 Theme Development on Mac OS X 10.5 (Leopard)

Posted: Wednesday, December 17th, 2008    Tags: Howto

I wanted to create/edit a WordPress theme on my local computer, so I had to install WordPress. It wasn’t quite as straightforward as I would have hoped. Here are some instructions:
MySQL
I had already downloaded and installed MySQL, so I didn’t have to do anything. If I remember, installing MySQL was straightforward.
Apache
Apache comes pre-installed on Mac [...]

A Ruby Script To Generate a JsUnit Suite

Posted: Saturday, May 26th, 2007    Tags: Howto, Javascript, JsUnit

I’ve got a bunch of JsUnit tests for a project I’m working on and I wanted an easy way to create a JsUnit suite that can run all the tests but also run any individual test page. Also, I wanted to be able to view any test page so I could debug the tests with Firebug. I also didn’t want to run a web server all the time, so I wanted a script that would create a static HTML file.

Debugging a JsUnit Test With Firebug

Posted: Thursday, November 16th, 2006    Tags: Howto, Javascript, JsUnit

Sometimes I find that I want to debug a JsUnit test because I’m not quite sure what’s going on in the browser. FireBug has a nice debugger, but I couldn’t get it to work with the JsUnit test runner. I could set breakpoints in JsUnit itself, but any breakpoints in my test would be ignored. And then it hit me: ditch the test runner.

A Bold Prompt in Bash

Posted: Sunday, February 12th, 2006    Tags: Howto

I wanted my Bash prompt to be bold and red so I could find my one line of input amongst the million lines of output in my terminal. I’m no Unix nerd, so I don’t really know offhand where to look for this info. After a bunch of Googling, I found something that works for me.

Join Tables with Attributes in Rails

Posted: Sunday, February 12th, 2006    Tags: Howto, Ruby on Rails

I had a little trouble today with join tables that contain attributes.

Setting XSL Parameters from Javascript in AJAXSLT

Posted: Sunday, October 23rd, 2005    Tags: Howto, Javascript, XSL

Recently, I was trying to pass some info from my Javascript into my XSL stylesheet. Here’s how I finally did it.

How To Use Google’s Ajaxslt Library

Posted: Friday, September 30th, 2005    Tags: Howto, Javascript, XSL

Google has written an open-source library called Ajaxslt that implements XPath and XSLT in Javascript. It took a bit of playing to get it to work.

Writing a Ruby Test Suite that RDT and Test::Unit Can Understand

Posted: Tuesday, September 20th, 2005    Tags: Howto, Ruby on Rails

I’m working on a Ruby project using Eclipse and RDT. RDT provides a couple useful features, including support for running unit tests with Test::Unit. Unfortunately, it’s pretty primitive at the moment. One big problem is that it can’t run all your tests. So we wrote a test suite class that runs all tests and can be run from Test::Unit:.

Installing Ruby on Rails on Mac OS X 10.4 (Tiger)

Posted: Wednesday, September 7th, 2005    Tags: Howto, Ruby on Rails

I had a hell of a time getting Ruby on Rails to work on Mac OS X 10.4 (Tiger). Here’s what ended up working for me.