Archive for December, 2007

Live and Die Rock and Roll

Monday, December 31st, 2007

This is the title of a cut on the new Ray Wiley Hubbard album. “Momma cried and Daddy burned when I told them what I learned … Live and die rock and roll, it ain’t something you control.” I love music, but I’m not gonna die if I can’t play it. This is the difference between a musician and a wannabe. Ray Wiley Hubbard is a musician. I may be a musician wannabe, but I am an honest to God engineer. I want to build things and get very grumbly when I can’t. I’m always looking for a better way to do things, whether it’s a better route to somewhere, a better way to cook a dish, a more elegant solution to a bit of code, whatever. I see an oddball wheelchair and I want to know it works better than the standard design and in what ways.

“Maybe follow your bliss” is a description of parts of the path, maybe “Do what you can’t not do.”

Dutycycle

Saturday, December 29th, 2007

I do all of my programming on a laptop. This is fine for most things, but anything that hits 100% CPU or GPU load for very long pushes the temperatures up farther than I’m comfortable with. For example, compiling the kernel peaks at 73°C, over 30C° above its typical idle temperature. This laptop, an IBM ThinkPad T41, has a great keyboard, durable construction, and not enough cooling for graphics heavy games like Quake or Doom nor CPU heavy tasks like compiling the kernel or searching the entire disk for a regular expression.

I don’t compile the kernel often so I am willing to trade off longer compile times for lower temperatures. There are blunt instruments like locking the CPU clock at a very low rate, but I just want to throttle a single task, not the whole laptop. My solution is a program I call dutycycle that runs a program with a given duty cycle, e.g., 1 second on, 1 second off is a 50% duty cycle. I plan on allowing the user to specify a duty cycle between 1% and 99%, a cycle time (e.g., 1 second cycle time with a 50% duty cycle is a half second on and a half second off), and perhaps temperature thresholds (e.g. stop above 65°C, resume below 50°C). For the last feature to be feasible, there needs to be a fairly standard way to access the temperature. I haven’t looked into this aspect yet.

What makes this possible is that child/background processes can be sent the STOP and CONT signals. The former pauses the process, the latter resumes it. This behavior appears to be the POSIX standard behavior so it should work on any program. I’ve verified that it works on find. Compiling the kernel will be my acid testcase.

Once the code is in working condition and I’ve done some testing, it will become a project on SourceForge.

Firebug

Thursday, December 27th, 2007

The last few months I’ve been writing a Web application in Ruby on Rails.  At first I used the view source function of the browser when things didn’t display like I expected.  But as I’ve used more AJAX, this doesn’t work, it displays the page as originally sent, not the current contents with the changes to various sections.

Firebug is an add-on for Firefox that makes debugging easy again.  Or at least easier.  It displays the page content hierarchy with collapse/expand buttons, shows the HTTP dialog with  the Web server, etc.  Very useful.  If you write Web apps, like looking at how a Web site does something, etc., Firebug is wonderful.

Take the Horn Out of Your Mouth

Saturday, December 22nd, 2007

A story, perhaps apocraphyal, quotes John Coltrane’s response to someone commenting on his overplaying, “I have so many ideas, I don’t know how to stop.” Miles Davis’ reply was, “Take the horn out of your mouth.”

Right now I have so many programming ideas tumbling out of my head that I am hard pressed to pay attention to driving, being with my wife after work, etc. Ruby on Rails helps because it is so fluid and as I learn how to work with it, I am so productive, I can implement ideas in a fraction of the time it would have taken in PHP or any other language for Web sites I’ve tried (it’s a short list).

Creativity is like any other muscle/skill, the more you exercise it, the stronger it gets. And the stronger anything is, the more it gets used. And wants to be used.

RubyGems 1.0.0

Thursday, December 20th, 2007

The previous post told how to update to RubyGems 0.9.5. Just run “gem update --system” again, RubyGems 1.0.0 is out!

Upgrading Rails 2.0.1 to 2.0.2

Thursday, December 20th, 2007

When I initially updated to Rails 2.0, it was at 2.0.1. The update went smoothly though I had to find a source for the pieces that had been spun off into plug-ins (see previous post). Of course, shortly afterwards 2.0.2 came out, so I tried to update the same way as 2.0.1. It would get half way through and quite with the following error:

ERROR: While executing gem ...(OpenURI::HTTPError)
404 Not Found

Blame was flung about on the mailing lists about mirrors not being up to date, but I received the same error when I went to the official repository. What I missed is that you must update to Gems 0.9.5. Apparently the Gems protocol or API has changed. As root:

gem update --system
gem install rails --source http://gems.rubyonrails.org

This worked and everything runs fine.

Converting to Rails 2.0

Sunday, December 16th, 2007

Conversion of my two Rails apps didn’t take nearly as long as I expected. The announcement tells you to first move to Rails 1.2.6 and fix the deprecated features. I was at 1.2.3 and had fixed all the complaints. No more showed up at 1.2.6.

Since that was so easy, I went for the jump to 2.0. Several pieces (pagination and acts_as_tree) are now separate plugins. It took a few hours for someone to reply on where to find them (svn://errtheblog.com/svn/plugins/ and http://dev.rubyonrails.com/svn/rails/plugins/
or http://mod-i18n.googlecode.com/svn/trunk/plugins/). The actual time at the keyboard was an hour or two.

Though little bugs may still lurk. Rails 2.0 is less tolerant of slop.

  • I had a count_cache hanging around without the proper support. Rails 1.2 didn’t complain. Rails 2.0 did.
  • A URL in an RSS feed was missing, resulting in a NULL value. Again Rails 2.0 complained, Rails 1.2 didn’t. Or maybe it wasn’t missing. I fixed the code to display the link only if the URL is non-NULL. Last several times when I’ve checked. The link was present every time I’ve checked since then.

The classic_pagination is deprecated. I haven’t moved to the new package, the API is changed and I don’t want to totally break backwards compatibility (some minor munging required) . I find hints that it may be possible to selectively run different versions of Rails (e.g., “rails _1.2.6_ …” generates a Rails skeleton app using rails 1.2.6, not the latest/default version).  Haven’t figured out the details yet.  Nothing obvious pops out in preliminary  Google searches.

Rails 2.0 Announced

Sunday, December 9th, 2007

Rails 2.0 has been announced.  The changes are substantial.  Now the question for developers is how/when to move.  And how to support Rails 1.X?