Skip to content

Instantly share code, notes, and snippets.

@benders
benders / git-setup.sh
Last active July 27, 2016 09:51
New Employee git setup
FULLNAME=`finger "$USER" | awk -F: '{ print $3 }' | head -n1 | sed 's/^ //'`
# Git needs to know who you are!
git config --global user.name "${FULLNAME}"
git config --global user.email "${USER}@newrelic.com"
# SVN style shortcuts
git config --global alias.st status
git config --global alias.ci commit
git config --global alias.co checkout
@benders
benders / .bashrc
Created January 16, 2013 20:16
bashrc voodoo for consistently connecting to ssh-agent
# ssh-agent needs to be running and we need to export the SSH_AUTH_SOCK
# environment variable to point to its location in /tmp/ssh-something/agent.PID
# so, find the ssh-agent PID and derive the socket filename from it, and then
# find that file in its randomly-named directory in /tmp and export that for
# ssh to use.
set -x
SSH_AGENT_PID=`pgrep -n -u $USER ssh-agent`
if [ -n "$SSH_AGENT_PID" ]; then
guessed_ppid=`expr $SSH_AGENT_PID - 1`
@benders
benders / log-rename.sh
Created March 26, 2011 05:31
Rename logs from logrotate style foo.1.gz to date style foo.2011-03-25.gz
#!/bin/bash
ls -l --time-style="+%Y-%m-%d" *.?.gz | awk '{ print $7,$6 }' | \
while read line; do
set -- $line
original=$1
datestamp=$2
filebase=`echo $original | rev | cut -f3- -d. | rev`
/bin/mv -vu $original $filebase.$datestamp.gz
done
@benders
benders / iscsi-removal.txt
Created January 17, 2014 07:05
isci removal example
df ; echo ; pvs
vgchange --available n VolGroupBackUps
multipath -ll
multipath -f mpath2
/etc/init.d/multipathd stop
chkconfig multipathd off
iscsiadm -m node
#!/bin/bash
set -ex
wget -O /etc/apt/sources.list https://gist.github.com/benders/8426266/raw/b4969acb524ba727b64cf8eaee7a6a31be8ae6fb/precise-sources.list
apt-get update
wget -O /tmp/pe3-install.sh https://gist.github.com/benders/8426266/raw/b1d4c9b6ea41839b74842f05f2ae9efba7a10394/ubuntu-pe-3-install.sh
#include <FastLED.h>
#include <MicroView.h>
#include <RBD_Timer.h>
#include <RBD_Button.h>
FASTLED_USING_NAMESPACE
// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
@benders
benders / delayed_job_classifier.sql
Last active December 27, 2015 12:59
Figure out WTF is in our delayed_job queue
SELECT
count(*) as count, priority, object, method from (
SELECT
@load_start := LOCATE('object: LOAD;', handler),
@method_start := LOCATE('method: ', handler) + 9,
@method_end := LOCATE('args:', handler) - 1,
IF(@load_start,
@object_start := @load_start + 13,
@object_start := LOCATE('object: !ruby/object:', handler) + 21
),
@benders
benders / config.ru
Created October 19, 2013 06:57
Get some New Relic on a Puppet Master server (version 2.7)
# Oh ho ho, let's see if we can have some fun with the Ruby Agent - Nic 2013-10-18
require 'rubygems'
require 'newrelic_rpm'
require 'new_relic/agent/instrumentation/rack'
# END monkey-business
# A "config.ru", for use with every Rack-compatible webserver.
# SSL needs to be handled outside this, though.
$0 = "master"
@benders
benders / new-employee-setup.txt
Last active December 17, 2015 11:29
New Employee setup
Repair Homebrew permissions
sudo chmod g+w /usr/local/
Put Chrome and Firefox on dock
Download and Install
TextMate
GitX
Run TextMate and setup terminal helper in /usr/local/bin
@benders
benders / reflate.rb
Created February 7, 2013 01:52
Display the contents of a DEFLATE compressed file (like an HTTP POST body)
#!/usr/bin/env ruby
require 'zlib'
print Zlib::Inflate.new.inflate($<.read)