JSONP and Sencha Touch

I was recently trying to get a Sencha Touch demo up-and-running, but my callback functions after requests for JSON data never ran, and Firefox would throw errors along the lines of “invalid label.” I didn’t understand why–until I read more about JSONP.

JSONP prefixes your JSON response with a function name, which runs when the response is retrieved. It’s a way of handling the data without a listener.

This means that your JSONP provider needs to detect a JSONP parameter, and then wrap or “pad” the response within the specified parameter value.

For Sencha Touch, the JSON returned should be wrapped in Ext.util.JSONP.callback();. If your JSON looks like this:


then your JSONP should look like this:


Not that you should hard-code that function name anywhere in your JSON output–web-based APIs and services should pick up the function from your request and wrap the JSON for you. For example, the twitter search API accepts a callback querystring parameter.


would wrap the JSON response inside


I ignored the extra letter in the acronym at my own peril–I figured it was just a trivial variation on JSON (which it is) that wouldn’t make any difference in how it was handled (but it does).

Why I’m Not Friends with My Bank on Facebook

I received a request today from my financial institution asking me to follow them on Facebook, Twitter, Flickr, and YouTube.

Aside from the fact that I doubt that their updates on these various services will enrich my life, there is another very good reason not to follow them:


It’s easy to trace your connections online. Most of this information, for most users, is public. If you follow Bank A, it stands to reason that you have an account at Bank A–something a malicious person would not have known before. Even if your online persona isn’t directly connected to your name, you might be surprised at how easy it is to connect the two with a Google search.

(That last item says a lot, I think.)

Any bank that suggests you follow them on social media must be pretty confident of their security! Or, more likely, their marketing teams and their security teams don’t talk to each other.

You wouldn’t stand on a street-corner handing out cards that say, “My name is Bob Billiards and I have an account at Bank A” would you? Then don’t follow your bank on a social media site.

7 Ways Twitter is Like Cigarette Smoking

1. People who have never tried it don’t get it.
As far as I can tell, the naysayers have never tried Twitter. I’ve seen people complain about Twitter on Facebook, but a Facebook status update and a tweet are nearly the same: short snippets of information that you want to share.

The at-signs (@) and hashes (#) that have become ubiquitous on Twitter may be part of the problem. Although I feel that if you can decipher an emoticon you ought to be able to handle @replies and #hashtags.

The difference?
A tweet is public if your Twitter timeline is public. (A timeline is akin to your wall on Facebook.) This is probably one reason why marketers love it: they get to push links out to the world, including search engines, whereas on Facebook you actually have to work to build an audience. (More on Facebook later.)

2. It’s addictive.
Clearly, it can be. Maybe not to the same extent as nicotine, but some people can’t stay off Twitter. People complain about how many breaks smokers take. Sick of your friends leaving you alone at a party while they compose a tweet? Annoyed that they ignore you to check the latest on their Blackberries? Tired of your co-workers taking tweet breaks? Which leads to…

3. It interrupts you.
Cravings for cigarettes driving you to distraction? Twitter can drive you insane. I quickly disabled updates on my phone, because I would have exceeded my 400 monthly SMS messages in the span of a few days. I installed twhirl, and later TweetDeck, and found that I was getting notifications almost every minute. That’s no way to work. I changed my TweetDeck settings to check for updates every 40 minutes. I may find out about the latest celebrity death 10 minutes after you do, but I still have some semblance of mental focus.

4. Users love to talk about it
Smokers love to talk about smoking. What brand you smoke, the way you hold your cigarettes, whether or not you prefer hard-packs or soft-packs, whether or not you pack your cigarettes before you open them–these are the sorts of conversations people have on their smoke breaks. My friend Brady cited all the unnecessary talking about smoking as a top reason to quit smoking.

Twitterers love to talk about Twitter. People are in love with Twitter right now, and they aren’t afraid to shout it from the rooftops. Which apps they use, who they follow, how it can turn their struggling companies into a giants. Even I am guilty of this: about a quarter of my tweets reference Twitter. I imagine this may fade over time, along with the accompanying backlash. After all, remember blowthedotoutyourass.com?

5. You do it more when you’re drinking.
…and that’s not a good thing.

6. Short and unsatisfying.
Oscar Wilde wrote, “A cigarette is the perfect type of a perfect pleasure. It is exquisite, and it leaves one unsatisfied.” I’ve seen people pack a lot of info into a mere 140 characters, but sometimes 140 characters just isn’t enough. That is why more than half of the tweets I am perusing right now contain shortened links from sites like bit.ly, short.to, ff.im, and tr.im.

[I actually really dislike shortened links, because they remove a critical piece of info–the destination URL–from the link. If someone posts a link with little-to-no explanation, I will not click on it for two reasons: one, there’s no incentive, two, it could be spam or lead to a malicious web site.]

7. It’s bad for your health.
OK, I admit it: that’s a weak link. Just don’t tweet while driving, OK? But just as smokers often pass on exercise, Twitter may cause people or companies to scrimp on more important things, like phone calls, face-to-face conversations, making good products, or even updating Facebook. Time spent on Twitter is time not spent on something else.

(That’s right, I said Facebook. As I mentioned to a friend recently, if Facebook stepped on Twitter, Facebook would hardly notice. Check out Facebook vs. Twitter on Compete.com. To which should you devote more time?)

I should note that I have been tobacco-free for years and would never advocate tobacco use. On the other hand, I think with some caveats, Twitter can be fun, useful, and relatively harmless.

I decided to capitalize Twitter in this post because it is a proper noun. I’ll respect bell hooks’ preference for lowercasing, but that’s where I decided to draw the line this time; I reserve the right to be inconsistent.

Feel free to contribute your own comparisons in the comments!

Twitter Status IDs and Direct Message IDs

twitter-birdI recently created a Magic Eight Ball twitter-bot as a demo. Written in Python using the python-twitter API wrapper, it runs every 2 minutes and polls twitter for new replies (status updates containing @osric8ball) and direct messages (DMs) to osric8ball. If there are any, it replies with a random 8-Ball response.

Every status update and DM has an associated numeric ID. Initially, I stored the highest ID in a log file and used that when I polled twitter (i.e. “retrieve all replies and DMs with ID > highest ID”). However, I discovered that status updates and DMs apparently are stored in separate tables on twitter’s backend, as they have a separate set of IDs. Since the highest status ID was an order of magnitude larger than the highest DM ID, my bot completely ignored all DMs. This was not entirely obvious at first, as the IDs looked very similar, other than an extra digit: 2950029179 and 273876291.

My fix for this was to store both the highest status update ID and the highest DM ID is separate log files.

Another interesting twist: you have to be a follower of a user in order to send that user a DM. Continue reading Twitter Status IDs and Direct Message IDs

Installing Adobe AIR and Tweetdeck on an Asus eee 701

Tweetdeck is an Adobe AIR application that is a twitter client, and recently also a Facebook client.

My attempts to install Adobe AIR on the Asus eee 701 (running the default Xandros distro) were foiled several times in spite of following the instructions:

  1. Download Adobe AIR
  2. Make the AdobeAIRInstaller.bin file executable
  3. Run the .bin file as a superuser

I got a nice friendly fail message from the Adobe AIR installer every time.

I found a few relevant forum posts, e.g. Adobe Air Linux won’t install on Eee PC, that suggested memory was an issue. Sure enough, running in Full Desktop Mode with 1440×900 screen resolution (on an external display), I only had about 90MB of 500MB free.

I restarted the eee in Easy Mode and then immediately ran AdobeAirInstaller.bin. Success! (I later found these same instructions on the eee user forums.)

Installing Tweetdeck was trivial at that point: download the .air file, find it in the File Manager, and double-click it. However, when I ran it, it didn’t do anything. At one point I got a message that I was running an unknown desktop, and that Tweetdeck required Gnome or KDE.

I restarted in Full Desktop Mode, and was surprised to find a Tweetdeck icon already on the desktop. I ran it and was prompted to use KWallet, a KDE password manager. I canceled out of that, and found that Tweetdeck opened, but still didn’t do anything.

I tried again, activated the KWallet password manager, and then it worked! Tweetdeck prompted me for my twitter login, I additionally logged in to Facebook, and now I have a mean, lean, social networking machine.

Javascript textarea counter

I’ve been thinking more about the textarea counter issue that I mentioned in my previous post (“Users Paste Differently“).

First of all, I noticed that some of the textarea counter scripts date back to at least 2000, so this has been a problem that developers have been looking to solve for 8 years. I checked the HTML 5 specification and found that in HTML 5, the textarea element has a maxlength attribute. Presumably user agents will build in the most elegant solution.

But what is the current most elegant solution? Continue reading Javascript textarea counter