aku-aku: v.. To move a tall, flat bottomed object (such as a bookshelf) by swiveling it alternatively on its corners in a "walking" fashion. [After the book by Thor Heyerdahl theorising the statues of Easter Island were moved in this fashion.] source: LangMaker.com. Aku Aku also has another meaning to the islanders: a spiritual guide.
login sugar for the salted hash login generator
Posted by dav at 2006 Aug 23 10:25 PM PST
File under: Geek

After being frustrated (yet again) last week when attempting to use
the salted_login_generator in a new rails project, I have modified it
so that it works better for my needs. Since the
SaltedHashLoginGenerator wiki page seems to indicate many people are
frustrated by this package (which is very nice but has been broken
since rails 1.1.4 I think) I have gem-ified my version of the
generator and released it. In my version:

* All of the tests pass on Rails 1.1.[456].
* Example DB schema uses migrations.
* The first_name, last_name attributes have underscores.
* Includes a quick start zip of preconfigured default rails app
files.
* The README_USER_LOGIN tells you everything you need to know.

It is available at
http://akuaku.org/code/login_sugar_generator-0.9.1.gem

This was my first time looking at the internals of generators and
gems, but I think I got it mostly right. It seems to work in fresh
rails projects in my tests. It's probably brittle in terms of naming
the controllers though, so you may have to make some adjustments if
you use something other than User and Localization as your controller
names.

I realize Deirdre Saoirse Moen has taken over the salted login project
and a fixed version 1.1.2 will probably be out soon, so just consider
this a measure of temporary sanity.

Updated on September 6: Making a last minute change before releasing and running off to Burning Man for a week is never a good idea is it? Version 0.9.1 released to fix the missing last_name references. Thanks BobF!

in_place_editor_field and blank values
Posted by dav at 2006 Aug 16 12:20 AM PST
File under: Geek
Updated to add the :nil_content_replacement option

One of the nice features in Rails is the in_place_editor_field view helper which wraps script.aculo.us's Ajax.InPlaceEditor and displays your model attributes in a nice ajaxy editor. However a major problem with it is that when the attribute is blank the editor effectively disappears and you are not able to set a value for it through the browser.

This seemed like a common problem but I wasn't able to find a nice solution to it after 20 minutes of googling. There were some kludgy fixes that required poor interface design on the web page, adding special handling code to my models [shudder], or else hacking the script.aculo.us code. What I wanted was for blank values to be replaced with a series of blank spaces (which would then give the user something to click on). It took a bit of poking around in the rails source, but I was able to pull it off by over-riding some of the default behavior. Here it is.

file RAILS_ROOT/lib/extensions.rb:

class Extensions

  ActionView::Helpers::JavaScriptMacrosHelper.class_eval do
    def in_place_editor_field(object, method, tag_options = {}, in_place_editor_options = {})
      tag = ::ActionView::Helpers::InstanceTag.new(object, method, self)
      tag.nil_content_replacement = in_place_editor_options[:nil_content_replacement] || 'Unknown'
      tag_options = {:tag => "span", :id => "#{object}_#{method}_#{tag.object.id}_in_place_editor", :class => "in_place_editor_field"}.merge!(tag_options)
      in_place_editor_options[:url] = in_place_editor_options[:url] || url_for({ :action => "set_#{object}_#{method}", :id => tag.object.id })
      tag.to_content_tag(tag_options.delete(:tag), tag_options) +
      in_place_editor(tag_options[:id], in_place_editor_options)
    end
  end

  ActionView::Helpers::InstanceTag.class_eval do
    attr_writer :nil_content_replacement

    def value
      unless object.nil?
        v = object.send(@method_name)
        if @nil_content_replacement.nil?
          return v
        else
          (v.nil? || v.to_s.strip=='') ? @nil_content_replacement : v
        end
      end
    end
  end

end

And put this line at the end of RAILS_ROOT/config/environment.rb:

require 'extensions'
Why I Microwaved My Passport
Posted by dav at 2006 Aug 6 02:08 PM PST
File under: News
A few months ago I got a new passport (since I got a new name). The first thing I did was throw it in the microwave for 20 seconds. Why? Because the USA is starting to embed RFID chips in new passports, and in case mine had one, I wanted to fry it. Here's a nice article that explains why RFID in passports is a bad idea, and in fact the last line of the article recommends doing exactly what I did.

At a pair of security conferences here, researchers demonstrated that passports equipped with radio frequency identification (RFID) tags can be cloned with a laptop equipped with a $200 RFID reader and a similarly inexpensive smart card writer. In addition, they suggested that RFID tags embedded in travel documents could identify U.S. passports from a distance, possibly letting terrorists use them as a trigger for explosives.

Researchers: E-passports pose security risk | CNET News.com

AllOfMp3 GreaseMonkey script
Posted by dav at 2006 Aug 2 03:32 AM PST
File under: Geek

For some reason I couldn't get to sleep tonight. I entertained myself partly by writing my first GreaseMonkey script. It takes all of the individual MP3 links on the AllOfMp3 download page and prints them as a series of wget commands. Then you can just cut and paste the block of commands to your terminal window.

Install it here: AllOfMp3 Download Helper