Skip to content

Instantly share code, notes, and snippets.

View Gabelbombe's full-sized avatar

Till Eulenspiegel Gabelbombe

  • The Deep Darkness, WA
View GitHub Profile
@Gabelbombe
Gabelbombe / createBinaryTree.py
Created January 29, 2015 22:12
Creates Binary Tree
class TreeNode:
def __init__(self, data, left=None, right=None):
self.data=data
self.left=left
self.right=right
def get_paths(node,sum):
def test():
n1=TreeNode(-2, TreeNode(2))
@Gabelbombe
Gabelbombe / .bashrc
Last active December 29, 2017 21:57
Working vSphere post processor, containts additional params --ipAllocationPolicy, --compression [0-9] and --powerOn
## Packer
export PACKER_CONFIG=$HOME/.packerconfig
export PACKER_OUTPUT=~/Repositories/T-Mobile/Packer/packer/output/ ## or your clonedir
export PACKER_USERNAME="$(whoami)@gsm1900.org"
export PACKER_PASSWORD='your_password'
@Gabelbombe
Gabelbombe / killbox.sh
Created February 5, 2015 19:18
Destroys all Virtualbox VM's in your environment.
#!/bin/bash
## Destroys all Virtualbox VMs
# Drop running pids
while read -r pid; do
kill -9 ${pid}
done < <(pgrep -i vboxheadless)
# Destroy all machine
while read -r name; do
@Gabelbombe
Gabelbombe / transfer-timeattack.sh
Created February 6, 2015 01:24
Wire to wire transfer of a virtual appliance between datacenters
#!/bin/bash
begin=$(date +"%s")
ovftool \ ## init ovftool
--powerOffSource \ ## shut down source machine prior to transfer
--powerOn \ ## after transfer boot device
--name='VMTransferName' \ ## rename target to something
--vmFolder='Templates' \ ## folder to place vm into
--datastore=${VC_DATASTORE} \ ## datastore to utilize
--network=${VC_NETWORK} \ ## network to attach to
@Gabelbombe
Gabelbombe / codes.php
Created February 18, 2015 22:52
Variadic closure using nested ternaries and short circuit requirements.
<?php
$codes = [
1 => 'CURL_UNSUPPORTED_PROTOCOL',
2 => 'CURL_FAILED_INIT',
3 => 'CURL_URL_MALFORMED',
4 => 'CURL_URL_MALFORMED_USER',
5 => 'CURL_COULD_NOT_RESOLVE_PROXY',
6 => 'CURL_COULD_NOT_RESOLVE_HOST',
7 => 'CURL_COULD_NOT_CONNECT',
@Gabelbombe
Gabelbombe / multiProcessPing.php
Last active August 29, 2015 14:16
Will ping 20 asynchronous hosts at a time until list if gone....
<?php
define('APP_DIR', dirname(__DIR__)); // autloads in non-sample script....
$hosts = array_filter(explode("\n", file_get_contents(APP_DIR . '/data/sites.txt')));
/**
* Processes in Parallel.
*
* Run a function (with no return result) on each item in an array in parallel.
#!/bin/bash
echo -e "[main]
certname = $(hostname).unix.gsm1900.org
server = puppet37.px.unix.gsm1900.org
ca_server = admpupt112.unix.gsm1900.org
vardir = /var/opt/lib/pe-puppet
logdir = /var/log/pe-puppet
rundir = /var/run/pe-puppet
modulepath = /etc/puppetlabs/puppet/modules:/opt/puppet/share/puppet/modules
@Gabelbombe
Gabelbombe / aixversion.ksh
Last active December 17, 2015 20:45
Get AIX version
#!/bin/ksh
function aixversion {
OSLEVEL=$(oslevel -s)
AIXVERSION=$(echo "scale=1; $(echo $OSLEVEL | cut -d'-' -f1)/1000" | bc)
AIXTL=$(echo $OSLEVEL | cut -d'-' -f2 | bc)
AIXSP=$(echo $OSLEVEL | cut -d'-' -f3 | bc)
## Outputs: AIX 6.1 - Technology Level 8 - Service Pack 3
echo "AIX ${AIXVERSION} - Technology Level ${AIXTL} - Service Pack ${AIXSP}"
}
@Gabelbombe
Gabelbombe / etc.sh
Created March 9, 2015 17:54
Repair ReFind on OSX 10.10
Boot OS X 10.10 Yosemite
Install rEFInd with --esp flag:
./install.sh --esp
mkdir /Volumes/esp
sudo mount -t msdos /dev/disk0s1 /Volumes/esp
Then rename the "refind" folder to "boot" and the "refind_x64.efi" to "bootx64.efi".
@Gabelbombe
Gabelbombe / automate.sh
Last active October 9, 2022 17:02
AppleScript to automate Keychain acceptance
function Accepts ()
{
osascript <<EOF
tell application "System Events"
repeat while exists (processes where name is "SecurityAgent")
tell process "SecurityAgent" to click button "Allow" of window 1
delay 0.2
end repeat
end tell
EOF