Archive

Posts Tagged ‘Apple’

iPhone to Android SMS Converstion Script

May 25th, 2010 welby 1 comment

As promised here’s a copy of my iPhone to Android script. Just a quick and dirty python script that reads in a backup from itunes and converts it to a bit of XML able to be read in by SMS Backup and Restore on the android platform

from sqlite3 import *
from sqlite3 import *
from xml.sax.saxutils import escape
import codecs
import re
f = codecs.open('sms.xml','w','utf-8')
f.write ('''< ?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<smses>
''')
# This is 31bb7ba8914766d4ba40d6dfb6113c8b614be442.mddata or 31bb7ba8914766d4ba40d6dfb6113c8b614be442.mdbackup usally
c = connect('sms.db')
curs = c.cursor()
curs.execute('''SELECT address,date,text,flags FROM message WHERE flags &lt;5 ORDER BY date asc''')
for row in curs:
        a= escape(unicode(row[0]))
        d = escape(unicode(row[1]))
        t = row[3]-1
        t = str(t)
        b = re.sub('"',"'",escape(unicode(row[2])))
 
        f.write( '<sms protocol="0" address="'+a+'" date="'+d+'000" type="'+t+'" subject="null" body="'+b+'" toa="0" sc_toa="0" service_center="null" read="1" status="-1" />'+"\n")
f.write(
'''</smses>''' )

Subway using Apple’s “There’s an app for that” slogan ?

September 10th, 2009 welby No comments

Tagging along at lunch with a few colleagues at work today to the local subway and notice a new set of adverts on the window.
It appears that subway are imitating Apple’s “there’s an app for that”. It turns out that this campaign has been done by McCann Erickson and is a ‘light-hearted’ campaign complete with UK TV adverts. The phrase Imitation is the sincerest form of flattery comes to mind.

Categories: Apple, Non Geeky Tags: , ,

IRSSI Prowl Notifications

July 9th, 2009 welby 1 comment

A quick script to send notifications from IRSSI for privmessages and also for highlights, I’ll put more commentary on later, but for now..

use strict;
use vars qw($VERSION %IRSSI);
use Irssi;
use LWP::UserAgent;
 
$VERSION = '0.1';
 
%IRSSI = (
        authors => 'Welby McRoberts',
        contact => 'irssi@whmcr.com',
        name => 'irssi_prowler',
        description => 'Sends a notification to Prowl to alert an iPhone of a new highlighted message',
        url => 'http://www.whmcr.com/2009/07/irssi-prowl-notifications',
        changes => 'Friday, 10 Jun 2009'
);
 
######## Config
my($PRIV_PRI, $PRIV_EVENT, $HI_PRI, $HI_EVENT, $APP, $UA, $APIKEY);
$PRIV_PRI = 2;
$PRIV_EVENT = 'Private Message';
$HI_PRI = 1;
$HI_EVENT = 'Highlight';
$APP = 'irssi';
$UA = 'irssi_prowler';
$APIKEY='7b5d817bd95911b4c049e3034dcf7a96dfa3fb53';
########
 
####### Highlights
 
sub highlight {
        my ($dest, $text, $stripped) = @_;
        if ($dest->{level} & MSGLEVEL_HILIGHT) {
                print "prowl($HI_PRI, $APP, $HI_EVENT, $text)";
                prowl($HI_PRI, $APP, $HI_EVENT, $text);
        }
}
 
####### Private Messages
 
sub priv {
        my ($server, $text, $nick, $host, $channel) = @_;
        print "prowl($PRIV_PRI, $APP, $PRIV_EVENT, $text)";
        prowl($PRIV_PRI, $APP, $PRIV_EVENT, $text);
}
 
####### Prowl call
 
sub prowl {
        my ($priority, $application, $event, $description) = @_;
        my ($request, $response, $url, $lwp);
        print 'pri: '.$priority;
        print 'app: '.$application;
        print 'event: '.$event;
        print 'description: '.$description;
 
        ######## Setting up the LWP
        $lwp = LWP::UserAgent->new;
        $lwp->agent($UA);
        # URL Encode
        $application =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
    $event =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
    $description =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
        # Setup the url
        $url = sprintf("https://prowl.weks.net/publicapi/add?apikey=%s&priority=%d&application=%s&event=%s&description=%s&",
                                        $APIKEY,
                                        $priority,
                                        $application,
                                        $event,
                                        $description
                                        );
        print $url;
        $request = HTTP::Request->new(GET => $url);
        $response = $lwp->request($request);
        print $response;
}
 
####### Bind "message private" to priv()
Irssi::signal_add_last("message private", "priv");
####### Bind "print text" to highlights()
Irssi::signal_add_last("print text", "highlight");
Categories: Apple, Linux, iPhone Tags: , , , ,