Search This Blog

Thursday, May 28, 2009

Amazing Treessss.....



Then &&&&&& Now

Now and then a thought comes to my mind
What if I could the clock unwind!!
Return to being a child once more
Ah! that wondrous age of four!



Then...
Life meant playing and reciting nursery rhymes
Dabbling with crayons and making colorful drawings.

Now...
To play one needs to be organized too
Join a play school at the tender age of two!



Then...
Mummy was my first teacher
Lovingly teaching me values which help in life later.

Now...
Mom's busy - working, socializing, and attending kitty parties
Child seems to be low on her priority!



Then...
If mummy had to go, grandma was there
Showering me with her love and care.

Now...
Left with housekeepers and maids
In front of the television passes the day.


Then...
I had never heard words like failure and rejection
Nor faced gruesome interviews for admission!

Now...
A three year old goes for tuition
To enter a prestigious school - the ultimate mission!



Then...
Holidays meant family get togethers, fun and enjoyment
At a relaxed pace honing our talents.

Now...
It's summer camps... professional guidance
Ever decreasing parental influence!



Then...
I had no computer games, no mobiles
No rat race to cover that extra mile!



Now...
Under peer pressure, childhood is wilting away
Competing with the Jones... whatever way!



Then...
The choices I was offered
did commensurate with my age.

Now...
Kids are burdened with choices
they are not mature enough to make!



Now and then I ponder
why kids are being propelled towards adulthood
Even before they have had a proper childhood?

Days.....

New Year's Day - January 1
Australia Day - January 26
Groundhog Day - February 2
Darwin Day - February 12
Valentine's Day - February 14
Texas Independence Day - March 2
International Women's Day - March 8
Pi Day - March 14
Saint Patrick's Day - March 17
April Fools Day - April 1
Children's Book Day - April 2
Earth Day - April 22
Labour Day - May 1
Mother's Day - May 11
Telecommunication Day - May 17
International Day for Biological Diversity - May 22
Towel Day - May 25
World Ocean Day - June 8
Canada Day - July 1
U.S.A. Day of Independence - Fourth of July
Victory over Japan Day - August 14/August 15
World Rubber Day - September 12
International Talk Like a Pirate Day - September 19
European Day of Languages - 26 September
German Unity Day - October 3
Boss' Day- Oct 16
Mole Day - October 23
Halloween - October 31
All Saints' Day - November 1
Day of the Dead - November 1(All Saints' Day) or November 2(All Souls' Day).
All Souls' Day - November 2
Armistice Day (also Remembrance Day) - November 11
Veterans Day - November 11
Transgender Day of Remembrance - November 20
Cities for Life Day - November 30


AND MANY MORE..................................

Linux command similar to history, list last used commands.

Linux command similar to history, list last used commands.

accton, lastcomm - accouting on and last command. This is
a way to monitor users on your system. As root, you
would implement this as follows:

$ accton -h
Usage: accton [-hV] [file]
[--help] [--version]

The system's default process accounting file is /var/account/pacct.

Note the default file location is /var/account/pacct so we'll turn
it on system wide with the following command.

$ accton /var/account/pacct

Now take a look at this file. It will grow. To see command that
are executed, use the lastcomm command.

$ lastcomm

The above command gives output for all users. To get the data
for user "chirico" execute the following command:

$ lastcomm --user chirico

You can also get a summary of commands with sa.

[chirico@big ~]$ sa
30 5.23re 0.00cp 10185k
11 4.83re 0.00cp 8961k ***other
8 0.13re 0.00cp 19744k nagios*
4 0.00re 0.00cp 2542k automount*
3 0.00re 0.00cp 680k sa
2 0.13re 0.00cp 17424k check_ping
2 0.13re 0.00cp 978k ping

To turn off accounting, execute accton without a filename.

$ accton

Linux command similar to history, list last used commands.

accton, lastcomm - accouting on and last command. This is
a way to monitor users on your system. As root, you
would implement this as follows:

$ accton -h
Usage: accton [-hV] [file]
[--help] [--version]

The system's default process accounting file is /var/account/pacct.

Note the default file location is /var/account/pacct so we'll turn
it on system wide with the following command.

$ accton /var/account/pacct

Now take a look at this file. It will grow. To see command that
are executed, use the lastcomm command.

$ lastcomm

The above command gives output for all users. To get the data
for user "chirico" execute the following command:

$ lastcomm --user chirico

You can also get a summary of commands with sa.

[chirico@big ~]$ sa
30 5.23re 0.00cp 10185k
11 4.83re 0.00cp 8961k ***other
8 0.13re 0.00cp 19744k nagios*
4 0.00re 0.00cp 2542k automount*
3 0.00re 0.00cp 680k sa
2 0.13re 0.00cp 17424k check_ping
2 0.13re 0.00cp 978k ping

To turn off accounting, execute accton without a filename.

$ accton

Display all system settings in linux.

Display all system settings in linux
Linux command to get system settings

[root@vikas Desktop]# getconf HOST_NAME_MAX
64
[root@vikas Desktop]#

Query all system settings with
getconf -a

Display all system settings or configirations.

[root@vikas Desktop]# getconf HOST_NAME_MAX
64
[root@vikas Desktop]#

Query all system settings with
getconf -a

List of rpms with size & name in order

rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n


To view rpm file contents
rpm -qlp file-package.name.rpm


To get info about rpm package itself
rpm -qip file-package.name.rpm


To extract or open rpm file in current directory:
rpm2cpio file.rpm | cpio -idmv

List of rpms with size & name in order

rpm -q -a --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n


To view rpm file contents
rpm -qlp file-package.name.rpm


To get info about rpm package itself
rpm -qip file-package.name.rpm


To extract or open rpm file in current directory:
rpm2cpio file.rpm | cpio -idmv

How to calculate subnet mask?

whatmask - This is a subnet mask notation conversion tool. Or a
Tool for calculating available host address ranges with CIDR
notation input.

[root@vikas Desktop]# whatmask 192.168.4.0/24

------------------------------------------------
TCP/IP NETWORK INFORMATION
------------------------------------------------
IP Entered = ..................: 192.168.4.0
CIDR = ........................: /24
Netmask = .....................: 255.255.255.0
Netmask (hex) = ...............: 0xffffff00
Wildcard Bits = ...............: 0.0.0.255
------------------------------------------------
Network Address = .............: 192.168.4.0
Broadcast Address = ...........: 192.168.4.255
Usable IP Addresses = .........: 254
First Usable IP Address = .....: 192.168.4.1
Last Usable IP Address = ......: 192.168.4.254

[root@vikas Desktop]#

if whatmask command is not found,
just do
yum install whatmask

How to calculate subnet mask?

whatmask - This is a subnet mask notation conversion tool. Or a
Tool for calculating available host address ranges with CIDR
notation input.

[root@vikas Desktop]# whatmask 192.168.4.0/24

------------------------------------------------
TCP/IP NETWORK INFORMATION
------------------------------------------------
IP Entered = ..................: 192.168.4.0
CIDR = ........................: /24
Netmask = .....................: 255.255.255.0
Netmask (hex) = ...............: 0xffffff00
Wildcard Bits = ...............: 0.0.0.255
------------------------------------------------
Network Address = .............: 192.168.4.0
Broadcast Address = ...........: 192.168.4.255
Usable IP Addresses = .........: 254
First Usable IP Address = .....: 192.168.4.1
Last Usable IP Address = ......: 192.168.4.254

[root@vikas Desktop]#

if whatmask command is not found,
just do
yum install whatmask

How to create a sequence? seq command

-f -- format

[root@vikas ~]# seq -f "vikas%03g" 5
vikas001
vikas002
vikas003
vikas004
vikas005
[root@vikas ~]#

How to create a sequence? seq command

-f -- format

[root@vikas ~]# seq -f "vikas%03g" 5
vikas001
vikas002
vikas003
vikas004
vikas005
[root@vikas ~]#

Seq commnd. How to print sequence of numbers using linux command?

seq - print a sequence of numbers

$seq 10
$seq -s "+" 10
$seg -s "+" 10 | bc

e.g
Factorial using linux command

seq -s "*" 5 | bc

Seq commnd. How to print sequence of numbers using linux command?

seq - print a sequence of numbers

$seq 10
$seq -s "+" 10
$seg -s "+" 10 | bc

e.g
Factorial using linux command

seq -s "*" 5 | bc

Wednesday, May 27, 2009

Input using dialog command or inputing in script using input box

Script
----------------------------------------------------------------------------
dialog --title "Input Box" --inputbox "Enter your name" 8 60 2>/tmp/inputTmp.$$
sel=$?
name=`cat /tmp/inputTmp.$$`

case $sel in
0) echo "Hello $name" ;;
1) echo "Cancel Pressed" ;;
255) echo "ESC key pressed" ;;
esac

rm -f /tmp/inputTmp.$$

Input using dialog command or inputing in script using input box

Script
----------------------------------------------------------------------------
dialog --title "Input Box" --inputbox "Enter your name" 8 60 2>/tmp/inputTmp.$$
sel=$?
name=`cat /tmp/inputTmp.$$`

case $sel in
0) echo "Hello $name" ;;
1) echo "Cancel Pressed" ;;
255) echo "ESC key pressed" ;;
esac

rm -f /tmp/inputTmp.$$

Dialog command example, how to make alerts in script?

dialog display dialog boxes from shell scripts

e.g

dialog --title "You Title" --yesno "\nDo you want to do this" 7 40
sel=$?
case $sel in
0) echo "You Clicked Yes";;
1) echo "You Clicked No";;
255) echo "Canceled by user by pressing ESC key";;
esac

Dialog command example, how to make alerts in script?

dialog display dialog boxes from shell scripts

e.g

dialog --title "You Title" --yesno "\nDo you want to do this" 7 40
sel=$?
case $sel in
0) echo "You Clicked Yes";;
1) echo "You Clicked No";;
255) echo "Canceled by user by pressing ESC key";;
esac

Tuesday, May 19, 2009

Creating shared object of C files for php usage [SWIG Usage]

STEP1 Create a C file
eg sofile.c
===========================================
#include

void fun_in_so()
{
printf("This is function called from so");
}
int add_param(int x,int y)
{
return(x+y);
}
===========================================

STEP2 Create a file and list all C functions there and include C file as well
example.i
================================================
%module example
%include cpointer.i
%include typemaps.i
%include phppointers.i
%pointer_functions(int,intp)


#define PI 3.14159
#define VIKAS 123456
#define ANKIT "asdgasdgfasf"

%{
#include "sofile.c"
%}

extern void fun_in_so(void);
extern int add_param(int x,int y);

================================================

STEP3 Commands
swig -php example.i
[Above command will create three files example_wrap.c php_example.h, example.php ]
gcc `php-config --includes` -fpic -c example_wrap.c
[Above command will create example_wrap.o file]
gcc -shared example_wrap.o -o example.so
[Above command will create example.so file]
cp example.so /usr/lib/php/modules/


STEP4 Create a php file and call c functions
php sofile.php
================================================
dl("example.so");
echo PI;
echo "\n";
echo VIKAS;
echo "\n";
echo ANKIT;
echo "\n";
fun_in_so();
echo "\n";
$aa = add_param(2, 4);
echo "\nRes = $aa";
?>

OUTPUT
[root@vikas so]# php sofile.php
3.14159
123456
asdgasdgfasf

This is function called from so
Res = 6
[root@vikas so]#

=================================================

How to create & use a .so (Shared Object) file.

STEP1 Create a C file having a function.
eg fun_with_so.c
=============================================
#include
extern void fun_from_so(void);
void fun_from_so()
{
printf("This is function called from so");
}
===========================================

STEP2 Create a C file that uses function from shared object Library i.e using fun_with_so()
eg using_so.c
============================================
#include
main()
{
fun_from_so();
}
=============================================

STEP3 Command to create .so file of fun_with_so.c
$ gcc -o fun_with_so.so -shared fun_with_so.c
This will create fun_with_so.so file.
Copy fun_with_so.so ro /lib or in includes

STEP4 Command to complie & linking C file with .so file
$ gcc using_so.c fun_with_so.so
This will create an a.out binary. [ you can change name with -o option]

STEP5 OUTPUT run binary on terminal............
[root@vikas so]# ./a.out
This is function called from so[root@vikas so]#

Tuesday, May 12, 2009

Some Command Line / Terminal Tips....

Key or key combination Function

Ctrl+A Move cursor to the beginning of the command line.

Ctrl+C End a running program and return the prompt,

Ctrl+D Log out of the current shell session, equal to typing exit or logout.

Ctrl+E Move cursor to the end of the command line.

Ctrl+H Generate backspace character.

Ctrl+L Clear this terminal.

Ctrl+R Search command history,

Ctrl+Z Suspend a program,

ArrowLeft and ArrowRight --- Move the cursor one place to the left or right on the command line, so that you can
insert characters at other places than just at the beginning and the end.

ArrowUp and ArrowDown -- Browse history. Go to the line that you want to repeat, edit details if necessary,
and press Enter to save time.

Shift+PageUp and Shift+PageDown --- Browse terminal buffer (to see text that has "scrolled off" the screen).


Tab -- Command or filename completion; when multiple choices are possible, the system
will either signal with an audio or visual bell, or, if too many choices are possible,
ask you if you want to see them all.

Tab Tab -- Shows file or command completion possibilities.

Some Command Line / Terminal Tips....

Key or key combination Function

Ctrl+A Move cursor to the beginning of the command line.

Ctrl+C End a running program and return the prompt,

Ctrl+D Log out of the current shell session, equal to typing exit or logout.

Ctrl+E Move cursor to the end of the command line.

Ctrl+H Generate backspace character.

Ctrl+L Clear this terminal.

Ctrl+R Search command history,

Ctrl+Z Suspend a program,

ArrowLeft and ArrowRight --- Move the cursor one place to the left or right on the command line, so that you can
insert characters at other places than just at the beginning and the end.

ArrowUp and ArrowDown -- Browse history. Go to the line that you want to repeat, edit details if necessary,
and press Enter to save time.

Shift+PageUp and Shift+PageDown --- Browse terminal buffer (to see text that has "scrolled off" the screen).


Tab -- Command or filename completion; when multiple choices are possible, the system
will either signal with an audio or visual bell, or, if too many choices are possible,
ask you if you want to see them all.

Tab Tab -- Shows file or command completion possibilities.

Saturday, May 9, 2009

Digit Vaildation in Java Script

// Java Script Code
[script]
function OnlyDig(val)
{
var exp = /[^\d]/g;
//The variable exp is the regular expression for digits only."[^\d]" means that all characters of keyboard except digits."/g" is used to validate all occurrences in a textbox.
//alert("digit only");
var a=val.value;
if ( a.match( exp ) )
alert("digit only");
val.value = val.value.replace(exp,'');
}

[/script]


// HTML LINE
[input type="text" name="txt" id="txtid" onkeyup="OnlyDig(this)" /]

Tuesday, May 5, 2009

IP Address Classes

The address class determined the potential size of the network. The class of an address specified which of the bits were used to identify the network, the network ID, or which bits were used to identify the host ID, host computer. It also defined the total number of hosts subnets per network. There were five classes of IP addresses: classes A through E.
Class A: Class A addresses are specified to networks with large number of total hosts. Class A allows for 126 networks by using the first octet for the network ID. The first bit in this octet, is always set and fixed to zero. And next seven bits in the octet is all set to one, which then complete network ID. The 24 bits in the remaining octets represent the hosts ID, allowing 126 networks and approximately 17 million hosts per network. Class A network number values begin at 1 and end at 127.

Class B: Class B addresses are specified to medium to large sized of networks. Class B allows for 16,384 networks by using the first two octets for the network ID. The two bits in the first octet are always set and fixed to 1 0. The remaining 6 bits, together with the next octet, complete network ID. The 16 bits in the third and fourth octet represent host ID, allowing for approximately 65,000 hosts per network. Class B network number values begin at 128 and end at 191.

Class C: Class C addresses are used in small local area networks (LANs). Class C allows for approximately 2 million networks by using the first three octets for the network ID. In class C address three bits are always set and fixed to 1 1 0. And in the first three octets 21 bits complete the total network ID. The 8 bits of the last octet represent the host ID allowing for 254 hosts per one network. Class C network number values begin at 192 and end at 223.

Class D and E: Classes D and E are not allocated to hosts. Class D addresses are used for multicasting, and class E addresses are not available for general use: they are reserved for future purposes.

Class Leftmost bits Start address Finish address
A 0xxx 0.0.0.0 127.255.255.255
B 10xx 128.0.0.0 191.255.255.255
C 110x 192.0.0.0 223.255.255.255
D 1110 224.0.0.0 239.255.255.255
E 1111 240.0.0.0 255.255.255.255

IP Address Classes

The address class determined the potential size of the network. The class of an address specified which of the bits were used to identify the network, the network ID, or which bits were used to identify the host ID, host computer. It also defined the total number of hosts subnets per network. There were five classes of IP addresses: classes A through E.
Class A: Class A addresses are specified to networks with large number of total hosts. Class A allows for 126 networks by using the first octet for the network ID. The first bit in this octet, is always set and fixed to zero. And next seven bits in the octet is all set to one, which then complete network ID. The 24 bits in the remaining octets represent the hosts ID, allowing 126 networks and approximately 17 million hosts per network. Class A network number values begin at 1 and end at 127.

Class B: Class B addresses are specified to medium to large sized of networks. Class B allows for 16,384 networks by using the first two octets for the network ID. The two bits in the first octet are always set and fixed to 1 0. The remaining 6 bits, together with the next octet, complete network ID. The 16 bits in the third and fourth octet represent host ID, allowing for approximately 65,000 hosts per network. Class B network number values begin at 128 and end at 191.

Class C: Class C addresses are used in small local area networks (LANs). Class C allows for approximately 2 million networks by using the first three octets for the network ID. In class C address three bits are always set and fixed to 1 1 0. And in the first three octets 21 bits complete the total network ID. The 8 bits of the last octet represent the host ID allowing for 254 hosts per one network. Class C network number values begin at 192 and end at 223.

Class D and E: Classes D and E are not allocated to hosts. Class D addresses are used for multicasting, and class E addresses are not available for general use: they are reserved for future purposes.

Class Leftmost bits Start address Finish address
A 0xxx 0.0.0.0 127.255.255.255
B 10xx 128.0.0.0 191.255.255.255
C 110x 192.0.0.0 223.255.255.255
D 1110 224.0.0.0 239.255.255.255
E 1111 240.0.0.0 255.255.255.255

What is 127.0.0.1

127.0.0.1 is the standard IP address used for a loop back network connection.
This means that if you try to connect to 127.0.0.1, you are immediately looped back to your own machine.

If you telnet, ssh, ftp, etc... to 127.0.0.1, you are connected to your own machine.
In other words, 127.0.0.1 is you.
Another name for 127.0.0.1 is localhost.

What is 127.0.0.1

127.0.0.1 is the standard IP address used for a loop back network connection.
This means that if you try to connect to 127.0.0.1, you are immediately looped back to your own machine.

If you telnet, ssh, ftp, etc... to 127.0.0.1, you are connected to your own machine.
In other words, 127.0.0.1 is you.
Another name for 127.0.0.1 is localhost.