and double oops
authorChris Koeritz <fred@gruntose.com>
Thu, 2 Feb 2017 06:57:49 +0000 (01:57 -0500)
committerChris Koeritz <fred@gruntose.com>
Thu, 2 Feb 2017 06:57:49 +0000 (01:57 -0500)
here are the new folders that were created, if any....

15 files changed:
scripts/buildor/locate_function_in_lib.sh [new file with mode: 0644]
scripts/buildor/zap_msbuilds.sh [new file with mode: 0644]
scripts/files/exploder.sh [new file with mode: 0644]
scripts/info_mgt/apache_log_sorter.sh [new file with mode: 0644]
scripts/multimedia/webcam_snagger.sh [new file with mode: 0644]
scripts/processes/find_user.sh [new file with mode: 0644]
scripts/processes/findme.sh [new file with mode: 0644]
scripts/processes/goodbye.sh [new file with mode: 0644]
scripts/security/get_x_auth.sh [new file with mode: 0644]
scripts/testing/rounder.sh [new file with mode: 0644]
scripts/testing/run_test_and_verify.sh [new file with mode: 0644]
scripts/testing/test_array_sifter.sh [new file with mode: 0644]
scripts/testing/test_assoc_array.sh [new file with mode: 0644]
scripts/testing/test_time_tracker.sh [new file with mode: 0644]
scripts/testing/verify_correct_input.sh [new file with mode: 0644]

diff --git a/scripts/buildor/locate_function_in_lib.sh b/scripts/buildor/locate_function_in_lib.sh
new file mode 100644 (file)
index 0000000..6a49c1e
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+filename="$1"; shift
+function_name="$1"; shift
+
+good_path="$(cygpath -w -s $filename)"
+
+#/exports 
+dumpbin /all $good_path | grep -q -i "$function_name"
+if [ $? -eq 0 ]; then
+  echo "Found $function_name in $filename"
+fi
+
+
+
diff --git a/scripts/buildor/zap_msbuilds.sh b/scripts/buildor/zap_msbuilds.sh
new file mode 100644 (file)
index 0000000..57c8e74
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+# this simple script kills off some troublesome processes in preparation for a new build
+# with visual studio.
+zap_process.exe msbuild.exe 
+zap_process.exe mspdbsrv.exe
+
diff --git a/scripts/files/exploder.sh b/scripts/files/exploder.sh
new file mode 100644 (file)
index 0000000..6199105
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+parm=$1
+
+#echo original parm is: $parm
+# turn the form that is just two characters of /X into X:/.
+parm=$(echo $parm | sed -e 's/^\/\([a-zA-Z]\)$/\1:\//g')
+#echo parm now is $parm
+# turn the msys path form into an msdos style path for the drive letter.
+parm=$(echo $parm | sed -e 's/^\/\([a-zA-Z]\)\//\1:\//g')
+#echo parm now is $parm
+# turn the form that is /cygdrive/X into X:/.
+parm=$(echo $parm | sed -e 's/^\/cygdrive\/\([a-zA-Z]\)$/\1:\//g')
+#echo parm now is $parm
+# turn regular cygwin paths into msdos style paths for the drive letter.
+parm=$(echo $parm | sed -e 's/^\/cygdrive\/\([a-zA-Z]\)\//\1:\//g')
+#echo parm now is $parm
+# rip off any slashes on the end, if they aren't too close to a colon.
+parm=$(echo $parm | sed -e 's/\([^:]\)\/*$/\1/g')
+#echo parm now is $parm
+# turn linux forward slashes into dos backward slashes.
+parm=$(echo $parm | sed -e 's/\//\\/g')
+#echo "totally chewed parm is: $parm"
+
+$WINDIR/explorer "$parm"
+
diff --git a/scripts/info_mgt/apache_log_sorter.sh b/scripts/info_mgt/apache_log_sorter.sh
new file mode 100644 (file)
index 0000000..5da498c
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ ! -f $1 ]; then
+  echo "Usage: $0 "
+  echo "This script needs a file to sort and a new name for the file after sorting."
+  exit 1
+fi
+
+echo "Sorting $1 into $2"
+
+sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $1 > $2
+
+
diff --git a/scripts/multimedia/webcam_snagger.sh b/scripts/multimedia/webcam_snagger.sh
new file mode 100644 (file)
index 0000000..9dcde0d
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# the file name to be found on the remote site is expected to be named
+# using the prefix and suffix below.
+# example: prefix=webcam and suffix=jpg leads to a picture named webcam.jpg
+FILE_PREFIX=webcam
+FILE_SUFFIX=jpg
+
+# this is the location on the internet (or local network) where the file
+# can be found.
+#WEBPIX_SITE='http://gruntose.com/'
+WEBPIX_SITE='ftp://velma/incoming'
+
+# this points at the directory where the downloaded pictures will be stored.
+WEBPIX_DIR=$HOME/pix_webcam
+if [ ! -d $WEBPIX_DIR ]; then mkdir $WEBPIX_DIR; fi
+# make sure that the directory creation worked.
+if [ ! -d $WEBPIX_DIR ]; then 
+  echo "The target directory $WEBPIX_DIR cannot be created."
+  exit 51;
+fi
+
+# the number of seconds to sleep between snapshots of the source file.
+SNOOZE_PERIOD=3
+
+# our loop variable.  if you want the numbers that are added to the name to
+# start at a different value, then change that here.
+index=1
+
+while [ $index -lt 10000 ]; do
+  # grab the file and store it to a local location.  
+  chewed_index=$index
+#hmmm: would be nice to have the numbers prefixed by zeros.
+  if [ $chewed_index -lt 1000 ]; then chewed_index=0$chewed_index; fi
+  if [ $chewed_index -lt 100 ]; then chewed_index=0$chewed_index; fi
+  if [ $chewed_index -lt 10 ]; then chewed_index=0$chewed_index; fi
+
+  wget -i $WEBPIX_SITE/$FILE_PREFIX.$FILE_SUFFIX -o $WEBPIX_DIR/$FILE_PREFIX$chewed_index.$FILE_SUFFIX
+
+  index=$(expr $index + 1)
+  sleep $SNOOZE_PERIOD
+done
+
diff --git a/scripts/processes/find_user.sh b/scripts/processes/find_user.sh
new file mode 100644 (file)
index 0000000..66358cf
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+if test $# -lt 1; then
+  echo $(basename $0): requires a user id for which to search.;
+  \exit 1;
+fi
+tempname="$(mktemp "$TMP/zz_trash.findme.XXXXXX")"
+ps wuax | grep "$1[    ]*[0-9]" | sed -e '
+       /sed/d
+       /\/bin\/sh.*\/scripts\/find/d
+       /ps -uxg/d' >$tempname
+# sed command eliminates field ambiguity for STAT field
+cat $tempname| sed -e '/[RSD] N/s/[RSD] N/NUN/' |
+awk '/^'$1'/ {
+       ORS=""
+       print "process #" $2, "started", $9 " "
+       if ($9 ~ /^[A-Za-z]/) {
+               print $10, "with "
+       } else {
+               print "with", $11 " "
+       }
+       print $12, $13, $14, $15, $16, $17 "\n"
+       }
+' | sort -k 1 -t\# -n
+/bin/rm $tempname
diff --git a/scripts/processes/findme.sh b/scripts/processes/findme.sh
new file mode 100644 (file)
index 0000000..95487b1
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/bash
+# finds the current user's processes in the process list.
+snuser=$USER
+if [ -z "$snuser" ]; then snuser=$USERNAME; fi
+# more checks?  what else would we get it from, REPLYTO?
+bash "$FEISTY_MEOW_SCRIPTS/users/find_user.sh" $snuser
diff --git a/scripts/processes/goodbye.sh b/scripts/processes/goodbye.sh
new file mode 100644 (file)
index 0000000..674a119
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# just prints a message before terminal exit.
+
+source $FEISTY_MEOW_SCRIPTS/core/functions.sh
+
+nechung
+
+# quick pause to reflect.
+sleep 2
+
+\exit 0
diff --git a/scripts/security/get_x_auth.sh b/scripts/security/get_x_auth.sh
new file mode 100644 (file)
index 0000000..c9f2ea8
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+# This script finds the X window system authorization info that's already
+# been established for this display.  The information can then be used to
+# set the authorization for a new su session, which keeps X secure as
+# well as allowing the user to run X programs on the original display.
+
+# make sure we have some information to return in the first place.
+if [ ! -z "$DISPLAY" ]; then 
+  disp_search=$(echo $DISPLAY | sed -e 's/.*:\([0-9]*\).*/:\1/')
+#echo disp search is $disp_search
+  temp_auth=$(xauth list | grep -i $HOSTNAME | grep $disp_search)
+#echo temp auth is $temp_auth
+  temp_auth2=$(echo $temp_auth | sed -e "s/$HOSTNAME/; xauth add $HOSTNAME/g" )
+#echo temp auth2 is $temp_auth2
+  export X_auth_info="echo setting X permissions $temp_auth2"
+#echo $X_auth_info
+
+fi
+
diff --git a/scripts/testing/rounder.sh b/scripts/testing/rounder.sh
new file mode 100644 (file)
index 0000000..3214ee6
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# sample the first argument to make sure it's not empty.
+# we can't know if the command is really valid or not, but it at least
+# needs to not be empty.
+test_to_run="$1"
+
+if [ -z "$test_to_run" ]; then
+  echo "This script requires a test or program to run as the first parameter."
+  exit 1
+fi
+
+trashdir="$(mktemp -d "$TMP/rounder.XXXXXX")"
+
+echo "Running command: $*"
+echo "Storing log files in: $trashdir"
+
+round=0
+while true; do
+  round=$((round+1))
+  echo ============================
+  echo round $round commencing
+  outputfile="$trashdir/run_round_${round}.log"
+echo real cmd:
+echo "${@}" 
+  eval "${@}" 2>&1 | tee $outputfile
+  if [ ${PIPESTATUS[0]} -ne 0 ]; then
+    echo FAILURE IN RUN $round
+    break
+  fi
+  echo round $round successful.
+done 
+
diff --git a/scripts/testing/run_test_and_verify.sh b/scripts/testing/run_test_and_verify.sh
new file mode 100644 (file)
index 0000000..cb03745
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+# a simple unit test component that takes three parameters: the test to run, the
+# input file to give that test, and the expected correct output file from the test.
+# the script will complain if there is an error in the test output.  otherwise it
+# says nothing, but the script's return value can also be checked.
+
+to_run="$1"; shift
+input_file="$1"; shift
+answer_file="$1"; shift
+
+eval "$to_run" < "$input_file" | bash "$FEISTY_MEOW_SCRIPTS/unit_test/verify_correct_input.sh" "$answer_file"
+
diff --git a/scripts/testing/test_array_sifter.sh b/scripts/testing/test_array_sifter.sh
new file mode 100644 (file)
index 0000000..26173f1
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# tests the array sifter methods.
+
+source $FEISTY_MEOW_SCRIPTS/core/array_sifter.sh
+
+#demo 1 & 2 for test presence.
+declare -a my_array=(peanuts sauce fish basil)
+
+test1=basil
+test_presence my_array $test1
+if [ $? != 0 ]; then
+  echo "test1 did not find flag, but should have."
+else
+  echo "test1 found expected flag."
+fi
+
+test2=spoo
+test_presence my_array $test2
+if [ $? != 0 ]; then
+  echo "test2 did not find flag, which is correct."
+else
+  echo "test2 found flag when should not have."
+fi
+
+#############################################
+
+#demo3 for sifting...
+
+declare -a sift_list=(ontrack selenium aggressive)
+declare -a stripping=(selenium)
+declare -a store_list=()
+
+sift_array "sift_list" "stripping" "store_list" 
+if [ ${store_list[0]} == "selenium" ]; then
+  echo "test3 found expected content in storage list."
+else
+  echo "test3 was missing expected content in storage list."
+fi
+echo sift is now ${sift_list[*]}
+if [ "${sift_list[*]}" == "ontrack aggressive" ]; then
+  echo "test3 found expected content in sifting list."
+else
+  echo "test3 was missing expected content in sifting list."
+fi
+
+
diff --git a/scripts/testing/test_assoc_array.sh b/scripts/testing/test_assoc_array.sh
new file mode 100644 (file)
index 0000000..8da0424
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+##############
+
+# simple examples...
+
+declare -A snuggles
+  # make an associative array
+
+snuggles=([book]=petunia [muffets]="glasgow robbery")
+  # keys: book and muffets
+  # values: (second part)
+
+snuggles+=([morgower]=flimshaw)
+  # adding entries to it.
+
+echo ${!snuggles[x]}
+  # show index x's key.
+
+echo ${snuggles[x]}
+  # show index x's value.
+
+##############
+
+# excellent code from:
+# http://blog.spencertipping.com/2009/08/constant-time-associative-arrays-in-bash
+typeset -a table_keys
+typeset -a table_values
+function index_of_key () {
+  initial=$(($(echo $1 | md5sum | cut -c 18-32 | awk '{print "0x"$1}')))
+  while [[ ${table_keys[$initial]} && ${table_keys[$initial]} != $1 ]]; do
+    initial=$((initial + 1))
+  done
+  echo -n $initial
+}
+function associate () {
+  index=$(index_of_key $1)
+  table_keys[$index]=$1
+  table_values[$index]=$2
+  echo -n $2
+}
+function lookup () {
+  index=$(index_of_key $1)
+  echo -n ${table_values[$index]}
+}
+echo Associating foo with bar and bif with baz
+associate foo bar && echo
+associate bif baz && echo
+echo -n Looking up foo:
+lookup foo && echo
+echo -n Looking up bif:
+lookup bif && echo
+echo -n Looking up bar:
+lookup bar && echo
+
+##############
+
diff --git a/scripts/testing/test_time_tracker.sh b/scripts/testing/test_time_tracker.sh
new file mode 100644 (file)
index 0000000..9a90857
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# tests out the time tracking methods.
+
+source $FEISTY_MEOW_SCRIPTS/system/time_tracker.sh
+
+echo testing time tracking...
+start_time_tracking crungle
+
+sleep $(($RANDOM / 1000))
+sleep 2
+
+end_time_tracking crungle
+
+echo ...done testing time tracking.
+
+show_tracked_duration crungle
+
diff --git a/scripts/testing/verify_correct_input.sh b/scripts/testing/verify_correct_input.sh
new file mode 100644 (file)
index 0000000..1cdef40
--- /dev/null
@@ -0,0 +1,40 @@
+#/bin/bash
+
+# a simple component of unit testing which verifies that the input matches
+# the expected input.
+
+# the single parameter to the script is a file that contains the correct answer.
+
+source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
+
+answer_file="$1"; shift
+
+if [ -z "$answer_file" -o ! -f "$answer_file" ]; then
+  echo This script needs a valid file parameter that points at the correct
+  echo values for the data stream.
+  exit 1
+fi
+
+input_save_file="$(mktemp "$TMP/zz_verify_input.XXXXXX")"
+
+while read line; do
+  echo $line >>"$input_save_file"
+done
+
+diff -q "$input_save_file" "$answer_file"
+if [ $? -ne 0 ]; then
+  sep 76
+  echo "The provided text differs from the correct answer!"
+  echo -e "\nAnswer file has:\n=============="
+  cat "$answer_file"
+  echo -e "==============\nBut the data we saw has:\n=============="
+  cat "$input_save_file"
+  echo -e "=============="
+  sep 76
+  false  # set bad exit value.
+fi
+
+rm "$input_save_file"
+
+exit $?
+