Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2009/03/26

Setting your GTalk Status with Perl

When confronted with a problem, I used to go to Google and type perl problem-domain , but I stopped that, because that, at best, sent me to a module page on CPAN, which, unfortunately, doesn't always tell you how to use the module.

I have started to use perl problem-domain site:blogspot.com instead, as it is likely that someone hit the same problem and found a solution. When I started looking into the problem of changing the status for Google Talk, I did this, and found this page, ending with the line "Worked? Or Crap?" I could not help responding "Worked AND Crap."

"Worked" is nothing to sneeze at. The IETF motto is "rough consensus and running code", and when you have code that does what you ask it to, what more do you want? But when you use the same variable name three times for three different things, you have to wonder if you could do a better job with it.


#!/usr/bin/perl
# http://digitalpbk.blogspot.com/2009/02/perl-change-google-talk-status.html
#usage : perl stat.pl

use Modern::Perl ;
use Net::XMPP ;
use subs qw{ get_status set_status } ;

my $status = get_status ;
if ( defined $status && length $status > 1 ) {
set_status $status ;
}
exit ;

sub get_credentials {
#this is the point where my setup sucks
my %creds ;
$creds{ username } = 'NO' ;
$creds{ password } = 'A Thousand Times NO' ;
return %creds ;
}

sub get_status {
return join ' ', @ARGV ;
}

sub set_status {
my $status = shift ;
my %cred = get_credentials ;
my $username = $cred{ username } ;
my $password = $cred{ password } ;
my $hostname = 'talk.google.com' ;
my $port = 5222 ;
my $componentname = 'gmail.com' ;
my $connectiontype = 'tcpip' ;
my $tls = 1 ;
my $Con = new Net::XMPP::Client( debuglevel => 0 ) ;
my $con_status = $Con->Connect( hostname => $hostname,
port => $port,
componentname => $componentname,
connectiontype => $connectiontype,
tls => $tls,
timeout => 10 ) ;

if ( !( defined( $con_status ) ) ) {
exit( 0 ) ;
}
my $sid = $Con->{ SESSION }->{ id } ;
$Con->{ STREAM }->{ SIDS }->{ $sid }->{ hostname } = $componentname ;
my @result = $Con->AuthSend( username => $username,
password => $password,
resource => "neuron" ) ;
$Con->Send(
"<iq type='get' to='gmail.com'>"
) ;
$Con->Process() ;
my $iq = $Con->SendAndReceiveWithID(
"<iq type='get' to='$username\@gmail.com'>"
) ;
my ( $cur_status, $statuslist, $show ) = ( "", "", "" ) ;
$cur_status = $1 if ( $iq->GetXML() =~ m/(.*?)<\/status>/ ) ;
$statuslist = $1
if ( $iq->GetXML() =~ m/(<status-list(.*)<\/status-list>)/ ) ;
$show = $1 if ( $iq->GetXML() =~ m/<show>(.*?)<\/show>/ ) ;
##Change status
$Con->Send(
"<iq type='set' to='$username\@gmail.com'>
<query xmlns='google:shared-status'>
<status>$status

<show>$show
</query></iq>" ) ;
$Con->Process() ;
$Con->Disconnect() ;
return $status ;
}


I'll admit that set_status is fairly cargo-cult. But I think it is a little less crap that it was before. Thanks to digitalpbk for the code.

2009/03/16

Ubuntu Intrepid + development Gnome+Do = Transparent Terminals



I don't know why that happened. I have not been able to touch the Compiz stuff, but I think Gnome-Do back-doors it in. Still, way cool.

2009/03/10

Simple Firefox Hack ...

Want more than one "Home Page" in Firefox?

In the "Main" tab of your Preferences/Options, where it has the Home Page text bar, separate your preferred home page URLs with a pipe character (|).

2009/03/06

Making Administration Illegal?

You guys heard about this?

It seems to me that, if I was an admin, I would be well advised to steer clear of San Francisco, because from where I'm sitting, I can't see where he's done anything wrong.

I remember when Kevin Mitnick was arrested. There were "Free Kevin" shirts and stickers, and I would never have stuck one or carried one. I was irked because he was jailed without trial for a long time, but I always thought he deserved a trial and jail time. But for Terry Childs, I feel very comfortable putting my name to this.

2009/03/03

And the company that will bring it to you? Hat-tip: CaliLewis

Futurism 2009
<a href="http://video.msn.com/?mkt=en-GB&amp;playlist=videoByUuids:uuids:a517b260-bb6b-48b9-87ac-8e2743a28ec5&amp;showPlaylist=true&amp;from=msnvideo" target="_new" title="Future Vision Montage">Video: Future Vision Montage</a>

Futurism 1993


Thanks GeekBrief

2009/03/02

Valuing the Network...


1) I am on this map. I am not within the circle. Cell tower triangulation doesn't get me in the correct county.
2) By Metcalfe's Law, Google Latitude is useless to me.

2009/02/24

Taking a Great Notion ...



I have a Blackberry. That makes me cool.

It has two mapping programs. Google Maps and Blackberry Map. And I can tell which one uses which.

According to the article in Wired, which I read last night in the library, there are three main geolocating technologies. There's WiFi, which my phone doesn't do. There's GPS, which works from satellites and is slow and sometimes has problems with buildings. Then there's Cell Tower Triangulation. Which doesn't really do triangulation, but rather uno-angulation. There's a cell tower. You connect to that tower. Therefore, you must be really really close to that cell tower.

I assure you that I have not jumped in the Wabash with my Blackberry. Nor am I on the edge of I65 when I'm home.

Which is a big downfall for Google Latitude. Which, considering how potentially orwellian it could be, might be a good thing.

Loading Jaunty Notifications....


You can get Jaunty-Style notifications in Intrepid. They're not 100% yet, I don't think, but I would say they're easily 85%, if not more.

It shows how much (or little) C++ programming I do that I had to apt-get so much stuff in order to make it work.