Skip to content

Instantly share code, notes, and snippets.

@wuftymerguftyguff
wuftymerguftyguff / gist:41b4ab5b2275c4fd973a
Created January 18, 2016 12:34
Python descriptor aide memoir - Custom getter server for dynamic attributes
class Person(object):
def addProperty(self, attribute):
# create local setter and getter with a particular attribute name
getter = lambda self: self._getProperty(attribute)
setter = lambda self, value: self._setProperty(attribute, value)
# construct property attribute and add it to the class
setattr(self.__class__, attribute, property(fget=getter, \
fset=setter, \
@wuftymerguftyguff
wuftymerguftyguff / gist:fb0162f5740a5d25b3d63a1de1872547
Created July 11, 2016 11:45
renew lets encrypt certs automatically when olde than 60 days for nginx
#!/bin/sh
# create new certs
cd /opt/letsencrypt
RESTART=false
for conf in $(ls -1 /etc/letsencrypt/live/); do
UPDATE=false
@wuftymerguftyguff
wuftymerguftyguff / adjuster.sh
Last active February 16, 2017 10:53
Script to adjust the number of R3load processes runnng in a SAP export or import when split tables have complete
#!/usr/bin/bash
#BE CAREFUL!!! THIS CAN RUN AMOK
TARGETJOBS=32
CFGFILE="import_monitor_cmd.properties"
CNT=$(ps -ef | grep R3load | grep -v grep | wc -l)
CONFIGURED=$(grep jobNum $CFGFILE | awk -F= '{print $2}')
WAITING=$(grep 'Monitor jobs' import_monitor.log | tail -1 | grep -e running -e waiting | awk '{print $6}' | sed s/,//g)
LOADAVG15=$(uptime | awk {'print $12'} | awk -F. '{print $1}')
NUMCPUS=$(grep -c ^processor /proc/cpuinfo)
SPARECPU=$(( $NUMCPUS / $LOADAVG15 ))
@wuftymerguftyguff
wuftymerguftyguff / generate_orderby_export.sh
Last active July 15, 2016 09:31
Script to generate a template orderby.txt when tablesplitting is used for a SAP R3load export
#!/usr/bin/sh
SID=$1
cd /migration/$SID/export/DUMP/ABAP/DATA
list=$(ls -la *.WHR | awk -F ' ' '{print $9}' | sed -e 's/\.WHR//g')
prev_table=""
for l in $list
do
table=$(echo $l | sed -e "s/-.*//g")
tableu=$(echo $table | tr '[a-z]' '[A-Z]')
if (test "$prev_table" != "$table") then
@wuftymerguftyguff
wuftymerguftyguff / generate_orderby_import.sh
Last active August 11, 2018 11:37
Script to generate a template OrderBy.txt file for SAP R3load import when using splits on DB2LUW
#!/usr/bin/sh
SID=$1
#cd /migration/$SID/exp/010715/ABAP/DATA
list=$(ls -la *.WHR | awk -F ' ' '{print $9}' | sed -e 's/\.WHR//g')
prev_table=""
for l in $list
do
table=$(echo $l | sed -e "s/-.*//g")
tableu=$(echo $table | tr '[a-z]' '[A-Z]')
if (test "$prev_table" != "$table") then
@wuftymerguftyguff
wuftymerguftyguff / gist:d41e2ca5609590c854b48e8a880e3c30
Created August 21, 2016 22:24
Swift 3.0 String Extension to create NSData from a String representation of a hexadecimal value
extension String {
func replace(_ string:String, replacement:String) -> String {
return self.replacingOccurrences(of: string, with: replacement, options: NSString.CompareOptions.literal, range: nil)
}
func removeWhitespace() -> String {
return self.replace(" ", replacement: "")
}
@wuftymerguftyguff
wuftymerguftyguff / gist:8ef60f659182f014ea899e845e79c8a8
Created October 14, 2016 11:53
Swift3 NSData extension to get a Unsafe Pointer of a generic type to the byte data
// This extension returns an unsafe pointer of the requested type to the bytes of the NSData
// It assumes you know what you are doing
// I created it to try to insulate myself from the volatility of the Swift memory access API
extension NSData {
func toUSP<T>() -> UnsafePointer<T> {
return self.bytes.assumingMemoryBound(to:T.self)
}
}
@wuftymerguftyguff
wuftymerguftyguff / expiry.sh
Last active February 21, 2022 10:57
bash script to set standard sap users to not expire
#!/bin/bash
user_exists(){ id "$1" &>/dev/null; } # silent, it just sets the exit code
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
DOCFILE="$SCRIPT_DIR/docfile.txt"
echo $DOCFILE
if [ "$1" == "" ]
then
@wuftymerguftyguff
wuftymerguftyguff / envy.sh
Last active July 11, 2017 11:17
convert an environment in a bash format into a script in csh format used mainly for vcs sap setups
#Reformats the output of the env command into a csh friendly format
#Usage env | ./envy.sh > outfile.csh
IFS="="
while read VAR VAL
do
if [ "$VAR" != "LS_COLORS" ]
then
echo setenv $VAR $VAL
fi
done
@wuftymerguftyguff
wuftymerguftyguff / gist:62e1e6aa7811abfd252ef65a3a0344bc
Created June 7, 2017 21:17
Bare minimum Sample Apps for VCS testing
call all with one parameter the name of the pretend sample app from the vcs application agent
# cat startsampleapp
#!/bin/sh
sleep $(shuf -i 10-30 -n 1)
touch /tmp/$1 # add any steps, if required
exit 0
# cat stopsampleapp
#!/bin/sh