I recently came up with a couple of pipeable perl one-liners. perl -pechop is a shortened form of perl -p -e chop. Here are the parts of it, explained:

  • perl – the perl executable, here for completeness. to learn about the options, type man perlrun into your terminal.
  • -p – perl assumes a loop around the program where it reads each line from the standard input and prints the output. since it’s a single character option that doesn’t take a parameter, it can be grouped with other options.
  • -e – evaluates (runs) the string that’s passed to it. the way perl’s option parser works, when an option takes data, it uses the rest of the command line parameter. so it can be shortened from perl -p -e chop to perl -pechop. This makes it short enough that typing it in often shouldn’t be a problem.
  • chop – the perl subroutine chop takes the current input and chops the last character off it. It’s handy for chopping the newline. For example pwd | perl -pechop will print the current directory to standard output. It can then be piped to the command to save the current directory to the clipboard (pbcopy on mac os x.

Another perl subroutine, chomp, removes the last character of a line but only if it’s the newline character. It’s useful when you don’t know if there’s a newline. The corresponding perl one-liner is perl -pechomp.

life is the variety of spice (life is about the variety of spice)

spice is the variety of life (spices, and things analogous to it, are what makes life interesting)

variety is the life of spice (spice may not be able to observe itself, but during the life of cumin various things happen to it)

variety is the spice of life (original)

Update 2013-11-10: I added some edge cases to show the completeness of this format.

Kris Zyp’s jsonpointer is a tool for addressing part of a JSON object, that’s designed to be both powerful and familiar. It supports any value for a key that JSON supports, yet it looks like a path from a URL or a filesystem.

A jsonpointer is the path from the root node of a JSON document to either itself or an interior node. A jsonpointer starts with a “/”. A “/” is also the simplest jsonpointer. After that, it contains one or more keys or indexes (in JavaScript an index is a key, but the JSON spec makes a distinction between keys and indexes), separated by “/” characters. To include a “/” character in a key (JSON supports this), use “~1”. To include a “~” character in a key, use “~0”.

What it lacks are relative paths and home paths (“~”). Since jsonpointer requires that it start with a “/”, this frees me to prepend anything but “/” to the start of the expression. Here are the things I can prepend:

  1. A dot (.), which makes it a relative path, like “./foo”.
  2. Two dots (..), which makes it a relative path from the parent node, like “../foo”.
  3. More than two dots (…), which will go up extra levels. “…/foo” would be analogous to “../../foo” in UNIX file paths. “../../foo” in my augmented json pointer would go to “baz” to quux in this json object: {“foo”: “not here”, “a”: {“b”: {“c”: “baz”}, “..”: {“foo”: “quux”}}} That is, instead of jumping up three levels, it would jump up two levels and interpret the second “..” as a key in a json object. Two dots go up one level, three dots go up two levels, four dots go up three levels, and so on.
  4. A tilde (~) makes it a path from the home directory.

Some examples of edge cases:

  1. the absolute path [“.”, “hello”] to access foo in {“.”: {“hello”: “foo”}} will be /./hello
  2. the relative path [“.”, hello”] to access foo in {“quux”: {“.”: {“hello”: “foo”}}} where the current path is /quux will be “././hello”.
  3. the relative path [“..”, “baz”] to access “foo” in {“quux”: {“..”: “hello”}, “baz”: “foo”} when where the current path is “/quux” where there is a “..” in the current node will be “../baz”. To access “hello” using a relative path from “/quux”, use “./..”.

I tried out hood.ie today after hearing about it a few times and I think it’s worth giving a shot, if you’re interested in rich web applications. It’s easy to install for what it does, which is set up a local node.js and couchdb environment with an admin interface. Deployment looks like it will be really easy, too.

A while back, I bought islessmore.com and put up a page.

It answers the question “is less more” with “No.”. My justification for this answer is that I think in the information age it is too hard to get a definitive answer to something, and the value of having a definitive answer to this simple question exceeds the insight to be gained from stating the paradox in this manner. The paradox is important, but there are other ways to state it.

But to give less, and the paradox, some credit, I made the site ultra-simple.


bat@bmamba.local:~ $ curl -I http://islessmore.com/
HTTP/1.1 200 OK
Date: Sat, 06 Apr 2013 02:10:22 GMT
Server: Apache/2.2
Content-Type: text/html
Via: 1.1 vhost.phx2.nearlyfreespeech.net:3128 (squid/2.7.STABLE7)

bat@bmamba.local:~ $ curl http://islessmore.com/
No.
bat@bmamba.local:~ $

Swaroop C H wrote a blog post about switching back to org-mode from using various apps, including Things.app and Evernote, which sync. He says he realized that he prefers a laptop-only workflow, and that his mobile devices don’t actually help him stay organized. If this is even close to being accurate, I want to switch to a laptop-only workflow, as I don’t appreciate the lack of presence that I get from relying on my cell phone.

I’m going to try to adopt a less stressful workflow by switching more to my laptop for organizing things. Wish me luck!