<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EchoTech &#187; CPAN</title>
	<atom:link href="http://www.echo-technology.co.uk/tag/cpan/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.echo-technology.co.uk</link>
	<description>technology blogging for the moribund</description>
	<lastBuildDate>Tue, 06 Apr 2010 12:35:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How To: Growl and Twitter</title>
		<link>http://www.echo-technology.co.uk/2008/11/11/how-to-growl-and-twitter/</link>
		<comments>http://www.echo-technology.co.uk/2008/11/11/how-to-growl-and-twitter/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 11:12:08 +0000</pubDate>
		<dc:creator>Richard Stelling</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Web Sites]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.echo-technology.co.uk/?p=28</guid>
		<description><![CDATA[THIS POST HAS BEEN SUPERSEDED BY Twitter + Growl = Trowel v1.0
 
OK, so I&#8217;m new to Twitter. I didn&#8217;t (don&#8217;t) get it. Who wants to know what I&#8217;m doing? Well as I keep telling myself thats not the point. The point is to spread information, I had a lot of fun on Election night tweeting away about the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: left; margin-right: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.echo-technology.co.uk%2F2008%2F11%2F11%2Fhow-to-growl-and-twitter%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.echo-technology.co.uk%2F2008%2F11%2F11%2Fhow-to-growl-and-twitter%2F" height="61" width="51" /></a></div><h2><strong>THIS POST HAS BEEN SUPERSEDED BY </strong><a title="Twitter + Growl = Trowel v1.0" href="http://www.echo-technology.co.uk/2009/01/26/twitter-growl-trowel-v10/"><strong>Twitter + Growl = Trowel v1.0</strong></a></h2>
<p> </p>
<p>OK, so I&#8217;m new to <a href="http://twitter.com">Twitter</a>. I didn&#8217;t (don&#8217;t) get it. Who wants to know what I&#8217;m doing? Well as I keep telling myself thats not the point. The point is to spread information, I had a lot of fun on <a href="http://twitter.com/rjstelling">Election night tweeting</a> away about the coverage and calling states (I was surprisingly accurate).</p>
<p>The one thing that did annoy me was it added another website to check &#8211; not just a lunch but a refresh every 5 minutes. Something had to be done.<span id="more-28"></span></p>
<p>For anyone who has <a href="http://www.adiumx.com">Adium</a> installed on their Mac, you will be aware of <a href="http://growl.info/">Growl</a> it&#8217;s a notification system that has yet to reach it&#8217;s full potential. As with background messages I wanted my incoming Tweets to be shown in small unobtrusive transparent bubble.</p>
<p>To cut a long story short &#8211; I couldn&#8217;t find anything. I found a few Ruby scripts (that didn&#8217;t work), I tried some nice applications but I didn&#8217;t want to run another app I wanted Growl!</p>
<p>So an hour or 2 or Googling and research for scripts I found some Perl modules that I could combine to produce the desired output.</p>
<p>My steps and code are listed below, its not 100% fool proof &#8211; please leave comments on how I can improve it.</p>
<p> </p>
<p><strong>1. Installing the Modules</strong></p>
<p>You will need only 3 modules <a href="http://search.cpan.org/~cnandor/Mac-Growl-0.67/lib/Mac/Growl.pm">Mac::Growl</a>, <a href="http://search.cpan.org/~cthom/Net-Twitter-1.17/lib/Net/Twitter.pm">Net::Twitter</a> and <a href="http://search.cpan.org/~gbarr/TimeDate-1.16/lib/Date/Format.pm">Date::Format</a>, if your lucky Date::Format might even be already installed. Type the following commands into terminal.</p>
<p>$ sudo perl -MCPAN -e shell</p>
<p>This will launch a <a href="http://cpan.org">CPAN</a> command line session to install the modules type (at the prompt):</p>
<p>&gt; install Mac::Growl</p>
<p>Agree to any dependancies, when it done type:</p>
<p>&gt; install Net::Twitter</p>
<p>Again agree to all dependancies, and lastly:</p>
<p>&gt; install Date::Format</p>
<p>&gt; exit</p>
<p>If you had any problems it may be because You need Apple&#8217;s Development tools installed, these are a free <a href="http://developer.apple.com/">download form Apple</a>. Please leave any problems in the comments.</p>
<p> </p>
<p><strong>2. Coding</strong></p>
<p>Now for the code, just copy the following into a empty text file and save as some thing sensible like growl_tweet.pl:</p>
<pre>#! /usr/bin/perl -wT

use Mac::Growl ':all';
use Net::Twitter;
use Date::Format;

my $app    = 'Growl/Twitter';
my @names  = ('New Tweet');

RegisterNotifications($app, \@names, [$names[0]]);

my $tweet = Net::Twitter-&gt;new( username=&gt;'##REPLACE WITH USERNAME##', password=&gt;'##REPLACE WITH PASSWORD##' );

my $last_id = undef;
my $switch = 0;

while(1)
{
<span> </span>my @tt = ();

<span> </span>if($last_id)
<span> </span>{
<span> </span>@tt = $tweet-&gt;friends_timeline({count =&gt; 200, since_id =&gt; $last_id });
<span> </span>}
<span> </span>else
<span> </span>{
<span> </span>@tt = $tweet-&gt;friends_timeline({count =&gt; 5 });
<span> </span>}

<span> </span>foreach my $t (@{$tt[0]})
<span> </span>{
<span> </span>if(!$switch) { $last_id = $t-&gt;{id}; $switch++; };

<span> </span>PostNotification($app, $names[0], $t-&gt;{user}{screen_name}, $t-&gt;{text});

<span> </span>printf("%s: %s\n", $t-&gt;{user}{screen_name}, $t-&gt;{text});

<span> </span>print "sleep 4\n";

<span> </span>sleep(4);
<span> </span>}

<span> </span>$switch = 0;</pre>
<pre><span> </span>print "sleep 37\n";
<span> </span>sleep(37);
}

exit;</pre>
<p> </p>
<p><strong>3. Running</strong></p>
<p>Now, simply run the script:</p>
<p>$ perl ./growl_tweet.pl</p>
<p>And bingo! All your tweets appear! Leave a comment if it works and especially if it doesn&#8217;t &#8211; if there is enough interest I might consider adding features and real installer!</p>
<p> </p>
<p><strong>4. Here&#8217;s one I made earlier</strong></p>
<p>If you would like the code, you can down load it here (with out any formatting issues).</p>
<p><a title="Growl+Twitter" href="http://www.echo-technology.co.uk/development/twitter+growl/growl.pl.txt" target="_blank">http://www.echo-technology.co.uk/development/twitter+growl/growl.pl.txt</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.echo-technology.co.uk/2008/11/11/how-to-growl-and-twitter/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>
