Skip to content

Instantly share code, notes, and snippets.

View natlownes's full-sized avatar

Nat Lownes natlownes

View GitHub Profile
@natlownes
natlownes / christ.txt
Created November 9, 2011 19:15
git pre-receive hook to catch Ruby debugger statements and reject push
.======.
| INRI |
| |
| |
.========' '========.
| _ xxxx _ |
| /_;-.__ / _\ _.-;_\ |
| `-._`'`_/'`.-' |
'========.`\ /`========'
@natlownes
natlownes / matchers.rb
Created November 29, 2011 15:03
javascript alert box rspec matcher for selenium
Spec::Matchers.define :be_displaying_alert do
match do |actual|
class_name = begin
actual.driver.browser.switch_to.alert.class
rescue => exception
exception.class
end
class_name == Selenium::WebDriver::Alert
end
@natlownes
natlownes / gist:1405105
Created November 29, 2011 15:04
non-fancy looking dock
defaults write com.apple.dock no-glass -boolean YES; killall Dock
setopt No_X_Trace;
setopt No_Verbose;
if ! type redisplay 2>/dev/null 1>/dev/null; then
declare -x PS1
declare -x PS2;
declare -x PS3;
declare -x PS4;
setopt Prompt_Percent
require 'open-uri'
open("http://icanhazip.com/").read.strip
# tiny success: http://bit.ly/RhpepU
# osx specific, mpg123 or the like for linux
nmap HH :silent ! afplay /Users/nat/.vim/audio/succ_horns01.mp3 1>&-2>&-&<CR><C-l>
require 'rubygems'
require 'rest-client'
require 'json'
#
# get all users in a program
#
client_id = 1069416700
client_api_key = 'b26420242ff0a48b192ddc4fa3e4ac96'
<domain type='kvm' id='22'>
<name>freebsd</name>
<uuid>edfc5177-de28-3f69-7da8-a18f90b10a9c</uuid>
<memory unit='KiB'>2097152</memory>
<currentMemory unit='KiB'>2097152</currentMemory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc-1.1'>hvm</type>
<boot dev='hd'/>
</os>
@natlownes
natlownes / chef.rake
Created January 30, 2013 15:54
rake task for dumping roles defined in the ruby DSL to json. expects dir .chef/chef_server_backup to exist in your chef-repo
namespace :roles do
desc 'dump roles defined in the Ruby DSL to json'
task :dump do
destination_dir = File.join(TOPDIR, '.chef', 'chef_server_backup')
files_paths = Dir["#{TOPDIR}/roles/*.rb"]
files_paths.each do |filename|
role_name = File.basename(filename, '.rb')
role = Chef::Role.new
#!/usr/bin/env bash
command_exists () {
type "$1" &> /dev/null ;
}
system_name="`uname -s`"
if [ "$system_name" == "Darwin" ]
then