Skip to content

Instantly share code, notes, and snippets.

View JohnArchieMckown's full-sized avatar
💭
Retired

John Archie McKown JohnArchieMckown

💭
Retired
  • 02:00 (UTC -06:00)
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / IND$FILE
Last active August 29, 2015 14:22
Example to wrap the 3270 file transfer program, IND$FILE, in another CSECT in order to: (1) make it run non-swappable (for speed) and (2) write the IND$FILE command to the z/OS SYSLOG for auditing / logging purposes.
//IND$FILE JOB (H00000I),'IND$FILE', 00010000
// CLASS=Z, 00020000
// MSGCLASS=X, 00030000
// NOTIFY=&SYSUID 00040000
//STEP010 EXEC ASMACL,PARM.ASM='OBJECT,NODECK,BATCH' 00050000
//ASM.SYSLIB DD DSN=SYS1.MACLIB, 00060000
// DISP=SHR 00070007
// DD DSN=SYS1.MODGEN, 00080000
// DISP=SHR 00090007
//ASM.SYSIN DD * 00120000
@JohnArchieMckown
JohnArchieMckown / config
Created September 8, 2015 12:54
git config example - disables compression on push
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
compression = 0
looseCompression = 0
[pack]
compression = 0
window = 0