Commutative data types and their operations is a powerful idea.

Somewhere this fortnight I read that I should read "CRDTs: Consistency without concurrency control" <http://hal.inria.fr/inria-00397981/en/>. The basic idea is to have a data structure where for the same set of operations applied in any order will lead to the same state. If I have a number of replicants of this data structure then as long as all the operations are applied to each replicant -- in any order -- then the replicants will have the same end state. With concurrent replicants then all replicants will eventually have the same state. Commutative data types and their operations is a powerful idea.

Downgrading my iPhone to iOS 3

I finally took the steps to downgrade my iPhone 3G from iOS 4 to iOS 3. The lose of responsiveness of basic features in iOS 4 is in no way made up by the new features, especially as few of them work with the 3G hardware. I followed the directions on the Lifehacker page at How to Downgrade Your iPhone 3G[S] from iOS 4 to iOS 3.1.3.

One-liner to find all occurrences of property names within a stream of text

One-liner to find all occurrences of property names within a stream of text:

cat * | perl -ne 'while ( /\G.*?([-a-z\.]+\.enabled)/gi ) { print "$1=x\n"; }' | sort -u > /tmp/enabled

This posting is mostly to remind me that 1) print "..." while /.../ does not work and 2) to use \G to anchor the regular expression to the first and/or last match.

Having a Java generic class return a type reference to its specialized class. Aka, using the self-type.

Emulating "self types" using Java Generics to simplify fluent API implementation is a very good example of how to more effectively use Java's generics and inheritance. The "self type" solution is something I would not have imagined. Further, it is motivating to see what other effects can be achieved through Java's generics. Read the article for a compete understanding of self types and a use of them. For those wishing to skip to the conclusion, if you need a generic class instance to return a typed reference to the specialized class then it is coded

public class GenericsTest {
    // We have a generic type here that needs to return from its check method
    // a reference to the specialized type (that is, the generic's sub-class).
    static class Common<SelfType extends Common<SelfType,ElementType>,ElementType> {

        protected SelfType self() {
            return (SelfType) this;
        }

        public SelfType check( ElementType e ) {
             // do something here that is general to all sub-classes
             return self();
        }

        // ...
     }

    static class Foo extends Common<Foo,Integer> {

        public Foo doFoo() {
            // do something here is is specific to Foos
            return this;
        }
    }

    static class Bar extends Common<Bar,String> {
        public Bar doBar() {
            // do something here is is specific to Bars
            return this;
        }
    }

    public static void main( String[] args ) throws Exception {
        Foo foo = new Foo();
        Bar bar = new Bar();
        foo.check(1).doFoo();
        bar.check("a").doBar();
    }
}

// END

Tools needed to support a simple content organization and workflow

I like to use the file system. And I like to use the file system's default explorer: On the Mac this is the Finder, on Windows this is the Windows Explorer, and on Gnome it is/was Nautilus. I much prefer to have other tools integrate into the file system explorer than for the tool to have its own explorer.

When this happens, it is then possible to create your own tools that support your workflows. (Note that in this posting I am concerned with explorer integration and not command line integration.)

Unfortunately, this has not been the norm and so we have iPhoto, iTunes, etc, having there own content organization that is independent of the file system. These content specific explorers are often created due to the weaknesses in extending the system's explorer but mostly it is because creating another explorer is just easier to both imagine and code. The up-shot is that we have organizational silos with little integration between them. And, worse, the inability to create your own specialized tools from the integrations.

This Sunday I spent far too much time tracking down tools that would allow me to use the file system to collect and organize content as follows:

1. Each content collection is a folder. I am comfortable with using the file system hierarchy for organizing and I am aware of the weaknesses of hierarchical organization. However, most collections can be organized into a primary hierarchy and augmented either by search or linking (aliases on the Mac and shortcuts on Windows).

2. Each folder will have, at least, one plain text file of dated notes. Each note is separated by a simple delimiter, for example, a row of dashes. My experience is that this one file of notes is much easier to review and keep updated than to place notes into individual files. With that said, a good tool that can hide the file-ness of the notes would be acceptable too. Until then, one file of notes and using Merlin Man's tip for adding content to it <http://bit.ly/a1kfV6> will do fine.

3. The primary hierarchy needs to be supplemented with full text search. Tagging is not enough and, moreover, tagging can be achieved via search by using specialized tokens: For example, in normal English typography a colon is always followed by a space and so the expression ":foo" distinguishes the tag "foo" from the rest of the text. Spotlight on the Mac is the system's full text searching facility. It is extendable so that other content types can be incorporated. The plugin I am looking for would index the dated notes in a file as collection of "records". (This Spotlight feature was introduced in OS X 10.6.) The Spotlight plugin is the most specific tool that I need. While it is a Mac only indexing solution it is based on plain text content and so could be indexed easily under other operating systems.  Unfortunately, as far as I can tell, and I spent a good amount of time looking, there is no plugin for indexing delimited content as records. There are plugins for content types that somewhat match, for example mailboxes, but there is no documentation on how to use them outside of their intended application. The up-shot that that for this very simple workflow I can not compose a supporting tool from existing parts. Looks like I am going to have to write my own Spotlight plugin: If anyone has skeleton code I can build upon please drop me a note.

Cat & tail

I needed to count the open and close events in an active log file. Since I needed to start the count at zero I needed to start counting at the first line of the log and continue as the log grew. I needed both cat and tail -f. Turns out that tail can do both using tail -c +0 -f events.log. And so all I needed to do was to pipe the output to the counting script. The script took several minutes to catch up from processing previous events to current events but the counts it displays are accurate.

Using gnuplot to plot a time-series in text

I needed to review a sizable time-series on a remote host. Since I work at the command-line here having the plot displayed in text would be very helpful. To do this I used gnuplot. The data has the form

2010-11-06T00:00:01  35
2010-11-06T00:05:01  38
2010-11-06T00:10:02  45
2010-11-06T00:15:01  38
2010-11-06T00:20:02  38
2010-11-06T00:25:01  38
...
Note the two spaces between the data columns. The command line & script to plot this data is

gnuplot <<EOH
set terminal dumb
set autoscale
set xdata time
set timefmt "%Y-%m-%dT%H:%M:%S"
set xlabel "Date & Time"
set ylabel "Count"
set title "Requests waiting on connection"
plot "data" using 1:2 with lines
EOH

which outputs
                          Requests waiting on connection
Count
  160 ++--+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+-++
      +      +      +      +      +      +      +   "data" using 1:2 ****** +
      |                         *****                                       |
  140 ++                  ******    *                                      ++
      |                  **         *                                       |
  120 ++                 **         *                                      ++
      |                 *           *                                       |
      |               * *           *                                       |
  100 ++              * *           *                                      ++
      |               ***           *                                       |
   80 ++              ***           *                                      ++
      |            *  **            *                                       |
      |            * **             *                                       |
   60 ++           ****             *                                      ++
      | *        ******             *                                       |
   40 +***************              *      ***************************     ++
      ***                           ********                                |
      +      +      +      +      +      +      +      +      +      +      +
   20 ++--+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+--+---+-++
    00:00  02:00  04:00  06:00  08:00  10:00  12:00  14:00  16:00  18:00  20:00
                                    Date & Time
Must easier to see the trend in the data.

I found the following helpful in figuring this out http://linuxgazette.net/126/peterson.html.

Update: Use the watch command to turn the graph generation into a dynamic visualization. For example watch -n 60 bash plotting_script will run the plotting_script every minute and update the terminal.

Update: See the bash script timeplot for a useful expression of this posting.

Vi and a little macro to step through a file of data

I needed to review a large number of data in a file each of which had a variable number of lines. Luckily, each datum started with the pattern ^"http- and so using vi I was able to quickly review the data by

1) creating a macro to find the next datum and move it's line to the top of the screen

qn
/^"http-
zt
q

2) use the macro to move from datum to datum

@n

I found the following helpful in figuring this out http://www.pixelbeat.org/vim.tips.html.

If you want to change the schools RUN FOR SCHOOL COMMITTEE

Do the candidates for South Kingstown Town Council understand that the TC and the School Committee are separate municipal bodies? The TC can only make SC budget recommendations. Legally it must transfer the money requested by the SC. Re-read those letters to the editor and the full page advertisements and note how many start with school issues and not town issues. If you want to change the schools RUN FOR SCHOOL COMMITTEE.

Windows Phone 7 is worthy addition to smartphone market

A useful review of Microsoft's new Windows Phone 7 user interface. Glade to see some good news about an MS product. Generalizing on two data points -- Office's "ribbon" and now Windows Phone 7 -- it seems MS is making good usability observations and providing good solutions to, as said below, the 10- to 30-second needs.

"Nobody seems to be committing themselves to optimizing those 10- to 30-second phone experiences. Everyone is focused on building phones that you can stare at for thirty minutes. If this is truly the path Microsoft has followed, then they've made strong and brave choices."

http://www.suntimes.com/technology/ihnatko/2829294,ihnatko-windows-iphone-android-phone-102310.article

Welcome to Code City!

Why are city and municipal codes not public domain? Why, in fact, are copyrighted by private companies? It is a $10B industry.

Prototype of an Open Web App Ecosystem

Mozilla is prototyping an "open" application ecosystem. App store + installation + upgrades + payments. Nothing really new here except the "open" part. What really bothers me is that this really isn't going to help most people any time soon and, worse, when it is done it will be outdated.

http://blog.mozilla.com/blog/2010/10/19/prototype-of-an-open-web-app-ecosystem/

The premise of Open Web App that I WANT to install and application in my browser. I don't want to do this because this ties me and the application to the browser I am CURRENTLY using. I don't use one browser. I don't use one machine. Today I regularly use three machines -- one MacBook, one iPhone, and one Windows laptop -- and four browser instances -- two of FireFox, one of Safari, and one of Internet Explorer. Tomorrow I expect to be using even more machines -- iPads, Android pads, setup boxes, Wii, etc. I don't want to be tied to one machine and one browser -- even if I can choose which ones. I want to be free to sit at any browser on any machine and just use an application and my data.

What I really want is for applications and data to be separated so that I can pick which application I want to use today to surface (visualize) a data repository. More on that another day.

Jim O'Neill must not be reelected to the South Kingstown Town Council

Jim O'Neill must not be reelected to the South Kingstown Town Council. His campaign placards speak to his "Thinking Ahead", [speaking] "Truth to Power", etc. But O'Neill lacks the basic skills needed to bring synergy with others' ideas and to build coalitions that move their ideas into actions. Spend a few evenings at Council meetings and especially at joint workshops with the School Committee and you will hear the authentic O'Neill. He is belligerent. He is divisive. He is dismissive. In, short, he is a bully. O'Neill has had many terms in office to bring action on the issues he raises and yet he has not succeeded. Nor has he learned from these failures.

A new independence is needed at Town Hall. One that will work with other councilors and interested parties in moving ideas to action. Do not vote for O'Neill this November.

Please share this note with others.

New Commons office space

Digging through some old folders I found the following sketch of the New Commons office space in Providence. I really liked the ideas in this space. The hallway that connects the open offices. The french doors into the meeting space. Etc.

Safari and accessing an HTTPS site behind a web proxy

Safari, unlike FireFox and Chrome, will not let you access a web site behind a proxy server if that site has an untrusted SSL certificate. Safari will ask you to login into the proxy server and then, after some time, tell you it can't access the site. The way I found around this to to import the untrusted certificate directly into the OS X's keychain using Keychain Access. The steps I used are

1. Use FireFox to initially access the site and to accept the untrusted certificate.

2. Use FireFox's certificate manager at ForeFox / Preferences... / Advanced / Encryption / View Certificates to export the certificate. Use the PEM encoding and make sure to name the file with a ".pem" extension.

3. Use Keychain Access to import the certificate

You should now be able to access the web site from within Safari.

A Gentle Introduction to CouchDB for Relational Practitioners

"CouchDB is a document-oriented database written in Erlang that addresses a particular "sweet spot" in data storage and retrieval needs. This blog post is an introduction to CouchDB for those of us who have a relational database background."

The short introduction to CouchDB at

http://blog.couchone.com/post/1167966323/a-gentle-introduction-to-couchdb-for-relational

is a fantastic writing example. Within a few paragraphs the author has conveyed the essence of the tool and for an experience tools user/evaluator the set of next questions that must be answered before it can be put to use -- security, contention, document size boundaries, etc -- can now all be asked discerningly.

How to add commands to the OS X "right-click" menu – Simple Help

"This tutorial will show you how to use OnMyCommand to create customized "right-click" (contextual) menus in OS X. If you're a recent Windows 'switcher', you might have noticed that the right-click options lack some of the commonly used tasks (move-to, copy-to etc). OnMyCommand allows you to add these, and hundreds of other commands, back to your contextual menu."
http://www.simplehelp.net/2007/06/12/how-to-add-commands-to-the-os-x-right-click-menu/

MongoDB is Web Scale

A very funny rant on no-sql repository advocates


I too have also been in favor or using /dev/null for document storage.