Skip to content

Instantly share code, notes, and snippets.

@opsmason
opsmason / riddler-2016-09-16
Last active September 16, 2016 19:34
Riddler for 2016-09-16
#!/usr/bin/env ruby
# http://fivethirtyeight.com/features/how-high-can-count-von-count-count/
# https://github.com/radar/humanize
# http://www.grammarbook.com/numbers/numbers.asp
# https://gist.github.com/opsmason/3dc61ea5cc690c113353c918e00aa01c
# "Count Von Count, the counting count on "Sesame Street," counts aloud on Twitter
# <https://twitter.com/CountVonCount>. If he counts up by one with each tweet — "One!"
# "Two!" "Three!" … "Five hundred thirty eight!" etc. — how high can he go before hitting
# the 140-character limit? Note: The count is enthusiastic and must end all of his tweets

Keybase proof

I hereby claim:

  • I am opsmason on github.
  • I am opsmason (https://keybase.io/opsmason) on keybase.
  • I have a public key whose fingerprint is AC0F 2D2D 0A2D CF4F 037A 92ED 7F5D C620 9365 ECF2

To claim this, I am signing this object:

@opsmason
opsmason / jq-1_3-from_entries-fix
Created June 14, 2013 16:38
from_entries in jq-1.3 appears to be case sensitive: It doesn't parse Key/Value pairs, it only parses key/value. This is with jq downloaded from http://stedolan.github.io/jq/download/osx64/jq
// cat ~/Desktop/aws/some.json | ~/Downloads/jq '.[] | {InstanceId , Tags , brokenTags :( .Tags|from_entries) , correctedTags: ( .Tags|map({(.key//.Key): (.value//.Value)}) | add)}'
{
"correctedTags": {
"Web": "Service",
"Production": "Environment"
},
"brokenTags": null,
"Tags": [
{
"Key": "Production",
@opsmason
opsmason / augtool_error.txt
Created September 11, 2012 19:47
augtool error
$ sudo augtool -n
augtool> clear etc/grub.conf/opsmason
augtool> print etc/grub.conf/opsmason
/files/etc/grub.conf/opsmason
augtool> save
error: Failed to execute command
saving failed (run 'print /augeas//error' for details)
augtool> print etc/grub.conf/opsmason
/files/etc/grub.conf/opsmason
augtool> print /augeas//error
@opsmason
opsmason / svn_shell_rc.sh
Created August 8, 2012 14:31
SVN shell functions
tag() {
DIR=${1:-.}
TAG=$DIR/tags/$(date +%Y%m%d-%H%M%S)
svn cp $DIR/trunk $TAG
}
@opsmason
opsmason / ssh-agent setup
Created February 9, 2012 15:58
Automatically setup ssh agent and add my default ssh key by adding this to .bash_profile
# Adapted from http://mah.everybody.org/docs/ssh
SSH_AGENT=/usr/bin/ssh-agent
SSH_ADD=/usr/bin/ssh-add
SSH_AGENT_ARGS="-s"
SSH_KEYS=$(cd ~/.ssh ; pwd)/*rsa
SSH_AGENT_TIMEOUT=21600 # 6 hours
if [ -z "$SSH_AUTH_SOCK" -a -x "$SSH_AGENT" ] ; then
eval `$SSH_AGENT $SSH_AGENT_ARGS`
trap "kill $SSH_AUTH_PID" 0
@opsmason
opsmason / screen login
Created April 14, 2011 18:06
Auto Launch screen on login, unless I'm already running screen on this host
SCREEN_D=`screen -ls | grep '(Detached)' | wc -l`
SCREEN_A=`screen -ls | grep '(Attached)' | wc -l`
if [[ "x$WINDOW" = "x" ]] ; then (
if [[ $SCREEN_D -eq 1 ]] ; then (
SCREEN=`screen -ls | grep '(Detached)' | awk '{print $1}'`
screen -r $SCREEN
) elif [[ $SCREEN_D -gt 0 ]] ; then (
screen -ls
) elif [[ $SCREEN_A -gt 0 && $SCREEN_D -eq 0 ]] ; then (
@opsmason
opsmason / apache stop sequence
Created March 14, 2011 18:43
detect apache has stopped before exiting
stop() {
echo -n "Stopping $SERVICE: "
if [ -f $PID_FILE ]
then
PID=`cat $PID_FILE`
else
PID=`rp_pid_find $BASE_DIR/apache/bin/httpd`
fi
@opsmason
opsmason / 2011 Anniversary Adventure
Created March 11, 2011 20:09
Super Secret Playlist for Anniversary Adventure
1. Superman Theme - John Williams 5:36
2. Fly Me To The Moon - Diana Krall 6:06
3. Learning To Fly - Tom Petty & The Heartbreakers 4:02
4. Fly Like An Eagle - Steve Miller Band 4:43
5. Somewhere Over the Rainbow - Israel Kamakawiwo'ole 3:31
6. I'll Fly Away - Alison Krauss & Gillian Welch 3:58
7. Ray Of Light - Madonna 5:21
8. Fly Away - Lenny Kravitz 3:41
9. Walkin' On Sunshine - Katrina Leskanich 3:39
10. Fly - Sugar Ray 4:53
@opsmason
opsmason / auto screen
Created March 4, 2011 16:51
Automatically reconnect to screen session when logging into a jumphost.
function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }
SCREEN_D=`screen -ls | grep '(Detached)' | wc -l`
SCREEN_A=`screen -ls | grep '(Attached)' | wc -l`
if [[ "x$WINDOW" = "x" ]] ; then (
if [[ $SCREEN_D -eq 1 ]] ; then (
SCREEN=`screen -ls | grep '(Detached)' | awk '{print $1}'`
screen -r $SCREEN
) elif [[ $SCREEN_D -gt 0 ]] ; then (