Archive for the ‘Uncategorized’ Category.

Beauty & code – serverless

Just ramping up on aws lambda, serverless, node – and thanks to Robert Purcea my new colleague, going thru these docs. A new standard in beautiful tutorials:

(I’m more of a reference guide person – but these are just sweet)

search by article length/features

Google knows stuff about pages, but its not exposed for users to search on.  Trying to read something in depth on a nontechie topic (parenting) results in a lot of shallow SEO-aimed pages.  Searching for longer, authored articles would probably help, or specifying print magazines, or .edu only.   Books are still much much higher quality than the highest-ranked web pages for most non-technical topics.

Test::Unit::Assert(qr/pattern/,…) seems to fail on multiline strings

Recently had to change a number of lines from

$self->assert(qr/some_pattern/, $string, $message)


$self->assert($string =~ qr/some_pattern/m, $message)

Not sure why – the $string was a multi-line XML fragment, and the pattern was a phrase containing / and . chars. May need to do some more testing to isolate the reason. Works with the change. /m should not be necessary to match against a multiline string, but failed without this switch for my particular test cases.

JAVA_HOME on linux (at least for compiling ruby-hdfs)

Posting this as the links I found for setting JAVA_HOME seemed to erroneously state to set it to the full path to the java executable. I’m not sure if there is a case where you would want to do that, but if you want to compile the ruby gem ruby-hdfs, then JAVA_HOME should be set to the directory above where the java binary is located, ie

export JAVA_HOME=/usr/lib/jvm/java-6-sun-

where the java executable is located at /usr/lib/jvm/java-6-sun- Then the install is straightforward

$ gem install ruby-hdfs
Building native extensions. This could take a while...
Successfully installed ruby-hdfs-0.1.0
1 gem installed

ruby non-intuitive multi-dimensional array assignment

All I want to do is work with an array of arrays…

ruby-1.9.2-p290 :012 > a =,[]) # here lies the problem...
=> [[], [], [], [], [], [], [], []]
ruby-1.9.2-p290 :013 > a[1].push("a")
=> ["a"]
ruby-1.9.2-p290 :014 > a
=> [["a"], ["a"], ["a"], ["a"], ["a"], ["a"], ["a"], ["a"]]

Trying again…

ruby-1.9.2-p290 :019 > a =, # This doesn't solve it
=> [[], [], [], [], [], [], [], []]
ruby-1.9.2-p290 :020 > a[1][0] = 'a'
=> "a"
ruby-1.9.2-p290 :021 > a
=> [["a"], ["a"], ["a"], ["a"], ["a"], ["a"], ["a"], ["a"]]

Argh! Perl makes this so easy…

Ok, the problem was, that the first two ways of initializing the array, were just creating 8 pointers to the SAME array

Now do it the right way:

ruby-1.9.2-p290 :031 > a = { } # NOW we have an array of different arrays
=> [[], [], [], [], [], [], [], []]
ruby-1.9.2-p290 :032 > a[1].push('a')
=> ["a"]
ruby-1.9.2-p290 :033 > a
=> [[], ["a"], [], [], [], [], [], []]

Ahh…but I miss an interpreter that always tries to ‘Do The Right Thing’

And, I wish the two versions didn’t look so identical when inspected…

The most helpful message yet

My Canon iP4300 printer is exceptionally helpful when anything goes wrong:

“Error Number : 311 Printer is in use or an error has occurred. If an error has occurred, eliminate the cause of the error.”

If an error has occurred, eliminate the cause! Why didn’t I think of that!

Oracle has broken registration form…

All I wanted was an updated copy of berkeley db…

Oracle has it, its free, but you have to register. Ok, I’ll register. The form has lots of required fields…two of which are broken select drop-downs with no options! This is embarassing for multi-million dollar company with a supposed commitment to open source, no?

Here is the culprit:

See the drop-downs for Job Title and State/Province.

Oh, and I tried the live chat. The rep told me to call the help line :
“No I can do nothing, please call one of those numbers to log and start a ticket sir”


Perl equiv to PHP’s md5(uniqid(rand(), true)

Trying to shoehorn some data from the back into the wp_connections database, I needed a perl equiv to the md5(uniqid(rand(), true) function. From some general suggestions at came up with the following snippet:

use Digest::MD5 qw (md5_hex);
use Data::Uniqid qw (suniqid uniqid luniqid );

sub gen_token {
# approx equiv to md5(uniqid(rand(), true));
return md5_hex(uniqid);

Will also need to use Scott Hurring’s to get it fully into the needed format…

activescaffold column overwrite – ugly

Perhaps this is somehow due to my config…but if it happens to me, it could happen to you:

I have a model, say table_one with a belongs_to: table_two. It happens that table_one and table_two each have a column named ‘datafile’. The two columns are intended to refer to entirely separate datafiles, and thru lack of imagination I named both the same. Now when I edit a row from table_one, it shows the associated row from table_two, and uses an identical name for the input fields for both ‘datafile’’s! record[datafile]

The result is that the datafile for table_one is wiped out on edit, as it is replaced by the blank datafile input for the associated record for table_two. Ouch!

Workaround of changing the name of the column in table_two fixes the problem.

Using activescaffold 3.0.5 for Rails 3.0

best practice for getting things – a hell of a lot of things – done

Seems to me the key is creating a language that lets you efficiently express what you need to. Well-designed dsl’s (domain specific languages) have a lot of power. But these guys are the ones that apparently know: