Skip to content

Instantly share code, notes, and snippets.

@jamerfort
jamerfort / avg.awk
Created November 28, 2012 21:22
Awk scripts for total/average/max/min. All numbers come in on STDIN
#!/usr/bin/awk -f
BEGIN { TOTAL=0 }
{ TOTAL = TOTAL + $1 }
END { print TOTAL/NR }
@jamerfort
jamerfort / print_variant.tcl
Created September 27, 2012 19:58
Tcl script to print a Cloverleaf variant out to stdout.
#!/usr/bin/env tclsh
#####################################################
# Usage: tclsh print_variant.tcl <variant_directory>
# OR: hcitcl print_variant.tcl <variant_directory>
#####################################################
proc print_variant {variant_dir} {
puts "################################################################################"
puts " Variant: $variant_dir"
@jamerfort
jamerfort / single_msg_per_file.tcl
Created September 25, 2012 14:49
Use this TPS proc to save each message to its own, unique file.
# Use this TPS proc to save each message to its own, unique file.
#
# To use this proc:
# - set the outbound thread's protocol to 'fileset-local'
# - set the outbound directory to the desired directory
# - set the outbound file to the prefix of the files that the messages will be placed in
#
# Output filename format: <DIRECTORY>/<FILE>.<DATE>-<COUNTER>
# where:
# DIRECTORY is the fileset-local outbound "Directory" setting
@jamerfort
jamerfort / error_msgs.tcl
Created September 13, 2012 23:35
List all the "Error Msg:" stats for each thread in the current site.
# Usage:
# hcitcl error_msgs.tcl
msiAttach
# get a list of threads
set threads [msiTocEntry]
set len [llength $threads]
# loop through each thread
@jamerfort
jamerfort / profile.tcl
Created August 30, 2012 17:01
Create procs to time sections of TCL code.
if { ![info exists ::__times] } {
proc __time_start {name} {
lappend ::__times(${name}::start) [clock clicks]
}
proc __time_end {name} {
set queue $::__times(${name}::start)
set start [lindex $queue end]
set queue [lrange $queue 0 end-1]
set ::__times(${name}::start) $queue
@jamerfort
jamerfort / remove_prior_to_addendum.tcl
Created June 14, 2012 22:49
This Cloverleaf TPS script removes all OBX segments prior to the first one that contains "ADDENDUM". This script also renumbers the OBX segments. See http://clovertech.healthvision.com/viewtopic.php?t=5953
# This Cloverleaf TPS script removes all OBX segments prior to the first one that contains "ADDENDUM".
# This script also renumbers the OBX segments.
#
# See http://clovertech.healthvision.com/viewtopic.php?t=5953
proc remove_prior_to_addendum {args} {
# set the procedure name
# This is used for error messages
set procname [lindex [info level [info level]] 0]
# bring some common variables into the scope of this proc
@jamerfort
jamerfort / ts
Created May 9, 2012 18:33
Add a timestamp to each line of standard input.
#!/bin/ksh
# Examples:
# tail -f some.log | ts
# ping -i 5 someserver | ts
while read LINE
do
echo "$(date $@): $LINE"
done
@jamerfort
jamerfort / imp.sed
Created April 20, 2012 20:18
Pull queries from the logs of Oracle imp utility. (http://iggyfernandez.wordpress.com/2012/04/20/i-sed-awk/)
#!/usr/bin/sed -n -f
# Usage: sed -n -f <THISFILE> <IMP_LOG_FILE>
# run these commands for any line that starts with a space
/^ /{
# replace the leading space
s/^ //
# define a label
@jamerfort
jamerfort / list_pending.tcl
Created April 6, 2012 18:46
Get a count of messages in the Cloverleaf recover database.
#!/usr/bin/env hcitcl
msiAttach
# get a list of threads
set threads [msiTocEntry]
set num_threads [llength $threads]
set total_pending 0
@jamerfort
jamerfort / increment_nte_labels.tcl
Created February 21, 2012 23:16
This file adds a number at the end of a label in each NTE.3 value.
# Example message
set msg {MSH|^~\&|APP.....
NTE|1||TEMP: Room Temperature
NTE|2||SOURCE: Hand
NTE|3||NOTES: First
NTE|4||SPECIMEN SITE: Thumb
NTE|5||TEMP: Room Temperature
NTE|6||SOURCE: Hand
NTE|7||NOTES: Second
NTE|8||SPECIMEN SITE: dorsal hand