| Lightning Writing |
|
15 Jan 05 |
|
[print
link
all
] |
|
Today I'm working on an invited session for SPA2005 with Laurent Bossavit, shepherded by Rachel Davies . It is about freewriting, the session is called Lightning Writing Workshop. Freewriting consists of setting apart 5 to 10 minutes to write in one go continuously, without censoring yourself. Getting Started with Freewriting contains a brief explanation of the process, as well as some useful links on the topic. My main motivation to co-create this workshop with Laurents is to get myself restarted with freewriting, and explore one more way of writing in-depth.
I just tried a 5-minute freewriting exercise on a question Marc Evers asked me today: What does product management mean? The exercise didn't come out with a specific answer, it did turn up some hints about what I think it should be: about a long-term vision translated in a concrete fashion to day-to-day actions, where software is developed in small increments without taking a mortgage on the future. I also started writing about some situations where I succeeded or failed to collectively do effective product-management with clients and developers on one hand, and consulting clients of mine whom I am helping to deal more effectively with outsourcing on the other hand.
As I was writing this, I was thinking I haven't done much freewriting before. In fact I have, but I wasn't aware of it. I have three or four notebooks filled with notes and diagrams, written at moments when I was contemplating my work. Amongst others, it is promoted in Becoming a technical leader by Gerald Weinberg, to set a few minutes apart every day to write about what you experienced that day. I did that for a few weeks in a notebook, but found it difficult to keep it up. On the other hand, I am writing about my experiences every day in e-mail messages to my friends and sometimes a blog-entry such as this one.
One of the reasons it may be hard to write regularly, is that writing is one of those things that is always important, never urgent. Freewriting may help to get started, as it takes only five minutes to begin. Getting good at anything requires lots and lots of practice, and sometimes letting go of the critic inside you, so you can enjoy small successes and failures.
|
| Using TagCleaner in Java with JRuby
|
|
13 Jan 05 |
|
[print
link
all
] |
|
After using the TagCleaner from the
command-line with text-files, it appeared that it would be nice to be able
to use TagCleaner
in Itor too. But, I-tor is in Java, and requiring a working installation of
ruby to run i-tor would introduce yet another dependency. Adding JRuby ( a
Ruby interpreter for java, see jruby.sourceforge.net for the
project) might be easier - it would be just another .jar file in
Itor’s lib directory.
Even though JRuby (at the time of writing) has not had a release since
October 2002, it wasn’t so hard to get it to work. I first start with
running jruby from the command-line with:
java -jar ~/install/jruby/jruby-0.5.3/lib/jruby.jar
after that, you can add your own file, I tried a ‘hello world’
file hello.rb, containing just ‘puts hello jruby world’ and it
worked straight away. Running the tag-cleaner proved a bit more difficult.
First, it complained it was missing files. The documentation of JRuby
doesn’t state much about the use of paths, but apparently, it
supports command-line options ruby supports as well. I found the -I option,
for including library directories worked.
So now my command-line (with jruby invocation in a home-made shell script)
looks like this:
jruby -I/usr/lib/ruby/site_ruby/1.6 -I/usr/lib/ruby/1.6 tag-cleaner.rb aDocument.html
Now it complains it hasn’t opened the file. So first, I try the
unit-tests in tagcleanertest.rb to see if the SGML parser will run at all,
and it does. The unit tests, however, do not test opening a file (they work
by feeding the tag-cleaner with html in strings). Apparently, the function
IO.readlines doesn’t succeed in opening the file (the message is a
bit cryptic). After rewriting the code to ‘File.new(inputFile).gets
’ it appears jruby can’t find the file. If I append the full
path of ‘aDocumen.html’ it works :-) With bash, we can replace
the current path with $PWD like so:
java -jar ~/install/jruby/jruby-0.5.3/lib/jruby.jar -I/usr/lib/ruby/1.6
-I/usr/lib/ruby/site_ruby/1.6/ tag-cleaner.rb $PWD/aDocument.html
unfortunately, jruby does not support the -C command line option (to change
to a directory) like ruby does. IO.readlines (retrying after I found the
path problem) doesn’t seem to work either. File.gets does. So, after
modifying two lines, the tag-cleaner now also works in Java.
only now I find out, the JRuby distribution includes a ready-made
shell-script in the bin directory… (DOH!) that script sets the path
correctly, so the $PWD hack is obsolete. The -I’s are still
necessary.
Integrating TagCleaner with Java.
In order to integrate TagCleaner in Itor,
it seems best to rewrite the unit-tests in tagcleanertest.rb in Java, and
then integrate the implementation with JRuby. That way, we can modify the
tests to suit integration into Itor if necessary, and do the integration in
small, repeatable steps. JRuby works according to something called the BSF, which
is short for the BeanScriptingFramework, a Jakarta project. The BSF is a
standard way to call other languages from within Java.
Before I start with the unit tests, I try to get an example provided by
JRuby to run from within Eclipse. This example is, how appropriately,
called BSFExample. This example requires jruby.jar and bsf.jar (from
JRuby’s lib directory) to be on the classpath. This example works
straight away, showing a small dialog, with the dialogs’ components
accessible from a ruby command line. I couldn’t resist trying this
bit of reflection:
puts $frame.methods
And it works! showing me all methods of the Java frame, mixed in with the
methods of Ruby’s Object. Now, to get my own thing running, I dive
into the BSF’s documentation and use
the example provided on the JRuby homepage. After having evaluated a simple
expression and checking the result, it is time to run the Ruby version of
the unit tests, to see if the ruby libraries are included correctly. This
turns out a bit difficult, since there is no method on the BSFManager to
set the library path. Eventually, it works by accessing the ruby library
path from the ruby side, by adding elements to the variable $:, which turns
out to be empty by default, so JRuby only looks in the current working
directory.
This line of ruby does the trick:
$: << '/usr/lib/ruby/1.6' << '/usr/lib/ruby/site_ruby/1.6'
In order to have my ruby files in the org.cq2.spike package, I need to add
that as well:
$: << '/usr/lib/ruby/1.6' << '/usr/lib/ruby/site_ruby/1.6' << 'src/org/cq2/spike'
the ’<<’ is a shorthand notation for adding elements to
an array. For integration into the Itor package it is probably better to
include the necessary libraries in the Eclipse project, but at least we
know now how to tell JRuby where to look for files.
I don’t like the ‘eval’ and ‘exec’ functions
of BSF very much. Why would I want to specify a line number every time? I
probably missed some convenience functions, but with Eclipse it’s
easy to add my own.
Here’s the full sourcecode of running the tagcleanertest. I tricked
the BSF into loading (and executing) the tagcleaner script, by asking it to
‘require’ (include) the script. Probably missed something there
as well, but I couldn’t find it in the documentation.
The printouts show how to retrieve a String back from JRuby and print it.
Strangely, $: is not returned as an array.
public static void main(String[] args) throws BSFException {
BSFManager.registerScriptingEngine(
"ruby",
"org.jruby.javasupport.bsf.JRubyEngine",
new String[] { "rb" });
BSFManager manager = new BSFManager();
rubyEval(manager, $: << '/usr/lib/ruby/1.6' << '/usr/lib/ruby/site_ruby/1.6'
<< 'src/org/cq2/spike');
Object obj = rubyEval(manager, "$:");
System.out.println(obj.toString());
System.out.println(obj.getClass());
String expression = "require 'tagcleanertest.rb'";
exec(manager, expression);
}
private static void exec(BSFManager manager, String expression) throws BSFException {
manager.exec("ruby",
"(java)",
1,
1,expression);
}
private static Object rubyEval(BSFManager manager, String rubyExpression)
throws BSFException {
return manager.eval(
"ruby",
"(java)",
1,
1,
rubyExpression);
}
After running this, the output shows the library path, its’ class and
four running tests:
/usr/lib/ruby/1.6/usr/lib/ruby/site_ruby/1.6src/org/cq2/spike
class java.lang.String
CleanFontTagsTest#testNoStripping .
CleanFontTagsTest#testSpecialCharacters .
CleanFontTagsTest#testStripTagsOnly .
CleanFontTagsTest#testTwoAttributesPreserved .
Time: 0.803
OK (4/4 tests 4 asserts)
So, I’m fairly happy with this result. Now I can continue and
integrate the main tagcleaner with my Java code. The tests in JRuby do run
almost 80 times slower than the tests in ‘native’ ruby, that
one only takes 0.012543 seconds. But at least I get to recycle my code
instead of rewriting it and profit from within Java from well-written
parser libraries etc. in Ruby.
|
| Using the Canon Digital Rebel with linux |
|
13 Jan 05 |
|
[print
link
all
] |
|
After some nice entries on management, hiring, firing, nice photographs etc., it is time to get down to technichal detail again (yes, I have been programming today as well, maybe more about that later). So, if you don't use linux or are not in to digital photography with large RAW images, this post is not for you... See you next time ;-) From my trip to Arizona I returned with a Canon Digital Rebel digital camera, which features exchangable lenses, SLR (the viewfinder looks through the lens with a mirror) and 6.3 mega pixels :-), and everything can be automatic or adjusted by hand. One thing I like about it especially, is that it is a photo camera: no diary, not games, no "boot up splash image", no movies. A very nice camera, even though I had to return it after two days because of a mechanical failure.
Since the images are large, I have a 512 MB compact flash card with it - I prefer to buy equipment that uses simple, cheap, industry standard components (as opposed to SD cards, Sony specific memory etc.). The camera is apparently supported under linux by gpoto2, but not by the version I have installed currently (SuSe 8.2) not wishing to install extra software (which would prove to be slow, given that the camera and my laptop support usb 1.0 only) I decided to get a compact flash reader for my laptop - which proved to be industry-standard cheap: 7 Euro and 50 cents at my local computer shop.
If you read the manual (pcmcia howto) carefully, it is easy. Of course I started reading after encountering problems.
lsmod found pcmcia-core and ide-cs installed, which means pcmcia is installed, and there is an ide-hard drive attached to it. The compact flash card acts as a harddisk, which is nice. /var/log/messages.
cat /var/lib/pcmcia/stab
Socket 0: ATA/IDE Fixed Disk
0 ide ide-cs 0 hde 33 0
tells me the flash card is assigned to /dev/hde. Now I could mount it, if I had noted this line in the pcmcia howto:
A common error when using IDE drives is try to mount the wrong device file. Generally, you want to mount a partition of the device, not the entire device (i.e., /dev/hde1, not /dev/hde
instead, when doing mount -t vfat /dev/hde pcflash I got the error 'wrong fs type bla bla bla'... After having found this in the manual it works flawlessly, doing mount -t vfat /dev/hde1 pcflash as usual with systems administration stuff, it is one small letter making a big difference. It seems that it is possible to mount it automatically as well using /etc/pcmcia/ something, I'll check that out later, now I want to do something with my pictures! (view them for instance...).
eat it RAW
Charles Vermeulen asked me innocently 'can your camera do RAW images', sure it can... RAW images are, unlike JPEG images, compressed without information loss (so-called 'lossless compression'), kind of like ZIP, but with meta-data about exposure, white-balance etc. The digital rebel spits them out, together with a small thumbnail (in JPEG) so you can see what the picture is about in your browser. Since there is no standard for RAW images, each manufacturer makes them differently.
Luckily, there is dcraw by Dave Coffin, which is reportedly faster and more accurate than the software provided by Canon (I am going to check that out, but the windows software for my Digital Ixus / Elph was so buggy it was hardly usable, so I find it believable for now). Dave's code is also used in commercial packages such as Photoshop.
Compiling dcraw is easy, just follow the instruction on the homepage, and one .c file leads to one executable. Dcraw transforms the raw image into PPM, which is universally read under linux. Having GIMP (the GNU Image Manipulation Program, the open source equivalent of Photoshop) read RAW files was a bit more work. Again, basic instructions on how to use gimptool to create a plugin are on Dave's page. But, you must have installed the gimp development toolkit. SuSe provides packages for that through YAST, and after that, it is simple, although you have to run gimptool in a user's directory where you have used the GIMP before, otherwise gimptool doesn't know where to put the freshly created plugin. And then, it just works, you can choose to use 4 colour RGB (whatever that is), use the camera's white balance or not (apparently just metadata) and some other options I do not yet understand.
|
| Checking OpenOffice documents for correct spelling in your mothers' tongue
|
|
13 Jan 05 |
|
[print
link
all
] |
|
Having completed the TagCleaner, so I
could clean HTML output from OpenOffice, I noticed I still hadn’t
gotten around getting the Dutch spell-checker to work under SuSe Linux. In
complexity of configuration OpenOffice sometimes matches commercial office
suites… sigh. Documentation exists, but it is a bit hard to find, it
took me half an hour to get to it.
These are the steps (for OpenOffice 1.02):
- go to yast, and install myspell-dutch (or your own language instead of
dutch :-)). Installing the package updates your open office dictionary
configuration file (dictionary.lst) automatically.
- add the dutch dictionary (and hyphenation list if you want to) by going to
Tools->Options->Language->writing aids. Behind the
‘edit’ button on the right you can then add the dutch
dictionary. More details for this step are outlined here: distribution.openoffice.org/cdrom/Dictionaries.html
- to use the dictionary in your document, you have to change the language,
which is un-intuitively hidden behind Format->Character, where you have
to look in the Font tab, where there is a ‘language’ drop-down
list. I wonder how it ended up there… I would have expected this
feature in paragraph styles under ‘language’, which
doesn’t exist.
|
| Careful Attributions |
|
13 Jan 05 |
|
[print
link
all
] |
|
I try to give credit to my sources in this blog, when I can remember where I found something. In the last day of the new year In the post on IT Conversations I made a slip, I wrote Kay Johansen where it should have been Kay Pentecost. Sorry Kays...
Luckily, blogs are made from bytes, not concrete. I use rublog to publish my blog. It is very basic, and publishes everything from text files. So I can easily correct slip-ups like this, by correcting the blog entry and after saving the text file, change the date back to the original date. Charles Vermeulen recently told me he had bought a program for this purpose. You don't have to buy software to get this feature. Unix has the touch command which allows you to change dates. Linux distributions have it, and Mac OS/X probably as well. Under the other desktop operating system, it is included in cygwin, which provides the familiar and powerful unix command line for the OS that hasn't improved its' command line since DOS 1.0 .
touch works like this: touch -d 20041231 ITConversations.html Use -d for changing the date, and then the year, month and day and the filename after the space. Quite simple.
To prevent slip-ups with links, I have made a small program that automatically inserts hyperlinks to people I quote regularly. That way, I only have to correct mistakes once...
|
| TagCleaner, or how I got my OpenOffice documents to behave on my website
|
|
13 Jan 05 |
|
[print
link
all
] |
|
|
| Failure is not an option - if your system keeps on running...
|
|
13 Jan 05 |
|
[print
link
all
] |
|
It is nice to have Linux servers run for months on end. What is not so
nice, is that your system administration skills and policies have to match
that…
I had moved willemvandenende.com over to a new high-bandwidth server
outside my house, all was well, except there was a strange idiosyncracy,
when starting the web-server, it complained it couldn’t find a script
with a strange name (net.defaultroute~ - I couldn’t figure out what
the tilde was doing). Oh, what the … I thought, I’ll figure it
out when I have some time, the system doesn’t seem to be running any
worse…
Until the folks operating the (virtual) server boxes decided to install a
kernel patch (there was a security whole in the Linux kernel - very rare).
They were nice enough to send us and advance warning that they were going
to reboot our machine. I thought, well, not much can go wrong.
I was, of course, wrong! When rebooting the machine, it started to look for
the net.defaultroute~ (notice the tilde), and it couldn’t find it (of
course not). Now the machine couldn’t give itself a name, and was
hence unreachable.
As Murphy would have it, this happens in the busiest week of the year. And
I still don’t know how to solve the defaultroute~ thingy, so it
remains down. After a few days, I finally realized, that I have a backup
server (the one in my attic that runs all the other domains) and that I
could simply point www.willemvandenende.com to
that…
Then of course, when I woke up this morning… no network… the
ADSL modem had given up (this happens about once a year).
Lessons learned:
- Most of my system administration troubles happen in late November and
throughout December (the whole thing seems to have an MTBF (Mean Time
Between Failure) of about a year, and then everything comes at once. The
rest of the year it is just simple power failures and such.
- Having known flaws in your system administration, even if they are minor is
not an option, just as with XP style programming: it works best when there
are no known defects.
- (again) test rebooting your server, and see if all services come up again.
|
|