SVN to Twitter

I’ve been really getting into developing my KickTweet project and set up a Twitter account for it at http://twitter.com/KickTweet. I wanted to feed in my subversion commits so I did some searching.

What I found was twitvn a monstrous (50-ish ‘real lines) Python script that sends commits to Twitter. I find that ridiculous. So here is my version, it drops right into the post-commit script and could be reduced to 2-3 active lines.

1
2
3
4
5
6
#!/bin/bash
REPOS="$1"
REV="$2"
 
TWEET="SVN Log (r$REV): $(svnlook log $REPOS -r $REV)"
curl -u KickTweet:mySecretPassword -d status="${TWEET:0:139}" http://twitter.com/statuses/update.xml

Note that the use of the ‘${TWEET:0:139}’ is a definite bashism, and not portable.

Update (2008-09-22)
Little tidbit to add into the script right before the curl call. If you want ellipses on commit messages over 140 characters, use this version.

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
REPOS="$1"
REV="$2"
 
TWEET="SVN Log (r$REV): $(svnlook log $REPOS -r $REV)"
 
if [ "${#TWEET}" -gt 140 ]; then
  TWEET="${TWEET:0:137}..."
fi
 
curl -u KickTweet:mySecretPassword -d status="${TWEET:0:139}" http://twitter.com/statuses/update.xml

Posted September 19th, 2008 - Permalink
Categories: BASH - Internet - KickTweet - Snippets
No Comments »
 
KickTweet or Creating a KDE3 Panel Applet

I started using Twitter again last week and wanted a Linux GUI client. I looked at the standard bunch, but none of them did it for me. I wanted something small and easy. Some had system tray modes, but I decided to make my own that would reside as a panel applet.

Doing the API interaction is easy, it’s just web services and I’ve used libcurl enough before to have that down. It’s the Qt/KDE piece that I wasn’t so sure about. I got started with my good friend Google, and found a few resources. If you are interested in creating a panel applet for KDE 3.5 or so, ignore the Google results they will only serve to lead you in the wrong direction!

Getting Started
I got started by firing up KDevelop and selecting “Project -> New Project” then choosing the “C++ -> KDE -> Kicker Applet” project. This will generate a nice framework for you to start developing your application on. It’s just like creating any other Qt application, but in a smaller space.

Caveats
There are a few small things that you won’t get unless you poke around a bit. The biggest problems I had were getting the applet to expand properly and getting my input text box to accept focus. Both of these problems were solved by reading the code from “mathapplet.cpp” by Andrew Coles in the KDE source tree.

I’ll start with the expanding issue. The first fix is to change the constructor to pass KPanelApplet::Stretch instead of the default KPanelApplet::Normal, as shown below.

1
2
3
4
5
6
extern "C" {
  KPanelApplet* init( QWidget *parent, const QString& configFile) {
    KGlobal::locale()->insertCatalogue("KickTweet");
    return new KickTweet(configFile, KPanelApplet::Stretch, KPanelApplet::About, parent, "KickTweet");
  }
}

This only fixes part of the problem though. If you load it into the panel as it is now, it will keep resizing until it has pressed all the other applets aside. This is because we need to fix the default implementation of widthForHeight(int height) and heightForWidth(int width). My fix here was to just feed back a standard value regardless of the current size requests. I copied mathapplet in sending back 110 for width and 22 for height. It doesn’t seem to be causing any problems yet.

The next issue is the input box focus. Again, this is taken from the mathapplet code and it is a simple if non-obvious fix. Just add watchForFocus(tweetText); to your constructor, where tweetText is your QLineEdit or derived. This is of course only relevant if you are using a text entry widget.

Testing
You can test your applet the easy way or the hard way. I tried it the hard way for quite a while, then when I got fed up I found the easy way.

the hard way is to do “make install” then add the applet to your panel. You will not notice changes if you do this version, because even if you add and remove the applet from the panel, it is not unload from memory. To get it unloaded you must restart the panel, easily done with a call to “dcop kicker default restart” This is slow an unwieldy however, and I recommend you only use it for testing the actual integration into the panel.

The easier way to test your applet is to still do “make install” but then to run your associated desktop file with appletproxy, like so “appletproxy /opt/kde3/share/apps/kicker/applets/kicktweet.desktop“. This lets you do quick and easy debugging and will send your cout and cerr to the terminal if you run it from one.

Conclusion
Creating a kicker applet is not nearly as hard as I thought it might be. After several missteps I now have “KickTweet” which readily scratches my Twitter itch.

KickTweet in action

Posted September 18th, 2008 - Permalink
Categories: C++ - Internet - KickTweet - Programming - Projects - Qt
No Comments »
 
Free Shrimp Ramen

A while back I posted a (sincere) offer for some shrimp ramen to anyone in the PKI building on craigslist. No one wanted them and I forgot about it. However, today I got this lovely email…

** CRAIGSLIST ADVISORY --- AVOID SCAMS BY DEALING LOCALLY
** Avoid:  wiring money, cross-border deals, work-at-home
** Beware: cashier checks, money orders, escrow, shipping
** More Info:  http://www.craigslist.org/about/scams.html

HELLO, gas is almost $4.00 a gallon!  Can't you just put those into a
food donation barrel next time you go to the grocery store or are
you starving for attention that bad.

------------------------------------------------------------------
this message was remailed to you via: sale-726621430@craigslist.org
------------------------------------------------------------------

Do you suppose someone is just cruising around craigslist looking at month old listings for something to criticize? Dear Internet: You are weird.

Posted August 1st, 2008 - Permalink
Categories: Funny - Internet
No Comments »
 
l337 h4X!!!1!

You have got to love MySpace. Their code has got to be so nasty, I mean, just the markup on a profile makes me sick to my stomach, I can’t imagine the pasted together backend that would generate that mess.

When I got an event invitation I went to RSVP and had a thought. I wondered how well they error checked their inputs. I mean, I’m sure they strip and escape for SQL injection, but do they constrain anything?

I busted out Firebug, edited the source for the RSVP and now I’m bringing several tens of thousands of friends with me to the party. Awesome.

Click for biggies.


(Note: the 91213 didn’t work, too big I bet)

Posted November 14th, 2007 - Permalink
Categories: Internet
No Comments »
 
Really Cool Video

I found this really neat video on web 2.0. Yay KSU.

Posted July 3rd, 2007 - Permalink
Categories: Internet
1 Comment »
 
More Posts
« Older
Newer »