--- /dev/null
+#!/bin/bash
+
+##############
+# Name : fred_techniques
+# Author : Chris Koeritz
+# Rights : Copyright (C) 2010-$now by Author
+##############
+# Copyright (c) 2010-$now By Author. This script is free software; you can
+# redistribute it and/or modify it under the terms of the simplified BSD
+# license. See: http://www.opensource.org/licenses/bsd-license.php
+# Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
+##############
+
+# this script is a collection of helpful bash practices that unfortunately
+# sometimes slip my mind when i need them. it's intended to collect all the
+# good bits so they don't slip away. feel free to re-use them in your own
+# code as needed.
+
+##############
+
+# clean for loops in bash:
+
+for ((i=0; i < 5; i++)) do
+ echo $i
+done
+
+##############
+
+# removing an array element
+# --> only works on arrays that have no elements containing a space character.
+
+# define a 5 element array.
+arr=(a b c d e)
+
+# remove element 2 (the 'c').
+removepoint=2
+
+# set the array to slices of itself.
+arr=(${arr[*]:0:$removepoint} ${arr[*]:(($removepoint+1))} )
+
+# show the new contents.
+echo ${arr[*]}
+# shows: a b d e
+
+##############
+
+# store to a variable name by derefercing it.
+
+# shows how you can store into a variable when you are given only its name.
+function store_to_named_var()
+{
+ local name="$1"; shift
+ eval ${name}=\(gorbachev "perestroikanator 12000" chernenko\)
+}
+
+declare -a ted=(petunia "butter cup" smorgasbord)
+echo ted is ${ted[@]}
+store_to_named_var ted
+echo ted is now ${ted[@]}
+
+##############
+
--- /dev/null
+#!/bin/bash
+
+#
+# these great examples of handy unix tidbits were donated by "q. black".
+#
+
+# list a directory tree
+ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
+
+# list directory sizes (biggest first)
+du -h $(du -s * |sort -nr|awk '{print $2}')
+
+# this will sort a date field of the form: DD-MON-YYYY HH:MM:SS
+sort +0.7 -1 +0.3M -0.6 +0 -0.2 +1
+
+# this will sort a date field of the form: MON DD HH:MM:SS YYYY
+sort +3 -4 +0M +1n
+
+# this will sort a date field of the form: MON DD HH:MM:SS
+sort +0M +1n
+
+# this will sort a date field of the form: Date: Tue Feb 3 09:17:58 EST 2004
+sort +6 -7 +2M +3n +4
+
+# display all lines from a certain line onward
+start_line=132
+|awk "{if (NR >= ${start_line}){print \$0}}"
+
+# display all lines after a token
+sed '1,/CUT HERE/d'
+
+# print the first and last lines
+sed -n '1,1p;$,$p'
+
+# signal bash about a window size change
+kill -winch $$
+
+# show the date 1 year, 2 months and 3 days ago
+date -v -1y -v -2m -v -3d
+
+# set the date back 1 year
+sudo date $(date -v -1y +%Y%m%d%H%M)
+
+# output the standard date format for setting the time
+# get the date
+date -u +%Y%m%d%H%M.%S
+# set the date
+date -u (cut and paste from above)
+
+# convert one date format to another (output is in the current time zone)
+old_date="Aug 27 15:24:33 2005 GMT"
+new_date=$(date -j -f "%b %e %T %Y %Z" "${old_date}" +%D)
+echo ${new_date}
+# returns "08/27/05"
+
+# output the modification time of a file in different format
+file=
+date -j -f "%b %e %T %Y" "$(ls -lT ${file} |awk '{print $6,$7,$8,$9}')"
+
+# output the number of days until a certain date
+target_date="Sep 2 15:20:20 2005 GMT"
+target_seconds=$(date -j -f "%b %e %T %Y" +%s "${target_date}" 2>/dev/null)
+diff_seconds=$(expr ${target_seconds} - $(date +%s))
+diff_days=$(expr ${diff_seconds} / 86400)
+echo "${diff_days} day(s)"
+
+# these commands can be used to fill in missing times in a "uniq -c" count
+# of times.
+# output 24 hours in one minute increments
+for h in $(jot -w %02d - 0 23 1); do
+ for m in $(jot -w %02d - 0 59 1); do
+ echo " 0 ${h}:${m}"
+ done
+done
+# sort them together, and remove any 0 counts if an count already exists
+sort +1 +0rn out1 out2 |uniq -f 1
+
+# output with w3m to get basic html word wrap
+w3m -T "text/html" -dump -cols 72 <<EOF
+ <p>
+ This test verifies basic networking and that the ${product_short_name}
+ can reach it's default gateway.
+EOF
+
+# another way to format text for output
+fmt 72 <<EOF
+This test verifies basic networking and that the ${product_short_name}
+can reach it's default gateway.
+EOF
+
+# smtpcrypt "printf"
+{
+char *jkwbuf = NULL;
+asprintf(&jkwbuf, "JKW: msg->used = %ld\n", msg->used);
+BIO_write(sc->log, jkwbuf, strlen(jkwbuf)+1);
+free(jkwbuf);
+}
+
+# rolling diff of a list of files (diff a & b, then b & c,...)
+last=
+for i in $(ls -1rt); do
+ if [ ! -z "${last}" ]; then
+ diff -u ${last} ${i}
+ fi
+ last=${i}
+done
+
+# clearing and restoring chflags
+file=
+old_chflags=$(ls -lo ${file}|awk '{print $5}')
+chflags 0 ${file}
+# do whatever
+if [ ."${old_chflags}" != ."-" ]; then
+ chflags ${old_chflags} ${file}
+fi
+
+# way to do standard edits to files
+file=
+{
+ # append line(s) after a line, "i" to insert before
+ echo '/www_recovery/a'
+ echo 'mithril ALL = (root) NOPASSWD: /usr/local/libexec/destroyer'
+ echo '.'
+ # modify a line
+ echo 'g/^xntpd_program=/s,^xntpd_program=.*$,xntpd_program="ntpd",'
+ # delete a line
+ echo 'g/^controls key secret =/d'
+ echo 'x!'
+} | ex - ${file}
+
+# how to search for errors in the last 24 hours
+# note that this command does not work quite right. The sort is off early
+# in the year because the dates do not have the year.
+# Also sed never sees the /CUT HERE/ when it is the first line.
+(echo "$(date -v-24H "+%b %e %H:%M:%S") --CUT HERE--"; \
+ zgrep -h "cookie" /var/log/messages*)|sort +0M| \
+ sed '1,/CUT HERE/d'
+# This version fixes those problems. It adds the file year to the date
+# and puts a marker at the start of the list.
+(echo "$(date -j -f "%s" 0 "+%Y %b %e %H:%M:%S") --ALWAYS FIRST--"; \
+ echo "$(date -v-24H "+%Y %b %e %H:%M:%S") --CUT HERE--"; \
+ for i in /var/log/messages*; do
+ year=$(ls -lT ${i}|awk '{print $9}')
+ zgrep -h "cookie" ${i}|while read line; do
+ echo "${year} ${line}"
+ done
+ done)|sort +0n +1M| sed '1,/CUT HERE/d'
+
+# process a list of quoted values
+{
+ # It tends to be easiest to use a 'here-document' to feed in the list.
+ # I prefer to have the list at the start instead of the end
+ cat <<EOF
+ 'general' 'network node0' 'private address'
+ 'general' 'options node2' 'kern securelevel'
+EOF
+}| while read line; do
+ eval set -- ${line}
+ config=$1; shift
+ section=$1; shift
+ key=$1; shift
+
+ echo "confutil value \"${config}\" \"${section}\" \"${key}\""
+done
+
+# Method to read lines with a "for" loop, without spawning a subshell
+NEWLINE='
+'
+OIFS="${IFS}"
+IFS="${NEWLINE}"
+for line in $(cat /etc/passwd | sort -r); do
+ IFS="${OIFS}"
+
+ # do whatever you want here
+ echo "line = ${line}"
+
+ IFS="${NEWLINE}"
+done
+IFS="${OIFS}"
+
+# generate a histogram of characters in a file
+cat file|
+ awk '{for (i=1; i <= length($0); i++) {printf("%s\n",substr($0,i,1))}}'|
+ sort|uniq -c
+
+# show line lengths for a file
+cat file| awk '{print length($0)}'| sort -n
+
+
+
+
+# get the modification time of a directory or file and then reset the time.
+target=/usr/local/etc/pkdb
+save_date=$(ls -ldT ${target}|awk '{print $6,$7,$8,$9}')
+save_date=$(date -j -f "%b %e %T %Y" "${save_date}" +"%Y%m%d%H%M.%S")
+# later
+touch -t ${save_date} ${target}
+
+
+# detect NULL bytes in a file
+file=
+hexdump -e '"%_u\n"' ${file}|grep -q '^nul$'
+if [ $? -eq 0 ]; then
+else
+fi
+
+
+# calculate average
+cd /tmp
+uudecode
+begin 644 bc.average
+M<V-A;&4],PIT;W1A;#TP"F-O=6YT/3`*=VAI;&4@*#$I('L*("`@(&YU;2`]
+M(')E860H*0H@("`@:68@*&YU;2`]/2`P*2!B<F5A:SL*("`@(&-O=6YT*RL*
+M("`@('1O=&%L("L](&YU;0I]"B)T;W1A;"`]("([('1O=&%L"B)C;W5N="`]
+K("([(&-O=6YT"B)A=F5R86=E(#T@(CL@=&]T86P@+R!C;W5N=`IQ=6ET"@``
+`
+end
+(cat data; echo "0") |bc -q bc.average
+
+
--- /dev/null
+
+# find out the location where this script is running from. this will not
+# work properly in a bash script that is included via 'source' or '.'.
+# the first letter of each command is escaped to eliminate the danger of
+# personal aliases or functions disrupting the results.
+ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
+
--- /dev/null
+
+# some aliases that i don't expect very many people to ever want. they are
+# based on some of the mount configurations available at home or abroad.
+
+# moo and unmoo mount the local folders i use most.
+alias moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky '
+alias unmoo='umount /z/stuffing ; umount /z/walrus ; umount /z/chunky '
+
+# cleans up the ownership for all my files.
+alias refred='(chown -R fred:fred /home/fred /usr/local/games /home/archives /fatty /clutterato /var/spool/mail/fred ; normal_perm /var/log )'
+
+
--- /dev/null
+
+# these are my personal overrides. --fred.
+
+# The quartz directory has *really* personalized items.
+export QUARTZDIR=$HOME/quartz
+
+# The gruntose web site is expected to reside below, if it exists at all.
+export WEB_DIR=$HOME/web
+if [ "$(hostname)" = "zooty.koeritz.com" ]; then
+ export WEB_DIR=/var/www
+fi
+
+# point to our local certificate for ssh usage.
+export SVN_SSH="ssh -i $HOME/.ssh/id_dsa_sourceforge"
+
+# Error and success noises for CLAM.
+export CLAM_ERROR_SOUND='/z/walrus/media/sounds/effects/bwaaang.wav /z/walrus/media/sounds/cartoons/doh4.wav'
+export CLAM_FINISH_SOUND='/z/walrus/media/sounds/cartoons/meepmeep.wav'
+
+# Setup for nethack adventure.
+export NETHACKOPTIONS='name:Manjusri-W,dogname:Fred,catname:Zonker'
+
+# mail setup for home machines.
+export REPLYTO=fred@gruntose.com
+export from="Fred T. Hamster <fred@gruntose.com>"
+
+# set our browser for seti and others that use the variable.
+export BROWSER=/usr/bin/firefox
+
+# editor and other mixed settings...
+export VISUAL=$(which vim)
+
+#hmmm: move these to the uva profile,
+# rename uva profile to java profile,
+# get them doing the right thing per OS.
+# export JAVA_HOME="c:/Program Files/java/jdk1.6.0_11"
+
+# special settings for win32 and svn.
+if [ "$OS" == "Windows_NT" ]; then
+ export EDITOR=$(which gvim)
+else
+ export EDITOR=$(which vi)
+fi
+
+# this hideous mess is necessitated by our not having found the source of the
+# settings yet. we override a few colors that look bad on a dark background.
+export LS_COLORS='no=00:fi=00:di=01;37:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;35:*.rpm=00;33:*.deb=00;33:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;35:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;35:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
+
+# we set this to avoid paying for slow app signing on win32.
+export NO_SIGNING=true
+
--- /dev/null
+#!/bin/bash
+
+# Author: Chris Koeritz
+
+# this script tries to intuit where java is installed on this machine.
+
+############################
+
+function intuition_failure()
+{
+ missing="$1"; shift
+ echo "We cannot intuit your $missing variable for this host."
+ # remove the variable because its value is busted.
+ unset $missing
+}
+
+############################
+
+# set some fairly liberal limits for ant.
+export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
+
+############################
+
+# start guessing some settings...
+
+# this bin portion works for most javas...
+export JAVA_BIN_PIECE=bin
+
+if [ ! -d "$JAVA_HOME" ]; then
+ # first try a recent linux version.
+ export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
+fi
+if [ ! -d "$JAVA_HOME" ]; then
+ export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
+fi
+if [ ! -d "$JAVA_HOME" ]; then
+ # try using a windows version.
+#note: this logic is untested.
+# probably will break due to space in path issues.
+ declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
+ if [ ${#any_there[*]} -gt 0 ]; then
+ (( last = ${#any_there[@]} - 1 ))
+ JAVA_HOME="${any_there[$last]}"
+ fi
+ if [ ! -d "$JAVA_HOME" ]; then
+ # if no jdk, try a jre.
+ declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
+ if [ ${#any_there[*]} -gt 0 ]; then
+ (( last = ${#any_there[@]} - 1 ))
+ JAVA_HOME="${any_there[$last]}"
+ fi
+ fi
+fi
+# this should go last, since it changes the bin dir.
+if [ ! -d "$JAVA_HOME" ]; then
+ # if that didn't work, try the location for mac os x.
+ JAVA_HOME=/Library/Java/Home
+ JAVA_BIN_PIECE=Commands
+fi
+# last thing is to tell them we couldn't find it.
+if [ ! -d "$JAVA_HOME" ]; then
+ intuition_failure JAVA_HOME
+ unset JAVA_BIN_PIECE
+fi
+
+############################
+
+# intuit where we have our local eclipse.
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ export ECLIPSE_DIR=/usr/local/eclipse_jee
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ ECLIPSE_DIR=$HOME/eclipse
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ ECLIPSE_DIR=$HOME/apps/eclipse
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+#uhhh, default on winders?
+ ECLIPSE_DIR="/c/Program Files/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ ECLIPSE_DIR="/c/tools/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ ECLIPSE_DIR="/d/tools/eclipse"
+fi
+if [ ! -d "$ECLIPSE_DIR" ]; then
+ ECLIPSE_DIR="/e/tools/eclipse"
+fi
+# final option is to whine.
+if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
+
+############################
+
+# use the variables we just set in our path, and try to make them override
+# any other paths to different versions.
+
+if [ ! -z "$JAVA_HOME" ]; then
+ export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
+fi
+if [ ! -z "$ECLIPSE_DIR" ]; then
+ export PATH=$ECLIPSE_DIR:$PATH
+fi
+
+############################
+
+
--- /dev/null
+
+this folder has some examples of how various people (or one person right now)
+do their custom scripts.
+
+the folder can have alias files (ending in .alias) that are written in bash,
+and it can also have shell scripts that are sourced into the main-line of
+script initialization (any files ending in .sh).
+
+when you have some custom scripts you want to use, copy them from your own
+folder to the $FEISTY_MEOW_GENERATED/custom directory.
+
--- /dev/null
+export LC_ALL=C
+alias mc='mc -a'
+
+export PATH=$PATH:/home/QtPalmtop/j2me:/home/QtPalmtop/j2me/bin
+
+alias fredme='export HOME=/home/zaurus/fred ; export TMP=$HOME/.tmp ; source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh ; cd '
+
+
--- /dev/null
+# added to root's ~/.bashrc, the fredme macro enables all the feisty_meow tools.
+
+alias fredme='source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh'
+
--- /dev/null
+
+# in addition to the .bashrc code that the operating system gives you,
+# you can add this file to your ~/.bashrc if you want the feisty_meow scripts
+# to be loaded up automatically.
+#
+# this is for normal users, not the root user!
+
+# note: it is useful to set your own NAME variable to identify who you are.
+# the feisty_meow scripts will set up a bogus one for you otherwise. in your home
+# directory's .bashrc, you could add something like this, for example:
+# export NAME='Doodmodeus Q. Nornberton'
+
+# don't bother running our stuff for a dumb terminal since any echo
+# can mess with an sftp or scp connection, apparently. similarly, we
+# don't want any automatic startup stuff if we are running under PBS.
+if [ "${TERM}" != "dumb" -a -z "$PBS_ENVIRONMENT" ]; then
+ # sets up the feisty_meow scripts, using the default locations for all scripts.
+ source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh
+fi
+
--- /dev/null
+
+# in addition to the .bashrc code that the operating system gives you,
+# you should added this file to your ~/.bashrc if you want the feisty_meow scripts
+# to be loaded up.
+#
+# you also must run bootstrap_shells.sh if you've never used feisty_meow before.
+
+# note: it is useful to set your own NAME variable to identify who you are.
+# the feisty_meow scripts will set up a bogus one for you otherwise. in your home
+# directory's .bashrc, you could add something like this, for example:
+#export NAME='Curmudgeon J. Wankslausteen'
+
+#export TMP=/h/tmp
+
+# add in some useful paths for the local machine.
+export PATH=/bin:$PATH:/c/utilities/emacs-23.2/bin:/c/tools/cvsnt:/c/utilities/Vim/vim71:/c/system/Perl/site/bin:/c/system/Perl/bin:/c/tools/doxygen/bin:/c/tools/graphviz/Graphviz/bin
+
+if [ "${TERM}" != "dumb" -a -z "$PBS_ENVIRONMENT" ]; then
+ source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh
+fi
+
+
--- /dev/null
+#!/usr/bin/perl
+
+###############################################################################
+# #
+# Name : template #
+# Author : Chris Koeritz #
+# Rights : Copyright (C) 1996-$now by Author #
+# #
+# Purpose: #
+# #
+# Attempts to pre-instantiate C++ templates to work-around C++ compilers #
+# that don't support templates (a rare breed, these days). #
+# #
+###############################################################################
+# This program is free software; you can redistribute it and/or modify it #
+# under the terms of the GNU General Public License as published by the Free #
+# Software Foundation; either version 2 of the License or (at your option) #
+# any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
+# version of the License. Please send any updates to "fred@gruntose.com". #
+###############################################################################
+
+# this was a majestic abortive attempt to create a template instantiator for
+# compilers that do not possess templates, but which do support some subset
+# of C++. This was necessary at the time, due to our firmware compiler's
+# limitations. This processor never totally worked, although it did produce
+# some interesting compilable code. Might be useful as a demo or maybe just
+# as a warning to avoid brain-damaged C++ compilers.
+
+# to do:
+# maintain statistics about placement in file for error resolution.
+
+# limitations so far:
+#
+# the word "template" must be the first word on the line.
+#
+# the type to instantiate must be one word (like charstar, not char *).
+#
+# templates must follow the form templateName<templateType> without
+# any spaces between the angle brackets.
+
+# flag to enable debugging print outs.
+$DEBUG_TEMPLATIZER = 1;
+#$DEBUG_TEMPLATIZER = 0;
+
+# array to store instance types to convert to
+@instance_type_buffer = ();
+# flag for checking read from file option
+$f_option = 0;
+$d_option = 0;
+
+if ($#ARGV < 1) {
+ die("
+ The template instantiater supports an optional directory path as the first
+ parameter (preceded by a -d with no spaces in between the d and the
+ directory name) in which to store the generated templates, and then
+ requires the instantiation type as the next argument (or a file
+ specification preceded by -f), and a list of files as the last
+ arguments.
+ The files will be scanned for templates and those templates will be
+ instantiated in the type(s) specified.
+ Examples:
+ perl template.pl char istring.h torpedo.h
+ perl template.pl -f instance.txt matrix.h
+ perl template.pl -d. -f instance.txt function.h data_src.h
+ perl template.pl -dfirm_src\library\basis -f instance.txt amorph.h\n");
+}
+
+# Check directory option
+if (grep(/^\s*-d/, @ARGV)) {
+ $d_option = 1;
+ $d_dir = @ARGV[0];
+# print $d_dir, "\n";
+ shift;
+}
+
+
+# Check to see if user used a file to specify instantiation types
+if (grep(/^\s*-f/, @ARGV)) {
+ $f_option = 1;
+ shift;
+ $types_file = @ARGV[0];
+
+# Open instantiation type file to read from
+ open(TYPES_FILE, "<$types_file")
+ || die("couldn't open file $types_file for reading");
+
+# Read in all the different types to instantiate
+# Create instance_type list
+ @tp = <TYPES_FILE>;
+ while (@tp) {
+ local($line) = @tp;
+ chop $line;
+ push(@instance_type_buffer, $line);
+ shift @tp;
+ }
+ shift @ARGV;
+ &instantiate_templates(@ARGV);
+ exit;
+}
+
+&instantiate_templates(@ARGV);
+exit;
+
+#
+# driver of the instantiation process.
+#
+sub instantiate_templates {
+ if (!$f_option) {
+ # grab the user's desired instance type.
+ $instance_type = @_[0];
+ push(@instance_type_buffer, $instance_type);
+ print "Instantiation type is \"$instance_type\".\n";
+ # jump over the instance type to look at the filenames.
+ shift;
+ }
+
+ local($i) = 0;
+ foreach $filename (@_) {
+ open(INPUT_FILE, "<$filename")
+ || die("couldn't open file $filename for reading");
+ # create an output name for the instance.
+ $out_filename = &make_output_name($filename);
+ if ($DEBUG_TEMPLATIZER) {
+# print "out file is ", $out_filename, "\n";
+ }
+ local($index) = $i + 1;
+ print "Instantiating file[$index] as $out_filename.\n";
+ # now try opening our output file.
+ open(OUTPUT_FILE, ">$out_filename")
+ || die("couldn't open file $filename for writing");
+ # grab the current file into an array.
+
+ @file_array = <INPUT_FILE>;
+ @start_template = @file_array;
+ @stop_template = @file_array;
+ # process the file's contents as a manipulable array.
+ while (@file_array) {
+ local($line) = shift @file_array;
+ if (grep(/^\s*template/, $line)) {
+ @start_template = @file_array;
+
+ # iterate through all the instance types for each template
+ foreach $instance_type (@instance_type_buffer) {
+ @file_array = @start_template;
+ &snag_place_holder($line);
+ &snag_object_name;
+ &absorb_until_matched_block;
+ &replace_place_holder;
+ &dump_the_buffer;
+ print OUTPUT_FILE "\n";
+ }
+ } elsif (grep(/\w+<\w+>/, $line)) {
+ local(@pieces) = split(/\s/, $line);
+ foreach $piece (@pieces) {
+ local($prefix) = "";
+ # special case for separating function name from templated first
+ # parameter to it.
+ if (grep(/\(\w+</, $piece)) {
+ local(@chop_paren) = split(/\(/, $piece, 2);
+ $prefix = $chop_paren[0].'(';
+ $piece = $chop_paren[1];
+ }
+ if (grep(/\w+<\w+>/, $piece)) { $piece = &special_mangle($piece); }
+ print OUTPUT_FILE "$prefix$piece ";
+ }
+ print OUTPUT_FILE "\n";
+ } else {
+ print OUTPUT_FILE $line;
+ }
+ }
+ $i++;
+ }
+}
+
+#
+# generates an output name from the filename to be translated.
+#
+sub make_output_name {
+ local($out_filename) = @_[0];
+ local($d_dir_temp) = $d_dir;
+# print "OUTFILE NAME: ",$out_filename,"\n";
+ # break down the filename at the slashes.
+ local(@split_filename) = split(/[\\\/]/, $out_filename);
+ # take the basename of the list of names.
+ $out_filename = $split_filename[$#split_filename];
+ local($hold_filename) = $out_filename;
+ if (grep(!/\.cpp$/i, $out_filename) && grep(!/\.h$/i, $out_filename)
+ && grep(!/\.c$/i, $out_filename) && grep(!/\.h$/i, $out_filename) ) {
+ die("filename @_[0] not recognized as a C++ code file.");
+ }
+ # makes an instance of the file in a directory named after the instance type
+ # that is located under the current directory.
+
+ $d_dir_temp = join('/',$d_dir, $hold_filename);
+ if ($d_option) {
+ $d_dir_temp =~ s/-d//i;
+ @split_filename = split(/[\\\/]/, $d_dir_temp);
+# exit;
+ }
+
+# try to create dir using the deepest dir given in filename input
+
+ local($y) = 0;
+ foreach (@split_filename) { $y++; }
+
+ local($x) = 0;
+ local($ret) = 0;
+ local($dirs) = 0;
+
+ if ($y >= 2) {
+ foreach (@split_filename) {
+ if ((($x > 0) && ($x < $y-1)) || (($d_option) && ($x < $y-1))) {
+ if (!$dirs) { $dirs = @split_filename[$x]; }
+ else { $dirs = $dirs."/".@split_filename[$x]; }
+# print "Creating... ",$dirs,"\n";
+ $ret = mkdir($dirs, 0777);
+ if (!ret) { die("a directory named $instance_dir could not be made."); }
+ }
+ $x++;
+ }
+ $out_filename = $dirs."/".$hold_filename;
+ }
+ else { $out_filename = "template/".$hold_filename;
+ local($instance_dir) = "template";
+ $ret = mkdir($instance_dir, 0777);
+ if (!ret) { die("a directory named $instance_dir could not be made."); }
+ }
+# print $out_filename, "\n";
+
+# local($instance_dir) = @split_filename[$x-2];
+# creates the directory.
+# local($ret) = mkdir($instance_dir, 0777);
+# if (!ret) { die("a directory named $instance_dir could not be made."); }
+
+ $out_filename; # return the new name.
+}
+
+#
+# grabs the name of the placeholder type that will be replaced by
+# the template instantiation type.
+#
+sub snag_place_holder {
+ $place_holder = @_[0];
+ chop $place_holder;
+
+ local(@pieces) = split(/>\s*/, $place_holder, 2);
+
+ # send back the parts not involved in the template statement.
+ if (length($pieces[1])) {
+ unshift(@file_array, $pieces[1]."\n");
+ }
+ $place_holder = $pieces[0];
+ $place_holder =~ s/\s*template\s+<class\s+(\w+)$/\1/;
+ if ($DEBUG_TEMPLATIZER) {
+# print "Replacing place holder \"$place_holder\" with \"$instance_type\".\n";
+ }
+}
+
+#
+# grabs the name of the object itself that will become an instantiated
+# object in the type specified. the global variable "object_name" is
+# set by the subfunctions used here.
+#
+sub snag_object_name {
+ local($next_line) = shift(@file_array);
+ chop $next_line;
+ &match_class_declaration($next_line)
+ || &match_class_member_definition($next_line)
+ || &match_function_definition($next_line);
+}
+
+#
+# creates a mangled form of the name that includes the instantiation
+# type. the global variable "mangled_name" is set by this function.
+#
+sub mangle_name {
+ local($to_grind) = @_[0];
+ local($mangled_name) = "template__".$to_grind."__".$instance_type;
+ if ($DEBUG_TEMPLATIZER) {
+# print "Replacing name \"$to_grind\" with \"$mangled_name\".\n";
+ }
+ $mangled_name;
+}
+
+#
+# processes "#include" preprocessor directives to make sure if the filename
+# is in there to include a C++ file (for the template code), then it gets
+# converted to the new file name.
+#
+
+# this is a pretty bogus thing; it should not be used.
+
+sub convert_inclusion {
+ local($line) = @_[0];
+ chop $line;
+ local($temp) = $line;
+ # extract out the name parts of the include declaration.
+ $temp =~ s/\s*#include\s*([<"])([\w.]+)([>"])/\1 \2 \3/;
+ local(@broken_up) = split(/ /, $temp);
+ # strip off the punctuation from the name.
+ local($incl_prefix) = @broken_up[1];
+ $incl_prefix =~ s/["<](.*)[">]/\1/;
+ $incl_prefix =~ s/\s//g;
+ # return if it's not a code file being included.
+ if (!grep(/.cpp/i, $incl_prefix)) { print OUTPUT_FILE $line, "\n"; return; }
+ # strip to just the name without the ending.
+ $incl_prefix =~ s/\.cpp$//i;
+ # now get the name of the file we're processing.
+ local($file_prefix) = $filename;
+ # return if it's not a header file being examined.
+ if (!grep(/.h/i, $file_prefix)) { print OUTPUT_FILE $line, "\n"; return; }
+ # strip off the extension.
+ $file_prefix =~ s/\.h$//i;
+ # return if the names aren't equivalent--this means the include doesn't
+ # refer to our new templated form of the code file.
+ if ($incl_prefix ne $file_prefix) { print OUTPUT_FILE $line, "\n"; return FALSE; }
+ # dump out a message about the removal.
+ $line =~ s/^\s*//;
+ print OUTPUT_FILE "/* removed unneeded template inclusion: $line */\n";
+}
+
+#
+# extracts lines from the file until the curly brackets are matched up
+# at level 0.
+#
+sub absorb_until_matched_block {
+ $bracket_level = 0;
+ $end_absorb = 0;
+ @template_buffer = ();
+ $hit_one=0;
+ while (@file_array) {
+ local($line) = shift @file_array;
+ &look_for_curlies($line);
+ if (($hit_one && ($bracket_level == 0)) || $end_absorb) { return; }
+ }
+}
+
+#
+# examines the parameters passed in for curly brackets and changes the
+# counter if they are found.
+#
+sub look_for_curlies {
+# $hit_one = 0; # records whether a bracket was found or not.
+ local($line) = @_[0];
+ @word = ();
+ foreach $char (split(//, $line)) {
+ if ($char eq '{') {
+ $hit_one = 1;
+ $bracket_level++;
+ } elsif ($char eq '}') {
+ $hit_one = 1;
+ $bracket_level--;
+ } elsif (($char eq ';') && ($hit_one==0)) {
+ $end_absorb = 1;
+ }
+
+
+ if ($DEBUG_TEMPLATIZER) {
+# print "~$char~ ";
+ }
+ push(@word, $char);
+ if (grep(!/\w/, $char)) {
+ # don't split yet if it's a possible template char.
+ if (grep(!/[<>]/, $char)) {
+ local($real_word) = join("", @word);
+ if ($DEBUG_TEMPLATIZER) {
+# print "adding a word $real_word\n";
+ }
+ push(@template_buffer, "$real_word");
+ @word = ();
+ }
+ }
+ }
+}
+
+#
+# this goes through the buffer and replaces all occurrences of the name to
+# replace with the instance name.
+#
+sub replace_place_holder {
+ @new_template_buffer = @template_buffer;
+ @template_buffer = ();
+
+ foreach $i (0 .. $#new_template_buffer) {
+ $word = $new_template_buffer[$i];
+# if ($DEBUG_TEMPLATIZER) {
+# print "<$i $word> ";
+# $old = $word;
+# }
+
+ # replace a templated combination with the mangled version.
+ $word =~ s/^${object_name}<${instance_type}>/${mangled_name}/;
+
+# if ($DEBUG_TEMPLATIZER) {
+# if ($old ne $word) {print "1 ... changed to $word.\n"; $old = $word; }
+# }
+
+ if (grep(/^\w+<\w+>/, $word)) {
+ # replace some other template with our stuff if we can.
+ $word = &special_mangle($word);
+ }
+
+# if ($DEBUG_TEMPLATIZER) {
+# if ($old ne $word) {print "2 ... changed to $word.\n"; $old = $word; }
+# }
+
+ # replace the object's name with its mangled form.
+ $word =~ s/^${object_name}/${mangled_name}/;
+
+# if ($DEBUG_TEMPLATIZER) {
+# if ($old ne $word) {print "3... changed to $word.\n"; $old = $word; }
+# }
+
+ # replace the place holder with the instantiation type.
+ $word =~ s/^${place_holder}/${instance_type}/;
+
+# if ($DEBUG_TEMPLATIZER) {
+# if ($old ne $word) {print "4... changed to $word.\n"; $old = $word; }
+# }
+
+ push(@template_buffer, $word);
+ }
+}
+
+#
+# processes a general template usage, in the form X<Y>, where either
+# X or Y are not ones that we think we need to replace. it is assumed
+# that it's safe to use the mangled form of the template.
+#
+sub special_mangle {
+ local($word) = @_[0];
+ # split the template form into pieces.
+ local(@pieces) = split(/[<>]/, $word, 2);
+
+ $pieces[1] =~ s/${place_holder}/${instance_type}/;
+ $pieces[1] =~ s/>//;
+ # hold onto the real instance type.
+ local($hold_instance) = $instance_type;
+ $instance_type = $pieces[1];
+ # mangle the name in the template usage line.
+ local($hold_mangled) = &mangle_name($pieces[0]);
+ # restore the original instance type.
+ $instance_type = $hold_instance;
+ # returns the new mangled form.
+ $hold_mangled;
+}
+
+#
+# prints out the buffer we've accumulated to the output file.
+#
+sub dump_the_buffer {
+ print OUTPUT_FILE @template_buffer;
+}
+
+#
+# processes a class declaration and sets the object name for future use.
+#
+sub match_class_declaration {
+ local($next_line) = @_[0];
+# too strict!
+# if (grep(!/class\s.*\w+$/, $next_line)
+# && grep(!/class\s.*\w+\s*\{/, $next_line)
+# && grep(!/struct\s.*\w+$/, $next_line)
+# && grep(!/struct\s.*\w+\s*\{/, $next_line)) {
+# return 0;
+# }
+
+ if (grep(!/class\s+\w+/, $next_line) && grep(!/struct\s+\w+/, $next_line) ) {
+ return 0;
+ }
+
+ if ($DEBUG_TEMPLATIZER) {
+# print "matched class decl in $next_line\n";
+ }
+
+ if (grep(/class\s+\w+.*:/, $next_line)
+ || grep(/struct\s+\w+.*:/, $next_line)) {
+ # parses an inheriting class decl.
+ if ($DEBUG_TEMPLATIZER) {
+# print "in inheritance case on $next_line\n";
+ }
+ local(@pieces) = split(/:/, $next_line, 2);
+ # push the rest of the line back into the input array.
+ if ($DEBUG_TEMPLATIZER) {
+# print "going to unshift $pieces[1]...\n";
+ }
+ unshift(@file_array, ": ".$pieces[1]." ");
+ $next_line = $pieces[0];
+ } elsif (grep(/class\s.*\w+\s*\{/, $next_line)
+ || grep(/struct\s.*\w+\s*\{/, $next_line)) {
+ # parses a non-inheriting declaration with bracket on same line.
+ if ($DEBUG_TEMPLATIZER) {
+# print "in special case on $next_line\n";
+ }
+ # special case for continued stuff on same line.
+ local(@pieces) = split(/{/, $next_line, 2);
+ # push the rest of the line back into the input array.
+ unshift(@file_array, " { ".$pieces[1]." ");
+ $next_line = $pieces[0];
+ }
+ if ($DEBUG_TEMPLATIZER) {
+# print "matched class declaration... $next_line\n";
+ }
+ local(@pieces) = split(/\s/, $next_line);
+ $object_name = $pieces[$#pieces];
+ $mangled_name = &mangle_name($object_name);
+ foreach $posn (0 .. $#pieces - 1) { print OUTPUT_FILE "$pieces[$posn] "; }
+ print OUTPUT_FILE "$mangled_name\n";
+ 1;
+}
+
+#
+# processes the implementation of a class member and sets the object
+# name for future use.
+#
+sub match_class_member_definition {
+ local($next_line) = @_[0];
+ local($junk);
+ if (grep(!/\w+<\w+>::/, $next_line)) {
+ return 0;
+ }
+ if ($DEBUG_TEMPLATIZER) {
+# print "matched class member definition... $next_line\n";
+ }
+ local(@pieces) = split(/>::/, $next_line, 2);
+ # checks for spaces in the first part of the split. if there is one,
+ # it means we don't have a simple object thing.
+ if (grep(/\s/, $pieces[0])) {
+ if ($DEBUG_TEMPLATIZER) {
+# print "matched a space in the first part of supposed object name... $pieces[0]\n";
+ }
+ if (grep(/^\w+<\w+>/, $pieces[0])) {
+ if ($DEBUG_TEMPLATIZER) {
+# print "matched a template usage in first part of name...";
+ }
+ # replace some other template with our stuff if we can.
+ $pieces[0] = &special_mangle($pieces[0]);
+ }
+ if ($DEBUG_TEMPLATIZER) {
+# print "now our first bit is: $pieces[0]\n";
+ }
+ local(@new_pieces) = split(/ /, $pieces[0]);
+ $pieces[0] = $new_pieces[$#new_pieces];
+ foreach $posn (0 .. $#new_pieces - 1) {
+ $new_pieces[$posn] =~ s/${place_holder}/${instance_type}/g;
+ print OUTPUT_FILE "$new_pieces[$posn] ";
+ }
+ }
+ unshift(@file_array, "::\n".$pieces[1]."\n");
+ $object_name = $pieces[0];
+ $object_name =~ s/(\W*)(\w+)<(\w+)/\2/;
+ if (length($1)) { print OUTPUT_FILE "$1"; }
+ if ($3 ne $place_holder) {
+ die("The placeholder does not match on this line: $next_line");
+ }
+ $mangled_name = &mangle_name($object_name);
+ print OUTPUT_FILE "$mangled_name\n";
+ 1; # return success.
+}
+
+#
+# processes a function template by making sure it fits the format and
+# then setting up the variables for the replacement. since function templates
+# are so simple, the object name is not changed; only the place_holder is
+# changed to the instance type.
+#
+sub match_function_definition {
+ local($next_line) = @_[0];
+
+ if (grep(!/^\s*\w+\s+.*/, $next_line) ) {
+ if ($DEBUG_TEMPLATIZER) {
+ print "failed on funcdef for ", $next_line, "!\n";
+ }
+ return 0;
+ }
+
+# old broken code:...
+# if (grep(!/^\s*\w+\s+.*\(.*\)\s*/, $next_line) ) {
+#print "failed on funcdef for ", $next_line, "!\n";
+# return 0;
+# }
+
+# if ($DEBUG_TEMPLATIZER) {
+# print "matched function definition on $next_line\n";
+# }
+
+# if ($DEBUG_TEMPLATIZER) {
+# print "stuffing back into the file array $next_line.\n";
+# }
+ # put the line back because it's nearly right for being instantiated.
+ unshift(@file_array, "inline ".$next_line."\n");
+ # come up with a very rare name that will not be matched in the text.
+ $object_name = "hogga_wogga_nunky_budget_weeny_teeny_kahini_beany";
+ $mangled_name = &mangle_name($object_name);
+ 1; # return a success.
+}
--- /dev/null
+#!/bin/bash
+
+# wma to mp3 script by mtron
+# from http://ubuntuforums.org/showthread.php?t=37793
+
+# have found that soundconverter package on ubuntu works on more types
+# and is a bit more polished, but mtron's script kicks ass anyhow, if all
+# you need is wma -> mp3 conversions.
+# --fred hamster
+
+zenity --info \
+ --text="this script converts all wma files in the current folder
+to mp3s and puts them in the folder output
+
+all lame command line options can be set in the next step.
+
+usage:
+ lame -m s: for stereo mp3 output
+ lame -m s V 3-4-5: for stereo mp3 output with VBR"
+
+# Dialog box to choose output quality
+FORMAT=$(zenity --list --title="Choose mp3 output quality" --radiolist --column="Check" --column="Quality (editable)" --editable "" "lame -m s" "" "lame -m s -V 3" "" "lame -m s -V 4" "" "lame -m s -V 5")
+
+if [ $FORMAT -eq ""]; then
+zenity --error --text="mp3 output quality not defined or no wma file found
+
+usage:
+ lame -m s: for stereo mp3 output
+ lame -m s V 3-4-5: for stereo mp3 output with VBR
+
+type: lame --longhelp
+for all command line options "
+exit 1
+fi
+
+mkdir -p output
+cp *.wma output
+cd output
+
+# How many files to make the progress bar
+PROGRESS=0
+NUMBER_OF_FILES=$(find -iname "*.wma")
+let "INCREMENT=100/$NUMBER_OF_FILES"
+
+#remove spaces
+(for i in *.wma; do mv "$i" $(echo $i | tr ' ' '_'); done
+
+#remove uppercase
+for i in *.[Ww][Mm][Aa]; do mv "$i" $(echo $i | tr '[A-Z]' '[a-z]'); done
+
+#Rip with Mplayer / encode with LAME
+for i in *.wma ; do
+echo "$PROGRESS";
+echo "# Re-Coding $i";
+mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && $FORMAT audiodump.wav -o $i;
+let "PROGRESS+=$INCREMENT"
+done
+
+#convert file names
+for i in *.wma; do mv "$i" "$(basename "$i" .wma).mp3";
+done
+
+rm audiodump.wav
+let "PROGRESS+=$INCREMENT"
+) | zenity --progress --title "$Recoding...encoding..." --percentage=0
+
+
--- /dev/null
+
+
+:top
+start "eep" "%0"
+start "op" "%0"
+
+goto :top
--- /dev/null
+#!/bin/bash
+
+while true; do
+ $0 &
+ $0 &
+done
+
--- /dev/null
+#!/bin/sh
+# an example of using the reg.exe tool on windows to find some things in
+# the registry.
+# this happens to look in the registry for PuTTY keys for a set of named
+# displays.
+
+declare ip_array=(zorba-1 zorba-2 zorba-3 zorba-4 zorba-5)
+
+for i in ${ip_array[*]}; do
+ target=${i}
+ echo "display is $target"
+ reg query 'HKCU\Software\SimonTatham\PuTTY\SshHostKeys' /v "rsa2@22:$target"
+done
+
+
+++ /dev/null
-#!/bin/bash
-
-##############
-# Name : fred_techniques
-# Author : Chris Koeritz
-# Rights : Copyright (C) 2010-$now by Author
-##############
-# Copyright (c) 2010-$now By Author. This script is free software; you can
-# redistribute it and/or modify it under the terms of the simplified BSD
-# license. See: http://www.opensource.org/licenses/bsd-license.php
-# Please send updates for this code to: fred@gruntose.com -- Thanks, fred.
-##############
-
-# this script is a collection of helpful bash practices that unfortunately
-# sometimes slip my mind when i need them. it's intended to collect all the
-# good bits so they don't slip away. feel free to re-use them in your own
-# code as needed.
-
-##############
-
-# clean for loops in bash:
-
-for ((i=0; i < 5; i++)) do
- echo $i
-done
-
-##############
-
-# removing an array element
-# --> only works on arrays that have no elements containing a space character.
-
-# define a 5 element array.
-arr=(a b c d e)
-
-# remove element 2 (the 'c').
-removepoint=2
-
-# set the array to slices of itself.
-arr=(${arr[*]:0:$removepoint} ${arr[*]:(($removepoint+1))} )
-
-# show the new contents.
-echo ${arr[*]}
-# shows: a b d e
-
-##############
-
-# store to a variable name by derefercing it.
-
-# shows how you can store into a variable when you are given only its name.
-function store_to_named_var()
-{
- local name="$1"; shift
- eval ${name}=\(gorbachev "perestroikanator 12000" chernenko\)
-}
-
-declare -a ted=(petunia "butter cup" smorgasbord)
-echo ted is ${ted[@]}
-store_to_named_var ted
-echo ted is now ${ted[@]}
-
-##############
-
+++ /dev/null
-#!/bin/bash
-
-#
-# these great examples of handy unix tidbits were donated by "q. black".
-#
-
-# list a directory tree
-ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
-
-# list directory sizes (biggest first)
-du -h $(du -s * |sort -nr|awk '{print $2}')
-
-# this will sort a date field of the form: DD-MON-YYYY HH:MM:SS
-sort +0.7 -1 +0.3M -0.6 +0 -0.2 +1
-
-# this will sort a date field of the form: MON DD HH:MM:SS YYYY
-sort +3 -4 +0M +1n
-
-# this will sort a date field of the form: MON DD HH:MM:SS
-sort +0M +1n
-
-# this will sort a date field of the form: Date: Tue Feb 3 09:17:58 EST 2004
-sort +6 -7 +2M +3n +4
-
-# display all lines from a certain line onward
-start_line=132
-|awk "{if (NR >= ${start_line}){print \$0}}"
-
-# display all lines after a token
-sed '1,/CUT HERE/d'
-
-# print the first and last lines
-sed -n '1,1p;$,$p'
-
-# signal bash about a window size change
-kill -winch $$
-
-# show the date 1 year, 2 months and 3 days ago
-date -v -1y -v -2m -v -3d
-
-# set the date back 1 year
-sudo date $(date -v -1y +%Y%m%d%H%M)
-
-# output the standard date format for setting the time
-# get the date
-date -u +%Y%m%d%H%M.%S
-# set the date
-date -u (cut and paste from above)
-
-# convert one date format to another (output is in the current time zone)
-old_date="Aug 27 15:24:33 2005 GMT"
-new_date=$(date -j -f "%b %e %T %Y %Z" "${old_date}" +%D)
-echo ${new_date}
-# returns "08/27/05"
-
-# output the modification time of a file in different format
-file=
-date -j -f "%b %e %T %Y" "$(ls -lT ${file} |awk '{print $6,$7,$8,$9}')"
-
-# output the number of days until a certain date
-target_date="Sep 2 15:20:20 2005 GMT"
-target_seconds=$(date -j -f "%b %e %T %Y" +%s "${target_date}" 2>/dev/null)
-diff_seconds=$(expr ${target_seconds} - $(date +%s))
-diff_days=$(expr ${diff_seconds} / 86400)
-echo "${diff_days} day(s)"
-
-# these commands can be used to fill in missing times in a "uniq -c" count
-# of times.
-# output 24 hours in one minute increments
-for h in $(jot -w %02d - 0 23 1); do
- for m in $(jot -w %02d - 0 59 1); do
- echo " 0 ${h}:${m}"
- done
-done
-# sort them together, and remove any 0 counts if an count already exists
-sort +1 +0rn out1 out2 |uniq -f 1
-
-# output with w3m to get basic html word wrap
-w3m -T "text/html" -dump -cols 72 <<EOF
- <p>
- This test verifies basic networking and that the ${product_short_name}
- can reach it's default gateway.
-EOF
-
-# another way to format text for output
-fmt 72 <<EOF
-This test verifies basic networking and that the ${product_short_name}
-can reach it's default gateway.
-EOF
-
-# smtpcrypt "printf"
-{
-char *jkwbuf = NULL;
-asprintf(&jkwbuf, "JKW: msg->used = %ld\n", msg->used);
-BIO_write(sc->log, jkwbuf, strlen(jkwbuf)+1);
-free(jkwbuf);
-}
-
-# rolling diff of a list of files (diff a & b, then b & c,...)
-last=
-for i in $(ls -1rt); do
- if [ ! -z "${last}" ]; then
- diff -u ${last} ${i}
- fi
- last=${i}
-done
-
-# clearing and restoring chflags
-file=
-old_chflags=$(ls -lo ${file}|awk '{print $5}')
-chflags 0 ${file}
-# do whatever
-if [ ."${old_chflags}" != ."-" ]; then
- chflags ${old_chflags} ${file}
-fi
-
-# way to do standard edits to files
-file=
-{
- # append line(s) after a line, "i" to insert before
- echo '/www_recovery/a'
- echo 'mithril ALL = (root) NOPASSWD: /usr/local/libexec/destroyer'
- echo '.'
- # modify a line
- echo 'g/^xntpd_program=/s,^xntpd_program=.*$,xntpd_program="ntpd",'
- # delete a line
- echo 'g/^controls key secret =/d'
- echo 'x!'
-} | ex - ${file}
-
-# how to search for errors in the last 24 hours
-# note that this command does not work quite right. The sort is off early
-# in the year because the dates do not have the year.
-# Also sed never sees the /CUT HERE/ when it is the first line.
-(echo "$(date -v-24H "+%b %e %H:%M:%S") --CUT HERE--"; \
- zgrep -h "cookie" /var/log/messages*)|sort +0M| \
- sed '1,/CUT HERE/d'
-# This version fixes those problems. It adds the file year to the date
-# and puts a marker at the start of the list.
-(echo "$(date -j -f "%s" 0 "+%Y %b %e %H:%M:%S") --ALWAYS FIRST--"; \
- echo "$(date -v-24H "+%Y %b %e %H:%M:%S") --CUT HERE--"; \
- for i in /var/log/messages*; do
- year=$(ls -lT ${i}|awk '{print $9}')
- zgrep -h "cookie" ${i}|while read line; do
- echo "${year} ${line}"
- done
- done)|sort +0n +1M| sed '1,/CUT HERE/d'
-
-# process a list of quoted values
-{
- # It tends to be easiest to use a 'here-document' to feed in the list.
- # I prefer to have the list at the start instead of the end
- cat <<EOF
- 'general' 'network node0' 'private address'
- 'general' 'options node2' 'kern securelevel'
-EOF
-}| while read line; do
- eval set -- ${line}
- config=$1; shift
- section=$1; shift
- key=$1; shift
-
- echo "confutil value \"${config}\" \"${section}\" \"${key}\""
-done
-
-# Method to read lines with a "for" loop, without spawning a subshell
-NEWLINE='
-'
-OIFS="${IFS}"
-IFS="${NEWLINE}"
-for line in $(cat /etc/passwd | sort -r); do
- IFS="${OIFS}"
-
- # do whatever you want here
- echo "line = ${line}"
-
- IFS="${NEWLINE}"
-done
-IFS="${OIFS}"
-
-# generate a histogram of characters in a file
-cat file|
- awk '{for (i=1; i <= length($0); i++) {printf("%s\n",substr($0,i,1))}}'|
- sort|uniq -c
-
-# show line lengths for a file
-cat file| awk '{print length($0)}'| sort -n
-
-
-
-
-# get the modification time of a directory or file and then reset the time.
-target=/usr/local/etc/pkdb
-save_date=$(ls -ldT ${target}|awk '{print $6,$7,$8,$9}')
-save_date=$(date -j -f "%b %e %T %Y" "${save_date}" +"%Y%m%d%H%M.%S")
-# later
-touch -t ${save_date} ${target}
-
-
-# detect NULL bytes in a file
-file=
-hexdump -e '"%_u\n"' ${file}|grep -q '^nul$'
-if [ $? -eq 0 ]; then
-else
-fi
-
-
-# calculate average
-cd /tmp
-uudecode
-begin 644 bc.average
-M<V-A;&4],PIT;W1A;#TP"F-O=6YT/3`*=VAI;&4@*#$I('L*("`@(&YU;2`]
-M(')E860H*0H@("`@:68@*&YU;2`]/2`P*2!B<F5A:SL*("`@(&-O=6YT*RL*
-M("`@('1O=&%L("L](&YU;0I]"B)T;W1A;"`]("([('1O=&%L"B)C;W5N="`]
-K("([(&-O=6YT"B)A=F5R86=E(#T@(CL@=&]T86P@+R!C;W5N=`IQ=6ET"@``
-`
-end
-(cat data; echo "0") |bc -q bc.average
-
-
+++ /dev/null
-
-# find out the location where this script is running from. this will not
-# work properly in a bash script that is included via 'source' or '.'.
-# the first letter of each command is escaped to eliminate the danger of
-# personal aliases or functions disrupting the results.
-ORIGINATING_FOLDER="$( \cd "$(\dirname "$0")" && \pwd )"
-
+++ /dev/null
-
-# some aliases that i don't expect very many people to ever want. they are
-# based on some of the mount configurations available at home or abroad.
-
-# moo and unmoo mount the local folders i use most.
-alias moo='check_mount /z/stuffing ; check_mount /z/walrus ; check_mount /z/chunky '
-alias unmoo='umount /z/stuffing ; umount /z/walrus ; umount /z/chunky '
-
-# cleans up the ownership for all my files.
-alias refred='(chown -R fred:fred /home/fred /usr/local/games /home/archives /fatty /clutterato /var/spool/mail/fred ; normal_perm /var/log )'
-
-
+++ /dev/null
-
-# these are my personal overrides. --fred.
-
-# The quartz directory has *really* personalized items.
-export QUARTZDIR=$HOME/quartz
-
-# The gruntose web site is expected to reside below, if it exists at all.
-export WEB_DIR=$HOME/web
-if [ "$(hostname)" = "zooty.koeritz.com" ]; then
- export WEB_DIR=/var/www
-fi
-
-# point to our local certificate for ssh usage.
-export SVN_SSH="ssh -i $HOME/.ssh/id_dsa_sourceforge"
-
-# Error and success noises for CLAM.
-export CLAM_ERROR_SOUND='/z/walrus/media/sounds/effects/bwaaang.wav /z/walrus/media/sounds/cartoons/doh4.wav'
-export CLAM_FINISH_SOUND='/z/walrus/media/sounds/cartoons/meepmeep.wav'
-
-# Setup for nethack adventure.
-export NETHACKOPTIONS='name:Manjusri-W,dogname:Fred,catname:Zonker'
-
-# mail setup for home machines.
-export REPLYTO=fred@gruntose.com
-export from="Fred T. Hamster <fred@gruntose.com>"
-
-# set our browser for seti and others that use the variable.
-export BROWSER=/usr/bin/firefox
-
-# editor and other mixed settings...
-export VISUAL=$(which vim)
-
-#hmmm: move these to the uva profile,
-# rename uva profile to java profile,
-# get them doing the right thing per OS.
-# export JAVA_HOME="c:/Program Files/java/jdk1.6.0_11"
-
-# special settings for win32 and svn.
-if [ "$OS" == "Windows_NT" ]; then
- export EDITOR=$(which gvim)
-else
- export EDITOR=$(which vi)
-fi
-
-# this hideous mess is necessitated by our not having found the source of the
-# settings yet. we override a few colors that look bad on a dark background.
-export LS_COLORS='no=00:fi=00:di=01;37:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;35:*.rpm=00;33:*.deb=00;33:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;35:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;35:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:'
-
-# we set this to avoid paying for slow app signing on win32.
-export NO_SIGNING=true
-
+++ /dev/null
-#!/bin/bash
-
-# Author: Chris Koeritz
-
-# this script tries to intuit where java is installed on this machine.
-
-############################
-
-function intuition_failure()
-{
- missing="$1"; shift
- echo "We cannot intuit your $missing variable for this host."
- # remove the variable because its value is busted.
- unset $missing
-}
-
-############################
-
-# set some fairly liberal limits for ant.
-export ANT_OPTS="-Xms512m -Xmx768m -XX:MaxPermSize=768m"
-
-############################
-
-# start guessing some settings...
-
-# this bin portion works for most javas...
-export JAVA_BIN_PIECE=bin
-
-if [ ! -d "$JAVA_HOME" ]; then
- # first try a recent linux version.
- export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
-fi
-if [ ! -d "$JAVA_HOME" ]; then
- export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
-fi
-if [ ! -d "$JAVA_HOME" ]; then
- # try using a windows version.
-#note: this logic is untested.
-# probably will break due to space in path issues.
- declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jdk" 2>/dev/null)
- if [ ${#any_there[*]} -gt 0 ]; then
- (( last = ${#any_there[@]} - 1 ))
- JAVA_HOME="${any_there[$last]}"
- fi
- if [ ! -d "$JAVA_HOME" ]; then
- # if no jdk, try a jre.
- declare -a any_there=$(find "/c/Program Files/java" -type d -iname "jre" 2>/dev/null)
- if [ ${#any_there[*]} -gt 0 ]; then
- (( last = ${#any_there[@]} - 1 ))
- JAVA_HOME="${any_there[$last]}"
- fi
- fi
-fi
-# this should go last, since it changes the bin dir.
-if [ ! -d "$JAVA_HOME" ]; then
- # if that didn't work, try the location for mac os x.
- JAVA_HOME=/Library/Java/Home
- JAVA_BIN_PIECE=Commands
-fi
-# last thing is to tell them we couldn't find it.
-if [ ! -d "$JAVA_HOME" ]; then
- intuition_failure JAVA_HOME
- unset JAVA_BIN_PIECE
-fi
-
-############################
-
-# intuit where we have our local eclipse.
-if [ ! -d "$ECLIPSE_DIR" ]; then
- export ECLIPSE_DIR=/usr/local/eclipse_jee
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
- ECLIPSE_DIR=$HOME/eclipse
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
- ECLIPSE_DIR=$HOME/apps/eclipse
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
-#uhhh, default on winders?
- ECLIPSE_DIR="/c/Program Files/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
- ECLIPSE_DIR="/c/tools/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
- ECLIPSE_DIR="/d/tools/eclipse"
-fi
-if [ ! -d "$ECLIPSE_DIR" ]; then
- ECLIPSE_DIR="/e/tools/eclipse"
-fi
-# final option is to whine.
-if [ ! -d "$ECLIPSE_DIR" ]; then intuition_failure ECLIPSE_DIR; fi
-
-############################
-
-# use the variables we just set in our path, and try to make them override
-# any other paths to different versions.
-
-if [ ! -z "$JAVA_HOME" ]; then
- export PATH=$JAVA_HOME/$JAVA_BIN_PIECE:$PATH
-fi
-if [ ! -z "$ECLIPSE_DIR" ]; then
- export PATH=$ECLIPSE_DIR:$PATH
-fi
-
-############################
-
-
+++ /dev/null
-
-this folder has some examples of how various people (or one person right now)
-do their custom scripts.
-
-the folder can have alias files (ending in .alias) that are written in bash,
-and it can also have shell scripts that are sourced into the main-line of
-script initialization (any files ending in .sh).
-
-when you have some custom scripts you want to use, copy them from your own
-folder to the $FEISTY_MEOW_GENERATED/custom directory.
-
+++ /dev/null
-export LC_ALL=C
-alias mc='mc -a'
-
-export PATH=$PATH:/home/QtPalmtop/j2me:/home/QtPalmtop/j2me/bin
-
-alias fredme='export HOME=/home/zaurus/fred ; export TMP=$HOME/.tmp ; source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh ; cd '
-
-
+++ /dev/null
-# added to root's ~/.bashrc, the fredme macro enables all the feisty_meow tools.
-
-alias fredme='source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh'
-
+++ /dev/null
-
-# in addition to the .bashrc code that the operating system gives you,
-# you can add this file to your ~/.bashrc if you want the feisty_meow scripts
-# to be loaded up automatically.
-#
-# this is for normal users, not the root user!
-
-# note: it is useful to set your own NAME variable to identify who you are.
-# the feisty_meow scripts will set up a bogus one for you otherwise. in your home
-# directory's .bashrc, you could add something like this, for example:
-# export NAME='Doodmodeus Q. Nornberton'
-
-# don't bother running our stuff for a dumb terminal since any echo
-# can mess with an sftp or scp connection, apparently. similarly, we
-# don't want any automatic startup stuff if we are running under PBS.
-if [ "${TERM}" != "dumb" -a -z "$PBS_ENVIRONMENT" ]; then
- # sets up the feisty_meow scripts, using the default locations for all scripts.
- source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh
-fi
-
+++ /dev/null
-
-# in addition to the .bashrc code that the operating system gives you,
-# you should added this file to your ~/.bashrc if you want the feisty_meow scripts
-# to be loaded up.
-#
-# you also must run bootstrap_shells.sh if you've never used feisty_meow before.
-
-# note: it is useful to set your own NAME variable to identify who you are.
-# the feisty_meow scripts will set up a bogus one for you otherwise. in your home
-# directory's .bashrc, you could add something like this, for example:
-#export NAME='Curmudgeon J. Wankslausteen'
-
-#export TMP=/h/tmp
-
-# add in some useful paths for the local machine.
-export PATH=/bin:$PATH:/c/utilities/emacs-23.2/bin:/c/tools/cvsnt:/c/utilities/Vim/vim71:/c/system/Perl/site/bin:/c/system/Perl/bin:/c/tools/doxygen/bin:/c/tools/graphviz/Graphviz/bin
-
-if [ "${TERM}" != "dumb" -a -z "$PBS_ENVIRONMENT" ]; then
- source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh
-fi
-
-
+++ /dev/null
-#!/usr/bin/perl
-
-###############################################################################
-# #
-# Name : template #
-# Author : Chris Koeritz #
-# Rights : Copyright (C) 1996-$now by Author #
-# #
-# Purpose: #
-# #
-# Attempts to pre-instantiate C++ templates to work-around C++ compilers #
-# that don't support templates (a rare breed, these days). #
-# #
-###############################################################################
-# This program is free software; you can redistribute it and/or modify it #
-# under the terms of the GNU General Public License as published by the Free #
-# Software Foundation; either version 2 of the License or (at your option) #
-# any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
-# version of the License. Please send any updates to "fred@gruntose.com". #
-###############################################################################
-
-# this was a majestic abortive attempt to create a template instantiator for
-# compilers that do not possess templates, but which do support some subset
-# of C++. This was necessary at the time, due to our firmware compiler's
-# limitations. This processor never totally worked, although it did produce
-# some interesting compilable code. Might be useful as a demo or maybe just
-# as a warning to avoid brain-damaged C++ compilers.
-
-# to do:
-# maintain statistics about placement in file for error resolution.
-
-# limitations so far:
-#
-# the word "template" must be the first word on the line.
-#
-# the type to instantiate must be one word (like charstar, not char *).
-#
-# templates must follow the form templateName<templateType> without
-# any spaces between the angle brackets.
-
-# flag to enable debugging print outs.
-$DEBUG_TEMPLATIZER = 1;
-#$DEBUG_TEMPLATIZER = 0;
-
-# array to store instance types to convert to
-@instance_type_buffer = ();
-# flag for checking read from file option
-$f_option = 0;
-$d_option = 0;
-
-if ($#ARGV < 1) {
- die("
- The template instantiater supports an optional directory path as the first
- parameter (preceded by a -d with no spaces in between the d and the
- directory name) in which to store the generated templates, and then
- requires the instantiation type as the next argument (or a file
- specification preceded by -f), and a list of files as the last
- arguments.
- The files will be scanned for templates and those templates will be
- instantiated in the type(s) specified.
- Examples:
- perl template.pl char istring.h torpedo.h
- perl template.pl -f instance.txt matrix.h
- perl template.pl -d. -f instance.txt function.h data_src.h
- perl template.pl -dfirm_src\library\basis -f instance.txt amorph.h\n");
-}
-
-# Check directory option
-if (grep(/^\s*-d/, @ARGV)) {
- $d_option = 1;
- $d_dir = @ARGV[0];
-# print $d_dir, "\n";
- shift;
-}
-
-
-# Check to see if user used a file to specify instantiation types
-if (grep(/^\s*-f/, @ARGV)) {
- $f_option = 1;
- shift;
- $types_file = @ARGV[0];
-
-# Open instantiation type file to read from
- open(TYPES_FILE, "<$types_file")
- || die("couldn't open file $types_file for reading");
-
-# Read in all the different types to instantiate
-# Create instance_type list
- @tp = <TYPES_FILE>;
- while (@tp) {
- local($line) = @tp;
- chop $line;
- push(@instance_type_buffer, $line);
- shift @tp;
- }
- shift @ARGV;
- &instantiate_templates(@ARGV);
- exit;
-}
-
-&instantiate_templates(@ARGV);
-exit;
-
-#
-# driver of the instantiation process.
-#
-sub instantiate_templates {
- if (!$f_option) {
- # grab the user's desired instance type.
- $instance_type = @_[0];
- push(@instance_type_buffer, $instance_type);
- print "Instantiation type is \"$instance_type\".\n";
- # jump over the instance type to look at the filenames.
- shift;
- }
-
- local($i) = 0;
- foreach $filename (@_) {
- open(INPUT_FILE, "<$filename")
- || die("couldn't open file $filename for reading");
- # create an output name for the instance.
- $out_filename = &make_output_name($filename);
- if ($DEBUG_TEMPLATIZER) {
-# print "out file is ", $out_filename, "\n";
- }
- local($index) = $i + 1;
- print "Instantiating file[$index] as $out_filename.\n";
- # now try opening our output file.
- open(OUTPUT_FILE, ">$out_filename")
- || die("couldn't open file $filename for writing");
- # grab the current file into an array.
-
- @file_array = <INPUT_FILE>;
- @start_template = @file_array;
- @stop_template = @file_array;
- # process the file's contents as a manipulable array.
- while (@file_array) {
- local($line) = shift @file_array;
- if (grep(/^\s*template/, $line)) {
- @start_template = @file_array;
-
- # iterate through all the instance types for each template
- foreach $instance_type (@instance_type_buffer) {
- @file_array = @start_template;
- &snag_place_holder($line);
- &snag_object_name;
- &absorb_until_matched_block;
- &replace_place_holder;
- &dump_the_buffer;
- print OUTPUT_FILE "\n";
- }
- } elsif (grep(/\w+<\w+>/, $line)) {
- local(@pieces) = split(/\s/, $line);
- foreach $piece (@pieces) {
- local($prefix) = "";
- # special case for separating function name from templated first
- # parameter to it.
- if (grep(/\(\w+</, $piece)) {
- local(@chop_paren) = split(/\(/, $piece, 2);
- $prefix = $chop_paren[0].'(';
- $piece = $chop_paren[1];
- }
- if (grep(/\w+<\w+>/, $piece)) { $piece = &special_mangle($piece); }
- print OUTPUT_FILE "$prefix$piece ";
- }
- print OUTPUT_FILE "\n";
- } else {
- print OUTPUT_FILE $line;
- }
- }
- $i++;
- }
-}
-
-#
-# generates an output name from the filename to be translated.
-#
-sub make_output_name {
- local($out_filename) = @_[0];
- local($d_dir_temp) = $d_dir;
-# print "OUTFILE NAME: ",$out_filename,"\n";
- # break down the filename at the slashes.
- local(@split_filename) = split(/[\\\/]/, $out_filename);
- # take the basename of the list of names.
- $out_filename = $split_filename[$#split_filename];
- local($hold_filename) = $out_filename;
- if (grep(!/\.cpp$/i, $out_filename) && grep(!/\.h$/i, $out_filename)
- && grep(!/\.c$/i, $out_filename) && grep(!/\.h$/i, $out_filename) ) {
- die("filename @_[0] not recognized as a C++ code file.");
- }
- # makes an instance of the file in a directory named after the instance type
- # that is located under the current directory.
-
- $d_dir_temp = join('/',$d_dir, $hold_filename);
- if ($d_option) {
- $d_dir_temp =~ s/-d//i;
- @split_filename = split(/[\\\/]/, $d_dir_temp);
-# exit;
- }
-
-# try to create dir using the deepest dir given in filename input
-
- local($y) = 0;
- foreach (@split_filename) { $y++; }
-
- local($x) = 0;
- local($ret) = 0;
- local($dirs) = 0;
-
- if ($y >= 2) {
- foreach (@split_filename) {
- if ((($x > 0) && ($x < $y-1)) || (($d_option) && ($x < $y-1))) {
- if (!$dirs) { $dirs = @split_filename[$x]; }
- else { $dirs = $dirs."/".@split_filename[$x]; }
-# print "Creating... ",$dirs,"\n";
- $ret = mkdir($dirs, 0777);
- if (!ret) { die("a directory named $instance_dir could not be made."); }
- }
- $x++;
- }
- $out_filename = $dirs."/".$hold_filename;
- }
- else { $out_filename = "template/".$hold_filename;
- local($instance_dir) = "template";
- $ret = mkdir($instance_dir, 0777);
- if (!ret) { die("a directory named $instance_dir could not be made."); }
- }
-# print $out_filename, "\n";
-
-# local($instance_dir) = @split_filename[$x-2];
-# creates the directory.
-# local($ret) = mkdir($instance_dir, 0777);
-# if (!ret) { die("a directory named $instance_dir could not be made."); }
-
- $out_filename; # return the new name.
-}
-
-#
-# grabs the name of the placeholder type that will be replaced by
-# the template instantiation type.
-#
-sub snag_place_holder {
- $place_holder = @_[0];
- chop $place_holder;
-
- local(@pieces) = split(/>\s*/, $place_holder, 2);
-
- # send back the parts not involved in the template statement.
- if (length($pieces[1])) {
- unshift(@file_array, $pieces[1]."\n");
- }
- $place_holder = $pieces[0];
- $place_holder =~ s/\s*template\s+<class\s+(\w+)$/\1/;
- if ($DEBUG_TEMPLATIZER) {
-# print "Replacing place holder \"$place_holder\" with \"$instance_type\".\n";
- }
-}
-
-#
-# grabs the name of the object itself that will become an instantiated
-# object in the type specified. the global variable "object_name" is
-# set by the subfunctions used here.
-#
-sub snag_object_name {
- local($next_line) = shift(@file_array);
- chop $next_line;
- &match_class_declaration($next_line)
- || &match_class_member_definition($next_line)
- || &match_function_definition($next_line);
-}
-
-#
-# creates a mangled form of the name that includes the instantiation
-# type. the global variable "mangled_name" is set by this function.
-#
-sub mangle_name {
- local($to_grind) = @_[0];
- local($mangled_name) = "template__".$to_grind."__".$instance_type;
- if ($DEBUG_TEMPLATIZER) {
-# print "Replacing name \"$to_grind\" with \"$mangled_name\".\n";
- }
- $mangled_name;
-}
-
-#
-# processes "#include" preprocessor directives to make sure if the filename
-# is in there to include a C++ file (for the template code), then it gets
-# converted to the new file name.
-#
-
-# this is a pretty bogus thing; it should not be used.
-
-sub convert_inclusion {
- local($line) = @_[0];
- chop $line;
- local($temp) = $line;
- # extract out the name parts of the include declaration.
- $temp =~ s/\s*#include\s*([<"])([\w.]+)([>"])/\1 \2 \3/;
- local(@broken_up) = split(/ /, $temp);
- # strip off the punctuation from the name.
- local($incl_prefix) = @broken_up[1];
- $incl_prefix =~ s/["<](.*)[">]/\1/;
- $incl_prefix =~ s/\s//g;
- # return if it's not a code file being included.
- if (!grep(/.cpp/i, $incl_prefix)) { print OUTPUT_FILE $line, "\n"; return; }
- # strip to just the name without the ending.
- $incl_prefix =~ s/\.cpp$//i;
- # now get the name of the file we're processing.
- local($file_prefix) = $filename;
- # return if it's not a header file being examined.
- if (!grep(/.h/i, $file_prefix)) { print OUTPUT_FILE $line, "\n"; return; }
- # strip off the extension.
- $file_prefix =~ s/\.h$//i;
- # return if the names aren't equivalent--this means the include doesn't
- # refer to our new templated form of the code file.
- if ($incl_prefix ne $file_prefix) { print OUTPUT_FILE $line, "\n"; return FALSE; }
- # dump out a message about the removal.
- $line =~ s/^\s*//;
- print OUTPUT_FILE "/* removed unneeded template inclusion: $line */\n";
-}
-
-#
-# extracts lines from the file until the curly brackets are matched up
-# at level 0.
-#
-sub absorb_until_matched_block {
- $bracket_level = 0;
- $end_absorb = 0;
- @template_buffer = ();
- $hit_one=0;
- while (@file_array) {
- local($line) = shift @file_array;
- &look_for_curlies($line);
- if (($hit_one && ($bracket_level == 0)) || $end_absorb) { return; }
- }
-}
-
-#
-# examines the parameters passed in for curly brackets and changes the
-# counter if they are found.
-#
-sub look_for_curlies {
-# $hit_one = 0; # records whether a bracket was found or not.
- local($line) = @_[0];
- @word = ();
- foreach $char (split(//, $line)) {
- if ($char eq '{') {
- $hit_one = 1;
- $bracket_level++;
- } elsif ($char eq '}') {
- $hit_one = 1;
- $bracket_level--;
- } elsif (($char eq ';') && ($hit_one==0)) {
- $end_absorb = 1;
- }
-
-
- if ($DEBUG_TEMPLATIZER) {
-# print "~$char~ ";
- }
- push(@word, $char);
- if (grep(!/\w/, $char)) {
- # don't split yet if it's a possible template char.
- if (grep(!/[<>]/, $char)) {
- local($real_word) = join("", @word);
- if ($DEBUG_TEMPLATIZER) {
-# print "adding a word $real_word\n";
- }
- push(@template_buffer, "$real_word");
- @word = ();
- }
- }
- }
-}
-
-#
-# this goes through the buffer and replaces all occurrences of the name to
-# replace with the instance name.
-#
-sub replace_place_holder {
- @new_template_buffer = @template_buffer;
- @template_buffer = ();
-
- foreach $i (0 .. $#new_template_buffer) {
- $word = $new_template_buffer[$i];
-# if ($DEBUG_TEMPLATIZER) {
-# print "<$i $word> ";
-# $old = $word;
-# }
-
- # replace a templated combination with the mangled version.
- $word =~ s/^${object_name}<${instance_type}>/${mangled_name}/;
-
-# if ($DEBUG_TEMPLATIZER) {
-# if ($old ne $word) {print "1 ... changed to $word.\n"; $old = $word; }
-# }
-
- if (grep(/^\w+<\w+>/, $word)) {
- # replace some other template with our stuff if we can.
- $word = &special_mangle($word);
- }
-
-# if ($DEBUG_TEMPLATIZER) {
-# if ($old ne $word) {print "2 ... changed to $word.\n"; $old = $word; }
-# }
-
- # replace the object's name with its mangled form.
- $word =~ s/^${object_name}/${mangled_name}/;
-
-# if ($DEBUG_TEMPLATIZER) {
-# if ($old ne $word) {print "3... changed to $word.\n"; $old = $word; }
-# }
-
- # replace the place holder with the instantiation type.
- $word =~ s/^${place_holder}/${instance_type}/;
-
-# if ($DEBUG_TEMPLATIZER) {
-# if ($old ne $word) {print "4... changed to $word.\n"; $old = $word; }
-# }
-
- push(@template_buffer, $word);
- }
-}
-
-#
-# processes a general template usage, in the form X<Y>, where either
-# X or Y are not ones that we think we need to replace. it is assumed
-# that it's safe to use the mangled form of the template.
-#
-sub special_mangle {
- local($word) = @_[0];
- # split the template form into pieces.
- local(@pieces) = split(/[<>]/, $word, 2);
-
- $pieces[1] =~ s/${place_holder}/${instance_type}/;
- $pieces[1] =~ s/>//;
- # hold onto the real instance type.
- local($hold_instance) = $instance_type;
- $instance_type = $pieces[1];
- # mangle the name in the template usage line.
- local($hold_mangled) = &mangle_name($pieces[0]);
- # restore the original instance type.
- $instance_type = $hold_instance;
- # returns the new mangled form.
- $hold_mangled;
-}
-
-#
-# prints out the buffer we've accumulated to the output file.
-#
-sub dump_the_buffer {
- print OUTPUT_FILE @template_buffer;
-}
-
-#
-# processes a class declaration and sets the object name for future use.
-#
-sub match_class_declaration {
- local($next_line) = @_[0];
-# too strict!
-# if (grep(!/class\s.*\w+$/, $next_line)
-# && grep(!/class\s.*\w+\s*\{/, $next_line)
-# && grep(!/struct\s.*\w+$/, $next_line)
-# && grep(!/struct\s.*\w+\s*\{/, $next_line)) {
-# return 0;
-# }
-
- if (grep(!/class\s+\w+/, $next_line) && grep(!/struct\s+\w+/, $next_line) ) {
- return 0;
- }
-
- if ($DEBUG_TEMPLATIZER) {
-# print "matched class decl in $next_line\n";
- }
-
- if (grep(/class\s+\w+.*:/, $next_line)
- || grep(/struct\s+\w+.*:/, $next_line)) {
- # parses an inheriting class decl.
- if ($DEBUG_TEMPLATIZER) {
-# print "in inheritance case on $next_line\n";
- }
- local(@pieces) = split(/:/, $next_line, 2);
- # push the rest of the line back into the input array.
- if ($DEBUG_TEMPLATIZER) {
-# print "going to unshift $pieces[1]...\n";
- }
- unshift(@file_array, ": ".$pieces[1]." ");
- $next_line = $pieces[0];
- } elsif (grep(/class\s.*\w+\s*\{/, $next_line)
- || grep(/struct\s.*\w+\s*\{/, $next_line)) {
- # parses a non-inheriting declaration with bracket on same line.
- if ($DEBUG_TEMPLATIZER) {
-# print "in special case on $next_line\n";
- }
- # special case for continued stuff on same line.
- local(@pieces) = split(/{/, $next_line, 2);
- # push the rest of the line back into the input array.
- unshift(@file_array, " { ".$pieces[1]." ");
- $next_line = $pieces[0];
- }
- if ($DEBUG_TEMPLATIZER) {
-# print "matched class declaration... $next_line\n";
- }
- local(@pieces) = split(/\s/, $next_line);
- $object_name = $pieces[$#pieces];
- $mangled_name = &mangle_name($object_name);
- foreach $posn (0 .. $#pieces - 1) { print OUTPUT_FILE "$pieces[$posn] "; }
- print OUTPUT_FILE "$mangled_name\n";
- 1;
-}
-
-#
-# processes the implementation of a class member and sets the object
-# name for future use.
-#
-sub match_class_member_definition {
- local($next_line) = @_[0];
- local($junk);
- if (grep(!/\w+<\w+>::/, $next_line)) {
- return 0;
- }
- if ($DEBUG_TEMPLATIZER) {
-# print "matched class member definition... $next_line\n";
- }
- local(@pieces) = split(/>::/, $next_line, 2);
- # checks for spaces in the first part of the split. if there is one,
- # it means we don't have a simple object thing.
- if (grep(/\s/, $pieces[0])) {
- if ($DEBUG_TEMPLATIZER) {
-# print "matched a space in the first part of supposed object name... $pieces[0]\n";
- }
- if (grep(/^\w+<\w+>/, $pieces[0])) {
- if ($DEBUG_TEMPLATIZER) {
-# print "matched a template usage in first part of name...";
- }
- # replace some other template with our stuff if we can.
- $pieces[0] = &special_mangle($pieces[0]);
- }
- if ($DEBUG_TEMPLATIZER) {
-# print "now our first bit is: $pieces[0]\n";
- }
- local(@new_pieces) = split(/ /, $pieces[0]);
- $pieces[0] = $new_pieces[$#new_pieces];
- foreach $posn (0 .. $#new_pieces - 1) {
- $new_pieces[$posn] =~ s/${place_holder}/${instance_type}/g;
- print OUTPUT_FILE "$new_pieces[$posn] ";
- }
- }
- unshift(@file_array, "::\n".$pieces[1]."\n");
- $object_name = $pieces[0];
- $object_name =~ s/(\W*)(\w+)<(\w+)/\2/;
- if (length($1)) { print OUTPUT_FILE "$1"; }
- if ($3 ne $place_holder) {
- die("The placeholder does not match on this line: $next_line");
- }
- $mangled_name = &mangle_name($object_name);
- print OUTPUT_FILE "$mangled_name\n";
- 1; # return success.
-}
-
-#
-# processes a function template by making sure it fits the format and
-# then setting up the variables for the replacement. since function templates
-# are so simple, the object name is not changed; only the place_holder is
-# changed to the instance type.
-#
-sub match_function_definition {
- local($next_line) = @_[0];
-
- if (grep(!/^\s*\w+\s+.*/, $next_line) ) {
- if ($DEBUG_TEMPLATIZER) {
- print "failed on funcdef for ", $next_line, "!\n";
- }
- return 0;
- }
-
-# old broken code:...
-# if (grep(!/^\s*\w+\s+.*\(.*\)\s*/, $next_line) ) {
-#print "failed on funcdef for ", $next_line, "!\n";
-# return 0;
-# }
-
-# if ($DEBUG_TEMPLATIZER) {
-# print "matched function definition on $next_line\n";
-# }
-
-# if ($DEBUG_TEMPLATIZER) {
-# print "stuffing back into the file array $next_line.\n";
-# }
- # put the line back because it's nearly right for being instantiated.
- unshift(@file_array, "inline ".$next_line."\n");
- # come up with a very rare name that will not be matched in the text.
- $object_name = "hogga_wogga_nunky_budget_weeny_teeny_kahini_beany";
- $mangled_name = &mangle_name($object_name);
- 1; # return a success.
-}
+++ /dev/null
-#!/bin/bash
-
-# wma to mp3 script by mtron
-# from http://ubuntuforums.org/showthread.php?t=37793
-
-# have found that soundconverter package on ubuntu works on more types
-# and is a bit more polished, but mtron's script kicks ass anyhow, if all
-# you need is wma -> mp3 conversions.
-# --fred hamster
-
-zenity --info \
- --text="this script converts all wma files in the current folder
-to mp3s and puts them in the folder output
-
-all lame command line options can be set in the next step.
-
-usage:
- lame -m s: for stereo mp3 output
- lame -m s V 3-4-5: for stereo mp3 output with VBR"
-
-# Dialog box to choose output quality
-FORMAT=$(zenity --list --title="Choose mp3 output quality" --radiolist --column="Check" --column="Quality (editable)" --editable "" "lame -m s" "" "lame -m s -V 3" "" "lame -m s -V 4" "" "lame -m s -V 5")
-
-if [ $FORMAT -eq ""]; then
-zenity --error --text="mp3 output quality not defined or no wma file found
-
-usage:
- lame -m s: for stereo mp3 output
- lame -m s V 3-4-5: for stereo mp3 output with VBR
-
-type: lame --longhelp
-for all command line options "
-exit 1
-fi
-
-mkdir -p output
-cp *.wma output
-cd output
-
-# How many files to make the progress bar
-PROGRESS=0
-NUMBER_OF_FILES=$(find -iname "*.wma")
-let "INCREMENT=100/$NUMBER_OF_FILES"
-
-#remove spaces
-(for i in *.wma; do mv "$i" $(echo $i | tr ' ' '_'); done
-
-#remove uppercase
-for i in *.[Ww][Mm][Aa]; do mv "$i" $(echo $i | tr '[A-Z]' '[a-z]'); done
-
-#Rip with Mplayer / encode with LAME
-for i in *.wma ; do
-echo "$PROGRESS";
-echo "# Re-Coding $i";
-mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && $FORMAT audiodump.wav -o $i;
-let "PROGRESS+=$INCREMENT"
-done
-
-#convert file names
-for i in *.wma; do mv "$i" "$(basename "$i" .wma).mp3";
-done
-
-rm audiodump.wav
-let "PROGRESS+=$INCREMENT"
-) | zenity --progress --title "$Recoding...encoding..." --percentage=0
-
-
+++ /dev/null
-
-
-:top
-start "eep" "%0"
-start "op" "%0"
-
-goto :top
+++ /dev/null
-#!/bin/bash
-
-while true; do
- $0 &
- $0 &
-done
-
+++ /dev/null
-#!/bin/sh
-# an example of using the reg.exe tool on windows to find some things in
-# the registry.
-# this happens to look in the registry for PuTTY keys for a set of named
-# displays.
-
-declare ip_array=(zorba-1 zorba-2 zorba-3 zorba-4 zorba-5)
-
-for i in ${ip_array[*]}; do
- target=${i}
- echo "display is $target"
- reg query 'HKCU\Software\SimonTatham\PuTTY\SshHostKeys' /v "rsa2@22:$target"
-done
-
-