Eid again!

Reward, its what God has transcribed it in clear words in His message for humanity. The love the sacrifice the wellbeing of His creatures is what Ramadan has been set for all of us. In a world of total deception, reflecting a true self is one hell of a challenge for all of philanthropists like me though I will urge all to not put a stop to charity initiatives. We are few percent of those who fast for a month. On the contrary, a myriad of fellow humans have to fast around the year [thanks to our capitalist society]. When I was kid, I always end up arguing with my pop about this ignorance of God to those who can’t even earn one time meal for their kids and my pop relied, “God has given you enough both in terms of this awareness and ample resources so you should reach out to those who are needy!”.

Wish you and your family a happy Eid! While you be celebrating with your loved ones please spare few minutes and bring smiles back to those street kids around the house 🙂

Categories: Uncategorized

List the languages of each countries

October 18, 2010 Leave a comment

Below is a list of actions that I have took to extract the languages of each countries. I am sharing the procedure so If you can suggest some optimal procedure to carry out the same task.

Steps:

  1. Visit the CIA world fact book page as mentioned above
  2. Copy that html code while holds the required data using Firebug
  3. Browse the file and copy the fields using pointer
  4. Paste the fields in the text file named languages.txt
  5. Learn how to read the file line by line from php manual
  6. Apply the following PHP script to filter out the data in terms of Country and Native languages

<?php
$myfile = ‘languages.txt’;
$lines = file($myfile);
for($i=count($lines);$i>0;$i–){

$arr = explode(‘ ‘, $lines[$i], 2); // Seperate Country and Native languages
$native = $arr[1]; // Only native languages sperated by “,”
echo “<pre>”;
echo $arr[0];
print_r(explode(‘,’, $native));
echo “</pre>”;
}
?>

What’s left:
Populating the database with the above extracted data.

Categories: Web Services Tags:

IP to country conversion

October 18, 2010 1 comment

Though there are a lot of available solutions to tackle this problem but the one reside in the Google Code is the perfect one with simplicity and ease of use. Below is the work around to setup a test case; –

Explore the code:

Visit the project’s profile and read about the documentation.

Download the code;

Get the latest code from the repo and extract it to the root directory of the web server. Linux – /var/www/phpip2country Windows – C:\xampp\htdocs\phpip2country

Test the code:

Browse the directory in the browser. http://localhost/phpip2country/index.php

You need to upload the sql file which is actually a mapper for IP and Countries.

Results:

IP: 127.0.0.1
IP numerical Value: 2130706433
IP registry: IANA
IP assigned (Y-m-d H:i:s): 1983-01-01 05:00:00
IP country RIR (Regional Internet Registry) representation: ZZ
IP Country Abbreviation: ZZZ
IP country name: RESERVED
IP range: array (
‘FROM’ => ‘127.0.0.0’,
‘TO’ => ‘127.255.255.255’,
)
IP range numerical: array (
‘FROM’ => ‘2130706432’,
‘TO’ => ‘2147483647’,
)
full IP informations array: array (
‘IP_FROM’ => ‘2130706432’,
‘IP_TO’ => ‘2147483647’,
‘REGISTRY’ => ‘IANA’,
‘ASSIGNED’ => ‘410227200’,
‘CTRY’ => ‘ZZ’,
‘CNTRY’ => ‘ZZZ’,
‘COUNTRY’ => ‘RESERVED’,
‘IP_STR’ => ‘127.0.0.1’,
‘IP_VALUE’ => 2130706433,
‘IP_FROM_STR’ => ‘127.0.0.0’,
‘IP_TO_STR’ => ‘127.255.255.255’,
)

Below is the output when the code has been set on a live server.

IP: 116.58.42.211
IP numerical Value: 1949969107
IP registry: APNIC
IP assigned (Y-m-d H:i:s): 2007-03-27 19:00:00
IP country RIR (Regional Internet Registry) representation: PK
IP Country Abbreviation: PAK
IP country name: PAKISTAN
IP range: array (
‘FROM’ => ‘116.58.0.0’,
‘TO’ => ‘116.58.127.255’,
)
IP range numerical: array (
‘FROM’ => ‘1949958144’,
‘TO’ => ‘1949990911’,
)
full IP informations array: array (
‘IP_FROM’ => ‘1949958144’,
‘IP_TO’ => ‘1949990911’,
‘REGISTRY’ => ‘APNIC’,
‘ASSIGNED’ => ‘1175040000’,
‘CTRY’ => ‘PK’,
‘CNTRY’ => ‘PAK’,
‘COUNTRY’ => ‘PAKISTAN’,
‘IP_STR’ => ‘116.58.42.211’,
‘IP_VALUE’ => 1949969107,
‘IP_FROM_STR’ => ‘116.58.0.0’,
‘IP_TO_STR’ => ‘116.58.127.255’,
)

Categories: Web Tools Tags: , ,

OpenInviter let’s drag friends

September 3, 2010 1 comment

OpenInviter is a fantastic edition to the open source widget domain. The purpose is pretty simple and straight forward that is dragging friends instantly.

Below is my 15mins interaction with that widget.

  • Get yourself register with the service. This is mandatory because the widget will use the private key generated for a particular user.
  • Extract the compress file in webserver root directory

#sudo tar zxvf openinviter-*.tar.gz

  • Fullfill the dependencies like wget and curl packages

$sudo apt-get install wget curl

  • Navigate the postinstall.php and look for the following output;-

Checking username and private key… *OK*
Checking PHP version… *OK*
Checking DOMDocument support… *OK*
Checking transport method… libcurl is installed. Using cURL to handle requests
SQLite is NOT installed. Unable to keep stats. This will not affect the OpenInviter modules since they will run without keeping any stats.
Checking write permisions… /tmp is writable. Using /tmp to store cookie files and logs
Checking for new versions of OpenInviter… Your OpenInviter software is up-to-date
Checking Abv… *OK*
Checking AOL… *OK*
Checking Apropo… *OK*
Checking Atlas… *OK*
Checking Aussiemail… *OK*
Checking Azet… *OK*
Checking Bigstring… *OK*
Checking Bordermail… *OK*
Checking Canoe… *OK*
Checking Care2… *NOT OK* – This plugin might not work correctly on your system
Checking Clevergo… *OK*
Checking Doramail… *OK*
Checking Evite… *OK*
Checking FastMail… *OK*
Checking 5Fm… *NOT OK* – This plugin might not work correctly on your system
Checking Freemail… *OK*
Checking Gawab… *OK*
Checking GMail… *OK*

  • Once done either delete the postinstall.php file or rename it.

# sudo mv /var/www/jump4tmp/openinviter/postinstall.php /var/www/jump4tmp/openinviter/postinstallDONE.php

  • For detail install instructions look for the install.txt file.
  • Navigate the openinviter root directory and look for config.php file while will set the settings of the widget

# sudo gedit /var/www/jump4tmp/openinviter/config.php

<?php
$openinviter_settings=array(
‘username’=>”register_user”, ‘private_key’=>”801cb788f47075fd3cf57328b7948527″, ‘cookie_path’=>”/tmp”, ‘message_body’=>”You are invited to http://website.com&#8221;, ‘message_subject’=>” is inviting you to http://website.com&#8221;, ‘transport’=>”curl”, ‘local_debug’=>”on_error”, ‘remote_debug’=>””, ‘hosted’=>””, ‘proxies’=>array(),
‘stats’=>””, ‘plugins_cache_time’=>”1800″, ‘plugins_cache_file’=>”oi_plugins.php”, ‘update_files’=>”1″, ‘stats_user’=>””, ‘stats_password’=>””);
?>

  • Adjust the file content according to you need like stayed above.
  • Finally navigate to the example.php in the browser to play around with the widget LIVE!

http://localhost/jump4temp/openinviter/example.php

 

example.php

openinviter/example.php

 

Flex development on Linux

September 2, 2010 1 comment

Hey guys, I hope there are lot of guys who are relying on linux distro like Ubuntu, centos or fedora to name some. As far as the developers, geeks and machine fanatics are concerned. Aftyer such an addiction it’s quite difficult to work back on Windows system for some specific reasons like previous was the case as flash development is restricted to windows based machines. But now as adobe took a nice decision to move to bit to open source society with their new open source flexsdk the dream to develop flash based application on the linux island come true. Now with a handful of simple plugins our distro will be up and ready to develop application in flash and actionscript.

1. Download the eclipse euorpa with JEE support (v3.2 or higher)
Visit the following link http://www.eclipse.org/downloads/
Look for Eclipse IDE for Java EE Developers
32bit: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/R/eclipse-jee-helios-linux-gtk.tar.gz
64bit: http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/helios/R/eclipse-jee-helios-linux-gtk-x86_64.tar.gz

or get a torrent: http://build.eclipse.org/technology/phoenix/torrents/jee/eclipse-jee-helios-linux-gtk.tar.gz.torrent

Move the tar file into /opt dir
# sudo mv eclipse-*.tar /opt

Untar the eclipse compress file
# sudo tar zxvf eclipse-*.tar
# sudo cd eclipse
# ./eclipse &

2. Install the following plugins

In the menu, we choose Help -> Install new software…

Click on the “Add…” button, and type the following:

Name: Eclipse IMP
Location: http://download.eclipse.org/technology/imp/updates/

Name: AXDT
Location: http://update.axdt.org/

Choose (at least) the following packages:
Axdt AS3 Feature
Flex3SDK Feature

Then click on the “Next >” button, accept the licence and proceed to install the AXDT + Flex SDK framework.

Once installed, restart Eclipse

Go to the menu: Window -> Open perspective -> Other… -> AXDT

That’s all what you need to get started with Flas application development.

Coming soon

Tutorial: Write and compile you first flex application

USB networking on mobile platforms

April 25, 2010 3 comments

After the dot com bubble the new bubble is surely mobile platforms.  The same trend is getting the hype in ma university where now lot of guys are working on mobile platforms and related technologies. Two of the guys are tease me with a lot of questions accordingly including Mr. Hassaan Masud and Mr. Humanyun Ali Daud.

Symbian:

Nokia network bridge

Which is a J2ME based api and can be downloaded from here. For a complete set of IP related application scan here. If you are a Linux guy then you are well aware of the importance of doing ssh on other machines here you go with a putty (.sis) for you symbian device. GNUBox is an application that let’s you share your machine’s internet with the device using USB.

Other applications repos: [1]

Windows Mobile:

You can connect your Windows mobile 6.0 or higher with you machine by following the following steps. By using the Virtual Machine Network Driver you can enable TCP/IP Networking on the Device Emulator.

Google Android:

Wow! Android is ma love :p the fantastic platform as far as mobile eco-system is concerned. There is one application called ConnecBot an port of linux terminal and a perfect SSH client. here’s an other how-to guide with HTC set.

Apple’s iPhone:


RIM’s Blackbery:


Palm’s WebOS:


OpenMoko’s Freerunner:

This is the world’s first Open source mobile phone both in terms of software and hardware. The USB networking on Openmoko has been well explained on it’s wiki which gives you the real feel of linux in your hands.

Flash-player for Mozilla Firefox

April 25, 2010 Comments off

I thing firefox should struggle a bit to make a contract with adobe on this regards which will save our time but in the mean while see the below methods to do it yourself.

From the tar file:-

unpack anywhere (as a root user)

# tar -zxvf install_flash_player_10_linux.tar.gz

Run the script

# ./flashplayer-installer

Copyright(C) 2002-2006 Adobe Macromedia Software LLC.  All rights reserved.

Adobe Flash Player 10 for Linux

Adobe Flash Player 10 will be installed on this machine.

You are running the Adobe Flash Player installer as a non-root user.
Adobe Flash Player 10 will be installed in your home directory.

Support is available at http://www.adobe.com/support/flashplayer/

To install Adobe Flash Player 10 now, press ENTER.

To cancel the installation at any time, press Control-C.

NOTE: Please exit any browsers you may have running.

Press ENTER to continue…

———– Install Action Summary ———–

Adobe Flash Player 10 will be installed in the following directory:

Mozilla installation directory  = /home/username/.mozilla

Proceed with the installation? (y/n/q): y

NOTE: Please ask your administrator to remove the xpti.dat from the
components directory of the Mozilla or Netscape browser.

Installation complete.

Perform another installation? (y/n): n

The flash plugin is installed now!

Or if the tar file just have the lib proceed with the following

copy unpacked ‘libflashplayer.so’ to ‘/usr/lib64/browser-plugins’ directory

# cp libflashplayer.so /usr/lib/browser-plugins

set permissions: ‘chmod 755 /usr/lib64/browser-plugins/libflashplayer.so’

# chmod 755  /usr/lib/browser-plugins/libflashplayer.so

From the repository:-

In Redhat :

# up2date  flash-plugin

In Suse:

# zypper in flash-player

Retrieving repository ‘openSUSE-11.2-Non-Oss’ metadata [\]

Expected errors:

System management is locked by the application with pid 4399 (/usr/sbin/packagekitd).
Close this application before trying again.

Fix:

Kill the process and rerun the command

# kill -9 <PID>

In Ubuntu:

Just visit youtube.com and a pop=up will appear asking you to install the required flash plugin it’s that simple!

Confirmation:

To confirm successful installation launch your Firefox browser and in the address bar type “about:plugins” and press enter.

Caution:

To install the plugin successfully it is advised to close all the instances of the firefox before running the plugin

Categories: How to Tags: , ,

Nokia Web Runtime WRT

April 23, 2010 1 comment
Categories: S60 Devices Tags: , , ,

Joomla installation on Ubuntu

April 23, 2010 2 comments

Today’s we are going to see how to use google map mashup in a famous CMS – Content Management System which is Joomla.  Though the documentation is self explanatory I’ll just list te common mistakes that fly-over testers make while installing Joomla but let me tell you experience developers (like Mr. Nabeel Mushtaq) always prefer to read the documentation evertime you you have to install some package or framework because it’s like the movie “The Matrix” every time you find something to grab!

Move the downloaded zip file of the Joomla package to webserver’s root directory;-

# mv /home/user-name/Downloads/Joomla***.zip /var/www/joomla

Unzip it here

# unzip Joomla***.zip

Delete the existing configuration.php-dist file

# rm -rf configuration.php-dist

Most users don’t perform the above step and just rename the filename

# mv configuration.php-dist configuration.php

Due to whish while running the web wizard or installation it causes problems as the script feels dizzy while updated the already populated configuration.php file

Create a new unwritten file

# toucj configuration.php

Give’em writes to apache users to writeable

# chmod 755 configuration.php

Some users while rename the configuration.php-dist file to configurtion.php while fall at the end of the web installation wizard with a fatal error.

If you got permission errors I would suggest you should give apache user the rights to read write the joomla folder

#chown www-data /var/www/joomla -R

That’s it!

Mail parsing via Ez Components

April 18, 2010 3 comments

Get started with EZ Components:

After spending ma 24hrs I landed on a blog where the guys have an excellent tutorial series to get started with Ez components in detail so skim it first here you go [1] Hello World![2]  Send an Email[3] RSS feed creation.

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

Pear Package Manager installation on Linux:

lynx -source http://pear.php.net/go-pear | php

sudo apt-get install lynx-cur

sudo apt-get install php5-cli

Ez Component using Pear Installed

pear channel-discover components.ez.no
pear install -a ezc/eZComponents

Setup include_path

Navigate to the following files and append the root PEAR directory.

/etc/php5/apache2/php.ini
/etc/php5/cli/php.ini

include_path=”.:/var/www/path/to/root/PEAR”

At the top of the code you wrote using ez libs

require_once(“ezc/Base/base.php”);  //depend of the installation method either pear or svn
function __autoload( $className )
{
ezcBase::autoload( $className );
}

Pre-requisites:

  1. Xampp
  2. Ez Components

Task 1: Receiving and Parsing emails:

In the code below we are going to receive emails from a remote server and parse it’s parts. Moreover we’ll tear down the attached files and move them to a separate directory for later processing.

<?php
$dir = dirname( __FILE__ );
require_once “$dir/../../ezcomponents-2009/Mail/docs/tutorial/tutorial_autoload.php”;

$options = new ezcMailPop3TransportOptions();
$options->ssl = true;
$pop3 = new ezcMailPop3Transport( “pop.gmail.com”, 995, $options  );
$pop3->authenticate( “sendmarks@gmail.com”, “cubesatlover” );
$pop3->status( $num, $size );
$messages = $pop3->listMessages();
$set = $pop3->fetchAll();
$parser = new ezcMailParser();
$mail = $parser->parseMail( $set );

//echo print_r($mail);

for ( $i = 0; $i < count( $mail ); $i++ )
{
echo formatMail( $mail[$i] );
}

function formatMail( $mail )
{
$t = ”;
$t .= “From:      “. formatAddress( $mail->from ). “<br />”;
$t .= “To:        “. formatAddresses( $mail->to ). “<br />”;
$t .= “Cc:        “. formatAddresses( $mail->cc ). “<br />”;
$t .= “Bcc:       “. formatAddresses( $mail->bcc ). “<br />”;
$t .= “Date:      “. date( DATE_RFC822, $mail->timestamp ).
“<br />”;
$t .= “Subject:   “. $mail->subject . “<br />”;
$t .= “MessageId: “. $mail->messageId . “<br />”;
$t .= “<br />”;
$t .= formatMailPart( $mail->body ) . “<br />”;
return $t . “<br /><br />”;
}

function formatMailPart( $part )
{
if ( $part instanceof ezcMail )
return formatMail( $part );

if ( $part instanceof ezcMailText )
return formatMailText( $part );

if ( $part instanceof ezcMailFile )
return formatMailFile( $part );

if ( $part instanceof ezcMailRfc822Digest )
return formatMailRfc822Digest( $part );

if ( $part instanceof ezcMailMultiPart )
return formatMailMultipart( $part );

die( “No clue about the “. get_class( $part ) . “<br />” );
}

function formatMailMultipart( $part )
{
if ( $part instanceof ezcMailMultiPartAlternative )
return formatMailMultipartAlternative( $part );

if ( $part instanceof ezcMailMultiPartDigest )
return formatMailMultipartDigest( $part );

if ( $part instanceof ezcMailMultiPartRelated )
return formatMailMultipartRelated( $part );

if ( $part instanceof ezcMailMultiPartMixed )
return formatMailMultipartMixed( $part );

die( “No clue about the “. get_class( $part ) . “<br />” );
}

function formatMailMultipartMixed( $part )
{
$t = ”;
foreach ( $part->getParts() as $key => $alternativePart )
{
$t .= “-MIXED-
$key——————————————————————
<br />”;
$t .= formatMailPart( $alternativePart );
}
$t .= “-MIXED
END———————————————————-<br />”;
return $t;
}

function formatMailMultipartRelated( $part )
{
$t = ”;
$t .= “-RELATED MAIN
PART———————————————————–<br />”;
$t .= formatMailPart( $part->getMainPart() );
foreach ( $part->getRelatedParts() as $key => $alternativePart )
{
$t .= “-RELATED PART
$key—————————————————–<br />”;
$t .= formatMailPart( $alternativePart );
}
$t .= “-RELATED
END——————————————————–<br />”;
return $t;
}

function formatMailMultipartDigest( $part )
{
$t = ”;
foreach ( $part->getParts() as $key => $alternativePart )
{
$t .= “-DIGEST-
$key—————————————————————–
<br />”;
$t .= formatMailPart( $alternativePart );
}
$t .= “-DIGEST
END———————————————————<br />”;
return $t;
}

function formatMailRfc822Digest( $part )
{
$t = ”;
$t .= “-DIGEST-ITEM-
$key————————————————————<br />”;
$t .= “Item:<br /><br />”;
$t .= formatMailpart( $part->mail );
$t .= “-DIGEST ITEM
END—————————————————-<br />”;
return $t;
}

function formatMailMultipartAlternative( $part )
{
$t = ”;
foreach ( $part->getParts() as $key => $alternativePart )
{
$t .= “-ALTERNATIVE ITEM
$key——————————————————-<br />”;
$t .= formatMailPart( $alternativePart );
}
$t .= “-ALTERNATIVE
END—————————————————-<br />”;
return $t;
}

function formatMailText( $part )
{
$t = ”;
$t .= “Original Charset: {$part->originalCharset}<br />”;
$t .= “Charset:          {$part->charset}<br />”;
$t .= “Encoding:         {$part->encoding}<br />”;
$t .= “Type:             {$part->subType}<br />”;
$t .= “<br />{$part->text}<br />”;
return $t;
}

function formatMailFile( $part )
{
$t = ”;
$t .= “Disposition Type: {$part->dispositionType}<br />”;
$t .= “Content Type:     {$part->contentType}<br />”;
$t .= “Mime Type:        {$part->mimeType}<br />”;
$t .= “Content ID:       {$part->contentId}<br />”;
$t .= “Filename:         {$part->fileName}<br />”;
$t .= “<br />”;
move_uploaded_file ( $part->fileName , “/var/www/vhosts/domain.com/
httpdocs/image.png”);
$t .= “<img src=’/image.png’>”;
return $t;
}

function formatAddresses( $addresses )
{
$fa = array();
foreach ( $addresses as $address )
{
$fa[] = formatAddress( $address );
}
return implode( ‘, ‘, $fa );
}

function formatAddress( $address )
{
$name = ”;
if ( !empty( $address->name ) )
{
$name = “{$address->name} “;
}
return $name . “<{$address->email}>”;
}

?>