Eventually I get into producing something I think is useful for others. You'll find random technical knowledge in this Blog so please be patient and use the search function. Some of these software are rather lame and old, the list is ordered by the approximate age (newest first). Unfortunately my older stuff are lost or scattered around my old CDs, not readable anymore 8(.
I was using this script to regression test some DNS servers with multiple personalities. All domains are tested on all servers - both private and public.
#!/bin/bash namecheck() { echo `date`" checking for $1 @$2" ans=`dig $1 A @$2 +recurse +qr +all 2>&1` res=`echo -e "$ans" | grep "ANSWER SECTION"` if [ -z "$res" ]; then echo -e "NO ANSWER FROM $2:\n$ans" fi # echo -e "$ans" | grep -A 1 "ANSWER SECTION" } multicheck() { domains="$1" servers="$2" for domain in $domains; do for server in $servers; do namecheck $domain $server done done } pubdomains="www.tricon.hu www.sztaki.hu www.index.hu www.origo.hu www.google.co.hu www.slashdot.com www.eastsideboxing.com" pubservers="193.225.86.1 195.70.57.4 195.111.2.2 195.70.56.227 193.225.12.58" privdomains="kozteka.itak.sztaki.hu stork.oplab.sztaki.hu ilias.ilab.sztaki.hu nat.sztaki.hu ismeretlen.ilab.sztaki.hu" privservers="195.70.57.4 195.111.2.2" multicheck "$pubdomains" "$pubservers" multicheck "$privdomains" "$privservers"
I'm using the excellent embeddable flash applet, Flowplayer to display videos online taken with my digital camera. Unfortunately my dc saves videos in an AVI container with MJPEG video and PCM audio so I have to convert them to a more web-friendly and modern format using ffmpeg.
ffmpeg -vcodec h264 -b 1000k -acodec aac -ab 128k -i input.avi output.mp4
tagliner.c.zip - My first Linux C code ever 8). I'm still actively use this fortune-like program that selects random lines from a textfile and outputs them to stdout, with word wrap support. The random seed is saved between runs to an external file to ensure good pseudo-random properties.
I'm planning to keep image related comments in my digital camera images. Unfortunately there are two ways to attach information to jpegs and there are tools that use one or the other but not both. So I've created the following script that syncs those two kinds of comments and handles conflicts gracefully.
#!/bin/bash dir=$1 dir=${dir:=`pwd`} echo "::: Equalizing JPEG comments and EXIF comments in $dir" prompt() { while true; do read -p "which takes precedence [E]xif, [J]peg (or [C]ancel)? " -n1 answer echo "" case $answer in [eE]) break;; [jJ]) break;; [cC]) exit;; esac echo "please aswer: e/j/c" done } jpeg2exif() { echo "+ copying jpeg to exif comment" exifcom -f -w "$jpegcom" "$file" } exif2jpeg() { echo "+ copying exif to jpeg comment" echo "FIXME: unimplemented" } pushd "$dir" >/dev/null for file in *.jpg *.jpeg *.JPG *.JPEG; do if [ ! -f "$file" ]; then continue; fi echo "+++ file: $dir/$file" exifcom=`exifcom "$file"` jpegcomtmp=`mktemp` jhead -cs "$jpegcomtmp" "$file" >/dev/null jpegcom=`cat "$jpegcomtmp"` rm -f "$jpegcomtmp" echo "+ jpeg comment: $jpegcom" echo "+ exif comment: $exifcom" if [ "$jpegcom" = "$exifcom" ]; then echo "! fields are equal - skipping" continue; fi if [ ! -z "$jpegcom" -a -z "$exifcom" ]; then jpeg2exif continue fi if [ -z "$jpegcom" -a ! -z "$exifcom" ]; then exif2jpeg continue fi if [ ! -z "$jpegcom" -a ! -z "$exifcom" ]; then echo "! both fields hold a comment" prompt case $answer in [eE]) exif2jpeg;; [jJ]) jpeg2exif;; esac continue fi done popd >/dev/null
A quick and dirty script to strip, save and compress attachments from a MIME message arriving to the standard input. The attachments are replaced with URL information and the processed message is then dumped to stdout. This makes a good use as a procmail filter to keep down mailbox sizes. Also can be a good starting base to achieve single attachment storage on large servers with many users.
#!/bin/bash # # stripattach - a quick and dirty script to strip, save and compress attachments # from a MIME message arriving to the standard input. The attachments are replaced # with URL information and the processed message is then dumped to stdout. This # makes a good use as a procmail filter to keep down mailbox sizes. Also can be a good # starting base to achieve single attachment storage on large servers with many users. # # Hacked together by Erno Rigo <mcree@tricon.hu> at 2005-10-05 # # Licensed under the GPLv2 # # directory to save attachments to: savedir=`mktemp -d -p /home/mcree/public_html/attachments attach.XXXXXX` chmod 0755 "$savedir" # directory accessible via URL: savedir_web="http://www.tricon.hu/~mcree/attachments/"`basename "$savedir"` ############################################################################### # don't touch anything below this line (unless you know what you do) ############################################################################### # sanity checks for req in tac sgrep ripmime gzip expr mktemp dd; do if ! command -v $req 2>&1 1>/dev/null; then echo -e "\nthis script requires $req to operate properly!\n" exit 0 fi done # read stdin to temporary workpad file file=`mktemp` cat > $file boundaries=`cat $file | grep '^--.*--$'` echo -e "$boundaries" | while read boundary; do bnd=`echo "$boundary" | rev | cut -b 3- | rev` #echo "BND:";echo -e "$bnd" part=`mktemp` # search for attachments for this boundary lastend=0 cat $file | sgrep -o "%s,%e,%l\n" 'inner("'$bnd'".."'$bnd--'") containing "Content-Disposition: attachment"' | tac | while read pos; do # extract attachments (in reverse order) belonging to this boundary #echo $pos posstart=`echo $pos | cut -f1 -d','` posend=`echo $pos | cut -f2 -d','` posend=`expr $posend + 1` poslen=`echo $pos | cut -f3 -d','` # save attachment attach=`mktemp` attachdir=`mktemp -d` dd if=$file of=$attach skip=$posstart count=$poslen bs=1 2>/dev/null ripmime -i $attach -d $attachdir gzip -9 $attachdir/* filename=`ls -1 $attachdir` cp "$attachdir/$filename" "$savedir" #cat $attach rm -rf $attachdir rm -f $attach # rip attachment from e-mail tmpfile=`mktemp` tmphead=`mktemp` tmptail=`mktemp` dd if=$file of=$tmphead count=$posstart bs=1 2>/dev/null dd if=$file of=$tmptail skip=$posend bs=1 2>/dev/null cat $tmphead >> $tmpfile echo -e "$bnd\nContent-Type: text/plain;\n\n attachment removed\n file saved as: $savedir/$filename\n file can be accessed as: $savedir_web/$filename\n\n$bnd--" >> $tmpfile cat $tmptail >> $tmpfile cp $tmpfile $file rm -f $tmpfile rm -f $tmphead rm -f $tmptail done rm -f $part done cat $file rm -f $file
<< Newer entries | Older entries >>