Shallow Thoughts : tags : twitter

Akkana's Musings on Open Source Computing and Technology, Science, and Nature.

Thu, 17 Sep 2020

Resizing Images for a Twitter Stream

[LWVNM tweet of a Vote411 image] In the LWVNM, we're promoting our new non-partisan state-wide online Voter Guide, Vote411.

I got roped into doing the Twitter side of this, using a bunch of images the communications team got from the national LWV.

The problem is, the images are square, 1500x1500 pixels. Turns out Twitter won't display square images: according to most references I found, it crops any image you tweet to 600x335 (16:9).

Read more ...

Tags: , ,
[ 14:13 Sep 17, 2020    More tech | permalink to this entry | ]

Wed, 30 Nov 2011

Bitlbee tips: hide timestamps, and share configurations

I recently set up bitlbee on a new machine. Things worked fine, mostly -- but here are a couple of tweaks that should speed things up when moving a bitlbee configuration to another machine.

Sharing configuration files

I get so tired of re-authenticating with Twitter every time I move to a new machine, disk, or distro. And it turns out you don't have to!

Your configuration is in /var/lib/bitlbee/yournick.xml, and you can copy that file to other machines and it will work just fine -- with one caveat.

Assuming you have bitlbee set up to run as a user named "bitlbee", rather than as root (the default is bitlbee), you'll need to make sure the /var/lib/bitlbee/yournick.xml file is owned by the bitlbee user. If you just copy it as root, you'll get an error like "The nick is (probably) not registered". You can fix it with chown bitlbee /var/lib/bitlbee/yournick.xml

Hiding timestamps

On the new machine, every new tweet had a timestamp added. Timestamps look like this:

<NatGeo> [20:26:24] Elusive marbled cat filmed: http://t.co/oOo3Xa81 
<OliverSacks> [20:28:09] Happy Thanksgiving week! Check out Dr. Sacks's new blog post about Gabby Giffords and what he is reading now: http://t.co/kZCTx53h 

These timestamps add clutter and make the lines too long. But googling for bitlbee timestamps only gets a lot of people who couldn't figure out how to suppress them and ended up writing scripts to hide them in various IRC clients.

Turns out bitlbee has a perfectly straightforward way to hide them. Go to your &bitlbee tab -- you know, the one that always opens first that you have to close manually every time after it finally opens the #twitter tab (I wish I could find a way to auto-close it!) and type:

set display_timestamps 'false'

That's it! Timestamps-b-gone.

You can see more bitlbee variables by typing set in the &bitlbee tab, or get help by typing help there.

Tags: ,
[ 20:13 Nov 30, 2011    More tech | permalink to this entry | ]

Tue, 05 Jul 2011

Bitlbee: How to re-authenticate with Twitter

I've been using Bitlbee for Twitter for quite a while now, and like it a lot.

But I guess Twitter recently changed something in their authentication, so I had to upgrade Bitlbee to the latest development version, 3.0.3, on each machine where I use it. Then on each machine, I got prompted to re-authenticate with Twitter -- except on one, my home desktop. There, all I saw was "Authentication failure" and "Logging out".

My normal procedure for setting up a Twitter account in Bitlbee didn't apply, because Bitlbee saw there was already an authenticated account, and didn't see any need to start over.

Here's the solution, courtesy of a helpful person on IRC: go to the Bitlbee channel where the authentication failed and type

acc 0 set password my-irc-passwd
-- substitute other account numbers for 0 as appropriate, and use the nickserv password you use for your bitlbee IRC account.

Then activate the account again:

account on
and it should contact Twitter and give you a URL to re-authenticate.

Tags: ,
[ 20:05 Jul 05, 2011    More tech | permalink to this entry | ]

Thu, 24 Mar 2011

How to use Bitlbee for Twitter

I've been using Bitlbee to follow Twitter from my IRC client (xchat) for many months now. I love it -- it's a great interface, really easy to use.

But every now and then I have to install it on a new machine, and I remember its one flaw: it has no documentation to speak of. What docs there are cover only pieces of the puzzle, and nobody covers basics like "How do I connect in the first place?"

So here's mine.

First, install bitlbee. The download page has tarballs, but if you're on Ubuntu or Debian, the easiest way is to add the bitlbee repository to your sources.list.

Once bitlbee is installed (the server should start automatically), it will run an IRC server on port 6667. So connect your IRC client to localhost/6667.

In the bitlbee server window that comes up, type this: register passwd
This will be your bitlbee password. It isn't related to your Twitter password.

Set your IRC client to identify passwd so you don't have to type the bitlbee password every time you connect.

Tell Bitlbee your Twitter account handle: account add twitter your-twitter-handle passwd
The password is just a placeholder; it doesn't have to match the one you just set up for bitlbee.

Then enable it: account on
Bitlbee should print:

<root> twitter - Logging in: Connecting
<root> twitter - Logging in: Requesting OAuth request token

Before long, you should see a new channel called twitter_, with a long URL. Paste this URL into your browser to authenticate. You'll have to log in with your Twitter handle and password.

Twitter will give you a code number. Paste this back into the Bitlbee twitter_ channel.

That should be all you need! Bitlbee should now log in to Twitter and give you statuses in a #twitter channel.

(Slightly updated from initial post to clarify the two passwords -- thanks pleia2 and wilmer.)

Tags: ,
[ 17:19 Mar 24, 2011    More tech | permalink to this entry | ]

Fri, 18 Mar 2011

Finding Twitter references to you

Twitter is a bit frustrating when you try to have conversations there. You say something, then an hour later, someone replies to you (by making a tweet that includes your Twitter @handle). If you're away from your computer, or don't happen to be watching it with an eagle eye right then -- that's it, you'll never see it again. Some Twitter programs alert you to @ references even if they're old, but many programs don't.

Wouldn't it be nice if you could be notified regularly if anyone replied to your tweets, or mentioned you?

Happily, you can. The Twitter API is fairly simple; I wrote a Python function a while back to do searches in my Twitter app "twit", based on a code snippet I originally cribbed from Gwibber. But if you take out all the user interface code from twit and use just the simple JSON code, you get a nice short app. The full script is here: twitref, but the essence of it is this:

import sys, simplejson, urllib, urllib2

def get_search_data(query):
    s = simplejson.loads(urllib2.urlopen(
            urllib2.Request("http://search.twitter.com/search.json",
                            urllib.urlencode({"q": query}))).read())
    return s

def json_search(query):
    for data in get_search_data(query)["results"]:
        yield data

if __name__ == "__main__" :
    for searchterm in sys.argv[1:] :
        print "**** Tweets containing", searchterm
        statuses = json_search(searchterm)
        for st in statuses :
            print st['created_at']
            print "<%s> %s" % (st['from_user'], st['text'])
            print ""

You can run twitref @yourname from the commandline now and then. You can even call it as a cron job and mail yourself the output, if you want to make sure you see replies. Of course, you can use it to search for other patterns too, like twitref #vss or twitref #scale9x.

You'll need the simplejson Python library, which most distros offer as a package; on Ubuntu, install python-simplejson.

It's unclear how long any of this will continue to be supported, since Twitter recently announced that they disapprove of third-party apps using their API. Oh, well ... if Twitter stops allowing outside apps, I'm not sure how interested I'll be in continuing to use it.

On the other hand, their original announcement on Google Groups seems to have been removed -- I was going to link to it here and discovered it was no longer there. So maybe Twitter is listening to the outcry and re-thinking their position.

Tags: , , ,
[ 10:53 Mar 18, 2011    More programming | permalink to this entry | ]

Tue, 18 Aug 2009

A Pair of URL-Shortening Bookmarklets

I'm not a big fan of URL-shortening services -- I like to see what page I'm about to load so I know if I want to go there. But with Twitter's 160-character limit, URL shorteners become necessary. It's tiresome to type in bit.ly every time, so I wanted a bookmark to say "give me a shortened version of the current URL".

Surprisingly, I had a hard time finding one. bit.ly itself has one on their front page, but it didn't work for me. Upon examination, it looks like their bookmark wants to read the clipboard, so you'd have to select a URL first before shortening it (though they don't actually tell you that). I don't want that extra step, so I made my own. Actually two of them.

First, a Javascript version that takes the current URL, encodes it and sends it to bit.ly. I gave it the keyword "bitly", so when I'm on a page, I just type "bitly" in the URLbar and it goes to bit.ly and makes the shortened URL.

The only problem with that is that I'd rather have the option of opening it in a new tab, so I can continue to read the original page. Normally I open new tabs by typing in a URL and typing Ctrl-Return (normally it's Alt-Return in Firefox, but it drives me nuts that Firefox uses Ctrl-click for new tab but Alt-Return and I can never keep them straight, and Firefox's normal behavior for Ctrl-Return is brain-dead useless so that's the first thing I fix when I get a Firefox update).

With this bitly bookmarklet, Ctrl-Return and Alt-Return don't work -- because then you lose the original tab's URL, and bitly gives you a shortened URL to nowhere ... "nowhere" being defined, in the bitly universe, as http://about.com (go figure). What to do?

So I made a second bookmarklet using a different technique: instead of using Javascript to get the current page's URL, call the bookmarklet with the URL as argument. I called this one bitly2. So if I'm pointing at http://shallowsky.com/blog/ and I want a shortened version in a new tab, I type:

Ctrl-L to go to the URLbar
Ctrl-A to go to the beginning of the URL
bitly2 and a space (inserted at the beginning before the URL)
so now I'll see bitly2 http://shallowsky.com/blog/
Ctrl-Return (or Alt-Return) to open in a new tab.

I'm not sure which one I'll end up using more, but I'll obviously change the bitly2 name to something better if I end up using it a lot.

If you want to use either of these bookmarklets: right-click on the link and choose Bookmark this link. Then, alas, since Firefox still doesn't let you enter a keyword in its Bookmarks dialog, you have to go to Bookmarks->Organize Bookmarks, find the bookmarklet you just added and click on it, click on More, and finally you can give it a keyword.

There used to be a Firefox extension called Openbook that let you see the Keyword field when you first add a bookmark, but it doesn't work any more in 3.5, alas. There's another extension called "Add Bookmark Here 2" that's supposed to do it, but the file on addons.mozilla.org is apparently corrupted and won't install. I don't understand why the Firefox crew is so obsessed with bookmark tags (for which I've never found any use) but won't let you add something as truly useful as a keyword. (It's bug 242834, marked WONTFIX.)

Of course, after I had my bookmarklets I finally found a page with a decent bit.ly bookmarklet very similar to my first one: A Quick Tutorial on JavaScript Bookmarklets.

Tags: , ,
[ 15:34 Aug 18, 2009    More tech/web | permalink to this entry | ]

Mon, 03 Aug 2009

Twit: Now with pattern searches

During OSCON a couple of weeks ago, I kept wishing I could do Twitter searches for a pattern like #oscon in a cleaner way than keeping a tab open in Firefox where I periodically hit Refresh.

Python-twitter doesn't support searches, alas, though it is part of the Twitter API. There's an experimental branch of python-twitter with searching, but I couldn't get it to work. But it turns out Gwibber is also written in Python, and I was able to lift some JSON code from Gwibber to implement a search. (Gwibber itself, alas, doesn't work for me: it bombs out looking for the Gnome keyring. Too bad, looks like it might be a decent client.)

I hacked up a "search for OSCON" program and used it a little during the week of the conference, then got home and absorbed in catching up and preparing for next week's GetSET summer camp, where I'm running an astronomy workshop and a Javascript workshop for high school girls. That's been keeping me frazzled, but I found a little time last night to clean up the search code and release Twit 0.3 with search and a few other new command-line arguments.

No big deal, but it was nice to take a hacking break from all this workshop coordinating. I'm definitely happier program than I am organizing events, that's for sure.

Tags: , ,
[ 18:23 Aug 03, 2009    More programming | permalink to this entry | ]

Thu, 09 Jul 2009

Twittering -- and writing Twitter clients

I finally dragged myself into 2009 and tried Twitter.

I'd been skeptical, but it's actually fairly interesting and not that much of a time sink. While it's true that some people tweet about every detail of their lives -- "I'm waiting for a bus" / "Oh, hooray, the bus is finally here" / "I got a good seat in the second row of the bus" / "The bus just passed Second St. and two kids got on" / "Here's a blurry photo from my phone of the Broadway Av. sign as we pass it" -- it's easy enough to identify those people and un-follow them.

And there are tons of people tweeting about interesting stuff. It's like a news ticker, but customizable -- news on the latest protests in Iran, the latest progress on freeing the Mars Spirit Rover, the latest interesting publication on dinosaur fossils, and what's going on at that interesting conference halfway around the world.

The trick is to figure out how you want the information delivered. I didn't want to have to leave a tab open in Firefox all the time. There was an xchat plug-in that sounded perfect -- I have an xchat window up most of the time I'm online -- but it turned out it works by picking one of the servers you're connected to, making a private channel and posting things there. That seemed abusive to the server -- what if everyone on Freenode did that?

So I wanted a separate client. Something lightweight and simple. Unfortunately, all the Twitter clients available for Linux either require that I install a lot of infrastructure first (either Adobe Air or Mono), or they just plain didn't work (a Twitter client where you can't click on links? Come on!)

But then I tried out the Python-Twitter bindings, and they were so easy to use I decided to write them up for my next Linux Planet article, which came out today: Write Your Own Linux Twitter Client In Less Time Than It Takes To Find One!.

The article shows how to use the bindings to write a bare-bones client. But of course, I've been hacking on the client all along, so the one I'm actually using has a lot more features like *ahem* letting you click on links. And letting you block threads, though I haven't actually tested that since I haven't seen any threads I wanted to block since my first day.

You can download the current version of Twit, and anyone who's interested can follow me on Twitter. I don't promise to be interesting -- that's up to you to decide -- but I do promise not to tweet about every block of my bus ride.

Tags: , , ,
[ 16:09 Jul 09, 2009    More writing | permalink to this entry | ]