Skip to content

Instantly share code, notes, and snippets.

@bsnape
bsnape / bash_args.sh
Created December 12, 2017 10:18
bash arguments
#!/usr/bin/env bash
set -x
set -e
if [ $# -eq 0 ]; then
echo "Received no arguments. Exiting..."
exit
fi
# $@ is one-based and not zero-based
function Invoke-SeqLogConfiguration {
$tempRoot = "D:"
$tempDirectory = "$tempRoot\temp"
if ([System.IO.Directory]::Exists($tempDirectory) -eq $true) {
rm $tempDirectory -Recurse -Force -Verbose -ErrorAction Ignore
}
mkdir $tempDirectory -ErrorAction Ignore
@bsnape
bsnape / seq.ps1
Last active August 9, 2017 19:42
configuration SeqInstall {
Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
node "localhost" {
File CreateFile {
DestinationPath = 'C:\Windows\Temp\foo3.txt'
Ensure = "Present"
Contents = 'Hello World!'
}
}
}

Keybase proof

I hereby claim:

  • I am bsnape on github.
  • I am bsnape (https://keybase.io/bsnape) on keybase.
  • I have a public key ASDW2X76h7KjXs91WikHSAEt9YGobKZlgfv0nabowf77Xwo

To claim this, I am signing this object:

# in every instance boot inject the public key to every instance
aws --profile deirdre-dev ec2 create-key-pair --key-name deirdre-ec2-provision
@bsnape
bsnape / gist:edff869d5b7dc0b0d7c2
Last active August 29, 2023 05:15
Rubymine find & replace string hash rockets with new syntax
find:
\'(\w+)\'\s*=>
replace:
$1:
replace symbol hash rockets with new syntax
find:
@bsnape
bsnape / gist:8cdbc0067e713a5129c1
Created April 2, 2015 12:57
Unpack RPM on OSX
brew install rpm
brew install rpm2cpio
rpm2cpio <rpm> | cpio -i -d
@bsnape
bsnape / gist:2574bcb399a5faf0f38f
Created May 20, 2014 11:34
Bash single-line for loop
for i in {1..50}; do curl localhost:9086/status; echo; sleep 1; done
@bsnape
bsnape / gist:7750443
Created December 2, 2013 14:41
delete merged local branches
git branch --merged master | grep -v 'master$' | xargs git branch -d
#!/bin/bash
while :
do
clear
git --no-pager log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ci) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all
sleep 1
done