Arithmetic in the bash shell
I prefer scripting in bash vs. Perl when at all possible. When I got comfortable with bash arithmetic operations, it made choosing bash over Perl a lot easier in some situations.
Here’s a script that uses this simple arithmetic to count the total number of Java files in a directory tree as well as the total number of lines in that same file set:
#!/bin/bash
set -u
flist=files.txt
find . -name \*.java > $flist
((totalLines=0))
((totalFiles=0))
while read aFile; do
((thisLineCount=0))
while read aLine; do
((thisLineCount=thisLineCount+1))
done < $aFile
((totalLines=totalLines+thisLineCount))
((totalFiles=totalFiles+1))
echo "$thisLineCount $aFile"
done < $flist
echo "total files: " $totalFiles
echo "total lines: " $totalLines
Bash also has “let” syntax that allows you an alternate way to signal that a variable is eligible for simple arithmetic operations (“let i=0″), but I find the equivalent double parentheses just easy to use and maybe a bit cleaner to read later.
Taglets.org public API reference implementation
We released an open source Java reference implementation for interacting with the taglets.org platform today. Java and Groovy developers, give it a whirl!
Introducing taglets.org
We are pleased to introduce the new site and service taglets.org. The service was cofounded by David Beckemeyer and I to explore tagging and tracking information on essentially any subject of which one can conceive.
The service is easy to use, with a more lengthy overview here. The short version: users create tags on objects (e.g., San Francisco BART or MUNI, your garage door sensor, iPhone development, The Genographic Project, and on and on.), then commence to post comments on those tags. Other users can “follow” that tag, which means that when comments are posted to the tag, they receive that comment in realtime via email, Twitter, or web service. By following a tag, you put yourself in the flow of information streaming from it. Anyone can post a comment to any tag, so the information on a tag accumulates and is made richer for its public accessibility.
The service is first a platform, with a reference implementation layered over it via the www.taglets.org web site, with the platform defined by a public API that developers can use to create and manage users, tags, and comments.
We thought the idea of following tags was interesting and potentially useful, and decided to implement it to see what such a service would look like. If you have feature requests or suggestions, please drop us a note at support@taglets.org.
Give it a try, and tell a friend. We think you’ll enjoy it.
Mark

Using xmllint to format xml
Long ago I used to use this utility with some frequency to pretty-print xml: xmllint, from the libxml2 project. I mention this here as much to remind myself how to use it as anything else.
$ export XMLLINT_INDENT=" "; xmllint --format foo.xml
where the environment variable XMLLINT_INDENT controls the indentation level. Two spaces are the default.
The utility is available without further ado on later versions of OS X, as well as on a number of Linux distributions, where I suspect it’s almost ubiquitous.
Configuring RESTlet’s via Spring
After help provided by my friends on the restlet.org mailing list, I successfully configured my restlet-based app via Spring. The unrelated parts of the Spring bean config have been removed for the sake of brevity.
To use this config, get a reference to the “server” bean and invoke its “start” method to start the server. The server bean has wired into it the restlet/resource routing information, so there is no need to explicitly refer or otherwise show concern for the “router” bean at the application level.
The app has a number of resources, with associated routes, all of which are easily identified.
Morse Code practice utilities and files
Jack Twilley has an excellent set of open source utilities for generating Morse code audio practice files. If you cannot put the source code to use, you can track the audio files he generates via RSS.
GWT-Restlet example app
Rob Heittman posted a simple, standalone example of integrating Restlet technology into GWT apps. See the “Examples” section toward the end of the page.
GWT-Restlet snippet
Rob Heittman was good enough to post this tidbit of what a RESTful call and callback look like using the Restlet API in Google Web Toolkit:
button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
new Client(Protocol.HTTP).put("http://localhost:8888/demo/hello.txt", "entity", new Callback() {
@Override
public void onEvent(Request request, Response response) {
try {
label.setText(response.getEntity().getText());
} catch (final Exception ioException) {
GWT.log("Restlet I/O failed", ioException);
}
}
});
}
});
You’d use this in conjunction with a server process that can handle RESTful requests. A bit more detail can be found here.
New JXTA ContentService
Mike Cumings, JXTA community member, has been busy at work writing a Content service for JXTA. In Mike’s own words:
“The ContentService is a recent addition to the JXTA (JXSE) API which allows arbitrary data (Content) to be transferred from one Peer to another. The specific mechanism/algorithms used to transfer the Content are abstracted away, allowing the developer to utilize an existing general purpose transfer mechanisms or create their own transfer implementation, all while exposing as much state information – such as the details of the transfer progress – to the API user.”
The ContentService is a great addition to the platform, making it much easier from a programmer’s perspective to move bits from one peer to another. The service is available in the platform now, at the head of the SVN trunk, and will be available in official release form with the next release of the platform.
Good stuff, Mike!
Boilerplate for Cocoa/iPhone NSURLConnection and NSXMLParser delegates
There may be an easier, more sophisticated way to do this, but here’s one way to add boilerplate code for the methods required of delegates of Cocoa or iPhone NSURLConnection and NSXMLParser. Add parser-delegates.sh and url-delegates.sh to your bin directory, then add them to your User Scripts in Xcode via “Edit User Scripts/Add Script File…”. When you need to implement these methods in a class file, place the cursor where you want the delegates, then execute the scripts via the Xcode User Script facility. The script output will be pasted into the editor at the cursor.