Posts

Showing posts from December, 2006

C/C++ Basic - protect data and pointer with const

char * const lpszct = "test"; //protecting pointer char szBuff[10]; strcpy(szBuff, "123"); const char* lpctsz=szBuff; //protecting data pointed. lpszct = "12"; // lpszct ++; // lpctsz[0] = '7'; //

Google Search Cheat Sheet

define:[word] Search word in dictionaries filetype:[ext] Query result with filetyp. E.g. "C++ filetype:pdf" /[country] Limited search to coutry E.g. "food /malaysia /language:[language shorthand] Limited to particular language group. e.g. "cari /language:ms" site:[domain] Limited to a domain. e.g. "thread site:edu" inanchor:[url] Limited search to anchor <a> inurl:[word] Limited search to URL of sites intitle:[word] Limited search to web site title (content inside html title tag i think) intext:[word] Limited search to web site content ...

Kill all my processes in current Unix machine (shell script)

This is a korn shell script, but should work in other shell with little change or none. #created by Anthony Yio, 28 Dec 06 #!/bin/ksh MYUSER=`whoami` for MYPID in `ps -ef | grep $MYUSER | awk '{ print $(2) }' | sort -r` do `kill -9 $MYPID` done

A little perl script to spice up your unix shell startup

Content of perl script ----------- use strict; $/ = "\n%%%\n"; #define separator for array open ARTS, "art.dat" or die $!; my @file = <arts>; my $random = rand(@file); my $ascii_art = $file[$random]; $ascii_art=~s/\n%%%\n//; #remove the separator string print $ascii_art, "\n"; ---------- sample content of art.dat, you can get more from the mentioned web site or newsgroup (sample below taken from http://www.chris.com/ASCII/) ---------- $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ $$$$$$$$$$$*" *$$$$$$$$$$$$$$$$$$$$$$$$$$$" "*" *$$$$$$" ^$$$"$$$$$$$$$$$ $$$$$$$$$" z$P"$$$$$$$$$$$$$$$$$$$$$$$$P e$"e4$b. "$$" d$ $P $$$$$$$$$$$$ $$$$$$$" .$$$ J$$$$$$$$$$$$$$$$$$$$$$$" .$Pz$$4$$$$c z" $$*" z$$$$$$$$$$$$$ $$$$$$ 4$$$$$$$$$$$$$$$$$$$$$$$$$$$P z$$4$$%$$$$$$$d " ...