Skip to content

Instantly share code, notes, and snippets.

@evilchili
evilchili / pssh
Created November 5, 2010 16:31
persistent SSH wrapper for autossh
#!/usr/bin/perl
# pssh
# -- "persistent SSH" wrapper for autossh
#
# Copyright 2010 Greg Boyington. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
@evilchili
evilchili / watchsync
Created November 5, 2010 16:57
watch a directory structure for changes and sync changes to another location every 30 seconds.
% while true; do i="`du |tail -1|cut -f1` `find . |cksum`" && [[ $i != $j ]] && rsync -aq --delete . ~/tmp/; j="$i"; sleep 30; done
@evilchili
evilchili / .vimrc
Created November 5, 2010 17:15
vimrc for perl/mason/js editing
" Embedded() is a function that will parse a text buffer
" looking for embedded vim commands, and execute them.
" Call it with a range of lines to check, eg to check the whole
" file:
"
" :%call Embedded()
"
" Commands should be prefixed by the sequence :vim: .
"
function Embedded() range
@evilchili
evilchili / bashrc
Created November 5, 2010 17:19
default bashrc template
# .bashrc defaults
export EDITOR=/usr/bin/vim
export PATH=$PATH:~/bin
export LSCOLORS=Hxfxcxdxbxegedabagacad
export PS1="\[\033[01;33;01m\]\[\033[00;37;01m\]\h:\u\[\033[01;32;01m\] \d \$(date '+%T %Z') \[\033[01;32;01m\] [\[\033[01;37;01m\]$SHLVL\[\033[01;32;01m\]]\n!\!\[\033[01;33;01m\] [ \w ]\[\033[00m\] "
export PS2="\[\033[01;33;40m\] ?\[\033[00m\] "
@evilchili
evilchili / wav2mp3
Created November 8, 2010 02:16
process a list of MP3s in the current directory with LAME
# assumes wav files are named according to the format 'N. Track Name.wav'
ls *.wav |cut -d. -f1-2 | xargs -I % lame -V0 --vbr-new --nohist "%.wav" "%.mp3"
@evilchili
evilchili / read-repo-config.sh
Created May 19, 2011 20:55
a generic method for storing repo configuration data in git
#!/bin/bash
#
# parse configuration options from a file in the current repository.
# Designed to be invoked from git hook scripts.
#
# Sample usage: toggle automatic branch building, per-branch
#
# config file looks like:
# BranchName=option1[,option2...]
#
@evilchili
evilchili / gist:981734
Created May 19, 2011 21:02
a sample post-receive hook that implements automatic branch building
# hook setup
read oldrev newrev refname
job="MyJenkinsJob"
jenkins_url="http://jenkins/job"
jenkins_token="seeeeekrit"
# what branch are we building?
regex='refs/heads/(.*)'
if [[ $refname =~ $regex ]]; then
target_branch="${BASH_REMATCH[1]}"
@evilchili
evilchili / chili.vom
Created August 2, 2011 00:38
vim colorscheme (xterm)
" Vim color file for xterm-256color
"
" Name: chili.vim
" Maintainer: Greg Boyington <evilchili@gmail.com>
"
" Adapted from:
" Name: inkpot.vim
" Maintainer: Ciaran McCreesh <ciaran.mccreesh@googlemail.com>
" Homepage: http://github.com/ciaranm/inkpot/
"
@evilchili
evilchili / gist:1189569
Created September 2, 2011 19:17
replace mixed-case usernames in a JIRA export file with their lowercase equivalents
#!/bin/bash
#
# grep "Membership.*jira-users" entities.xml
# -- extract the lines of XML defining members of jira-users. for JIRA 4.4, these lines look like:
# <Membership id="10002" parentId="10002" childId="10000" membershipType="GROUP_USER" parentName="jira-users" lowerParentName="jira-users" childName="Greg.Boyington" lowerChildName="greg.boyington" directoryId="1"/>
#
# cut -d' ' -f12
# -- extract just the childName attribute eg. childName="Greg.Boyington"
#
# awk '{FS="\""; print $2}'
@evilchili
evilchili / git-hook-functions.sh
Created October 4, 2011 20:17
function library for git hooks & a post-receive hook for automatic branch building
#!/bin/bash
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ -z "$GIT_DIR" ]; then
echo >&2 "fatal: hooks/functions: GIT_DIR not set"
exit 1
fi
read oldrev newrev refname