Skip to content

Instantly share code, notes, and snippets.

@wuftymerguftyguff
wuftymerguftyguff / validhosts.awk
Created May 31, 2019 08:50
Hosts File Validation
#!/usr/bin/awk -f
function valid_ip(ip) {
octets=4
search="."
# Class to JSON encode nested and awkward python objects
import json
import inspect
class ObjectEncoder(json.JSONEncoder):
def default(self, obj):
if hasattr(obj, "to_json"):
return self.default(obj.to_json())
elif hasattr(obj, "__dict__"):
d = dict(
@wuftymerguftyguff
wuftymerguftyguff / transdir.sh
Created October 10, 2018 10:33
Recreate required directories under sap transport directory
#as user sidadm
cd /usr/sap/trans # or where wherever TRANSDIR should be
mkdir -p actlog bin data log buffer sapnames cofiles olddata tmp backup serial
@wuftymerguftyguff
wuftymerguftyguff / hostAgentStuff.sh
Last active April 18, 2024 09:19
Useful SAP HostAgent commands
#GET A LIST OF INSTANCES
#/usr/sap/hostctrl/exe/saphostctrl -function Listinstances -format Script
#GET A LIST of databases
saphostctrl -nr 99 -function Listdatabases
# manage a db with the host agent
# /usr/sap/hostctrl/exe/saphostctrl -nr 99 -function StopDatabase -dbname NPL -dbtype ada -user sapadm passwd
#query a db with the host agent
@wuftymerguftyguff
wuftymerguftyguff / script-skel.sh
Created February 13, 2018 23:15
bash script skeleton to help with the basics (whatever that means)
#!/usr/bin/env bash
############################
############################
############################
# Script Skeleton
# does nothing
# copy it and change it
# its supposed to be a starting
# point for your own scripts
############################
@wuftymerguftyguff
wuftymerguftyguff / Common Swift String Extensions
Created October 13, 2017 21:24 — forked from sketchytech/Common Swift String Extensions
Added and amended to use pure Swift where possible
import Foundation
extension String
{
// Works in Xcode but not Playgrounds because of a bug with .insert()
mutating func insertString(string:String,ind:Int) {
var insertIndex = advance(self.startIndex, ind, self.endIndex)
for c in string {
@wuftymerguftyguff
wuftymerguftyguff / git-oneline-date-and-message.sh
Created July 12, 2017 15:08 — forked from seeflanigan/git-oneline-date-and-message.sh
git oneline for short date and commit message within a range
git log --oneline --after="2016-03-28" --before="2016-04-03" --pretty=format:"%ad, %s" --date=short
@wuftymerguftyguff
wuftymerguftyguff / gist:2ac17fd60115f4bb0189dd4dce44ff7c
Created June 14, 2017 14:18
A Set of Bash Scripts to control SAP application instances from VCS
monitorapp.sh
#!/bin/bash
#CONSTANTS
OFFLINE=100
UNKNOWN=99
ONLINE=110
@wuftymerguftyguff
wuftymerguftyguff / get_global.sh
Last active June 11, 2017 09:48
Script to archive customer data in a SAP global dir
#This is a script to get the bits of the sapmnt global dir that you want during a migration
#but not the bits that you dont want
#first make sure we are in something that looks like a global dir
if [[ $(pwd) =~ ^/sapmnt/[A-Z0-9]{3}/global ]]
then
echo Great you are in the global directory
echo Generating Unique Archive filename
fname="$(cat /dev/urandom | tr -cd 'a-f0-9' | head -c 32).tar"
echo Archive filename is $fname
@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