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

Read the rest of this entry »

Popularity: 19% [?]

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.

Read the rest of this entry »

Popularity: 8% [?]

Raw Sockets C Source Code on Linux

The structure of IP Header as given by RFC 791 is :

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Read the rest of this entry »

Popularity: 12% [?]

SYN Flood DOS Attack with C Source Code

TCP/IP 3-way handshake is done to establish a connection between a client and a server. The process is :

1. Client –SYN Packet–> Server
2. Server –SYN/ACK Packet –> Client
3. Client –ACK Packet –> Server

Read the rest of this entry »

Popularity: 22% [?]

Top Games on Ubuntu Linux

So here is a list of games which can be played on Ubuntu.

On Ubuntu 8.10

1. TORCS – The Open Racing Car Simulator – Racing game

Read the rest of this entry »

Popularity: 42% [?]

Get Country City from IP address in PHP

Here is a simple php script that lets you track the location of the visitor’s on your site using his IP address.

Code:

<?
$ip = $_SERVER['REMOTE_ADDR'];
$url = "http://www.ipmango.com/api.php?ip=".$ip;
$xml = simplexml_load_file($url);
echo "IP address : {$xml->ipaddress}";
echo "City : {$xml->city}";
echo "Region : {$xml->region}";
echo "Country Name : {$xml->countryname}";
echo "Latitude : {$xml->latitude}";
echo "Longitude : {$xml->longitude}";
?>

Read the rest of this entry »

Popularity: 36% [?]

Parse and Format Dates between PHP and Mysql

Mysql Database stores dates in the format :
yyyy-mm-dd e.g. 2009-04-15

Whereas humans are more used to the formats like :
dd-mm-yyyy or mm-dd-yyyy e.g. 21-04-2009

And while reading a format like :
dd-Month-yyyy is more usable e.g. 21-Mar-2009

Read the rest of this entry »

Popularity: 4% [?]

PHP Database Class to access Mysql

This is a simple class that evolved out of the php code I wrote so far.
It has the following functions :

1. dbms() – The constructor to do the initialisation like connecting to the database etc.
2. query($query) – The method to take a sql string and perform the query.
3. close() – Close the database connection
4. backup() – Create a backup of the database as an sql file and then zip it.
5. restore() – Restore database from a zip file which was created using the previous function backup()
6. get_last_insert_id() – Get the id from the last INSERT statement using the LAST_INSERT_ID() function of mysql database.
7. indb($table , $field , $value) – Checks whether a value of $value already exists in the $field column of a table $table. e.g. checking whether a username or an email already exists or not.

Read the rest of this entry »

Popularity: 2% [?]

Restore Mysql Database from a sql or zip file using PHP

In the previous post we saw how the backup of a database can be taken in the form of a sql file and then zipped.

Read the rest of this entry »

Popularity: 3% [?]

Backup mysql database with php and zip it

PHP can be used to backup a mysql database and make a zip file of it.

mysqldump is the utility which can be used to perform this function of backing up a mysql database as sql file. The command would be like this :
mysqldump –user={$username} –password={$password} –quick –add-drop-table –add-locks –extended-insert –lock-tables –all {$db} > backups/backup.sql

Read the rest of this entry »

Popularity: 4% [?]