Sunday, December 31, 2006

tail -f 2006

ah! end of the year 2006. Well, hmmm! another year, a good year. over all for me its been a very good year. Right now I am in India with my family due to some medical issues, thank god all is fine now. So I am celebrating this new year as a happy guy and with my family, only thing I miss is my son. He is back in Male' with his mom. If he was here it would have been so complete. Anyway no one gets it all ey? Just hope I'd be with him on the next new year.

Next year (2007) might be a bit of tough year. Seems I have to be on medication for one year (taking an injection every week). Ouch! Next thing would be I can't spend as much time at office as this year (all thanks to the doctors again). Besides that I don't think much will change. It will be just work, loads of sleep. And yeah no resolutions, yep none. Guess only major change will be I would try to move away from totally devoting my time at office and try to do something on my own too. Don't really know what or how yet. Just have some slight idea, but no real plans. I don't think living on USD 900 a month is good enough anymore. I guess its time a lot of us give it a thought and try harder. Fight back if needed. Anyway, lets see.

Since this is my last post of the year, would like to post about me :) and this is my blog! Firstly I would like to thank my family for the support they always give me and standing by me. Without them I can't be the me I am, be it bad or good. I love them. My close friends who's always been a good company and from whom I learn so much. Some people always have stood by me, no matter what. Thank you so much. What I have learned and known is no one knows it all. No one. And there is always someone out there, who is better than you and from whom you can always learn. They maybe elder to you or even younger. Always learn from them and give back what you can. If anyone ever says "I am the best", Its "simply not true". Or if anyone thinks in that attitude its not the right attitude. Last one year I've met some amazing people, and hope to work with some of them a bit longer. Its really good to be part of an amazing team at work. Ah and before I forget; I should thank my wife for keeping up with me and always making me smile and laugh.

Hopefully next year will be a good start. I was really happy to see the mail from IOSN inviting me to participate in the Asia Source II camp in Sukabumi, Indonesia, between 22nd and 30th of January 2007. I don't know if I can make it or not. But I sure hope so. Best part is its all fully sponsored. I would be honored to be representing Maldives and the Maldivian Linux Users Group if I can make it. Anyway I don't have much hopes since I am already on leave now and to get another leave the same month, I know I have to put up a major fight. But lets hope I can.

Finally I think I've decided on my carrier path. geee! took me long. I guess I love the part of my job which involves product development in the mobile sector. I guess VAS (value added services) is where I wanna move on. Hopefully I'd be able to learn more on it and gain more experience there. Its kinda fun area and involves a lot of stuff which makes it really interesting. Best part I love about it is the integration of different technologies for our requirements. There is always something new to learn and do. I hate to do the same routing stuff everyday. I'd rather commit suicide then that. I don't know how some people can do it. Its amazing.

Today is the last day of the year and I met someone who's helped me a few years back and whom I respect so much. Today again I've had the pleasure of having a chat with him for an hour or so. Thanks to him I am more convinced with certain things and have helped me to clear something better. We all have our own issues and problems, facing them and over coming them is the challenge in life. Some times we are lost, we don't know where we should head to or do. Its good to stop and analyze things and if possible share it with people who can help or care. Then follow the advise of these people. It really helps. Some times it also happens that you are aware of somethings and understand things, but you might find it hard to accept those things and act on them. Again at these times its good to stop and do the same. Might not apply for everyone, but for me it sure does help. So to rap up, I thank everyone who's been a part of my life in anyway and wish them a very happy new year. Damn I got to run. Happy new year again!

Saturday, December 23, 2006

Malé the most congested, maybe..?

It is very likely that Malé is the most congested in the world. It is estimated that around 48,007 citizens per square kilometer live in Malé. The closest rival is Cairo, hmmm! a close connection some where maybe ?. This has and will cause a lot of problems in the long run, unless some people acted on it. Problems like health issues, crime and other social issues are on the rise. Hardly anyone addresses these issues and measures are taken.

One of the biggest reasons why Malé is so populated is almost everything is centered in Malé. Good education compared to others islands, health and job opportunities. Most people are forced to leave their homes in the islands and live in Malé. Here some times 5 or 7 people share the same room or even worse. The rents are up so high. An average one room apartment costs MRf 5,000 (USD 389) per month, when the average salary is about MRf 2,500. This is amazing. Its hard to imagine how most people survive in Malé. Yet we see a country blooming, at least thats what we are told.

It is said that the quality of education has badly gone down over the last few years. I don't know how true this is but its been a widely talked subject. The increasing number of vehicles is the other problem. Hardly you can find a parking spot, if you own a car its even worse.

There is nothing much anyone can do in Malé. Except of-course the usual coffee sessions and burning of fuel unnecessarily. The new means of entertainment is politics for the grownups and brown sugar for the young.

Thursday, December 21, 2006

IM's and IMPS

IM's or Instant Messaging is nothing new to us. We all use it now, as a means of communication. Over the PC's we use MSN Messenger, Yahoo, Google Talk and ICQ, etc. These have been around for sometime. Now they are on our mobiles as well. We can use them almost anywhere anytime. Things have changed a lot. So whats that we lack? One major draw back is that these IM's are not able to communicate with each other (mostly). Recently MSN and Yahoo have made this possible. We still lack one unified messaging solution.

This is where IMPS comes in. IMPS stands for instant messaging and presence system. It is an instant messaging standard initiated by Wireless Village Forum which is primarily supported by Ericsson, Nokia and Motorola. This standardization aims is to bring and to have one single instant messaging system regardless the media and the client. This client is not only designed for PC but also for normal handset. It creates the communication standard between different IM servers and also communication standard between client and IMPS server. We can find the sample of IMPS client in Sony Ericsson handset in “My friends” menu or in “My Presence” menu in Nokia handset. We are free to connect to any IMPS server in the internet.

We do have things like Agile Messenger and GAIM, but what actually happens inside them is they have different clients inside these applications for each of the protocol or IM server.

Monday, December 11, 2006

postscript to html (ps2html)

Ever needed to convert postscript (ps) files to html? I had to. I needed to convert a batch of ps files to html. I looked around a lot, but failed. Could not find a good tool to get this done. Next choice was to write one. I worked on it over the week end, but failed. Got too lazy at a point. I was able to convert the text to html, but when it came to the formating it was a pain. The tool worked fine when I needed to export just the text, but with the formating; it was a pain. So I looked for other alternative solutions. The best choice was to use 2 simple tools that came with most *nix's. ps2pdf and pdftohtml. The first one converted the file to pdf the next from pdf to html. I could not find any good tools to directly convert from ps to html. The only issue I found with pdftohtml is that it does not convert Unicode characters well. Some how that is messed up, besides that no issues.
ps2pdf file.ps
pdftohtml -c -noframes -zoom 5 -i file.pdf
Thats all you need. file.ps is the file you need to convert. the result will be file.html

Sunday, December 10, 2006

e-mail to SMS (email2SMS )

We talked about how to set up a simple SMS based service before using free and open software. Next we'd look how we can use this in to more practical use. In this example I will try to demonstrate how to develop a simple e-mail to SMS solution. It is assumed that the mail server is an internal server on the local LAN (example the intranet server).

Here again we will use Linux but this can even be applied on FreeBSD and alike. We will use Kannel as the SMS gateway, postfix as the MTA. As for a MDA (mail deliver agent) we will use procmail. You need to install all of this on your system before we start. Also we will be again using Perl as the scripting language. The diagram below illustrates the simple over view of how the system works.

The system is designed to send sms using the internal mail system. The sender needs to be a predefined user of the mail system to use this system. A set number of sms recipients is set. Example send to 10 people (customers) with a single mail. Logs of emails sent will be kept on the system. System will also sent the sms to a given list of numbers; for each email (system usage).

To start off we first setup postfix. The default configuration of postfix is used. Please insert the following line to the postfix configuration file fount at /etc/postfix/. Append the line below to the file main.cf, to edit this file login as root and use a text editor like vim.

mailbox_command = /usr/bin/procmail

Explanation:
The mailbox_command parameter specifies the optional external command to use instead of mailbox delivery. The command is run as the recipient with proper HOME, SHELL and LOGNAME environment settings. Exception: delivery for root is done as $default_user. Other environment variables of interest: USER (recipient username), EXTENSION (address extension), DOMAIN (domain part of address), and LOCAL (the address localpart). Unlike other Postfix configuration parameters, the mailbox_command parameter is not subjected to $parameter substitutions.
- from the man pages -

IF YOU USE THIS TO DELIVER MAIL SYSTEM-WIDE, YOU MUST SET UP AN ALIAS THAT FORWARDS MAIL FOR ROOT TO A REAL USER.

To overcome the above issue please edit the fie aliases in /etc. Append the following line to the bottom of the page.

root: sms

also add the following line to file virtual at /etc/postfix.

@intranet.ourcompany.com sms

This will make the system to catch all mails to the sms user account.

Also add(modify) the following 2 line to the main.cf file.

myhostname = intranet.ourcompany.com
mydomain = ourcompany.com

Procmail configuration

create a file named .procmailrc in the /home/sms folder. Add the following line to the file and save the file.

TO=`formail -xTo:`
SUBJECT=`formail -xSubject: \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
SENDER=`formail -xFrom: \
| expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
BODY= `formail -I "" \
| expand | sed -e '1,/^$/ d' -e '1,/^$/ d'`
BODY=`formail -I "" `
SENDER=`formail -rtzxTo:`
:0
| perl /home/sms/massms/newsms.pl $SENDER $TO $SUBJECT $BODY >> /home/sms/massms/maillog.txt

The above configuration sets up variables for each required filed and then passes these as parameters to a scrip called newsms.pl located at /home/sms/massms/

The script (newsms.pl)
use POSIX qw(strtod);
use LWP::Simple;

#if ($#ARGV !=1) {
# print "usage :sendsms \n";
# exit;
#}

$from = $ARGV[0];
$number = $ARGV[1];
$subject = $ARGV[2];
$text = $ARGV[3];
$maxsend = 10;

print 'params: ' .$from . ' ' . $number . ' ' . $subject . ' '. $text . "\n";

sub getnum {
my $str = shift;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
$! = 0;
my($num, $unparsed) = strtod($str);
if (($str eq '') || ($unparsed != 0) || $!) {
return;
} else {
return $num;
}
}

sub trim($)
{
my $string = shift;
$string =~ s/^\s+//;
$string =~ s/\s+$//;
return $string;
}

my @orinum = split('@', $number);
print 'orinum: '. $orinum[0] . "\n";
$orinum[0] =~ s/^;
$orinum[0] = trim($orinum[0]);

$words = @ARGV;

$text= "";
for ($r=3;$r<=$words;$r++){
$text = $text . " " . $ARGV[$r];
}
$text = trim($text);
print 'text: '. $text . "\n";
#$text =~ s/<(.*?)>//gi;
# $orinum[0]=~ s/\D//gi;
#print $text;

@months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
@weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear, $daylightSavings) = localtime();
$year = 1900 + $yearOffset;
$theTime = "$hour:$minute:$second, $weekDays[$dayOfWeek] $months[$month] $dayOfMonth, $year";
print 'time: ' . $theTime;

sub authuser {
my ($fromuser) = @_;
print 'in function ' . $fromuser . "\n";
$okuser = 0;
my @user = split('@', $fromuser);
print 'passed to authuser as @: ' . @_ . "\n";
print 'the user:'. $user[0] ."\n";
open (CHECKBOOK, "/home/sms/massms/access.list") || die "couldn't open the access list file!";
print "file open \n";
while ($record = ) {
if (lc(trim($record)) eq lc(trim($user[0]))) {
$okuser = 1;
}
print lc(trim($record)) . " <> " . lc(trim($user[0])) . "\n";
}

close(CHECKBOOK);

return $okuser;
}

sub sendEmail
{
my ($eto, $efrom, $esubject, $emessage) = @_;
my $sendmail = '/usr/lib/sendmail';
open(MAIL, "|$sendmail -oi -t");
print MAIL "From: $efrom\n";
print MAIL "To: $eto\n";
print MAIL "Subject: $esubject\n\n";
print MAIL "$emessage\n";
close(MAIL);
}

$orimail = 'smsdemon@intranet.ourcompany.com';
print 'da user is: '. $from . "\n";
$isitoktosend = authuser($from);
my $sent = 0;
if ($isitoktosend eq 1) {
#if user is authorised to send sms
print "auth ok \n";
my @sendlist = split (',',$subject);
my $listcount = @sendlist;
print $listcount . ' > ' . $maxsend . "\n";
if ($listcount <= $maxsend) {
#send list cannot exceed more then maxsend if only less
print "in if list and max\n";
my $longnumbers = 'sms sent to ';
foreach (@sendlist) {
$ournumber = $_ ;
if ($ournumber =~ /^9609/i) { # all numbers should have 9609
my $url = 'http://127.0.0.1:5034/cgi-bin/sendsms?username=usr&password=password&from=' . $orinum[0] .'&to=' . $_ . '&text='. $text ;
$html = getprint ($url); # ok shoot to kannel to send sms
$lognumbers = $lognumbers . ',' . $_ ;
$sent = 1;
}
}
if ($sent eq 1) {
$lognumbers = $lognumbers . ' with the message : ' . $text;
sendEmail ($from, $orimail , 'sent sms status' , 'sms sent to ' . $lognumbers);
open(FILE,">>/home/sms/massms/log/sent.log") or die "cannot create file";
print FILE $theTime . ' ' . 'from:' . $from . ' ' . ' sent through: '. $number . ' >' . $lognumbers . "\n";
close(FILE);

# enable to send every time to follwing numbers the sms for control
my $alwayssendlist ='9609620001,9609620002'; #change as needed
my @loopsend = split(',',$alwayssendlist);
foreach (@loopsend) {
my $url = 'http://127.0.0.1:5034/cgi-bin/sendsms?username=user&password=password&from=' . $orinum[0] .'&to=' . $_ . '&text='. $text ;
$html = getprint ($url); # ok shoot to kannel to send sms
}

print "sent";
}
} else {
sendEmail ($from, $orimail , 'sent sms status' , 'error : cannot send to more then ' . $maxsend . ' numbers');
print "send list exceed err:";
}
} else {
# sendEmail ($from, $orimail , 'sent sms status' , 'error: sorry you do not have authorization to use this service');
print "cannot send";
}

A close look at the code. I've designed it to have some security levels. You can modify as you need. The control measures are that there is an access list. You need to have your email address in the access file for you to send the SMS. Next I have implemented a control to copy all SMS to a given list of numbers. These can be taken off the script as you wish. But the basic thing is there.

This demonstrates how simple and easy it is to get these sort of things done. Maybe next time I'd try to post about how to do the reverse. SMS2email. With little effort the script can be changed together with the system to bring better improvements.

Saturday, December 09, 2006

1980's, 1990's, 2000...


Been a long time... long long time. I remember my first Sinclair ZX Spectrum. I wrote my very first programs on it. BASIC was the language. When I needed to save them or load games, I had to connect it to our cassette player. I used the normal audio tapes. It did not come with a VDU. So I had to connect it to our TV. I never owned it, but was able to borrow it from a friend (who did not find any use of it), in exchange with my Atari 2600 game console.

We have come a long way since then. Today, we have access to almost everything. The internet is here, latest gadgets is in local shops, etc. Parents try to educate the kids about all this stuff, they teach computers with our "ABC". How have we changed? Better gamers? What has changed, what improvements have we seen or will see? The kids who had access to nothing but casio programmable calculators or the kids of today? Will the access to new improved hardware and information only enough? "Too much games"? Too much information? What can be the issue?. I have all these questions now. Are we improving; will we have a good generation of kids who will make us proud? Are they being directed in the right direction? Are they being motivated enough? Do they have a proper educational system? Back then, we did not have all these facilities and stuff, and it was too expensive. Not any kid was able to afford a computer. Things has changed now, but has it improved? Are the talented kids recognized and taken care of? I don't know. Yeah sure, we do get kids coming in after graduating. Make their parents happy and all. Make us all proud, but do they have enough skill or the talent? After they come back, or identified are they given the right opportunities to develop further?. I had a chat with a guy who's back from his studies after doing computing and the job he got was to work for a companies "HR" department. I know a real talented guy who's won first place in his class for his diploma and higher diploma from Singapore; who prints t-shirts for living. Is it just me who thinks something is wrong? Maybe.. I don't know, but this is how I feel about it. A few months back, I was looking for local programmers and system admins. Sad to say I was so frustrated not to find good people. I hope these will change and it will improve. At the same time I have been amazed at some kids skills, and talents.. I hope it does not go wasted too. Seen too many of that. The system and the lack of recognition is to blame? A stupid thought maybe...

The Island

Usually I spend all of my week ends at office. This Friday I thought I would take a break. Went out for a walk all around the island (Hulhumale'). Its mostly empty; except for a small area where people live, there is not much vegetation, since its all a man made island. Anyway I took some pictures and thought I'd share them. I don't own a camera; so just took them using my phone.

Road Flower

Badi Magoo & Bon'bigadu

What do you call them?

The road to Male'

Wednesday, December 06, 2006

Motivation or not Demotivating?

I was doing some research and came across an interesting article about why your employees are losing motivation by David Sirota, Louis A. Mischkind, and Michael Irwin Meltzer. In their opinion it is not about motivating employees, but about not demotivating them.

In the article they talk about the following three goals of employees:
* Equity: To be respected and to be treated fairly in areas such as pay, benefits, and job security.
* Achievement: To be proud of one's job, accomplishments, and employer.
* Camaraderie: To have good, productive relationships with fellow employees.
What shocked me was that according to this it saying that this is not strictly a top-down process and if the company doesn’t work that way you simply have no chance of achieving these goals for your employees. According to the article individual managers can make a difference for their employees, either for the better or worse. - The fact itself is not a big surprise, but having this statement in this article really surprised me.

I guess a lot of companies have these issues; but are often ignored. In the end its not the employees who loose, its the companies. I guess its high time for most of them to give more attention to HR issues. Productivity often is directly related to these factors. These are good things to study and learn from. Who knows might come in handy at a point in life.

what the f**k is Web 2.0 ?

We hear and talk about Web 2.0 so often now. Ask most of the web designers what is it? Hardly anyone is able to answer straight. Same went with me; I am not a web guy at all. But just want to be kept informed about these stuff that goes around us.

Anyway whats the big deal about this Web 2.0? The new world wide web? hmmm! now I don't think anyone should look at it that way. I guess for most people Web 2.0 means a combination of technologies implemented on to a web site, like namely AJAX, DHTML,RSS,CSS and a few. More to add to those, sites which are more interactive and open socially. Also I guess no longer we have simple web pages, mostly its small applications and systems. These systems should work inside a web browser ; without having to launch external applications.

I guess the biggest contributor to this vibe was and is google. But I guess nothing new has come up in reality or there is not much major new stuff, compared to the so called "Web 1.0". Its just the same stuff; with new names and with improvements. Yeah sure; there is new stuff, but maybe just based on the same old techniques and concepts. You throw out; ActiveX and Applets and bring in AJAX, etc. But over all the web has developed and maybe we call these new developments the "Web 2.0" era. For me the biggest change was things becoming more platform in depended. Also the fact that data is made more available and easy accessible.

As for us Maldivian and our sites, we need to improve too. Mostly the web sites are very static and too much focused on hard core graphics. Too much useless content and images. Yeah! the travel sites. They do have loads of content and pictures, but how informative and easy its to access them and locate what you are looking for. Simple things like that is ignored. We do see some improvements slowly, but I guess mostly the developers don't care much about web standards or any such issues. But I do sure hope and wanna see better stuff coming up.

Maybe I am not the right person to talk about web development and standards, so guys out there who are more experienced in this field would like to shed some light on this? What can we do to improve the looks and functionalities, what do we need to stop doing, etc.

Tuesday, December 05, 2006

wooo hoo!

my new toy.

Sunday, December 03, 2006

ripping web sites with perl

I was working on a small project, and thought I'd share part of its code. A lot of web sites like www.haveeru.mv and some travel web sites, like to display the local weather. Very often this is taken from global weather web sites, etc. I thought since we do have the local met department web sites; we could use it. All you need to do is modify the script to be more presentable for web pages.

Also this is an example which demonstrates how easy it is to rip data off external web sites using perl.


#!/usr/bin/perl 
use LWP::Simple;
use HTML::TreeBuilder;
use XML::Simple;

my $url = 'http://www.meteorology.gov.mv/?PD=WEATHER&ID=2';
my $page = get($url) or die $!;
my $p = HTML::TreeBuilder->new_from_content( $page );
my @links = $p->look_down(
_tag => 'table',
width => '656'
);
for my $row (@links) {
my @cells = $row->look_down( _tag => 'td' );
$text = join ( "\n", map { $_->as_trimmed_text( ) } @cells )."\n";
@lines = split(/\n/, $text);
}

$p = $p->delete; # don't need it anymore
print "\nWeather Forecast for Maldives\n";
for ($r=0;$r<6;$r+=2){
print $lines[$r] ." : " . $lines[$r+1]."\n";
}

$xml = new XML::Simple;
$raw = get('http://www.meteorology.gov.mv/xml.asp');
$data = $xml->XMLin($raw);

foreach my $ST ("HANIMAADHOO","MALE","KADHDHOO","KAADEDHDHOO","GAN") {
print "\n";
print ('Temp. for '.$ST .': '. $data->{STATIONS}->{$ST}->{TEMPERATURE}->{CELSIUS} .' . '
.'Wind speed: '. $data->{STATIONS}->{$ST}->{WIND}. ' . '.'Sun Rise: ' .$data->{STATIONS}->{$ST}->{SUN}->{RISE}
.' and set: '. $data->{STATIONS}->{$ST}->{SUN}->{SET} .' . '.'Rain Fall: '. $data->{STATIONS}->{$ST}->{RAINFALL}.'
. '
.'Humidity: '. $data->{STATIONS}->{$ST}->{HUMIDITY});

print "\n";
}


Friday, December 01, 2006

TVM , fahimagu ?

I don't watch TV much; specially the local TV. A few reason behind it; which rather not be discussed. Anyway I've seen parts of a few program called “fahimagu”. Its been around for sometimes now. The program is about computers and IT. A local presentation. One of my x student and a friend of mine presents it. Its good to see them on TV. Anyway the producers need to improve this program. I am really sorry to say its really bad; in term of content. I feel the program being a local presentation; it lacks local content a lot. Not much focus is given to the local IT or vibes. Yes; they do cover all major events; so does the news. But seriously if anyone knows the producers of this program they need to be told about this.

There is a lot they can cover and focus on; which I feel hardly they even know. IT is growing in the Maldives and we have new things everyday. Why not cover them, or try to make it more informative to the locals. I agree they do pick on local stuff every now and then, but I feel they can do better. End of the program the views should learn something new or get some information out of it. Whats the point in telling that MS Word is a word processor. We all know that. Educate us, enlighten us and entertain us. Maybe my expectations are too high?

So; what can they do to make a change. Well thats what they need to figure out. One suggestion I can think of is make people aware about current events and vibes. Talk about them discuss about them. Example www.mvblogs.org. There is so many out there who use it and so many bloggers now. But at the same time there is a lot of people who don't know what is blogging. The power of blogs and what it can do, etc. Simple things like these can be looked into. Recent events like www.dhivehin.net and other online communities and their contributions. WiFi networks in male', the forums,irc,etc. These are all good topics. Things like IT jobs in male', what the employers are looking for. Things like that. Other stuff like ; “will the marine fiber give me more speed, etc”? These are all areas that can be covered and which is good topics.

But then again; I wonder too. Do they really want the general public to know about these things? Internet already has caused so much problems (for some people) socially and politically. This might be a factor too, to keeping somethings closed and untouched. Again, I maybe wrong. I am told the country is in reform and more transparency is being introduced. Maybe soon we will see all this. Who knows?