extract table names from sql log file
grep "from " /var/log/mysql/mysqld.log | awk -Ffrom '{print $2}' | awk '{print $1}' | cat > /home/shantanu/testing.txt
12390 users tagging and storing useful source code snippets
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
grep "from " /var/log/mysql/mysqld.log | awk -Ffrom '{print $2}' | awk '{print $1}' | cat > /home/shantanu/testing.txt
DICT_PATH = '/usr/share/dict/words' DICT_SIZE = 234936 def self.generated_name words = 2, length = 23 name = 'a'*(length+1) while name.length > length name = (1..words).map{%x[sed -n '#{rand(DICT_SIZE)} {p;q;}' '#{DICT_PATH}'].chomp.capitalize}.join end end
bind '"\t":menu-complete'
set show-all-if-ambiguous on
svn propset svn:ignore -F .cvsignore .
… with line number: -n … with file name: -H
sudo perl -MCPAN -e 'install Bundle::LWP'
<meta http-equiv=Refresh content="0; URL=http://blog.jm3.net/" />
ssh -l cs 208.101.26.91
# Usage: pman ls; pman getopts # convert a singel man page to a PDF file, save and open it pman 8 sticky # same with manual section number pman m toe pman -b ls 'open(2)' dd "chmod(2)" curl 'open(n)' # batch convert man pages into PDF files pman -p rm srm open\(2\) 'toe(m)' 'ncurses(3)' # print man pages using the default printer pman() { section="$1" manpage="$2" mandir="/Users/Shared/manpages" # save the created PDF man pages to the specified directory # batch process man pages to PDF files with the "-b" switch and save them to $mandir # example: pman -b ls 'open(2)' dd 'chmod(2)' 'open(n)' 'sticky(8)' # cf. man -aW open for "man n open" if [[ "$1" = "-b" ]]; then if [[ ! -d $mandir ]]; then mkdir -p $mandir chmod 1777 $mandir fi shift # remove "-b" from "$@" for manfile in "$@"; do # example for $manfile: open(2) manpage="`echo $manfile | grep -Eos '^[^\(]+'`" # extract name of man page section="`echo $manfile | grep -Eos '\([^\)]+\)' | grep -Eos '[^\(\)]+'`" # extract section of man page if [[ ! "$section" ]]; then section="1" fi if [[ ! -f "`man ${section} -W ${manpage} 2>/dev/null`" ]]; then #if [[ ! -f "`man -W ${section} ${manpage} 2>/dev/null `" ]]; then echo "No such man page: man ${section} ${manpage}" continue fi manfile="${mandir}/${manpage}(${section}).pdf" echo "$manfile" if [[ ! -f "$manfile" ]]; then man $section -t $manpage 2>/dev/null | pstopdf -i -o "$manfile" 2>/dev/null chmod 1755 "$manfile" # hide file extension .pdf if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi fi done return 0 fi # END of batch processing man pages to PDF files # print PDF man pages using the default printer (see man lpr and man lpoptions) # if necessary, create the specified PDF man pages and save them to $mandir # example: pman -p rm srm if [[ "$1" = "-p" ]]; then if [[ ! -d $mandir ]]; then mkdir -p $mandir chmod 1777 $mandir fi shift # remove "-p" from "$@" for manfile in "$@"; do # example for $manfile: open(2) manpage="`echo $manfile | grep -Eos '^[^\(]+'`" # extract name of man page section="`echo $manfile | grep -Eos '\([^\)]+\)' | grep -Eos '[^\(\)]+'`" # extract section of man page if [[ ! "$section" ]]; then section="1" fi if [[ ! -f "`man ${section} -W ${manpage} 2>/dev/null`" ]]; then echo "No such man page: man ${section} ${manpage}" continue fi manfile="${mandir}/${manpage}(${section}).pdf" echo "$manfile" if [[ ! -f "$manfile" ]]; then man -t $section $manpage 2>/dev/null | pstopdf -i -o "$manfile" 2>/dev/null chmod 1755 "$manfile" # hide file extension .pdf if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi lpr "$manfile" else lpr "$manfile" fi done return 0 fi # END of printing man pages using the default printer # convert a single man page to a PDF file, save it to $mandir and then open it in a PDF viewer if [[ -z "$1" ]] || [[ $# -gt 2 ]]; then # check number of arguments #if [[ -z "$1" || $# -gt 2 ]]; then #if [ -z "$1" -o $# -gt 2 ]; then echo "Wrong number of arguments!" return 1 fi if [[ ! "$manpage" ]]; then # turn "pman ls" into "pman 1 ls" manpage="$section" # if $manpage is an empty string because there has been no "$2" then $manpage is set to "$section" and ... section="1" # ... $section is set to "1" fi if [[ ! -f "`man ${section} -W ${manpage} 2>/dev/null`" ]]; then echo "No such man page: man ${section} ${manpage}" return 1 fi if [[ ! -d $mandir ]]; then mkdir -p $mandir chmod 1777 $mandir fi manfile="${mandir}/${manpage}(${section}).pdf" if [[ -f "$manfile" ]]; then open "$manfile" else man $section -t $manpage 2>/dev/null | pstopdf -i -o "$manfile" 2>/dev/null chmod 1755 "$manfile" # hide file extension .pdf if [[ -f /Developer/Tools/SetFile ]]; then /Developer/Tools/SetFile -a E "$manfile"; fi open "$manfile" fi return 0 }
#!/bin/sh usage() { echo "Usage: $0 -c -d -e -a all -b ball"; exit 1; } if [ $# -lt 1 ] ; then usage; fi # ":" decides which options require an argument # In the example below options "a" and "b" will require a value to be passed along while getopts a:b:cde opt do case "$opt" in a) echo "hello $OPTARG";; b) echo "hello $OPTARG";; c) echo "c is selected";; d) echo "d is selected";; e) echo "e is selected";; \?) usage;; esac done
sub basename($) { my $file = shift; $file =~ s!^(?:.*/)?(.+?)(?:\.[^.]*)?$!$1!; return $file; } sub dirname($) {my $file = shift; $file =~ s!/?[^/]*/*$!!; return $file; }
grep killed /usr/games/lib/nethackdir/logfile | awk -F killed '{print"killed"$NF}' | sort | uniq -c | sort -r
/* Put this line at the top of the file: */ #include <sys/time.h> /* Put this right before the code you want to time: */ struct timeval timer_start, timer_end; gettimeofday(&timer_start, NULL); /* Put this right after the code you want to time: */ gettimeofday(&timer_end, NULL); double timer_spent = timer_end.tv_sec - timer_start.tv_sec + (timer_end.tv_usec - timer_start.tv_usec) / 1000000.0; printf("Time spent: %.6f\n", timer_spent);
history | awk '{print $2}' | awk 'BEGIN {FS="|"}{print $1}' | sort | uniq -c | sort -n | tail | sort -nr