HardingBlog

The most recent posts to my blog. See also the Archives and the Feeds.

Putting Twitter and Jabber Back Together Again

Humpty Dumpty sat on a wall.
Humpty Dumpty had a great fall.
All the king's horses and all the king's men
Couldn't put Humpty together again.

When I began using Twitter, I entered my XMPP (Jabber) address and had my friends' updates sent straight to my instant messaging client. Those updates made me feel like Twitter was a convenient chatroom filled with updates from my best friends, and despite my initial reservations about the service, I became addicted. But my addiction was suddenly curtailed when, without announcement, the Twitter Jabber service went down and never came back up. Although started as a temporary service outage, Twitter recently announced they are suspending their Jabber service indefinitely.

In the months since the Twitter Jabber service went down, I've tried nearly every free software Twitter client, but none of them made me happy.[1] I want Twitter Jabber back. I guess I'll have to do it myself.

How to Send Twitter Updates to Your Jabber Account

The program, twidge, is a full-featured command-line Twitter client. It's a recent addition to Debian Unstable and may not be packaged for other free software operating systems. Yet it only has two dependencies -- both common -- and can be readily installed on any Unix-style operating system. After you tell it your Twitter username and password by running twidge setup, you can get a list of your recent unseen updates in the following format by running the following command:

twidge lsrecent -us
<loxosceles>           20K and going strong. #nanowrimo
<dossy>                Are Twitter spammers called Spitters?
<pleia2>               Mmmm, naps 

The -us, which is optional, makes twidge show only (u)nseen updates while (s)aving the identifier of the most recent message so you don't see it or older messages the next time you use -u.

The program, sendxmpp, is a XMPP (Jabber) client that works similar to the classic BSD mailx command. It's been around for several years and is probably in most major distributions. Even if it's not in your distribution, its only requirements are perl and the Jabber perl module, which should be easy to obtain. After you tell it your Jabber username and password by editing ~/.sendxmpp, you can send a Jabber to me by running the following command[2]:

echo "Hello, Dave." | sendxmpp dharding@jabber.org

Although I enjoy feedback from my readers, you'll get better results from this and following examples if you replace my Jabber address with yours.

After you've set up both twidge and sendxmpp, you can very simply connect them together:

twidge lsrecent -us | sendxmpp dharding@jabber.org 

When generating output, twidge automatically wraps lines so that they appear nicely formatted in a terminal. But when sent to my Jabber client, the wrapped lines look ugly, so I use twidge's -l option to generate detailed unwrapped output and then remove the details I don't want:

twidge lsrecent -usl | cut -f2,4 | sendxmpp dharding@jabber.org 

In the above command, sendxmpp sends an empty Jabber message to me even when there are no new Twitter updates. That isn't a problem for me: my Jabber client automatically ignores empty messages. But if you have problems with empty messages, I suggest you install the moreutils suite of command-line utilities and use the If Not Empty program. For example:

twidge lsrecent -usl | cut -f2,4 | ifne sendxmpp dharding@jabber.org 

The original Twitter Jabber sent updates as soon as they arrived. There's no way to duplicate that with the above command, but during the months since Twitter Jabber died, I've become used to a five-minute delay between updates, so I use my crontab to send me the most recent twitters every five minutes:

## Jabber me unseen twitters
*/5 * * * * twidge lsrecent -usl | cut -f2,4 | sendxmpp dharding@jabber.org 

(Please don't put my Jabber address in your crontab. If I start receiving all of your friends' Twitter updates, I'll be forced to block you, which I don't want to do.)

Although you'll automatically receive Twitter updates in Jabber now, you still won't be able to send them through Jabber. If that's important to you, I suggest you examine the excla.im service. It's not important to me; I just type:

twidge update "My new Twitter setup (with Jabber!): http://gnuisance.net/twitter-jabber.html" 

New Advanced Twitter Features

Passing your Twitters through a pipe before reading them creates many new opportunities. I'm excited that it lets me filter out uninteresting posts from people I otherwise find interesting. For example, my friend John LeMasney recently started Twittering every song he listens to:

<lemasney> I am listening to: Megadeth - One Thing
<lemasney> I am listening to: Megadeth - Megadeth - Paranoid
<lemasney> I am listening to: Megadeth - Never Say Die
...

I had to unsubscribe from John because his numerous minor updates hide his and my other friends' major updates, but now I can re-subscribe to John and filter out the updates I don't want to see:

twidge lsrecent -usl | cut -f2,4 | grep -v 'lemasney.*I am listening to: ' | sendxmpp dharding@jabber.org 

With a little programing, which I haven't done yet, I can even direct unimportant updates to a file that gets automatically emailed to me once a day while sendxmpp continues to send me important and uncategorized updates. This makes me happy: I not only got back a feature I've been missing, but I got a new feature too.


[1] Every graphical Twitter client I used had much the same interface -- a copy of the Twitter web interface. That isn't the only way to present micro-blogging data, and I doubt it's the best way either. Moreover, development on Twitter clients seemingly ceases after duplicating the Twitter web interface: no client I used had any significant advanced features.

[2] The Jabber message format sent by sendxmpp is not compatible with all Jabber clients, including the popular Pidgin instant messager. Pidgin, for example, silently drops any messages from sendxmpp. There's a configuration file and command line option to sendxmpp that make it send Jabber messages Pidgin can read, but, unfortunately, both are broke in the version of sendxmpp on Debian; I'll file a Debian bug report when I discover why. For now, you can edit the sendxmpp file (a perl script) and find the following line:

my $message_type                                = 'message'; # default message type 

Then replace it with the following line and save:

my $message_type                                = 'chat'; # default message type 
Posted Sat 08 Nov 2008 11:19:00 PM EST Tags: ?beth ?debian ?examples ?fs ?lemasney ?mycode
License: Verbatim copying and distribution of this entire article is permitted in any medium if this notice is preserved.
The Wireless Industry Captures Congress

You can't buy a part of the radio spectrum in the United States. You can't even lease a part of it from the government for a fixed amount of time—say 15 years. No, if you want to use the radio spectrum, you must lease part of it for an indefinite amount of time; you get to use it until the government says you can't anymore. For example, Congress recently confiscated and auctioned off spectrum belonging to serveral TV stations.

Imagine if you could only buy normal property for an indefinite amount of time. That book you just bought could be taken away tomorrow; so could your house. You'd live in perpetual fear of losing your property, and you'd probably try to persuade the government not to take it. If the government was a rational one, you'd hire the best sophists to persuade them of your need. If the government was a venal one, you'd bribe them outright. Economists call regulatory capture the idea that the people most affected by a regulation are the people who will work the hardest to influence the regulators in their favor. Congress has been captured.

Instead of blaming the wireless industry for corrupting Congress, or blaming Congress for becoming corrupted, I demand that Congress sell or lease radio spectrum with definite guarantees. Spectrum buyers should know what they can do with their property and for how long they can do it, and they should know this in advance. There is no other simple way to free Congress from bondage to the wireless industry.

Posted Thu 03 Jul 2008 09:00:00 PM EDT Tags: ?economics ?politics
License: Verbatim copying and distribution of this entire article is permitted in any medium if this notice is preserved.
Pre-Borrow This Book

While surfing Amazon.com, you discover your favorite living author will publish a new book in a couple months. At this moment, if you were me, the pressure to click the pre-order button will strain your fiscal restraint. You don't need the book in hardcover; you don't feel like spending $20 on a book that might suck; but you don't want to forget about it, and you'd really like to read the book the same week all your friends do.

You might have an alternative to the pre-order button. My local library pre-orders books itself. As soon they order the book, they enter it into their catalogue—making it available to request. I currently have the first request for By Schism Rent Asunder by David Weber (due out July 22nd) and Zoe's Tale by John Scalzi (August 19). I can forget about these books until the library calls and says they're ready. What a deal!

Other people know about this technique, but not too many. I requested Harry Potter book 4 from the library a month before it was released and there were 12 people ahead of me in the queue. Happily, the library system ordered more than 12 copies, so I got to read a copy the Tuesday after the Saturday official release.

I keep hoping that, by some fluke, the library might get a book and lend it to me before the official release date. This hasn't happened to me—yet—and even if it did, it would only be the icing on top of a very delicious cake.

Posted Tue 01 Jul 2008 11:03:00 PM EDT Tags: ?bio ?books ?scalzi ?sfbook
License: Verbatim copying and distribution of this entire article is permitted in any medium if this notice is preserved.