Tuesday, January 17, 2012
Find a process and kill it in a script in Linux
ps -ef | grep process_name | awk '{ print $2; }'| xargs kill -9
Tuesday, April 19, 2011
Computer Science Terms
Algorithms: Are well-defined procedures for solving problems.
Data Structure: Is a particular way of storing and organizing data in a computer so that it can be used efficiently.
Dangling Pointers: Pointers that point to invalid addresses. Some examples of programming errors that can lead to dangling pointers include casting arbitrary integers to pointers, adjusting pointers beyond the bounds of arrays, and deallocating storage that one or more pointers still reference.
Data Structure: Is a particular way of storing and organizing data in a computer so that it can be used efficiently.
Dangling Pointers: Pointers that point to invalid addresses. Some examples of programming errors that can lead to dangling pointers include casting arbitrary integers to pointers, adjusting pointers beyond the bounds of arrays, and deallocating storage that one or more pointers still reference.
Thursday, March 10, 2011
Hash Table or Hash Map
In computer science, a hash table or hash map is a data structure that uses a hash function to map identifying values, known as keys (e.g., a person's name), to their associated values (e.g., their telephone number). Thus, a hash table implements an associative array. The hash function is used to transform the key into the index (the hash) of an array element (the slot or bucket) where the corresponding value is to be sought.
Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table after creation). Most hash table designs assume that hash collisions—the situation where different keys happen to have the same hash value—are normal occurrences and must be accommodated in some way.
In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table. Many hash table designs also allow arbitrary insertions and deletions of key-value pairs, at constant average (indeed, amortized[1]) cost per operation.[2][3]
In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.
Credit for above paragraphs: http://en.wikipedia.org/wiki/Hash_table
Ideally, the hash function should map each possible key to a unique slot index, but this ideal is rarely achievable in practice (unless the hash keys are fixed; i.e. new entries are never added to the table after creation). Most hash table designs assume that hash collisions—the situation where different keys happen to have the same hash value—are normal occurrences and must be accommodated in some way.
In a well-dimensioned hash table, the average cost (number of instructions) for each lookup is independent of the number of elements stored in the table. Many hash table designs also allow arbitrary insertions and deletions of key-value pairs, at constant average (indeed, amortized[1]) cost per operation.[2][3]
In many situations, hash tables turn out to be more efficient than search trees or any other table lookup structure. For this reason, they are widely used in many kinds of computer software, particularly for associative arrays, database indexing, caches, and sets.
Credit for above paragraphs: http://en.wikipedia.org/wiki/Hash_table
Monday, November 22, 2010
Building thrift 0.5.0 on CentOS 5.3
You will need php 5.2 or above to successfully build thrift 0.5.0 or you will see the following error:
'zend_std_get_constructor' was not declared in this scope.
Download php 5.2.14 source from here and go through the usual "configure->make->sudo make install" cycle.
'zend_std_get_constructor' was not declared in this scope.
Download php 5.2.14 source from here and go through the usual "configure->make->sudo make install" cycle.
Friday, November 19, 2010
Thursday, November 4, 2010
Installing CentOS 4.4 using USB
Ok, I know this is an old version. But if for some reasons, your environment still calls for this kind of system.
1. Download the following from http://vault.centos.org/4.4/isos/i386
CentOS-4.4-i386-bin1of4.iso
CentOS-4.4-i386-bin2of4.iso
CentOS-4.4-i386-bin3of4.iso
CentOS-4.4-i386-bin4of4.iso
Windows
2. Use MagicDisc to mount the the ISOes to different drives. Open the the drives and copy all the files to a directory. Overwrite the files that have the same names.
Linux
2. Mount the iso
# mkdir /mnt/iso
# mount -o loop disk1.iso /mnt/iso
Copy all the files to a directory, e.g. centos44
# cp -r /mnt/iso/* centos44
Do the above for all the iso files.
3. Windows: Use MagicISO to write the files to an ISO; Linux:
# mkisofs -o centos44-i386.iso ./centos44
4. Use UNetbootin (http://unetbootin.sourceforge.net) to write the ISO to your USB drive
5. Boot from USB in your system that is to be installed. Select HTTP installation.
Site: vault.centos.org
Direcotry: 4.4/os/i386
The reason why we have to do this instead of using the CentOS-4.4.ServerCD-i386.iso file is that the
Server ISO does not match with the installation directory structure. The installation will not start.
1. Download the following from http://vault.centos.org/4.4/isos/i386
CentOS-4.4-i386-bin1of4.iso
CentOS-4.4-i386-bin2of4.iso
CentOS-4.4-i386-bin3of4.iso
CentOS-4.4-i386-bin4of4.iso
Windows
2. Use MagicDisc to mount the the ISOes to different drives. Open the the drives and copy all the files to a directory. Overwrite the files that have the same names.
Linux
2. Mount the iso
# mkdir /mnt/iso
# mount -o loop disk1.iso /mnt/iso
Copy all the files to a directory, e.g. centos44
# cp -r /mnt/iso/* centos44
Do the above for all the iso files.
3. Windows: Use MagicISO to write the files to an ISO; Linux:
# mkisofs -o centos44-i386.iso ./centos44
4. Use UNetbootin (http://unetbootin.sourceforge.net) to write the ISO to your USB drive
5. Boot from USB in your system that is to be installed. Select HTTP installation.
Site: vault.centos.org
Direcotry: 4.4/os/i386
The reason why we have to do this instead of using the CentOS-4.4.ServerCD-i386.iso file is that the
Server ISO does not match with the installation directory structure. The installation will not start.
Friday, October 29, 2010
Find out gcc version in a script
user@local$ gcc -v 2>&1 | tail -1 | awk '{print $3}'
4.4.3
Only want the major version number:
gcc -v 2>&1 | tail -1 | awk '{print $3}'|cut -d. -f1
4
4.4.3
Only want the major version number:
gcc -v 2>&1 | tail -1 | awk '{print $3}'|cut -d. -f1
4
Subscribe to:
Posts (Atom)