Skip to content

Instantly share code, notes, and snippets.

View JohnArchieMckown's full-sized avatar
💭
Retired

John Archie McKown JohnArchieMckown

💭
Retired
  • 00:33 (UTC -06:00)
View GitHub Profile
@JohnArchieMckown
JohnArchieMckown / nodups.awk
Last active August 29, 2015 14:21
AWK code to remove duplicates lines. This does not require sorting then input, but may use a lot of memory. It simply uses an "associative array" in which the index is the data line. From an tweet by Tim Chase (@Gumnos)
#!/bin/awk
!a[$0]++
@JohnArchieMckown
JohnArchieMckown / vincentize.R
Last active August 29, 2015 14:21
R code for "vincentize", originally written by Paul Lemmens, gotten from https://stat.ethz.ch/pipermail/r-help/2003-May/034272.html
vincentize <- function(data, bins)
{
if ( length(data) < 2 )
{
stop("The data is really short. Is that ok?");
}
if ( bins < 2 )
{
stop("A number of bins smaller than 2 just really isn't useful");
@JohnArchieMckown
JohnArchieMckown / SelectOrInsert.sql
Created January 13, 2015 17:56
An example of a CTE in SQL which will either SELECT a column from a table, or insert a new column into that table.
WITH sel AS (
SELECT id FROM hometowns WHERE name = 'Portland'
),
ins AS (
INSERT INTO hometowns(name)
SELECT 'Portland'
WHERE NOT EXISTS (SELECT 1 FROM sel)
RETURNING id
)
@JohnArchieMckown
JohnArchieMckown / JES2DISK.REXX
Last active April 28, 2016 13:06
z/OS REXX program which uses the SDSF / REXX interface to copy all held sysout from the JES SPOOL to individual disk data sets or z/OS UNIX files. The logic does not copy output which is already on disk, as determined by the DSN of file already existing.
/* REXX */
PARSE ARG JOBNAME HLQ .
NUMERIC DIGITS 12
IF JOBNAME='' THEN JOBNAME='*'
HLQ=STRIP(HLQ,'B',"'")
IF HLQ='' THEN HLQ='SYSJO'
IF '/' = LEFT(HLQ,1) THEN DO
if syscalls('ON')>3 then
do
say 'Unable to establish the SYSCALL environment'
@JohnArchieMckown
JohnArchieMckown / Dovetail-tricks.md
Last active August 29, 2015 14:09
Just some z/OS UNIX tricks using Dovetailed Technologies Co:Z product

Short vignettes using Co:Z from Dovetailed Technologies

Submit a job from a shell script.

todsn //intrdr <<EOF
//JOBNAME JOB ACCT,NAME,CLASS=A,MSGCLASS=B
//BR14 EXEC PGM=IEFBR14

//

@JohnArchieMckown
JohnArchieMckown / ADDCHAR.REXX
Created November 10, 2014 13:10
Transcribed from an email on ISPF-L about a routine by Doug Nadel How to add characters so that ISPF edit recognizes them as belonging in a "word" as opposed to being a word separator
/* Rexx ispf edit macro to add characters to the meaning of word */
/* */
/* This changes internal tables to force specific characters to be */
/* considered part of a word. For example, In COBOL, The dash is */
/* valid in a name. If you have code */
/* MOVE ABC-DEF TO ABC. */
/* and you issue */
/* CHANGE ABC XYZ WORD */
/* the result is */
/* MOVE XYZ-DEF XYZ. */
@JohnArchieMckown
JohnArchieMckown / which
Last active August 29, 2015 14:07
Shell function for BASH or Bourne shell which partially emulates the GNU/Linux which command output.
#
# This shell function will return with a 0 if the specified program is on the ${PATH}.
# and will echo the full path name, including the executable. If it is not on
# the ${PATH}, it will return with a code of 1, but no output. The return value saves
# the necessity of testing to see if anything was returned. A "conditional execution"
# might be something like:
# fullname=$(which someprog) && ${fullname}
# Not that you'd actually do the above. Perhaps something more like:
# fullname=$(which someprog) && {
# while read i;do ${fullname} $i;done <some.input
@JohnArchieMckown
JohnArchieMckown / classmunge
Created October 16, 2014 12:30
classmunge is a shell function to add a directory to the CLASSPATH used by Java. It will add the specified directory only if: (1) it currently exists and (2) it is not already on the PATH. It can add the directory either at the beginning of the CLASSPATH (defautl) or at the end of the CLASSPATH.
classmunge () {
if [ -e $1 ]; then
if ! echo $CLASSPATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
CLASSPATH=$CLASSPATH:$1
else
CLASSPATH=$1:$CLASSPATH
fi
fi
fi
@JohnArchieMckown
JohnArchieMckown / pathmunge
Created October 16, 2014 12:29
pathmunge is a shell function to add a directory to the PATH. It will add the specified directory only if: (1) it currently exists and (2) it is not already on the PATH. It can add the directory either at the beginning of the PATH (defautl) or at the end of the PATH.
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if [ -e $1 ]; then
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
@JohnArchieMckown
JohnArchieMckown / sql_good-advice.txt
Created September 18, 2014 11:38
A wonderful post by Keith Medcalf [email protected] on "thinking in SQL" from General Discussion of SQLite Database <[email protected]>
You cannot do any of these things in any relational database. You can only do this in navigational databases. There are various kludges which permit you to simulate navigational abilities on top of relational databases, but they are all kludges which are performed by various forms of fakery to impose navigability on top of a model which inherently is not navigable.
For example, many database drivers can kludge you up what is called a "keyset" driven cursor. It does this by executing the query and storing a temporary table containing the primary keys of each table in the query for each result row (this is stored either in the driver (for a client-driven keyset) or on the server (for a server driven keyset). When you ask for a row from the keyset, the primary keys are used to issue a bunch of queries to "reconstruct" the "present view" of the result that would be at that navigational location for you. There are also, usually in these same drivers, what are called "scrollable" cursors. These differ from a