Archive for January, 2008

DutyCycle on SourceForge.net

Thursday, January 31st, 2008

DutyCycle is now feature complete and is a SourceForge.net project. There is a source tarball in the download section and all files are checked into version control (CVS). Today I added signal propagation so interrupting dutycycle interrupts the controlled program and switched from usleep() to nanosleep() for finer time slices.

Progress on RSpec tests

Tuesday, January 29th, 2008

The brand new tests, though few in number, on my newest Rails app work fine with RSpec 1.1.2. The older tests initially written for RSpec 1.0.8 misbehave when run as “rake spec“. However, they work fine when run with “scripts/spec spec“. I suspect some cruft left behind when upgrading.

City of Austin WiFi mesh blocks outgoing mail

Tuesday, January 29th, 2008

The City of Austin has a free WiFi mesh network around City Hall, Republic Square, and East Austin. Fine for browsing reading e-mail via IMAP or Webmail, but it blocks outgoing connections to an SMTP server on port 26. Boo. Port 25 is standard but frequently blocked. My Web & e-mail hosting company also makes the SMTP server available on port 26 to work around this.  Several other WiFi hotspots downtown do this also.

The e-mail client on the Nokia N810 is turning out to be less useful than expected.

DutyCycle options complete

Tuesday, January 29th, 2008

DutyCycle is ready for release.  It now has command line options to set the duty cycle percentage and the cycle time.  I’ve applied for a project on SourceForge.  Approval is pending.

Duty Cycle Core Functionality Complete

Thursday, January 24th, 2008

With a little help for my (e-mail list) friends, I’ve completed the core functionality of Duty Cycle.  It runs a program with an fixed on/off cycle, including any spawned children.  On my laptop kernel builds run the CPU temperature up to the mid 70Cs.  With dutycycle, the temperature peaks in the mid 50Cs, approximately half the temperature increase (and takes twice as long).  Currently it is running with a fixed 50% duty cycle (10s on/10s off).  Makes sense.

Now that the core functionality is there, all that is left is options for the dutycycle and the cycle times.

RSpec Stories and MVC

Thursday, January 24th, 2008

RSpec Stories are usually in two files: the story in natural language (e.g., English) and a Ruby file with code that implements clauses of the story. The story has a fixed structure:
Story: [title]
As [role]
I want [outcome]
So [benefit]

Scenario: [title]
Given [preconditions/assumptions]
When [action]
Then [postcondition]

There can be multiple scenarios in a story (though only one story per file) and each of the clauses in a scenario can have multiple sections starting with “And”. The first story for my shopping list app is:
Story: create a shopping list
As a cook
I want a list of needed ingredients
So I can make a meal

Scenario: Create an ingredient list
Given the list is empty
When I add several items
Then those items are in the list

Now this story makes sense at the Model (database), Controller (HTTP GET/POST requests and controller instance variables), and View (HTTP GET/POST request and rendered HTML page response) levels. The Ruby files are code fragments that implement the clauses and ends with a request for the RSpec story runner to process the natural language file. So there can be multiple Ruby files that “run” the same story file. So I have one or more Ruby files for each natural language story when the story makes sense at multiple levels of the implementation. The Model Ruby file for the above natural language story looks like this:

require File.dirname(__FILE__) + '/helper'

steps_for(:items) do
  Given("the list is empty") do
    Item.destroy_all
  end

  When("I add several items") do
    add_ingredients
  end

  Then("those items are in the list") do
    check_ingredients
  end
end

INGREDIENTS = %w(potatoes carrots stewmeat)

def add_ingredients
  INGREDIENTS.each do |i|
    Item.new(:name => i, :category_id => 1, :priority_id => 1).save!
  end
end

def check_ingredients
  INGREDIENTS.each do |i|
    Item.find_by_name(i).should_not be_nil
  end
  Item.count.should equal(INGREDIENTS.length)
end

with_steps_for :items do
  run File.dirname(__FILE__) + '/create_list', :type => RailsStory
end

Nice.

RSpec 1.1.2 and Stories

Thursday, January 24th, 2008

I am building a small Rails app to be the guinea pig for a presentation at the Texas Open Source Symposium in San Angelo in April and as a prototype for a Nokia N810 app.  It is built from scratch with Rails 2.0.2 so I expect fewer legacy problems. So far, RSpec 1.1.2 has behaved itself.  The has_many_through plug in isn’t completely Rails 2.0 compatible (Model.find_first needs to be replaced with Model.find(:first)).  The generated test code does appear to be RSpec 1.1.x compatible.

The story feature is new with RSpec 1.1.1 and 1.1.2.  It has taken peering at a lot of Websites and blogs and some experimentation to get it working.  Part of the problem is the various examples are describing a moving target so some of the information is obsolete.  And “official” documentation is still very minimal.

Nokia N810 – First Impressions

Monday, January 14th, 2008

I’ve had my Nokia N810 for 3 days now. The first things I setup were the laptop like things, e-mail, Web bookmarks, etc. It is not the idea platform for dealing with large amounts of e-mail (100-300/day). Not surprise here. I do want to use it for e-mail on short trips where I don’t need to do serious work and so don’t want to drag along the laptop, but am not willing to be totally out of touch. I have multiple e-mail accounts and am now moving all the high volume mailing lists (OpenSuSE and RubyOnRails-Talk) to one account. The laptop when on and connected to the Internet moves all accounts onto itself (with fetchmail, a very nice utility). When traveling, the laptop is off and the N810 accesses the non-high volume incoming e-mail server via IMAP. I can reply, delete, write, etc. Adequate for low volume. The stuff I don’t need to deal with immediately can wait until I am home on the laptop.

Web browsing is problematic. It requires young eyes and/or a lot of scrolling up/down and sideways. Adequate to check the weather and news headlines, but not for heavy Web surfing.

Yesterday and today I started setting up the PDA type things. The included Nokia apps are very weak but the GPE suite is adequate. For the moment I am running both my Handspring Visor (PalmOS) and the N810 in parallel. Using the N810 as a PDA requires leaving it booted up all day. The approximately 30 second boot time is too much for adding an appointment, one thing to the grocery list, a todo item, etc.

Doom has been ported to the N810. The demo runs full speed. However, I didn’t find the way to configure the keystroke shortcuts. And without a mouse, I’m not quite sure how to begin to play it. I could see playing it with a both hands on a (Bluetooth) keyboard. However, with just two thumbs, I’m dead meat. No fun.

While unpacking during our move, I plugged in some headphones and listened to an Internet radio station. The wireless access point was never more than 50 feet away. Reception was excellent with no breaks in audio.

It is going to take some time to figure where it fits. It is a mediocre very small laptop and a clumsy PDA. That is kind of what I am using it for, but I’m sure there is a better way.

Dutycycle Progress

Tuesday, January 8th, 2008

After following and then hacking tutorials on forking child processes and communicating through pipes, reading dozens of man pages on fork(), signal(), waitpid(), kill(), etc., I have a sort of working first cut. There are some limitations: fixed 10s on/10s off, only works with programs that don’t fork (i.e., doesn’t work on kernel builds – make forks at least three levels deep, probably one for each level of subdirectory), etc. The big cycle time makes it obvious in GKrellm that it is working.  It’s not done, but progress.  And forward.

Nokia N810 – Dell vs. Amazon

Tuesday, January 8th, 2008

My wife gave me a Nokia N810 Internet Tablet for Christmas.  Dell had overwhelmingly the best price, $419, and promised shipment in less than a week, December 28.  Before that date came, they postponed it to January 8.  Yesterday (January 7) they postponed it again until January 28.  I’m afraid their credibility is now shot.  I went to the Websites of various vendors that claimed to sell it.  Back in December, Amazon was only $10 under list so I didn’t go with them.  They are now $40 under list, claimed to have it in stock and to ship within 1-2 days.  So I ordered it and canceled the Dell order.  The automatic confirmation e-mail arrived announcing a Thursday ship date (2 days).  Alright!  About another hour later an e-mail arrived saying it had shipped and giving a UPS tracking number.  The UPS Website doesn’t recognize the number yet, so presumably it is sitting on Amazon’s shipping dock waiting for pickup tomorrow or the wheels are still grinding at UPS.

Businesses complain about Amazon stealing their business, but they are handing their customers to Amazon.  There isn’t hardly any business in America that is the only game in town anymore for items small enough to ship UPS/USPS/FedEx.  Amazon has never disappointed me.