This feed contains pages in the "perl" category.

Christine Spang shortening URLs in barnowl

I post to identica through BarnOwl using Nelson's Twitter extension. This generally means I want to shorten URLs in my posts ("dents" as they're called on identica) so it's easier to fit them into the 140-character limit.

Luckily, BarnOwl can be extended using Perl, which, combined with some libraries from CPAN, makes this task simple. Here's the snippet I wrote:

package ShortenURLs;
use BarnOwl::Editwin qw(:all);
use Text::FindLinks;
use WWW::Shorten 'Bitly', qw(:short);

my $bitly_username = 'YOUR_BITLY_USERNAME_HERE';
my $bitly_apikey = 'YOUR_BITLY_APIKEY_HERE';

sub shorten_urls {
    my $text = save_excursion {
    my $linkified_text = Text::FindLinks::markup_links(
        text => $text,
        handler => sub {
            my ($url, $before, $after) = @_;

            my $short_link = q{};

            # hack around Text::FindLinks including trailing )
            # characters in URLs, which 99% of the time I don't
            # want, since it probably means I've surrounded the
            # link in parens
            if ($before =~ m/\($/ && $url =~ m/\)$/) {
                $url =~ s/\)$//;
                $short_link .= ")";

            return short_link($url, $bitly_username, $bitly_apikey).$short_link;


BarnOwl::new_command('shorten-urls' => \&shorten_urls);
BarnOwl::bindkey(edit => 'C-l' => command => 'shorten-urls');


You'll need a account, and to enter your username and API key from that account in the relevant locations. Paste the snippet into e.g. ~/.owl/, and add require "$ENV{HOME}/.owl/"; to your ~/.owlconf.

It has a sort of ridiculous dependency chain that I am too lazy to cull, which you'll need to install, probably using cpan. I recommend using local::lib if you're installing without root. (I found this to be a pretty good walkthrough). Installing WWW::Shorten::Bitly and Text::FindLinks should pull in all relevant dependencies.

And that's it! Hit C-l in the editwin and all the links in it will be replaced with shortened versions.

Posted Mon 12 Apr 2010 05:23:41 AM UTC Tags: tags/perl

Jesse Vincent and I just pushed a first release of Prophet and SD which is what I've been hacking on for all of this summer and half of last.

Jesse summarises Prophet and SD well:

Prophet is a lightweight schemaless database designed for peer to peer replication and disconnected operation. Prophet keeps a full copy of your data and (history) on your laptop, desktop or server. Prophet syncs when you want it to, so you can use Prophet-backed applications whether or not you have network.

SD (Simple Defects) is a peer-to-peer issue tracking system built on top of Prophet. In addition to being a full-fledged distributed bug tracker, SD can also bidirectionally sync with your RT, Hiveminder, Trac, GitHub or Google Code issue tracker.

Website here, full announcement here .

All the missing core dependencies have been uploaded to Debian and made it through NEW; Prophet and SD packages will come shortly (1-2 days, likely).

Debian folks may also be wondering when SD will support syncing with debbugs (at least one of you have asked me already). The answer is "eventually, but maybe sooner if you want to help". I started sketching out a debbugs foreign replica type last summer, but it's fallen off my radar since. I also spoke with Lars and Don at DebConf9 about their ideas for a Bug exchange format, which might be worth waiting for debbugs to support.

However, this afternoon I felt inspired to poke around at the old skeleton again and started making some changes. I'll hopefully push a debbugs feature branch that is at least closer in the next couple days, depending on how far I get. Talk to me if you're interested in lending a hand.

Posted Wed 26 Aug 2009 07:37:01 PM UTC Tags: tags/perl

Last week, eight pounds of Perl books arrived at my doorstep, courtesy of deciding to work for Best Practical this upcoming summer. They're cool people, very free software friendly, and conveniently located in Davis Square. They are also the makers of RT among other things, which Debian uses for a variety of purposes. It should be a good time. (No, I probably won't actually be hacking on RT, but exactly what I'll be working on is as yet undetermined.)

Speaking of the summer, I have a vague plan to make a West-coast visit for a week or so at some point. I'll be hitting at least Seattle and San Francisco; if you're around either of these areas or possibly even somewhere in between and would like to hang out, drop me a line in comments or via email.

Posted Tue 22 Apr 2008 06:53:00 PM UTC Tags: tags/perl