Support people and blocked numbers

I tend to not answer the phone when it turns out to be a blocked number, however more and more I need to answer the phone because it’s a confirmation of a support meeting.
Leave a bloody message

Natural sorting order

Over at Coding horror, we have an interesting article about ‘Alphabetical Sorting‘, which is one of those problems that us computer programmers can’t seem to get around. I have one that’s even more evil than that. It’s language-based sorting for names. For example in Irish, we have a lot of bits that get added to the start of names (for example Mac, Mc, O’, D’, h). It’s even more fun than simple numeric sorting. The phone book doesn’t even try on this. I think it has people inured to the fact that they won’t have their name in the right place in the phone book.

webtext.pl

Send Vodafone ireland text messages from the command line. Uses the keychain info from safari on the mac. There’s an annoying sleep as it looks to detect pump-and-dump html requests (i.e. scripts like this).


#!/usr/bin/perl -w

use strict;
use HTML::Form;
use HTTP::Request;
use LWP;
use Data::Dumper;
my $username;
my $password;
my $message;
my @recipients = ();
if ($^O eq “darwin”) {
# Log in once to webtext under safari and this will work
# you need to allow the security program to access the keychain
open(IN, “security find-internet-password -g -s www.vodafone.ie -r htps 2>&1 |”) || die “$!”;
while(<IN>) {
if (m/”acct”<blob>=”(.*)”/) { $username = $1; }
if (m/password: “(.*)”/) { $password = $1; }
}
close(IN);
} else {
# use something else, or program the passwords here
$username=”0876666666″;
$password=”password”;
}
my $webtext_url=”https://www.vodafone.ie/myv/messaging/webtext/index.jsp”;
sub usage {
print “$0 <addressee1> […<addressee5>] \”Message\”\n”;
exit 0
}
usage() if ((scalar(@ARGV) < 2) || (scalar(@ARGV) > 6));
while (scalar(@ARGV) > 1) {
push(@recipients, shift @ARGV);
}
$message = pop(@ARGV);
if (length($message) > 160) {
die “Message too long.\n Shorten to: \”” . substr($message, 0, 160) . “\””;
}
my $ua = LWP::UserAgent->new;
push @{ $ua->requests_redirectable }, ‘POST’;
$ua->cookie_jar({ });
$ua->agent(‘Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/523.10.3 (KHTML, like Gecko) Version/3.0.4 Safari/523.10’);
my $response = $ua->get($webtext_url);
#print Dumper($response);
my @forms = HTML::Form->parse($response->content, $response->base);
my $form = undef;
foreach (@forms) {
if (defined($_->{‘attr’}) &&
lc($_->{‘attr’}{‘name’}) eq “login”) {
$form=$_;
}
}
die “Could not get Login Form” unless $form;
$form->value(‘username’, $username);
$form->value(‘password’, $password);
$response = $ua->request($form->click);
die “Login Failed” if (!$response->is_success || $response->base =~ /Login.shtml/);
$response->as_string() =~ /emaining messages this month:.*>(\d+)</s
or die “Unexpected response: ” . $response->as_string() . ” Couldn’t determine number of remaining texts”;
my $remaining = $1;
@forms = HTML::Form->parse($response->content, $response->base);
$form = undef;
foreach (@forms) {
if (defined($_->{‘attr’}) &&
lc($_->{‘attr’}{‘name’}) eq “webtext”) {
$form=$_;
}
}
die “Could not get Webtext Form” unless $form;
# walk the label for=… -> form id=… matches
my %chk_labels;
my %address_book;
%chk_labels = $response->content =~ m/label for=”chk_box_(\d*)”>([^<]*)</g;
#print Dumper($form);
foreach (keys(%chk_labels)) {
my $iv = $form->find_input(“chk_box_$_”);
$address_book{$chk_labels{$_}} = $iv->{menu}[1]{‘value’};
}
$form->value(‘message’, $message);
my $i = 0;
print “Sending: $message to “;
foreach (@recipients) {
my $phone = $_;
if (!($phone =~ /^[0-9]/)) {
$phone = $address_book{$phone};
}
$form->value(“recipients[$i]”, $phone);
print $phone . ” “;
$i++;
}
print “\n”;
sleep(5);
$response = $ua->request($form->click);
die “Message was not sent correctly” . Dumper($response) if (!($response->as_string() =~ /Your message was sent to:/));
$response = $ua->get($webtext_url);
$response->as_string() =~ /emaining messages this month:.*>(\d+)</s
or die “Unexpected response: ” . $response->as_string() . ” Couldn’t determine number of remaining texts”;
if ($remaining == $1) {
die “Even though the message was sent, the number of available messages didn’t reduce”;
}
print “Remaining Messages: $1\n”;
exit 0

Download Here

del.icio.us where are you

I can’t access del.icio.us from the house. Works from the office, and most of the time from the USB widget.
Hasn’t worked for weeks.
NTL ireland?

Kind of tilting towards a console / media extender

It’s a valid question. I’m thinking about getting a console/media extender. The problems are that 1. I’ve seen the xbox 360 in action, and while the list of games is good, the level of ambient noise does not make me feel like a happy camper (mind you I run from a laptop most of the time).

On the other hand, the lack of games for the ps3 makes it a bit of a lame duck. I mean really, Sony, what can you be thinking by removing the entire backwards compatibility from the latest variants of the 40gb model (I don’t want to check the other models). I can still play ps1 compatible titles on the ps2. Microsoft have the right idea on this – support it until you have the rolling mass of next-gen titles to allow you to stop adding old games to the list (damned barbie horse adventures).

I don’t want a crippled 20gb model of the 360, which leaves the elite. Well, it’s black. So at least it matches the rest of the furniture 🙂
I just don’t see the value of the elite; really I don’t. Sony allow you to replace the HDD with something off the shelf, which is really nice, considering I have several large capacity ATA and SATA laptop hard drives.

Whaddya mean no https

Leopard is not spiffy:

$ lwp-request -x https://mail.google.com/mail/
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://mail.google.com/mail/
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error
500 Can't connect to mail.google.com:443 (Invalid argument)

Update 2008-05-06: How I got it working for me. It’s not the cleanest, but it works!

Been sitting here waiting for an iWork serial number

I could have sworn I paid for the damned thing a few hours ago, and I still have yet to receive the damned serial number so I can print my work. I got a serial number for textmate within minutes of paying for it. What’s so difficult about Apple that it takes them so long to get their asses in gear over this?