This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# create new certs | |
cd /opt/letsencrypt | |
RESTART=false | |
for conf in $(ls -1 /etc/letsencrypt/live/); do | |
UPDATE=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 )) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: "") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer