Jul 30, 2010

Eco Fashion and Maldives


And in our Spring lineup, we have this lovely number.

Made entirely of plastic bags for the Environment day exhibition held at A.Dh  Hangnaameedhoo Madhrasa by two students; Reesh (9th Grade) and Iffath (10th Grade)

This sort of thing hardly ever gets the exposure it deserves.

Jul 28, 2010

Grab Dhiraagu ADSL usage from the terminal

UPDATE: There's a new version of the script out with more options and better configurability. Check it out HERE

Anybody who even occasionally stumbles on my blog should know full well by now that I have some personal beef with Dhiraagu. It's not that they suck..per se. It's just that I feel that they could, as a company, do much better.

Having said that, not having plain-text data available on the ADSL usage page (which incidentally has been trapped in a time-freeze-bubble since the 1960's) is just plain stupid on the part of whoever designed it. No matter though, where there is a will, there will be a way.

Previously I used to do it like this; Simply grabbing the graph image from the concerned page and popping it into eog so I can have a look.

wget --post-data "web_user=${username}&web_pass=${password}" -p http://dsl.dhivehinet.net.mv/login.php;eog ./dsl.dhivehinet.net.mv/comparision_graph.php;rm -r ./dsl.dhivehinet.net.mv

substitute ${username},${password} and eog as necessary.

But that wasn't enough..what If I wanted something in Conky or something to that effect? That would be a lot more convenient than having to look at that fart of a graph they have up there. So I came up with this simple solution.

SIMPLE but NOT ELEGANT... this is ugly, but it gets the job done.

#!/bin/bash
#simple "hack" to grab and decode the ADSL usage
#graph from Dhiraagu. No magic going on here.
#require caca-utils (img2text)
#
#2010 KudaNai - http://kudanai.blogspot.com
#-------------------------------------------------


username= #your username
password= #your password
package_allowance=20 #your_package allowance

cd /tmp
wget --quiet --post-data "web_user=${username}&web_pass=${password}" \
 -p http://dsl.dhivehinet.net.mv/login.php

gstring=$(img2txt -H 400 -W 4 -d none -f ansi dsl.dhivehinet.net.mv/comparision_graph.php) #yes...gstring
gtotal=$(echo "${gstring}" | grep 44 | wc -l) #blue colored line
gused=$(echo "${gstring}" | grep 43 | wc -l)  #yellow colored line
gbused=$(echo "scale=3;${gused} / ${gtotal} * ${package_allowance}" | bc -l)
gbleft=$(echo "scale=3;${package_allowance} - ${gbused}" | bc -l)

echo "used: \t${gbused} Gb\nleft:\t${gbleft}Gb\nAllow: \t${package_allowance}Gb"

rm -r dsl.dhivehinet.net.mv

Jul 25, 2010

Guitar Chords: Ey Hithaa

I don't know who the original artist of this song is, but the version I'm posting is the cover done by "Out of Doors" featuring the lovely Ms. Lubaina from their new album "Eyzamaanaa" (out now and available in select shops around the country - try ShellBeans)

If you think the Original was good, you should hear the new one :)

Enjoy.

{t:Ey hithaa}
{st:Out of Doors (Feat. Luba)}

{c:Intro chords A#m, D#m , F }
{c:Or play with Capo on 1st - Am,Dm,E}

[A#m]Beyvafaa heydhen vaanvee, [A#m]roohu beynunvaa araamu dh[D#m]eefaa eyhith[F]aa, eyhi[A#m]thaa
[A#m]Beynumeehey aniyaadheyn, [A#m]meyge vindhah fun araamu dh[D#m]eefa, eyhith[F]aa, eyhi[A#m]tha
[A#m]Loabi veynee karunaigaa [A#m]thehmanee hey dhen mih[D#m]aaru heefaa, eyhit[F]haa, eyhi[A#m]tha

[A#m]Loabi mee veyn libey th[D#m]oofaanakee hey, eyhi[F]thaa, eyhi[A#m]thaa

{c:Interlude Riff}

[A#m]Neydheme dhaaimee vey[D#m]naa mi hoonaa eyhi[Fm]thaa, eyhi[A#m]thaa

[A#m]Ashigen mee loabeegaa, [A#m]hadhahaa veyneh libey engeyhey, ey hi[F]thaa, eyhi[A#m]thaa
[A#m]Roohu loabin hehvaalaa [A#m]jaadhuvee hoonun ufaan[D#m]udhenhey ey hi[F]thaa, eyhi[A#m]thaa
[A#m]Ishqugaa, dhen mivee beyk[D#m]aaruvaan hey... ey hi[F]thaa, eyhi[A#m]thaa

Beyvafaa heydhen vaanvee, roohu beynunvaa araamu dheefaa eyhithaa
Beynumeehey aniyaadheyn, meyge vindhah fun araamu dheefa, eyhithaa..eyhithaa


And here is a youtube video of the original song.

Jul 21, 2010

DICT database for Dhivehi Radheef

An year ago I asked myself "wouldn't it be cool if you could lookup words from the Radheef right from gnome-dictionary?"

and so dict-radheef was born.... (bear with me)

a screenshot should give you an idea of what I'm talking about.


now isn't that just dandy?

Anyway I've put it all together in a neat little deb file for you kids to install. It should tell you all the dependencies and stuff. Grab it..install it..voila.

Setup

at this time, you'll need to setup a DICT server on your local machine (or intranet..however you wanna roll) if you're installing from the deb, it should grab all the necessities for you, and all you have to do is point gnome-dictionary to the local DICT server.

do do this, go to edit->preferences and click "add". Enter whatever in the fields except hostname. HOSTNAME: 127.0.0.1 and that's it.

for you hardcore types.
http://ubuntuforums.org/showthread.php?t=145949

Download

Jul 16, 2010

Overhaulin'

this sshiteskies are being updated yo..


Expect a few things to break in the meanwhile. Sorry about that..

Jul 5, 2010

To boldly go where I never thought I'd go...

Have you ever done something that you really wanted to do, but you doubted all the way through. Should I do it? Would it end in disaster or triumph? There's only one way to find out...

The choice has been made though... there is no turning back.

Jun 22, 2010

Dhiraagu webSMS Conduit

I posted a simple bash script a long time ago to try and ease the process of sending webSMS's. While the age when everybody around here was messing around with the service is long gone, I have personally found the service to be quite useful (it's free after all!), and still occasionally mess around with it. The script works through and through and has served it's purpose well over the ages. The problem however, was that it still required the exchange of a (relatively) large amount of data between the client (me) and the server(Dhiraagu). While this is inconsequential on a regular broadband connection, it is a problem on my rather expensive mobile data connection.

Thus, out of this particular need, and after a brief spurt of late night coding (4:00 am - 4:15am?) the following PHP script was born. It is to live on my hosted server, and there act as a "Conduit" between myself and Dhiraagu. As you can see, it is, more or less, a "port" of the original Bash script to PHP...and I hope the PHP gods won't rain thunder and rocks on my head for the horrible job I did of it.

An unexpected upshot of this however, is that it allows me to use it over SSL which I suppose is always a good thing.

 

Anyways...here be the thing.

Enjoy.

 

 

<?php
/*....
PHP script to act as a go-between for Dhiraagu websms
to minimize data-exchange. Ideally for use over a
mobile network.

just upload the php file to some place that supports
php_curl and make a standard GET request to the file
with the follwing parameters:

user,pass,num,msg,<cookie>

where cookie is optional, and is the session string of
an existing session.

The Script returns a JSON encoded status message.
*/

$old_error_handler = set_error_handler("myErrorHandler");
$SessionData=array(
'status' => 'OK',
'count' => NULL,
'cookie' => NULL,
'retries' => 0,
);

function terminate_now() {
global $SessionData;
echo json_encode($SessionData)."\n";
exit(1);
}

function myErrorHandler($errno, $errstr, $errfile, $errline)
{

global $SessionData;
if (!(error_reporting() & $errno)) {
return;
}

switch ($errno) {
case E_USER_ERROR:
$SessionData['status']="ERR: ".$errstr;
terminate_now();
break;

case E_USER_WARNING:
$SessionData['status']="WARN: ".$errstr;
break;

default:
$SessionData['status']="ERRUNKWN: ".$errstr;
terminate_now();
break;
}

return true;
}

function make_curl_request($url,$post_params,$useCookie) {

global $SessionData;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_params);
curl_setopt($ch,CURLOPT_COOKIESESSION,1);
if($useCookie) {
curl_setopt($ch,CURLOPT_COOKIE,'Dhi='.$SessionData['cookie']);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);

return $output;

}

function login()
{
global $SessionData;
$username=$_GET['user'];
$password=$_GET['pass'];

$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl',
'username='.urlencode($username).'&password='.urlencode($password),FALSE);

if(preg_match('/^Set-Cookie: Dhi=(.*?);/m', $return, $cookie_out)) {
$SessionData['cookie']=$cookie_out[1];

//CHECK DAILY QUOTA
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
if(($SessionData['count']=$msg_count[1])<1){ trigger_error('You have Reached your Daily Quota',E_USER_ERROR); } else { sendsms(); } } return true; } else { trigger_error('Invalid Username andor Password',E_USER_ERROR); return false; } } function sendsms() { global $SessionData; $number=$_GET['num']; $message=$_GET['msg']; if(strlen($message) > 140) {
trigger_error('Message Truncated',E_USER_WARNING);
$message=substr($message,0,140);
}

$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl',
'mobilenumber='.urlencode($number).'&message='.urlencode($message),TRUE);

//VALIDATE THE RETURN STUFF
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
$SessionData['count']=$msg_count[1];
} else {
if(($SessionData['retries']++)>3){
trigger_error('maximum number of retries exceeded',E_USER_ERROR);
}
login();
}

}

if (isset($_GET['user']) && isset($_GET['pass']) && isset($_GET['msg']) && isset($_GET['num'])) {
if(preg_match("/^7[4-9][0-9]{5}$/",$_GET['num'],$number)){
$_GET['num']=$number[0];
} else {
trigger_error('Invalid Number Format',E_USER_ERROR);
}
} else {
trigger_error('Insufficiant Arguments',E_USER_ERROR);
}

if(isset($_GET['cookie'])){
$SessionData['cookie']=$_GET['cookie'];
sendsms();
} else {
login();
}

terminate_now();
?>

Dhiraagu webSMS Conduit

I posted a simple bash script a long time ago to try and ease the process of sending webSMS's. While the age when everybody around here was messing around with the service is long gone, I have personally found the service to be quite useful (it's free after all!), and still occasionally mess around with it. The script works through and through and has served it's purpose well over the ages. The problem however, was that it still required the exchange of a (relatively) large amount of data between the client (me) and the server(Dhiraagu). While this is inconsequential on a regular broadband connection, it is a problem on my rather expensive mobile data connection.

Thus, out of this particular need, and after a brief spurt of late night coding (4:00 am - 4:15am?) the following PHP script was born. It is to live on my hosted server, and there act as a "Conduit" between myself and Dhiraagu. As you can see, it is, more or less, a "port" of the original Bash script to PHP...and I hope the PHP gods won't rain thunder and rocks on my head for the horrible job I did of it.

An unexpected upshot of this however, is that it allows me to use it over SSL which I suppose is always a good thing.

 

Anyways...here be the thing.

Enjoy.

 

 

<?php
/*....
PHP script to act as a go-between for Dhiraagu websms
to minimize data-exchange. Ideally for use over a
mobile network.

just upload the php file to some place that supports
php_curl and make a standard GET request to the file
with the follwing parameters:

user,pass,num,msg,<cookie>

where cookie is optional, and is the session string of
an existing session.

The Script returns a JSON encoded status message.
*/

$old_error_handler = set_error_handler("myErrorHandler");
$SessionData=array(
'status' => 'OK',
'count' => NULL,
'cookie' => NULL,
'retries' => 0,
);

function terminate_now() {
global $SessionData;
echo json_encode($SessionData)."\n";
exit(1);
}

function myErrorHandler($errno, $errstr, $errfile, $errline)
{

global $SessionData;
if (!(error_reporting() & $errno)) {
return;
}

switch ($errno) {
case E_USER_ERROR:
$SessionData['status']="ERR: ".$errstr;
terminate_now();
break;

case E_USER_WARNING:
$SessionData['status']="WARN: ".$errstr;
break;

default:
$SessionData['status']="ERRUNKWN: ".$errstr;
terminate_now();
break;
}

return true;
}

function make_curl_request($url,$post_params,$useCookie) {

global $SessionData;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_AUTOREFERER,1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch, CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post_params);
curl_setopt($ch,CURLOPT_COOKIESESSION,1);
if($useCookie) {
curl_setopt($ch,CURLOPT_COOKIE,'Dhi='.$SessionData['cookie']);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$output = curl_exec($ch);
curl_close($ch);

return $output;

}

function login()
{
global $SessionData;
$username=$_GET['user'];
$password=$_GET['pass'];

$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/index.pl',
'username='.urlencode($username).'&password='.urlencode($password),FALSE);

if(preg_match('/^Set-Cookie: Dhi=(.*?);/m', $return, $cookie_out)) {
$SessionData['cookie']=$cookie_out[1];

//CHECK DAILY QUOTA
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
if(($SessionData['count']=$msg_count[1])<1){ trigger_error('You have Reached your Daily Quota',E_USER_ERROR); } else { sendsms(); } } return true; } else { trigger_error('Invalid Username andor Password',E_USER_ERROR); return false; } } function sendsms() { global $SessionData; $number=$_GET['num']; $message=$_GET['msg']; if(strlen($message) > 140) {
trigger_error('Message Truncated',E_USER_WARNING);
$message=substr($message,0,140);
}

$return=make_curl_request('http://websms.dhimobile.com.mv/cgi-bin/websms/send_message.pl',
'mobilenumber='.urlencode($number).'&message='.urlencode($message),TRUE);

//VALIDATE THE RETURN STUFF
if(preg_match('/send (.*?) more/',$return,$msg_count)) {
$SessionData['count']=$msg_count[1];
} else {
if(($SessionData['retries']++)>3){
trigger_error('maximum number of retries exceeded',E_USER_ERROR);
}
login();
}

}

if (isset($_GET['user']) && isset($_GET['pass']) && isset($_GET['msg']) && isset($_GET['num'])) {
if(preg_match("/^7[4-9][0-9]{5}$/",$_GET['num'],$number)){
$_GET['num']=$number[0];
} else {
trigger_error('Invalid Number Format',E_USER_ERROR);
}
} else {
trigger_error('Insufficiant Arguments',E_USER_ERROR);
}

if(isset($_GET['cookie'])){
$SessionData['cookie']=$_GET['cookie'];
sendsms();
} else {
login();
}

terminate_now();
?>

Jun 12, 2010

Bulk responding to facebook wallposts

So it happens that my birthday is coming up, and like last year there's bound to be a shitload of posts on my Facebook wall...and like last time I'm probably expected to respond to said posts otherwise I'd be "rude".

Here's the dilema though, I can't be bothered to spend all the time going through the wall, clicking on links..responding blah blah. What I'd like to do, is respond to all of them in bulk. So here's my solution...

1.download all wallposts to a csv file
2.edit said csv file and add responses to those posts that i want to respond to
3.send off said responses.

How-to after the jump

May 10, 2010

If I'm going down...

I ain't dead yet folks. Not that I think anybody cares much. The last few months have been a bad time for me, as I've been trying to get my life back in order and sort out my priorities... mostly I've been trying to get off my ass.

and It's working... as you can see (yes I know this is a little vain, but I'm rather proud of my achievement)

arrghh...fancybox is not workeh