Monday, January 30, 2006

The \\ command for auto-fixing typos in yubnub commands

I like the \\ command because it has a bit of a story to it. But first, what it does: it automatically corrects typos in your yubnub commands. For example, if you type \\ g paecekeepers, it will automatically convert this to "g peacekeepers" and do a Google search for peacekeepers.

The challenge was laid down by kore7 yesterday:

Wondering whether we couldn't use Google to create a universal spell check command as well. When an unrecognized word is submitted to Google, it usually returns with "Did you mean: X?", where X is almost always what you meant to type. I'm envisioning a YubNub prefix command called "?"...

This seemed pretty hard to me, so I just gave some encouragement but didn't think it would be done, at least not anytime soon:

Heh - that's an interesting idea. Perhaps the first step is to create a command called respell that returns the google-fixed spelling of a given word. Once that's in place, it would be trivial to create the ? command.

The indefatigable Eliazar rose to the challenge and actually made an attempt:

I managed to scrape Google's spelling suggestion consistently with a command I created, sp1. Now I want to work with this result but I'm not able to pipe this command...

An hour and a half later, Brian Armknecht was inspired by Eliazar's code and took it a step further:

Eliazar -- Check out the ?> command. I just built it based on your sp0 command.> I added an ifthen to return the original input if the spelling was correct. This seems to work with piping. e.g.: g {?> cmbodia}

So, much of the hard work was done; what remained was to create a single command to tie everything together and answer kore7's original challenge. And that's what Jacob Ensor did, with assistance from Anastas and myself:

Took me all day, but I've done it. I've implemented your spellcheck in this new command, check it out: \\

Checks the spelling of your input of any Yubnub command.

\\ gim cmbodia (performs a google image search for "cambodia")

Go ahead try it! AWESOME! LOL.

And it's funny how these wonderful advancements and incremental improvements build on the work of early YubNub pioneers and experimenters: Fuska's % command for positional parameters, Jeremy Hussell's suggestion of a url command, Sean O'Hagan's ambitious scrape command, Allen Ormond's handy ifthen command.

Actually I feel moved as I consider all these people striving together to advance this idea of the URL as command line.

Friday, January 27, 2006

Instant Mashups: The "mash" Command

The mash command is the inverse of the multi command mentioned earlier. Instead of applying several words to a single command, it applies several commands to a single word. In other words, you can create instant mashups.

So for example, you can mash up Google Images, Yahoo Images, and Flickr: mash porsche gim yim flk

Or see how various dictionaries compare: mash antidisestablishmentarianism dic thes a encarta

Here's a combination of Google Maps and Amazon: mash honolulu gmaps am

The "multi" command: Run several searches simultaneously

multi is an interesting YubNub command. You can use it to run several Google searches simultaneously -- for example, multi gim porsche ferrari lamborghini bmw.

Or the same thing in Yahoo: multi yim porsche ferrari lamborghini bmw.

You can look up 5 dictionary definitions at the same time: multi a blog incumbent electoral insurgent hurricane

Or have lottery numbers automatically chosen for you: multi random 49 49 49 49 49 49

multi is composed of a few other commands. The ifthen and strlength commands were written by Allen Ormond. The % command (for positional parameters) was done by Fuska. And the split command was done by yours truly!

Thursday, January 26, 2006

YubNub 200-character URL limit (bug) fixed by Sean O'Hagan

Sean O'Hagan has snatched the pebble from the master's hand.

By examining the YubNub source code, Sean found the cause of the bug preventing URLs from exceeding 200 characters. This was proving quite problematic for the split command, which allows you to display several commands in split-screen mode (for example, gimyim porsche).

As I have said many times, it takes a village to build a command line.

Saturday, January 21, 2006

">" - the Universal I'm Feeling Lucky command

This evening, I found the following note in my inbox from Fuska:

COOL!!! elzr, I love this command
It's like a universal "I'm feeling lucky" button.

I think it deserves a Golden Egg right now

Did I say that I love it?

Fuska was raving about a new command called ">" -- not by Fuska himself but by Eliazar. I dug through my mailbox and found Eliazar's note announcing the ">" command. It's a super-cool command:

I read in a recent post about "amr" (Amazon through Google's Feeling Lucky) and thought it was a great idea. Exploring Yubnub I found a couple of other similar examples --"gww" (Wikipedia through GFL), "lfl", and "amluck" (interestingly, it does basically the same as
"amr")-- and thought that this could be an interesting pattern to exploit: using Google's Feeling Lucky as a fast, efficient and direct gateway.

Being in love with Yubnub, I thought about this in command terms and after some thinking came up with ">". I chose a symbol because I think it could become a fairly common command and because the syntax it allows is quite nice -- it makes me think of directness (->) and compression (><), which I think is appropriate. Here's how it works: (from it's man page)


URL: gfl site:{ extractDomainName { url {% 1 %s} } } {% 2- %s} [no url encoding]

> [Yubnub command] [query]

> wp Figures of speech
results: the article in the English Wikipedia about Figures of speech

> wpde Jonathan Ive
results: the article in the German (de!) Wikipedia about Jonathan Ive

> am The Future and its Enemies
results: the page in Amazon for Viginia Postrel's book The Future and its Enemies

> imdb Amelie
results: the page in the IMDB for Le Fabuleux destin d'Amélie Poulain

> cia India
results: the CIA Factbook entry for India. (And this is is a much convenient than just using "cia", since then you have to know the country two letter code.)

> cnn NYC transit workers
results: the CNN article "New Yorkers walk as transit strike ruled illegal." This brings up a subtle point: this is not be the most recent article in the topic, but rather the most important article on CNN about NYC transit workers according to Google. So ">" can be interpreted to mean: Quick! Take me to the most important page in this site related to this query.

> lj annzah
results: the LiveJournal user page of the user Annzah.

> kottke just enough
results: Kottke's post "Just enough is more"

> / Shockwave Rider
results: an article in Slashdot about Schockwave Rider

In practice, what ">" does is search a "content" website through Google for your query and send you straight to the first result. It is convenient because it builds on your knowledge of Yubnub commands and because it is often more direct.

Here's a more precise description: Yubnub generates a URL by interpreting the 1st param as a Yubnub command, it then extracts a domain name from that URL and uses it to configure a Google Feeling Lucky search for the 2nd param.


The command is far from perfect but I hope it's useful. The one think that's killing me is that it's slow! The domain extraction mini-script (man extractDomainName) is hosted on my server and that brings the total speed down. A command is as fast as it's slowest sub-command. This is a pity, Google is pretty much as fast as you can be in the web. But more importantly, being fast is the raison d'etre of this command. Suggestions please!

Oh, and this is the first Yubnub command after "man" that eats (has as a parameter) other Yubnub commands, right?

Cheers to Yubnub!


Friday, January 06, 2006

"if" command, by Samuel Hoffstaetter

Samuel Hoffstaetter obviously did a lot of work to create the new "if" command. One cool thing about it is that it builds on the landmark IfThen command created by Allen Ormond.

Anyway, here's if in all its glory:

ifthen -value1 ${lt}${gt}${le}${ge}${eq}${ne} -value2 -test EQUAL -then {ifthen -value1 %s -value2 False -test EQUAL -then ${else} -else {ifthen -value1 %s -value2 No -test EQUAL -then ${else} -else {ifthen -value1 %s -value2 0 -test EQUAL -then ${else} -else {ifthen -value1 %s -value2 -test EQUAL -then ${else} -else ${then} -redirect ${follow}} -redirect ${follow}} -redirect ${follow}} -redirect ${follow}} -else {ifthen -value1 %s -value2 ${lt}${gt}${le}${ge}${eq}${ne} -test {ifthen -value1 -value2 ${eq} -test EQUAL -then {ifthen -value1 -value2 ${gt} -test EQUAL -then {ifthen -value1 -value2 ${lt} -test EQUAL -then {ifthen -value1 -value2 ${ge} -test EQUAL -then {ifthen -value1 -value2 ${le} -test EQUAL -then NOTEQUAL -else LESSEQUAL} -else GREATEREQUAL} -else LESS} -else GREATER} -else EQUAL} -then ${then} -else ${else} -redirect ${follow}}

if - compare two values and return a value based on the result.

if [-lt|gt|le|ge|eq|ne ] [-then ] [-else ] [-follow True|False]

if 1 -lt 2 -then yes -else no
(returns "yes" since "1" is less than "2")
if -eq ${var} -then yes -else no
(returns "yes" if var is empty, "no" otherwise)
if True -then yes -else no
(returns "yes")
if False -then yes -else no
(returns "no")
if abc -eq bcd -then -else -follow True
(returns the Yahoo! webpage)

Either compares two values, or checks for the truth of a value.
All values other than "False", "No", "0" and "" are interpreted
as True.

Permitted comparisons are:
-lt (Less Than)
-gt (Greater Than)
-le (Less than or Equal)
-ge (Greater than or Equal)
-eq (EQual)
-ne (Not Equal)

When checking if a variable is empty, the variable has to
be specified behind the comparison switch:
if -eq ${var} -then yes -else no
The following WILL NOT work:
if ${var} -eq -then yes -else no

If the -follow switch is set to "True", if tries to follow links
that begin with "http://". The default setting for -follow is "False".

Samuel Hoffstaetter ""
based on "IfThen" by Allen Ormond

Wednesday, January 04, 2006

Firefox plugin for yubbing the highlighted text

Michele has written a Firefox plugin that takes the text you've highlighted in your browser and prompts you for a YubNub command to apply to it. All with a hotkey: Ctrl+Shift+K.

A bit of a bear to install (gotta hunt for the download link then, once it's downloaded, drag the xpi file into Firefox). Interesting nonetheless!

Tuesday, January 03, 2006

New RSS feed for all commands

There are now two YubNub RSS feeds: golden-egg commands, and all commands (the latter requested by Shantanu Oak).