Welcome to Internet WorkShop

We provide consulting and custom software development services, as well as licensing of the Webglimpse search engine. We also collaborate with partners on ad-supported citizen journalism sites. Please visit our Services page for more details.

vote for Strawberry Perl

At least when requiring XML::LibXML in a Windows environment, it was much easier to get running with Strawberry Perl than with ActiveState, mainly because Strawberry Perl has libxml and libxslt included with the install. Also I like using cpan better than ppm. ppm archives for perl 5.14 do not seem complete, and ActiveState will not give you an earlier perl in the community edition.

So, while I appreciate the contributions of both maintainers, the most painless path is the one to take…and in this case that was Strawberry Perl 5.14 with a cpan install of some other required modules (XML::LibXML was already installed).

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)

to

$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.

Ctrl-Alt-Del for VirtualBox on MacOS

Ok, not a showstopper, but….running Windows in VirtualBox for MacOS, and had to press Ctrl-Alt-Del to start. There is an Alt key on my MacBookPro, but its fn-option and that didn’t work. The answer turned out to be under the VirtualBoxVM menu Machine->Insert Ctrl-Alt-Del. There might be other ways as well, but that was enough to get it going…

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-1.6.0.24/

where the java executable is located at /usr/lib/jvm/java-6-sun-1.6.0.24/bin/java. 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

hadoop fs is space-sensitive

HDFS, high density file system, is useful for big data. However, hadoop fs is not quite there as a shell replacement. Today I kept getting the message

cp: When copying multiple files, destination should be a directory.

when trying to copy multiple files to a directory using

hadoop fs -cp /path/to/files/*  /path/to/destination/directory

Finally figured out that the problem was I had two spaces between the file list and the directory path, which made hadoop not see the directory path in the command. Aaahh.

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 = Array.new(8,[]) # 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 = Array.new(8,Array.new()) # 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 = Array.new(8) { Array.new(0) } # 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…

don’t try creating gdbm file on an nfs mount

gems/gdbm-1.2/lib/gdbm.rb:256:in `initialize': Empty database (GDBMError)

error occurs when trying to use

g = GDBM.new('somefile')

on an nfs-mounted partition. GDBM works fine on normal drives, just don’t try it on nfs-mounts. Posting this as I found nothing when I googled the error message, and wasted several minutes before I realized the problem. The error message may be specific to the ruby ‘gdbm’ gem, but the rule is a general one.

Wordpress debug notes

Note: I’m not a wordpress expert, just returning to it after several years without having touched PHP – and looking for the best way to quickly understand the flow of a wordpress site using buddypress and a few other plugins. Raw notes here, will be annotated as I progress…

http://fuelyourcoding.com/simple-debugging-with-wordpress/

Clojure makes the JVM a friendly place…

Yes! Someone gets it – “It has always been an unfortunate characteristic of using classes for application domain information that it resulted in information being hidden behind class-specific micro-languages, e.g. even the seemingly harmless employee.getName() is a custom interface to data. Putting information in such classes is a problem, much like having every book being written in a different language would be a problem. You can no longer take a generic approach to information processing. This results in an explosion of needless specificity, and a dearth of reuse.”
–Rich Hickey, http://clojure.org/datatypes

Data is just data. Please, coders – free the data from all those bureaucratic OO controls on it, and just expose the rules if any, let us obey them thoughtfully our own way. It has got to be better than all these little bureaucratic fiefdoms exerting paranoiac control over their bits of data.

Ok, so it sounds good…now to finish the clojure koans, having realized that the ___ construct is just where you put your answers and not a new triple-underscore special variable. But I’m also hacking on a larger clojure app while learning the basic syntax…it really does seem promising…

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!