Skip to content

Instantly share code, notes, and snippets.

View dominics's full-sized avatar

Dominic Scheirlinck dominics

View GitHub Profile
@dominics
dominics / git-clean-remote.bash
Created February 7, 2012 22:53
A quick bash script to remove stale remote branches (merged into master, head commit is old) by pushing an empty reference to them
#!/bin/bash
# vim: set ts=4 sw=4 expandtab tw=79 :
#
# Asks to delete remote branches that have been merged into master and haven't
# been committed to in a fortnight. Also asks to delete unmerged branches that
# haven't been committed to in three months.
set -e
c_red=`tput setaf 1 || tput setf 4`
.
├── F00
│   ├── AAXG.mp3
│   ├── .. and 180 other badly named files
│   └── ZRSJ.mp3
├── ... and fifty other directories exactly the same
└── F49
@dominics
dominics / from-iphone.bash
Created February 20, 2012 06:21
Quick script to rsync music off an iPhone
#!/bin/bash
# vim: set ts=4 sw=4 tw=79 et :
#
# rsyncs the music from an iPhone into the iphone directory
if [[ ! -z "$1" ]]; then
ADDRESS="$1"
else
# Attempt to use avahi to get the iPhone's IP
# - Make sure your iPhone is unlocked
@dominics
dominics / symtest.py
Created March 6, 2012 09:29
Open and read a file quickly in a loop
import sys
while True:
try:
with open('current/foo') as f:
contents = f.read()
if contents != 'a' and contents != 'b':
sys.exit("Couldn't read the contents")
except IOError:
sys.exit("Couldn't open the file")

Keybase proof

I hereby claim:

  • I am dominics on github.
  • I am dominics (https://keybase.io/dominics) on keybase.
  • I have a public key whose fingerprint is 5D4E 69C9 1300 92C2 06E9 D460 EB3E 4C9E E747 114F

To claim this, I am signing this object:

@dominics
dominics / git-splay
Created March 31, 2015 04:59
git splay
#!/bin/bash
command='/usr/bin/env git'
wd=$PWD
parallel=1
quiet=1
function usage() {
echo "git splay [-p] <directory> <git command>"
echo ""
@dominics
dominics / build.sh
Last active October 5, 2015 03:19
Building a Ganglia 3.7.x .deb package
# Initial settings
VERSION=3.7.2
ITERATION=0
BUILD=/tmp/ganglia/build
INSTALL=/tmp/ganglia/install
# Dependencies
sudo apt-get install -y build-essential libconfuse-dev libapr1-dev
sudo gem install fpm
@dominics
dominics / Setting.spec.js
Last active November 23, 2015 04:40
Mocha + Sinon FakeServer unit test, no browser required, runs entirely in node
describe('client api class Setting', function() {
before(() => {
this.server = sinon.fakeServer.create();
this.server.autoRespond = true;
this.server.respondWith('/api/setting/all', [
200,
{ 'Content-Type': 'application/json' },
'{"type": "setting", "data": [{ "id": "foo", "value": true }]}',
]);
@dominics
dominics / agent.pp
Last active December 13, 2016 05:22
Wrapping a class in a resource so it can be made virtual (i.e. datadog_agent::integrations::jenkins only included if datadog_agent is)
class profile::datadog::agent(
$ensure = 'present',
) {
class {
'datadog_agent':
puppet_run_reports => true;
}
# Realize wrapped integration classes
Profile::Datadog::Integration<| |>
@dominics
dominics / aws-alias-host
Last active February 7, 2017 02:32
"hostfile" an AWS ALB
#!/bin/bash
set -e
set -o pipefail
if [ $EUID -ne 0 ]; then
exec sudo "$0" "$@"
fi
readonly hostname=$1