Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

nevada

« Newer Snippets
Older Snippets »
Showing 21-30 of 31 total

compiling

Checking Missing Symbols
   1  
   2  ldd -r *.so | grep -v "main" | grep missing

diff

diff two directories
   1  
   2  diff <dir1> <dir2>

processing columns

print the first column, delimited by space
   1  
   2  nawk -Fc '{print $1}' test.txt


print the second column, delimited by :
   1  
   2  nawk -F: '{print $2}' test.txt

patching source

Making Patch -- to represent the addition of a new file, diff it against /dev/null.
   1  
   2  diff -Naur test.old test.cpp > test.patch

Apply Patch
   1  
   2  patch test.cpp test.patch

Undo Patch
   1  
   2  patch -R test.cpp test.patch

dump mysql database

   1  
   2  mysqldump -uroot dbname > dbtest.sql

reverse linked list

Reverse Linked list by reversing links for each node or swapping the nodes at each end.

test for even and odd numbers

   1  
   2  if( x%2 == 0)
   3  {
   4    print "even number"
   5  }
   6  elsif( x%2 > 0)
   7  {
   8    print "odd number"
   9  }

swap values without temporary variable

The XOR swap algorithm is an inefficient method of swapping two variables. http://en.wikipedia.org/wiki/Xor_swap_algorithm

   1  
   2  void XORSwap(void *x, void *y)
   3  {
   4     *x ^= *y;
   5     *y ^= *x;
   6     *x ^= *y;
   7  }

check ip in linux


   1  
   2  #!/usr/bin/perl -w
   3  my @ifconfig = `/sbin/ifconfig eth0`;
   4  for( @ifconfig )
   5  {
   6  	if( /(\d+\.\d+\.\d+\.\d+)/ )
   7  	{
   8  		print "IP : $1\n";
   9  		last;
  10  	}
  11  }
« Newer Snippets
Older Snippets »
Showing 21-30 of 31 total