- Start a Sinatra server on port 4000
- GET / to that server triggers a
git pull
and mod_rails restart - Hit port 4000 locally after pushing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- ruby -*- | |
module AutoGrowl | |
def self.pt(msg) | |
msg.gsub %r{\\e\[[0-9]+m?}, '' | |
end | |
def self.growl(title, msg, pri = 0) | |
system "/usr/local/bin/growlnotify -n autotest --image /Applications/Mail.app/Contents/Resources/Caution.tiff -p #{pri} -m #{pt msg.inspect} #{pt title.inspect}" unless RUBY_PLATFORM =~ /java/ | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple example of using ShadowFacter with RSpec to verify system configuration | |
# http://twitter.com/bradleyktaylor | http://railsmachine.com | |
# | |
# run with 'spec -c installed_test.rb' | |
require 'shadow_facter' | |
def installed_fact(n) | |
name = n | |
fact(name) { exec("#{name.to_s} --version") ? true : false } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monitor HTTP requests being made from your machine with a one-liner.. | |
# Replace "en1" below with your network interface's name (usually en0 or en1) | |
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*" | |
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile: | |
# (again replace "en1" with correct network interface name) | |
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"" | |
# All the above tested only on OS X. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a useful little pattern for working with gems without | |
# explicitly requiring rubygems in your code. | |
# | |
# The approach taken is to require a library and catch any LoadError | |
# that might get thrown. In the rescue clause we require rubygems. | |
# | |
# The require method is nice in that it will return true if the code | |
# was loaded, and it returns false if the code was _already_ loaded. | |
# If the require of rubygems returns true, we will retry our original | |
# require. It will either succeed this time (since we now have rubygems |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'curb' | |
require "net/http" | |
require 'benchmark' | |
# http://0.0.0.0:8080 | |
# | |
# class HomeController < ApplicationController | |
# def index | |
# sleep 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# collect information about a running process | |
# ruby debug.rb <pid> | |
begin | |
raise ArgumentError unless pid = ARGV[0] | |
pid = pid.to_i | |
raise ArgumentError unless pid > 0 | |
Process.kill(0,pid) | |
rescue TypeError, ArgumentError | |
raise 'pid required' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash function to get a certificate from a remote host | |
function getcert { | |
host=$1 | |
port=$2 | |
if [ -n $port ]; then | |
port=443 | |
fi | |
openssl s_client -connect ${host}:${port} </dev/null 2>/dev/null | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# test/spec/mini 5 | |
# http://gist.github.com/307649 | |
# [email protected] | |
# | |
def context(*args, &block) | |
return super unless (name = args.first) && block | |
require 'test/unit' | |
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do | |
def self.test(name, &block) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
# url dsl -- the ultimate url dsl! | |
# | |
# You just can't beat this: | |
# | |
# $ irb -r url_dsl | |
# >> include URLDSL | |
# => Object | |
# >> http://github.com/defunkt.json |
OlderNewer