Category Archives: Technology

Creating a JSON API

I was assisting someone recently in building an API for their website and it occurred to me that while the current trend is generally using XML/REST/SOAP for APIs, there is quite a bit of benefit to using plain old Javascript and JSON.  Most users won’t venture into API territory, so if your goal is to make your API accessible – and this goes double if your primary purpose is embedding content in a third party site – it’s hard to argue with Javascript.

The Phish.net API, for example, is a simple HTTP request to an endpoint that returns JSON.  If you provide a callback function name as an argument, and then pre-define that function, it will return the contents wrapped in a function call.  In short, if you define a function called “example()” that accepts JSON an array/object as an argument, then by requesting the API with a callback of “example”, the response will be returned like so:

example(json response);

The benefit, of course, is that it allows a user to embed your code easily. If you host your own callback functions, you can very easily walk a user through a data embed. For example, on Phish.net, we offer the band’s latest setlist.  So we host a callback called pnet3setlist().  Then we offer the API response.  Embedding the setlist is literally as easy as this:

<script src="http://api.phish.net/callbacks/pnet3-setlist.js" type="text/javascript"></script>
<script src="https://api.phish.net/api.json?method=pnet.shows.setlist.recent&amp;amp;callback=pnet3setlist" type="text/javascript"></script>

I’m going to dig more into this later, but the gist of this is that the API can be constructed in a way that allows novice users to interact with it in their WordPress- or Blogger-blogs with little to no modification, it allows semi-skilled users to modify it slightly and tweak it for display purposes, and it allows advanced users to control virtually all aspects. Since virtually every major web language can encode and decode JSON (Javascript, PHP, Ruby, ASP, etc), it’s a near-universal way to exchange data. It doesn’t carry the overhead or complexity of XML, nor does it have the limited scope of something like serialized PHP.

Javascript-based APIs may not be the ultimate solution to a fully interconnected web, but they’re certainly going to be one of the best and simplest methods of data exchange for the foreseeable future.

A Guide to Base Changing For Short URLs

Some time ago, I developed a VERY simple way to fake a bit.ly-style short URL. On any server that uses any form of an integer to identify an article (either in the database or the URL), on an Apache server that supports mod_rewrite, you edit your .htaccess file like so:

RewriteEngine Off
<ifmodule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^index.php$
RewriteRule . index.php [NC,L]
</ifmodule>

This essentially tells your server to redirect anything that isn’t a file or directory to index.php.

Then index.php looks like this:

$url = str_replace("/","",$_SERVER['REQUEST_URI']);
if(isset($url) && trim($url)!='') {
$id = base_convert($url,36,10);
//this is where you either query your database for a slug or build the URL
$uri = 'http://your-site-goes-here.com/path/to/article';
}
 
if($uri) {
header('HTTP/1.1 301 Moved Permanently');
header('Link: < '.$uri.">; rel=shortlink");
header('Location: '.$uri);
exit;
} else {
header("Location: http://your-site-goes-here.com/"); exit;
}

How do you get your short links? That’s easy. Just run this function:

$shorturl = base_convert($id,10,36);

However, this isn’t the most compact way to condense. Obviously, this is base36, the highest PHP can go. But what about uppercase letters? And other characters?

So I set out, for some reason, to build a better condenser.

This is the result of several hours of work, mostly wasted, on some intellectual pursuit that was more a case of simply not letting it defeat me. A few notes: I’m quite confident that given enough time, and if I cared, I could make the code cleaner and more efficient in some places. I’m also aware that on 32 bit machines, it maxes out at the integer limit. I does support signed integers though, from min to max.

$ft_str = '0123456789abcdefghijklmnopqrstuvqwxyzABCDEFGHIJKLMNOPQRSTUVQWXYZ';
# uncomment the next line if you prefer to use potentially non-URL-safe base96
# $ft_str .= '0123456789abcdefghijklmnopqrstuvqwxyzABCDEFGHIJKLMNOPQRSTUVQWXYZ_@$!#%^&*()=+\|}{][,;:~'; }

$powers = array();
for($p=0;$p&lt;=10;$p++) {
$powers[$p]=pow(strlen($ft_str),$p);
}
 
function ft_unconvert($str) {
if(substr($str,0,1)=='-') { $pfx='-'; } else { $pfx=''; }
global $ft_str,$powers;
$base = strlen($ft_str); $q=0;
$s = str_split(strrev($str)); $len = sizeof($s);
foreach($s as $k=>$v) {
$sp = strpos($ft_str,$v);
$decimal += pow($base,$k)*$sp;
}
return $pfx.$decimal;
}
 
function ft_converter($int) {
if($int > 0) { $pfx='-'; $int=abs($int); } else { $pfx=''; }
global $ft_str,$powers;
$base = strlen($ft_str); $q=0;
$p = str_split($str);
krsort($powers);
foreach($powers as $k=>$v) {
if($int>=$v) {
$timesinto = floor($int/$v);
$digit .= $ft_str{$timesinto};
$int = $int % $v;
} elseif($int>0 && $k==0) {
$digit .= $ft_str{$int};
$int = $int % $v;
}
}
return $pfx.$digit;
}
 
function ft_convert_demo($num) {
global $ft_str;
$ftc = ft_converter($num);
return "Converting ".$num." into base ".strlen($ft_str).": ".$ftc."<br />Unconverting ".$ftc." to base 10: ".ft_unconvert($ftc);
}
 
echo ft_convert_demo('50687');

Apple's Future is Exciting

Sayeth Steve Jobs:

You know, there’s a porn store for Android. Anyone can download them. You can, your kids can. That’s just not a place we want to go.

But then, there’s this:

What is that? It’s the Porn Store for iPhone, aka “The App Store.” Get real. Apples doesn’t want you to run Apps because they want full control of the revenue the iPhone generates downstream. That’s it. It’s not about privacy, it’s not about children, it’s not about anything other than corporate strategy. And I predict it WILL come back to bite Apple in the butt.

Then there’s the now infamous section of the iPhone 4.0 SDK that bans the use of non-native apps on the iPhone.  But let’s get real, shall we? As Gruber said, this is about only one thing: once the apps are portable, the device lock-in is compromised.  It’s not about multi-tasking, although, there’s probably truth in that, it’s not about new APIs, although, there’s probably truth in that too.  But it’s about corporate strategy: keep people on Apple products in the Apple ecosystem.

Let’s not forget that Adobe has built its CS5 master suite with a new feature it’s been proudly touting: the ability to compile Flash apps as iPhone binaries.  So they are the ones with egg on their face since that feature is simply pointless now.

If I were Adobe, after the peak of sales after the release of CS5, I’d announce that it’s the last Adobe suite to be released for Mac.  No more Photoshop, no more Lightroom, no more Illustrator.  Maybe even cut off Adobe Air.  You could pretty rapidly destroy the enterprise presence for Apple, as people decide if they want to keep working on Macs, given the lack of true enterprise quality tools.   It would be an interesting corporate strategy. (Update: They say nope.)

If I were Apple, I wouldn’t worry too much.  Businesses are now a small subset of Apple users, who are, more and more, college students and home users.  And those users would rather buy iWork, and maybe a few more apps Apple wasn’t producing (such as Office or Pixelmator).  No big loss, right? Or is it…?

Once Apple loses the “it’s better for graphics” thing, then it might be labelled “not for serious work.”  Microsoft runs some ads pushing a new image: Macs are okay for home use, but you need Windows to do any real work.  And then “real workers” start switching back to Windows at home.  Maybe.  But it would make for a grand corporate strategy.

It’s interesting that once again, the computing landscape is full of action.  I can’t wait to see how Apple behaves in the next few years.  It may well deliver some of the best software ever.  Then again, soon enough, I might be using Windows 8, an Android phone, and an HP Slate. Either way, the future is exciting.

I’ve Been Hacked! WP-Lytebox Sucks

Hacking WordPressThis is the third time I’ve had to spent serious time “fixing” WordPress.  Say what you will about my old “Small Axe” or “Flip” solutions, but I never had a problem.  With WordPress, I have found regular issues.

This time, I traced the problem back to wp-lytebox, and I’m ashamed to say I’ve had to fix the same problem before.  It all started when I couldn’t load the post page in the backend of firsttube.com.  Digging in, I eventually found a file called sys.php in the root of the site, and it listed the contents of my site and had a form that allowed someone to add a page, chmod a page, or delete a page.  Killer!

I found that it was defaulting to /path/to/WP/wp-includes/plugins/wp-lytebox, and sure enough, digging into that directory revealed several other fun scripts, all of which gave someone the ability to access all the files on my site.  Fun!

I found that I already had replaced this plugin before, so I decided to get rid of it altogether, this now proving it wasn’t a misconfiguration, but rather, a problem with the wp-lytebox itself.

In this process, however, I was unable to fix my issue.  Visiting /wp-admin/post-new.php still rendered only a page footer, and nothing more.

So I starting fooling around in my directories looking for files that had been modified more recently than when I did my 2.9.2 upgrade.  One of the files? My .htaccess file.

This be odd,” I thought to myself, “I’ve changed this not, methinks.

Sure enough, there was a rogue line within: RewriteCond ^/default/$ /wp-admin/includes Huh?

I dug into that folder, and the .htaccess file there was recent too? It’s contents? DefaultIndex users.php

Of course, I immediately opened users.php and found, as you might have guessed, a bunch of Russian crap. Savvy WP hackers will know, it’s not a real file, there is no users.php in the real wp-admin/includes directory.

I also found a folder that had two large files, both named core.XXXX where XXXX was a 4 digit number, and a massive 40 MB error_log.  Yikes.

I thought I had everything cleaned out, and I truly believed that the way in was wp-lytebox.  Then I found this.  And sure enough, all of the listed files were compromised.  So I nuked all the files, and replaced them all.  D’oh!

So, if you’re arriving via Google or Bing or Yahoo!, do NOT use wp-lytebox.

AT&T Suckage

AT&T’s network has improved dramatically in the last year or so.  I’ve been really happy with them lately.  So it pissed me off a little extra today when I called to get a number blocked and got this nonsense for a response: a non-English speaking person with a phone number one digit off from me continues to call and leave me long rambling voice mails, over and over and over.  So I called and asked to have the number blocked, and you know what they told me? They can’t do it.  They can’t block a number.

Except, they can. They can block the number, but only for $4.99 a month.

So I’m forced to have the phone ring endlessly or take their “recommended resolution.”  You know what that is? I can change my number.

Hey, AT&T? Unacceptable.

Dragon Dictation

Dragon Dictation for the iPhone is spectacular.  It works so well it constantly amazes me.  Even when I dictated my wife’s name – Jenn – it suggested “Jenn” as a possible alternative for “Jen.”  It frequently gets what I say right the first time, and often catches the wrong words in the tap-to-correct mode when it makes a mistake.

So I decided to sing into it and give it a run for its money.  I was singing Trey Anastasio’s “Host Across the Potomac,” whose chorus is “The time has come for desks and chairs to be elevated.”  I sang the line several times, annunciating a bit more with each line, and here are the results:

  • The time has come for desk send JS to be a little David
  • The time has come by best chance to be added day babe
  • The time has come for dad send chance to be added day again
  • The time has come for desk and chairs to be inundated

Gotta love it; four times sung, four totally different results.

The moral of the story is: Dragon is great for dictation, but not so much for transcribing singing.

First Thoughts on the iPad

Yesterday, after the Apple presentation “Come See Our Latest Creation,” geeks and bloggers worldwide took to their medium of choice to complain about the underwhelming iPad and its impending failure. I’ve seen all sorts of arguments for why this device will fail, but I’m convinced that this device is going to make them all red in the face, and soon.

The problem here, as is often the case, is that this device is not built for geeks. In truth, the iPhone isn’t either. But it’s an undeniable success, largely because it solves most of the problems people have with computing interfaces: single vs double click, right click vs left click, app install, the HFS, etc. And the iPad will be a huge success too. Let’s take a deeper look.

The biggest complaint heard round the world is the lack of multi-tasking. Let’s be straight about this: that’s a friggin’ software issue! It’s widely rumored that some sort of light multi-tasking is part of iPhone OS 4.0, we know the demo’ed iPad was running 3.2 beta. So it’s fair to expect that this could come in a future update. But if it doesn’t, it’s still fixable if Apple determines that lack thereof is a major weakness.

I’ve heard people complain about lack of Flash. I couldn’t care less about Flash. Flash is a total monkey on the shoulder of the internet. I have an iPhone, I pretty much never miss it. Every site that relies on Flash is a poorly designed site I don’t want to visit. Flash is NOT coming to iPhone OS. Here’s why, in a nutshell: there are no runtimes on the iPhone, Flash is a runtime; Apple supports only one native platform – through their own SDK; Flash is the most unstable part of OS X; and most importantly, Flash is quickly gaining the reputation of being the #1 source of vulnerabilities, which Apple does NOT want to inherit. Since it’s closed source and controlled by another company, it ain’t happening, and not only don’t I care, I bet most others don’t either. And the proof? Literally millions of sites have built iPhone specific versions of their sites. With Android and WebOS both sporting compatible Webkit-based browsers, those sites are getting to be “smartphone” type sites, but people are clearly hearing the word of the future: you can’t depend on a plugin for the core of your site.

Third largest complaint we hear is that people could just buy a laptop. Sure, you could, but the iPad is a supplement. I have a 24″ iMac and it sits in my office. I don’t always want to get up to check my email, browse Google Reader, or fool around on the web. It’s a great lightweight extension of my Mac. I don’t need a whole new desktop with a whole new library of data in iLife. I don’t want a big old laptop. With the laptop, I hold the keyboard portion, and inevitably, my kid comes up and pulls on the lid which bends back out of my way. It gets 4 hours of life if we’re lucky, so it’s always plugged in. It’s pretty hot, so it usually rests on a cushion or a laptop pillow. The iPad is light, one piece that can be aligned to my liking, and has a much better battery. It’s a near perfect supplement to my current computer, because it works as an EXTENSION of my current Mac, not in addition to.

Next up is the bezel. Yes, people are complaining about the border around the screen. Apparently, these ninnies would prefer to grip their movie player with their fingers overlapping the content. This one is too stupid to address seriously.

I’m sad to say that the biggest yammering I’ve heard around town is that “Apple fanboys will slurp this up”, as if anyone who wants one is too lovedrunk to think clearly. This arrogant tenant is especially silly given that the iPhone is pretty much an iPad nano plus a phone. If you just wanted a phone, there are much better choices than the iPhone. Flip phones last for days or weeks without a charge and certainly connect more reliably, but people wanted iPhones. Does this sentiment extend to ALL of them? I suppose the 21 million active iPhone users are all blind Apple loyalists as well?

Some people have said, based on real experience, that this is a 1.0 product, they’ll wait for the revision. But to me, this one is just ignoring history. The old computer catch 22 is “this will be outdated in 6 months.” That’s still true. The next revision will always be better. But the iPad is not a rev 1 product, it’s a rev 4 product. It’s an evolution of the iPhone. Yes, it has a new chip, but so did the 3Gs. The 3G had the first 3G antenna. Every rev has a first generation of something, but this is obviously a revision (maybe a big one, but still a point release) of existing hardware.

HDMI out? Seriously? Is there ANY “average joe” who’s going to use this? I think a TV out connector is probably fine for most that require the iPad to be a portable movie player. You have to remember that Apple doesn’t – and has no history of – catering to geeks when they can cater to the masses. The device is a device “for everyone”, and that usually means leading edge technologies are not included and geeks are disappointed.

I’ve heard quite a few people sharing how a netbook is so much cheaper, yadda yadda yadda. Puh-lease. But these are facts: virtually every netbook I’ve used is SLOW SLOW SLOW. They almost always run either XP – which is not only old and clumsy on a tiny screen, but has a sordid history of becoming slow and broken for most users, or Ubuntu, which is a total mystery to the average guy, and also has an even more complex install system. Netbooks have tiny screens and ALL of the same problems and confusions that traditional computers have had when it comes to most users. My mother still names documents with additional underscores so they move to the front of the folder list, and she has no idea where she saves anything… My Docs, Desktop, root of C, etc. I see this all the time, people can’t manage a traditional install, that’s why they need geeks. Except… they don’t with the iPhone, and they won’t with the iPad. The netbook is a joke compared to an iPad. You show me an HP Slate, I’ll show you an LG Voyager or some other would be “iPhone Killer”. Almost everyone’s response to the iPad is already an also-ran, because it will most likely be based on Windows or Linux, and it will almost certainly fail where the iPhone OS has already succeeded. I think the only hope here is that Android evolves over the next few years at this continued rapid pace.

Another complaint being tossed around is the lack of a physical keyboard. Are we seriously still addressing this? Did the lack of physical keyboard stop the iPhone from selling something like 75 million units? No. Because this device is all about touch, and the virtual keyboard is going to be just fine, just like it is on the iPhone for the vast majority of people who use it. After 20 minutes of using the iPhone keyboard, I was comfortable and much more accurate. I’m sure the iPad will be the same way. Yes, software like Pages seems odd without a keyboard. I suspect it’s more for viewing and quick editing than it is for full creation. It’s a supplementary device, not a full on computer. Non-issue.

There are definitely some legitimate complaints against the iPad.

  1. At 1024×768, the resolution, and aspect ratio, leave me wanting more. Widescreen videos will require zoom or letterboxing, which means I lose content or real estate. Boo.
  2. The name iPad is horrible. If I have an accent, iPod and iPad might sound the same.
  3. Still no wireless syncing!?
  4. No SD slot for media? The “shared directory” is a nice concept, it could show up like the camera does as mountable file storage. I hope it’s writable, but I bet it’s not. Native SD slot would have been nice.
  5. No camera. I’m not sure I really care about a camera, per se, but I certainly think the ability to video chat would have been an incredible sales point for this device.
  6. Lack of format variety. I can’t believe Apple can’t add support for AVIs and MPGs to the iPhone, iPad, AppleTV, and iTunes. Also, I don’t get why Apple doesn’t just add FLAC support to iTunes.

The biggest and most valid complaint is that once again, we’re locked into the arbitrary and closed App Store. This is, by far and away, the most legitimate complaint. But, we live in a capitalist world, and the best of breed will succeed. People are generally okay with this. Once again, the masses have accepted something less than stellar. People will jailbreak their iPad the same way we’ve jailbroken our iPhones, and once again, we’ll be a small group in a large pool of users. This practice by Apple is horrible, and I predict it will eventually lead to a Microsoft IE style lawsuit that requires Apple to open up not just the App Store, but maybe even the iTunes Store as a whole to competition (meaning a separate store on the device that can manage apps, or another way to get apps on the phone without going through Apple).

That said, I’ll likely be getting an iPad at some point. It’s a fantastic complement to the big iMac in another room, an extension of my data, and a great surfing device. The 16GB is plenty for me now (The 64 GB would cover my entire MP3 and iPhoto libraries, but not with enough growth space, so the 128 may be the magic point for me), but I’ll probably want the 3G just so the device isn’t confined to my living room 100% of the time.

This is all my opinion. No question about that. But some of it is steeped in fact. Geeks looking for a geek friendly device were bound to be let down. Those suggesting that the iPad can’t meet someone’s needs unless they are drinking the Apple Kool-Aid are high on their own pompousness. And those who don’t want one, well.. they’re entitled to their own opinion and can pass on this device. But those who suggest this is going to be a failure… check back with me in 18 months. My money is that I’ll be the one saying “Toldja so.”

Rethinking Robocop

Yesterday, during commercial breaks of the Saints/Vikings NFC championship game, I was flipping over to watch bits of Robocop 2. When I was younger, I remember my friends would gather to watch Robocop and were very excited when the sequel was announced. Watching it now, however, I see how bad that movie was. Or was it?

It struck me how old the entire thing felt, and how silly the technology was. It got me thinking about a franchise reboot, and then it got me thinking about what Robocop would be today, if he were re-envisioned.

The first thing I noticed is that Robocop is slow and deliberate, and when his “joints” move, they produce a hydraulic buzzing sound. So we’ll need him to be smoother in movement, and without announcing his presence. He’ll need to be significantly lighter on his feet than the slow and heavy-stepping original.

The original sported an eye plate, that stretched only a centimeter or so in height and a few inches in wrap. That will need to change to be supplemented by smaller cameras that can give Robocop a 360 degree view of his surroundings.

Since Robocop was severely damaged after being caught in a magnet, we’ll need a better metal. I propose new Robocop be constructed of a smarter, so-called “space age” metal such as titanium, vanadium, tungsten, or magnesium.

The original Robocop recorded interaction on an in-body video camera, presumably storing it digitally, which was pretty pretty commonplace for the 1987. New Robocop will not only record interaction to a bank of flash memory or some sort of SSD array, but he will be equipped with Wifi and some sort of cellular connection like LTE or WiMax (he’ll be in a big city, so we can presume coverage). He will transmit all of his data periodically, so he won’t need to store terabytes of memory in-body.

New Robocop will not have exposed skin (or internal mechanics). Period. That’s weakness.

Original Robocop stored his gun in his leg. This is an outdated concept based on a concept that looked cool in the 80′s. Today’s Robocop will store multiple weapons throughout his body, small rubber-bullet-like projectiles perhaps in his forearm. We can equip his chest or fingers with mace or tear gas. If he requires an actual gun, it will be not be trigger deployed. It will be activated only when connected to Robocop, and very likely controlled via WifiDirect or Bluetooth. There’s simply no good reason to rely on old fashion triggers that can be exploited. In the event of system malfunction, a manual weapon will be present, but since Robocop shouldn’t be relying on his gun most of the time, he will have a nightstick of some sort.

New Robocop should not have an over-synthesized voice.

One of the constant flaws we saw in Robocop 2, as they attempted to build a second Robocop, was the lack of control they had over the machine. We fix this by running the Robocop program on a Linux-based system and jailing/chrooting it. New Robocop can do what he wants, but if he gets out of hand, we still have control. We allow remote SSH logins from authorized IPs, and sudo up to root guaranteeing ourselves a remote shutdown option. No sloppy infrared remote control here, just pure IP access.

Once Robocop is a computer, we’ll need a few more accommodations, because that becomes the chief point of vulnerability. We’ll need pretty sophisticated software here to prevent someone from hacking into Robocop, but that’s of course the plot of the movie, I’d suggest: someone hacks into Robocop remotely and alters the programming, and despite Robocop’s knowledge that he’s been compromised, he’s unable to prevent his own actions since he’s jailed into a subdirectory. The twist at the end, I’d suppose, is that some hot-shot teenage hacker finds an exploit and jailbreaks Robocop remotely, thereby giving Robocop the ability to control himself, at which point, he pretends to be following orders, but instead, tracks down the guy controlling him.  Right before his death, the guy should shout something cliche like “But… I’m your masterrrrrrrrrrrrrr….!

One of the unaddressed issues I saw with the robotic cops in the movie was the perpetual need for a lubricant like oil. It seems submersion in water would simply short out all of these solutions. So I’ll reiterate the lack of exposed skin and mechanics, and we’ll spend some time making our Robocop water resistant and reuse some sort of internally stored WD-40-like fluid, which is also “green.”   It would be a shame to build a billion dollar robocop only to have him quashed by a bucket of water.

I’d like to see Robocop be a little less terrifying to the average citizen.  Robocop ought to represent something, and cops are supposed to be there to protect and serve the average citizen, not just to get the bad guys.   So Robocop ought not be stomping around the police station and calling people “punk,” nor should he be be marching into an arcade, smarmily offering “Isn’t today a school day?” Nein, Robocop should be there for citizens, first and foremost.  We’ll disable his sarcasm and “witty quip” programs.   Robocop should offer an air of protection, not a fear he’ll malfunction.

Lastly, if I’m going to invest a billion into a Robocop, I think I might put him in something a touch nicer than an old, banged up Ford Taurus.

Javascript Ninja!

Thank you, John Resig. Because of you, I’m learning about Javascript the way Andy Gadiel taught me HTML. In the days before server-side scripting, I learned my first bits of HTML largely by viewing the source of Andy Gadiel’s Phish page (which, for some reason, remains largely unchanged since ~1997).  By reading Gadiel’s HTML, I slowly pieced together my own understanding of HTML.  It was Joe Burns’ fantastic Javascript Goodies that first had me dipping my n00b fingers into client side active scripting.  I picked up CSS all over the web.

Resig’s jQuery is so powerful and so easy that even with basic knowledge of CSS and Javascript, anyone can be a virtual scripting master.  It’s so easy, that I’ve slacked on learning about javascript objects, inheritance, closures, anonymous functions, prototypes, and scores of  other Javascript staples that I should’ve long since mastered.   I just discovered John’s new web app, cleverly titled “Learning Advanced Javascript“, and so far, so good!

I wrote this myself and understand why it works, which is much more than I could say yesterday.

var ninja = {
	walk: function(steps,turn) {
		toDo = 'Walking '+steps+' steps forward, then turning '+turn;
		return this;
	  },
	star: function(action,distance) {
		toDo = toDo+' '+action+'ing star '+distance+' feet'; return this;
	  },
	then: function() {
		toDo = toDo+', then '; return this;
	},
	doIt: function() {
		log(toDo);
	}
}
ninja.walk('7','south').then().star('throw','50').doIt();

Output:

> Walking 7 steps forward, then turning south, then throwing star 50 feet

It’s clear to me – and has been for some time – that the future of the web, for better or for worse, rests heavily on the mighty shoulders of client side scripting.   Building on powerful, extensible frameworks like jQuery and MooTools, the next generation of web apps is sure to compete with the desktop.  The ability to understand how to utilize the frameworks when necessary and hack together powerful scriptlets for other purposes seems essential to success in the future web. I know I’ll be investing in “Secrets of a Javascript Ninja” just as a result of this tutorial.