beer porn for jaypoe

April 4th, 2010

Test…
Mmmmm … Test.

beer porn for jaypoe

April 4th, 2010

Test…
Mmmmm … Test.

Parse Blackberry IPD Files

March 4th, 2009

It kinda pisses me off that you cannot open all you contacts/messages/information from the blackberry desktop manager.  I have my old backup.ipd file that has a bunch of contacts and information that I want on my new blackberry (Bold for thoses that care) but I dont want to replace all the information on my new BB, mostly because I am unclear as to what would happen and dont want to redo any of my existing work.

It also ticked me off that the only tool ABC Amber BlackBerry Converter available was going to cost me.  Not that the tools isnt any good, it very well could be, but for certain I am cheap and I have perl.  So I create a parser for the ipd file.  This parser will list all the databases, and create a CSV file for any specific database.

./extipd.pl -l file.ipd    ( to list all the databases in the file)
./extipd.pl 53 file.ipd  (to extract database #53 as a CSV to standard out)
./extipd.pl ‘Address Book’ file.ipd (to extract database ‘Address Book’ as a CSV to standard out

I have only tested the address book dump, as that is all I was interested in.  Should you have a specific need please feel free to contact me.

Here it is free for you use.
Update Jan 12, 2010: Added a custom output routine only for ‘Address Book - All’
Update July 23, 2009: Added a custom output routine only for ‘Phone Call Logs’
Update: Added some functionality to extipd.pl to output the fields order by their ‘type’

extipd3

#!/usr/bin/perl -w
use strict;
use Data::Dumper;

my $bDump = 0;

my $f = $ARGV[0];

# $0 -l file.ipd
# $0 53 file.ipd
# $0 'Address Book' file.ipd
if($#ARGV != 1 || ! -f $ARGV[1]){
    print "Usage $0 -l file.ipdn";
    print "Usage $0 53 file.ipdn";
    print "Usage $0 'Address Book' file.ipdn";
    exit();
}

my $bInfoOnly = 0;
my $dbRequired = -1;
my $dbRequiredName = '';

if($ARGV[0] eq '-l'){
    $bInfoOnly = 1;
}elsif( $ARGV[0] =~ /[0-9]+/ ){
    $dbRequired = $ARGV[0];
}else{
    $dbRequiredName = $ARGV[0];
}

my %CustomOutput =( 'Phone Call Logs' => &PhoneCallLogs,
    'Address Book - All' => &AddressBookAll );

sub ProcessFields($){
    my $f = shift;
    my @fields = ();
    my ($flen, $ftype, $fdata);

    while(length($f) > 0){
        ($flen, $ftype, $f) = unpack('SCa*', $f);
        ($fdata, $f) = unpack("a[$flen]a*", $f);
        my $field = { 'type' => $ftype, 'len' => $flen, 'data' => $fdata};
        push @fields, $field;
    }
    return @fields;
}

my $buf;
my @dbnames = ();

open(FF, $ARGV[1]) or die "Cannot open file $!n";

read(FF, $buf, 38); # Inter@ctive Pager Backup/Restore Filen
read(FF, $buf, 4); # Version(1) numdb(2) dbname_sep(1)

# WTF I thought this was little-endian?????
# if it was then I could use 's' instead of 'n' .. but its not :(
my ($v, $numdb, $dname_sep) = unpack('cnc',$buf);

if($bInfoOnly){
    print "Version [$v]nNumber of databases [$numdb]n";
}

for(my $i = 0; $i < $numdb; $i++){
    read(FF, $buf, 2);
    my $len = unpack('S',$buf); #Whereas this is most defnitely 's' not 'n'
    read(FF, $buf, $len);
    my $name = unpack('A*',$buf);
    if($bInfoOnly){
        print "Database $i : $namen";
    }
    push @dbnames, $name;
    if($dbRequired == -1){
        if($name eq $dbRequiredName){
            $dbRequired = $i;
        }
    }elsif($i == $dbRequired){
        $dbRequiredName = $name;
    }
}

if($bInfoOnly){
    close FF;
    exit();
}

my @dbRecs = ();
while (not eof(FF)){
    read(FF, $buf, 6);
    my ($id, $len) = unpack('SL', $buf);

    read(FF, $buf, $len);
    my ($v, $rh, $uniq, $fields) = unpack('CSLa*', $buf);

    my @fields = ProcessFields($fields);
    #sort fields by type
    if($dbRequired == $id){
        my @ofields = sort { $a->{'type'} <=> $b->{'type'} } @fields;
        push @dbRecs, @ofields;
    }

}
close FF;

if(! @dbRecs){
    exit();
}

foreach my $r (@dbRecs){
    if($bDump){
        print "[" . Dumper($r) . "]n";
    }else{
        my $bFirst = 1;
        foreach my $f (@{$r}){
            if(!$bFirst){print ',';}
            if($f->{'len'} > 0){
                if(exists $CustomOutput{$dbRequiredName}){
                    $CustomOutput{$dbRequiredName}->($f);
                }else{
                    print '"'.unpack('A*', $f->{'data'}).'"';
                }
            }else{
                print '""';
            }
            $bFirst = 0;
        }
        print "n";
    }
}

exit;

{
use bigint;  # using bigint globally slows this puppy down
    sub GetEpoch(@){
        my @b = @_;
        my $exp = 0;
        my $V = 0;
        foreach my $b (@b){
            $V = $V + $b * (256 ** $exp);
            $exp++;
        }
        $V = $V / 1000;
        return int($V);
    }
}

sub PhoneCallLogs {
    my $f = shift;
    if($f->{'type'} == 4){
        # 8 byte trickery
        my @b = unpack('C8', $f->{'data'});
        my $e = GetEpoch(@b);
        print '"'.$e.'"';
    }elsif ($f->{'type'} == 2){
        my $dir = unpack('I', $f->{'data'});
        if($dir == 0){
            print '"Received"';
        }elsif($dir == 1){
            print '"Placed"';
        }elsif($dir == 2){
            print '"Missed"';
        }else{
            print '"Unknown"';
        }
    }elsif ($f->{'type'} == 3){
        print '"'.unpack('I', $f->{'data'}).'"';
    }elsif ($f->{'type'} == 12){
        print '"'.unpack('A*', $f->{'data'}).'"';
    }elsif ($f->{'type'} == 31){
        print '"'.unpack('A*', $f->{'data'}).'"';
    }else{
        print '""';
    }
}
# ADDRESS BOOK - ALL
# Has format
# 'len' => 8, 'type' => 2 'data' => 'ÿÿÿÿÿÿÿÿ',
# 'len' => 7, 'type' => 3 'data' => 'Default',
# 'len' => 4, 'type' => 5 'data' => '_<89>BV',
# 'len' => XXYY, 'type' => 10
# This is the data part
## length->SS, type->C, data->xzxczxc
## length->SS, type->C, data->xzxczxc
## length->SS, type->C, data->xzxczxc

sub AddressBookAll {
    # not used .. simply going to sort by type and
    # print if printable
    my %ATYPE = ( 32 => 'Name', 1 => 'Email', 6 => 'Work',
        16 => 'Work 2', 7 => 'Home', 17 => 'Home 2', 8 => 'Mobile',
        35 => 'Address', 38 => 'City', 39 => 'Province', 40 => 'Postal Code',
        41 => 'Country', 10 => 'Pin', 42 => 'Title', 33 => 'Company');

    my $f = shift;
    if($f->{'type'} == 10){
        my @Afields;
        my $adlen;
        my $adtype;
        my $addata;
        my $data = $f->{'data'};
        while(length($data) > 0){
            ($adlen, $adtype, $data) = unpack('SCa*', $data);
            ($addata, $data) = unpack("a[$adlen]a*", $data);
#print "[$adtype]n";
#           if($adtype == 49){
            if(($addata =~ m/^([[:print:]]+)$/) && ($adtype != 100)){
                $addata = $1;
                my $Afield = { 'type'=>$adtype, 'len'=>$adlen, 'data'=>$addata};
                push @Afields, $Afield;
            }
        }
        @Afields = sort { $a->{'type'} <=> $b->{'type'} } @Afields;
        my $bFirst = 1;
        foreach my $f (@Afields){
            if(!$bFirst){
                print ',';
            }
            $bFirst = 0;
            print '"';
            if(exists($ATYPE{$f->{'type'}})){
                print '[' .$ATYPE{$f->{'type'}} .']' ." : ";
            }else{
                print '[' . ord($f->{'type'}).'] : ';
            }
            print $f->{'data'};
            print '"';
        }
    }

    # not outputting anything else
}

SMS Relay v2!

February 28th, 2009

I added a new feature to my SMS Relay Blackberry application.!.  If you remember WAY BACK last week I wrote a little bb app that took all my incoming emails and emailed them to an address.  I have added the reverse feature.  So now I can send myself emails and my phone will relay them out to an phone  number!  Not uber-useful, but it had to be done.  They key was to how to authenticate the message.  I opted for the incredi-secure plain text in the subject line method.

So the UI now takes

email address: to forward incoming SMS

subject: to prepend to the forwarded email before the incoming phone number

passcode: the plaintext code that is at the start of the subject line to authenticate the message.  So if the passcode = PLSSEND then you email yourself a message with the subject line “PLSSEND 519xyzabcd” and the body of the text (upto 140 characters) will be SMS to 519xyzabcd.

I think that is all the work that I am going to do on it.

Send a message. Write on the wall.

February 27th, 2009

I know what I am getting that special someone for their birthday!

http://www.sendamessage.nl

SMSRelay

February 26th, 2009

Okay I built the stupidest Blackberry app ever, but I had a reason.  This isnt my first bb app, but it is my first is a while.  Here is the story.  I was upstairs waiting for an email about a problem that we where having with some software that we had written (turned out to be a non-issue).  So I was upstairs on the computer, waiting for this email (I live on email .. be careful as this can happen to you if you dont get a life).  The email never came, so I packed up to go to the grocery store and grabbed my phone on the way out.  I am pretty sure you can figure out the rest.  This person had been SMSing me instead of emailing.  In fact there are about 1/2 dozen people in my life that SMS me instead of email, so I built this app for them.

This app has two parts a relay thread and an UI.  It grabs all incoming SMS messages and forwards then to a email address of your choice with a subject line of your choice.  Simple.  The hardest part was getting the keys from RIM to sign their APIs.

Should anyone care I will post the cod files.

@wordgame

February 23rd, 2009

I have been playing a game with my Dad over SMS for a little while now.  I couldnt help but to start cheating, I resorted to my often used rationalization of “Why bother trying figure it out when I could write a program to solve it”.  That is how this started.  This ‘wordgame’ is the first half of this game and here is how it works.

@wordgame will pick a secret 5 letter word with NO repeating letters.  Your job is to try and guess that word by guessing other 5 letter words that may have repeating letters and be in the dictionary.  In turn @wordgame will tell you how many of the those letter in the guess match the secret word.

The best explanation is an example:

Secret 5 letter no-repeating letter word is ‘FRUIT’

I’ll Guess ‘MARRY’ (my guess are allowed double letters … in fact that help)

The answer to that guess will be MARRY = 2

M=0, A=0, R=1, R=1, Y=0 which adds to 2, for the 2 ‘R’ in the guess.

here is another guess

FLUFF = 4.  3 for the ‘F’s and 1 for the ‘U”.

—————————————–

Other bits of info

To restart the game … @wordgame restart

+ more information to follow

1) second half of the game where @wordgame guesses your word.

Pong

February 20th, 2009

My Dad brought over ps2 so we could play some Medal of Honour.  A game he has been hooked on for a while now.  So we played all night and into the next d when I got reminiscing about some older games.  Well I had this old pong game around that I had never used (actually it is a tenis/hockey/squash/handball) .

So I got a soldering iron and made some modifications (added a power supply) and voila bub beep  bub beep bub beep

PONG

and yes I totally smoked my 8 year old.

Automatic, Systematic, Hydromatic .. why its grease lightning

January 24th, 2009

GREASE is now over 30 YEARS old.  I find that amazing.  That means I was 8 when I first saw it.  My daughter is now approaching 8 (Feb 14).  It seems almost inconceivable that I saw that saw show at her age.  Really what were my parents thinking.

What got me here was that I was crusing YouTube with my Son -cheap parenting- and I thought I would combine his love of Music with his love of cars and I found Grease Lightining.  He was moved.  We rocked.  Good times.  And I thought there is only one person who loves music more .. Isabel.  Se can’t stop singing Sounds of Music, Mary Poppins, and here latest obsession Mamma Mia.  I was going thru the various Grease scenes on YouTube and although the lyrics are -at time- mature I figured I could let that slide.  The most disconcerting imagery of all was JT and his spectacular and incessant pelvis thrust.  To that end I found a better version of Summer nights for Isabel to watch

So I think I am going to have to go and buy the DVD for my kids (and me).  This was such a big part of my early tweens.  Listenning to the LP over and over and over again (side 1&2 because sides 3&4 where all elvis crap).  Thank Olivia and John

-It doesn’t matter if you win or lose, it’s what you do with your dancin’ shoes. (Vince)

Poe’s Bday

January 22nd, 2009

the 200th birthday of Poe.  Who also was the inspiration behind the BEST 404 page ever.

http://img.photobucket.com/albums/v353/Mordarkea/9404.jpg

Once upon a midnight dreary,
while I websurfed, weak and weary,
Over many a strange and spurious website of hot chicks galore,
While I clicked my fav’rite bookmark,
suddenly there came a warning,
And my heart was filled with mourning,
mourning for my dear amour.
‘Tis not possible, I muttered,
give me back my cheap hardcore! —
Quoth the server, “404″.