Archive for June, 2009

Create short links using bit.ly from php

bit.ly is a simple url shortner which has an api , which can be called from within php to shorten links.
Code :

function get_short_url($url)
{
$bitly_login = "your_login_name";
$bitly_apikey = "your_api_key";

$api_call = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=".$bitly_login."&apiKey=".$bitly_apikey);

$bitlyinfo=json_decode(utf8_encode($api_call),true);

if ($bitlyinfo['errorCode'] == 0)
{
return $bitlyinfo['results'][urldecode($url)]['shortUrl'];
}
else
{
return false;
}
}

Create a deb file from source on Ubuntu

To create a .deb package file on Ubuntu you need a utility called checkinstall.sudo apt-get install checkinstall
1. Extract the source of the application in a folder.2. Run : ./configure3. Run : make4. Now run : sudo checkinstall

Put flash in webpage – html page

Here is the simple code to put flash animation (swf file) on a webpage.

<object width="550" height="350" data="myalbum.swf" type="application/x-shockwave-flash">
<param name="quality" value="high" />
<param name="id" value="tech" />
<param name="name" value="tech" />
<param name="src" value="myalbum.swf" />
</object>

Screen Resolution 1440 x 900 in Ubuntu

Ubuntu 9.04 did not detect the native resolution of my new LCD monitor which was 1440 x 900.
Fix :
1. Get the modeline for the required resolution + refresh rate using the gtf command.
desktop:~$ gtf 1440 900 75

Draw – Plot graphs with mootools

Plootr is a useful library based on mootools 1.11 which can be used to plot bar graphs , line graphs and pie charts.
It is similar to Plotkit which is based on Mochikit javascript framework.