Dec 31, 2008

Home...

is where you make it!

Dec 10, 2008

Tag-fest

This has been on my to-do list for a little while now, ever since Mr.DarkDominion tagged me in THIS post... so it's been a while yea... So here it is. Sorry it took so long bro.

1. What’s your latest addiction?
genetic programming. I read about it on Hackaday, and now I can't seem to get my mind off it.

2. What are you listening to? 
a cricket :) it's eerily silent at the moment.

3. How late did u stay up last night and why?
Usually I stay up till 3 in the morning but last night was an exception. I think 11 pm :|

4. Who were you with last friday night?
Friday friday...forgetting my cousin's birthday...shit!!!! oh fuck...

5. Do you think you’ll be in a relationship 3 months from now?
YES!!!!!!

6. When is the next time you’ll see your close friends?
December 24th. You better be there at the airport nut.

7. what were you doing this morning at 7AM?
I was wacking my alarm clock for making that god-aweful noise

8. What radio station do u listen to the most?
I don't do radio... :|

9. What was the reason you last cried?
Hmm...that's a tough one. I'm not sure if talking about that here is such a good idea.

10. Have you ever talked to someone when they were high?
Yup. talked, yelled at slept with you name it.

11. What’s the fifth text in your inbox say?
"Tomorrow is mr.suresh's (a.k.a mama) birthday so don't forget to wish - benju"

12. Where was the last coffee shop you went to?
Cafe' Coffee day :|

13. What’s your outfit right now?
black pants, brown t-shirt.

14. What were you doing at 11pm last night?
sleeping dude sleeping.

15. Who was the last person you talked to last night before bed?
Talked to.. well if you consider issuing some commands to your computer "talking" then I suppose that would be my laptop. But in human terms that would be my room-mate. The bastard said he'd wake up in the morning to study. (but he didn't)

16. Will you be driving in a year?
Hopefully something bigger than what I'm driving now.

17. Is there anything that you are craving for right now?
a good movie!

18. When did your last hug take place?
not too long ago.

19. Have you ever started a sentence with “No offense, but…”?
Nah I always say something offensive and say "no offense" afterwards.

20. Do you drink tea?
Yea, I don't really like Coffee.

21. Have you ever been arrested?
ehehe ehehe...no.

22. Have you rode in someone else’s car today?
No

23. Have you made a mistake this past week?
Oh I've made plenty.

24. Who was the last person you texted?
My uh ..finance' :p

25. Are you happy with your life right now?
mostly yes, and then there are the days when I want to commit suicide..or homicide. the latter being the more common.

26. In the past 72 hrs have you been under the influence of sleep?
yea it's been a good day

27. What’s the connection between you and the last person you texted?
We're dating..and yea we're doing it :P

Yea so the tagging goes out to tholath and keyolhubey

Dec 6, 2008

Kapoing!!!!

Testing out mobile blogging software. This is just a test.



And yes this kind of shit does happen to me quite a lot these days. Worthless peice of junk!!!

Nov 25, 2008

Bash Script: Dhiraagu WebSMS

I've been noticing a lot of problems with Dhiraagu's WebSMS site, mostly that annoying "Session Expired" Errors. So I decided it was time for a major overhaul of my websms script. So here it is. enjoy! Don't forget to comment, and send bug-reports, suggestions, hate-mail etc.

first, a change-log

REV 0 : Initial Release

REV 1 :
+ Verbosity
+ Checking message length
* Cleaned up regex

REV 2 :
+ Directory (alias)
+ Error checking numbers

Ver 2.0:
25-Nov-2008
Major overhaul, re-written from scratch

* Moved directory out of script to external file
* Moved cookie to /tmp (changeable)
+ Added argument processing
* NUMBER must now be given as an argument to -n option
+ Added option to silence output
+ Added option to display help
+ Added option to override default user and pass
+ Added option to override default directory
* Will detect old cookie-and try to re-use instead of logging in every-time.
+ Error checking of username and password
+ Handles "Session expired" error to an extent.It will keep re-trying until success

* Some more small changes that I can't remember


Installation is pretty standard. It uses cURL to do the heavy lifting so you'll need that. The directory file now defaults to ~/.wsmsdir. This is a comma seperated text file with name-number pairs

eg:
hotchick1,123943
hotchick2,123432
daddy,12432
wife,1498052
Change the default values for user and pass. Although this is not required anymore because you can give username and password info to the script using the -u and -p options now. It is not recommended if you share you computer with snoopy people. The script will leave a cookie file in /tmp by default (change "cookiebase" to whatever you like if you want to change this) name USERNAME.wsmscookie (this can be changed on the fourth line from the bottom).If you consider this feature a security risk or something, uncomment the last line to delete the cookie everytime after you send a message.
#!/usr/bin/env bash

##########################################
##                                      ##
##               \|/                    ##
##              '-D                     ##
##             BDWSMS 2.0               ##
##       (Bash Dhiraagu Web-Sms)        ##
##                                      ##
##########################################
##                                      
##  Written By, kudanai [2008]                 
##  http://kudanai.blogspot.com         
## 
##  This script is released as-is and 
##  without any liability on my behalf.
##
##  You are free to make modifications  
##  and redistribute. Credits where they
##  are due are appreciated, but not 
##  necessary.
##
##  Please submit feature requests and 
##  bug reports to moc.liamg@ianaduk
##  (email address is written backwards)
##
##########################################

user=DEFAULT-USER
pass=DEFAULT-PASS

#---leave these if you don't know what they mean --##

dirlist=~/.wsmsdir
cookiebase=/tmp

## ----no need to edit beyond this point --##
version=2.0
cookie=0
number=0
msg=0
verbose=1 #change to 0 if you want silence as default
uflag=0
pflag=0

main()
{
 if [ -e ${dirlist} ];then dcheck=`cat ${dirlist} | grep -w ${number} | cut -f2 -d","`;fi 

 if [ -n "${dcheck}" ]
 then
  number=${dcheck}
 fi

 if [ -z `echo ${number} | grep -E "^7[6-9][0-9]{5}$"` ]
 then
  echo "ERROR: Invalid Number or unknown alias"
  exit 1
 fi

 if [ $verbose -gt 0 ]
 then
  echo "Sending to: ${number}"
  if [ `expr length "${msg}"` -gt 140 ]
   then 
       echo "WARNING: Message will be truncated at ...${msg:130:10}"
  fi
 fi

 if [ -e ${cookie} ]
 then
  if [ $verbose -gt 0 ];then echo "Found cookie file - will try to re-use";fi
  sendsms
 else
  login
 fi

}

login()
{
 if [ $verbose -gt 0 ];then echo "Authenticating ... Getting cookie";fi
 ret=`curl -s --compressed -c ${cookie} -d "username=${user}" -d "password=${pass}" \
  http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl`

 if [ -n "`echo ${ret} | grep -i "password is incorrect"`" ]
 then
  echo "ERROR: Incorrect password"
  exit
 elif [ -n "`echo ${ret} | grep -i "you are not the"`" ]
 then
  echo "ERROR: Incorrect username"
  exit
 elif [ -n "`echo ${ret} | sed -n \"s/.*\( 0 more \).*/\1/p\"`" ]
 then
     echo "ERROR: Daily quota reached"
     exit
 else
     sendsms
 fi
}

sendsms()
{
 if [ $verbose -gt 0 ];then echo "Attempting to send message... ";fi
 ret=`curl -s --compressed -b ${cookie}  -d "mobilenumber=${number}" -d "message=${msg:0:140}" \
  http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl`
 
 rem=`echo ${ret} | sed -n 's/.*\([yY]ou .* Day\).*/\1/p'`
 
 if [ -n "${rem}" ]
 then
  echo ${rem}
  exit
 else
  if [ $verbose -gt 0 ];then echo "ERROR: session expired? trying again";fi
  rm ${cookie}
  login
 fi
  
}

printhelp()
{
 echo "BDWSMS - KudaNai (kudanai.blogspot.com)"
 echo "Version: $version"
 echo "USAGE: $0 [OPTIONS...] -n number 'message'"
 echo
 echo "OPTIONS"
 echo " -h  Print this help and exit"
 echo " -v  Print version information"
 echo " -s  Silent. Supress additional information."
 echo " -d  Overried default directory file. The Directory file"
 echo "   is a comma seperated file containing name,number pairs"
 echo " -u USERNAME Override default username. Must use with -p"
 echo " -p PASSWORD Override default password. Must use with -u"
 echo
 echo "Please note that the -n argument is MANDATORY"
 exit 1
}

while getopts 'vshu:p:n:d:' OPTION
do
 case $OPTION in
  s) verbose=0 
   ;;
  v) echo "BDWSMS Version: ${version} [2008]"
   exit 0
   ;;
  u) user="${OPTARG}"
   uflag=1
   ;;
  d) dirlist="${OPTARG}"
   ;;
  p) pass="${OPTARG}"
   pflag=1
   ;;
  n) number="${OPTARG}"
   ;;
  h) printhelp
   ;;
  ?) printhelp
   exit;;
 esac
done

shift $(( $OPTIND - 1 ))
msg=$1

if [[ -z ${number} ]] || [[ -z ${msg} ]]
then
 printhelp
elif [[ ${uflag} -ne ${pflag} ]]
then
 echo "ERROR: You must specify values for both -u and -p options or not at all"
 printhelp
else
 cookie="${cookiebase}/${user}.wsmscookie"
 main 
fi

#rm ${cookie}

Nov 21, 2008

Automate birthday wishes on facebook

NEW VERSION IS OUT, and is now compatible with the latest (v0.95) version of fbcmd. You can find it HERE

EDIT 3: 02/DEC/08 - Fixed birthday issue for single digit days. Damn paddings...

EDIT 2: 23/NOV/08 - Fixed the incorrect date matching problem. You should update before the 2nd of December or you'll be in trouble.

EDIT: I fixed one serious error in the code, and updated the how to and made it..simpler.


let's face it, no matter how much you try you will always forget somebody's birthday and end up in a hole. I've been " " this close to death on several occasions now, and I'm actually reputed for having a good grip of the whole birthday business.

so last night I wanted to kill some time and I came up with a little bash script that might be of help to some of you. Basically what it does is

  1. Go online and grab the user ID's of everybody who's birthday falls on "today" (make sure your system clock is setup properly)
  2. Write a message on their wall

This is setup to run once a day, and voila! you have yourself a free ticket out of...birthday forgetters hell... *cough*

Should be fairly straightforward on any *nix system.

We'll be needing some way to access information on facebook. For that we're going to use fbcmd which is, as the developer describes "a simple command line interface for facebook." Go to the projects website here and download the latest version. At the time of writing, this was 0.90 (BETA)

Note that the patch file provided is for this particular version. I will update it if necessary in the future.

extract the archive to your home directory (places->home).
now download the patch file and script from here and also extract it to ~/fbcmd (directory should already exist from the previous archive)

Now go to the facebook application page, HERE and allow the application to access your information, and click "generate" to get an AUTH CODE for your account. Copy this down

open up a terminal now and run the following commands, one at a time.
sudo apt-get install curl php5-cli gnome-schedule
cd ~/fbcmd
patch -b -i fbcmd.diff fbcmd.php
php fbcmd.php AUTH XXXXXX
where XXXXXX is the AUTH CODE you copied down earlier. Now you should have access to your account through the application. Now we can move on to the wish script. In the same terminal type out the following.
php fbcmd.php FRIENDSC > fbUIDlist
gedit fbbdaywish
when the editor pops up, change the values for email, pass and put in your email ad and password. Change the value of "post" to whatever you want your friend to be greeted with. (TIP: avoid !'s, it causes some problems)

now type
gnome-schedule
The scheduled tasks dialog should come up. Click on new->recurrent. Enter any description you like. In the command field type
~/fbcmd/fbbdaywish >> ~/fbcmd/bday.log
uncheck the "no output" option, and select "every day" from the drop down menu. Click ok, and you're set to go!

Let me know how it turns out.

Nov 15, 2008

Testing out flock

testing testing 1....2...3..

Nov 6, 2008

Michael Crichton dies of cancer at 66 - DAMN!

So I was going through my daily news today and...damn! I didn't see this one coming for some time.
Michael Crichton, the legendary author of many of my all time favourites has passed away at the age of 66. I've read almost all of his books! Jurassic park, timeline, the andromeda strain, the great train robbery,empire of the sun, airframe, next, eaters of the dead, disclosure, prey.. you name it I've read them all.

Read the full story here http://blog.wired.com/underwire/2008/11/sci-fi-giant-mi.html

Now a moment of silence please :(

Oct 31, 2008

My kinda elections...! hehe

Alright then, now that the "other" elections are over it's now time for my sort of elections. Don't take me for being shallow, I do give shit - a Lot of shit! and I don't mean the poopy kinda shit either. I'm talking real hard stuff here.

Now then, It's time for this years show-down season of the Linux distributions. We had Debian releasing the fifth revition of Etch a couple of days ago to get things started. Get your hats on kiddies, it's gonna be a fun ride this time around, with lots of exciting stuff going down. Today we have one uh...goat...going nuts in the neighborhood. Ubuntu's out people! and YEAAAHHH!!!! it's gonna be awesome! My wireless card is finally gonna get some native loving. Thank you Mr.kernel 2.6.27 :D

Hot on it's heels we got openSUSE, Fedora and simplyMEPIS. Let's see if openSUSE can convince me to ditch Ubuntu this time around. The last one didn't go so well for me personally. It's good, but just not good enough...for me :) Debian of course is the way to go if you're all hardcore [and have a lot of spare time (read Gentoo)] but I did try that, and it really wasn't for me.

so here we go..ready..annnnnnnnnnnnnnnnd... let the downloading begin :)

Oct 25, 2008

Ping Pong...!

just letting everybody know that I'm alive.

Oct 11, 2008

Scraping facebook email addresses

Last night I had a dilema - I came to realize that I don't even have a fraction of my friends email addresses in my contact book, which is a very bad thing by any means. Of course there's facebook for ya! but it's still no substitute for some good ol' emails.

So I thought maybe I could simply get them off of facebook - no go!

why? Facebook doesn't provide plain-text email adds, which presents a bit of a problem. After a little research, it became clear that FB uses one of those string-to-image scripts. Hah! easy I thought, I'll just decode the Base64 string and voila... as it happens it's not that easy. It's not a Base64 string and to be honest I couldn't figure out what it was. So that left me with the other option - OCR

This didn't prove too difficult at all. For the most part all I had to do was go through all my friends profile pages, extract the string_image hash, and pass that to

http://m.facebook.com/string_image.php?ct=XXXXXXX&fp=8.7&state=0

where ct takes the has, and fp is a float that controls the size of the output image. 8.7 is standard. you can crank that up to improve the OCR detection rate. I found 35 to be the optimal value between size and clarity.

based on this, i was able to whip up a quick bash script to take in a list of User-ID's (just a bunch of numbers that corrospond to a given user. Do what you will to grab that), grab the email image and use OCR on it. I used OCRAD to do the OCR, and imagemagick for convertion.

EDIT: It saddens me that some people have been making money off the code that I wrote. I helped you guys out in good faith. Really sucks that you took advantage of it. Anyway, I've decided to re-post the code here so the lamesters can be exposed for what they are. I'm posting the rewritten perl code here, since the original bash thing didn't work anyway.

NOTE: I have made some deliberate omissions here. modifications are needed before the code will be functional. you WILL GET BANNED by facebook if you overdo it.

here's the bash stuff:

BOING BOING!!! where did the code go? SOrry guys, I had to remove it.

and in perl: (the xxxx's should be easy to figure out if you see my other scripts)

#!/usr/bin/perl
use strict;
use xxxxx;
use xxxxx;
use Image::Magick;
use Shell qw[ocrad];

my $username = @ARGV[0];
my $password = @ARGV[1];
my $iurl;#temp var
my $id;  #temp var
my $x;   #temp var
my $uids="uids"; #path of uid list file
my $idlist="idlist"; #path of output file
my $size=35;  #size of email image to download

my $mech = xxxxxxx->new();
my $image = Image::Magick->new();

$mech->cookie_jar(xxxxxxxxx->new());

#login
$mech->post("https://login.facebook.com/login.php?m&next=http://m.facebook.com/inbox",{email=>$username,pass=>$password});

#star processing uids
open(UIDS,$uids);
open(IDLS,">>$idlist");
foreach $id ()
{
  chomp($id);
  $mech->get("http://m.facebook.com/profile.php?id=".$id."&v=info&refid=17");
  if(defined ($iurl=$mech->find_image( url_regex => qr/string_image.php/ )))
  {
    ($iurl=$iurl->url_abs())=~s/8.7/$size/;
    chomp($iurl);
    $x = $image->Read($iurl);
    $x = $image->Write(gamma=>0.3,colorspace=>'rgb',filename=>$id.".ppm");
    print IDLS "$id,".ocrad("$id.ppm")."\n";
    @$image = ();

   }
   else 
   {
    print IDLS "$id,undefined\n";
  }
}

close(UIDS);close(IDLS);

This works remarkably well for the most part, although ocrad did confuse some 1's for l's. I had better results with tesseract - but had to convert all the images to bi-tonal graymaps first. otherwise it's simply useless.