Skip to content

Instantly share code, notes, and snippets.

View aerickson's full-sized avatar

Andrew Erickson aerickson

View GitHub Profile
@mattknox
mattknox / humanize.rb
Created May 3, 2011 03:28
Numeric#humanize makes numbers more readable.
class Numeric
SCALE_TO_WORD = Hash.new do |h, i|
" * 10^#{i * 3}"
end.merge({ 1 => " thousand",
2 => " million",
3 => " billion",
4 => " trillion"
})
# in my unscientific test, no one really found names beyond trillion useful.
@ryanking
ryanking / gist:954555
Created May 4, 2011 00:55
Selectively stop classes from being modified in ruby.
# Ever get tired of people messing with your ruby classes?
# now you can put the hammer down and stop them. Just
# include this module and no one will be able to modify the
# class implementation or any instance implementations.
module Stop
module CantTouchThis
def self.included(mod)
@tokudu
tokudu / ec2ssh.sh
Created October 27, 2012 23:55
A helper script for SSH'ing into EC2 instances by name
#!/bin/bash
# SSH into an EC2 instance by name
# Author: tokudu@github.com (SoThree.com).
set -e
if [ $# -lt 1 ]
then
echo "Usage: `basename $0` instance_name"
exit 1
fi
@dpetersen
dpetersen / circle.yml.diff
Created March 11, 2015 16:28
CircleCI junit integration
commit 744cfc17ad795077a427b19d02c10e4f0b5008b7
Author: Don Petersen <don@donpetersen.net>
Date: Tue Mar 10 15:43:22 2015 -0600
Include circle-compatible test output.
diff --git a/circle.yml b/circle.yml
index a2763cf..ece9b30 100644
--- a/circle.yml
+++ b/circle.yml
#!/usr/bin/env ruby
# Ruby script to create recurring maintenance windows in PagerDuty
#
# Copyright (c) 2012, PagerDuty, Inc. <info@pagerduty.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
@tehprofessor
tehprofessor / watir_phantomjs_user_agent_settings.rb
Created May 1, 2013 18:28
Configuring Watir to use a custom user agent with the PhantomJS driver. The user agent gem has been deprecated, and this functionality is not documented anywhere (obvious).
require 'watir-webdriver'
capabilities = Selenium::WebDriver::Remote::Capabilities.phantomjs("phantomjs.page.settings.userAgent" => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1468.0 Safari/537.36")
driver = Selenium::WebDriver.for :phantomjs, :desired_capabilities => capabilities
browser = ::Watir::Browser.new driver
# Quick test to make sure it's set
browser.goto 'http://www.useragentstring.com/'
browser.textarea(:id => "uas_textfeld").value
@tribut
tribut / mosh_pc.sh
Last active June 4, 2018 11:33
wrapper for mosh to work with ssh's proxycommand directive. this only makes sense if the target machine is directly reachable from the internet using udp (but probably not via tcp). usage: mosh_pc.sh [host as mentioned in .ssh/config] [public ip of host]
#!/bin/sh
# ########################################################## #
# wrapper for mosh to work with ssh's proxycommand directive #
# this only makes sense if the machine is directly reachable #
# from the internet using udp. #
# ########################################################## #
THISSCRIPT="`basename \"$0\"`"
REMOTE="$1"
@cuibonobo
cuibonobo / \boot\cmdline.txt
Created May 30, 2013 03:28
To use bootchart on the Raspberry Pi, `sudo apt-get install bootchart bootchart-view` and then add `init=/sbin/bootchartd` to the end of `/boot/cmdline.txt`
dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=120,data=writeback elevator=deadline rootwait quiet init=/sbin/bootchartd
#! /usr/bin/env python3
import re
import sys
import json
import urllib.request
import argparse
import subprocess
# get config
try:
@willurd
willurd / set-wallpaper.sh
Last active January 18, 2020 11:02
Set the Desktop Background for all of your open Spaces in Mountain Lion
read -e IMAGE;
defaults write com.apple.desktop Background "{default = {ImageFilePath='$IMAGE'; };}"
killall Dock