Skip to content

Instantly share code, notes, and snippets.

View benjaminws's full-sized avatar

Benjamin W. Smith benjaminws

View GitHub Profile
### Rakefile
task :template do
require 'yaml'
require 'erb'
base = File.join(File.dirname(__FILE__), 'config')
source = File.join(base, 'dna.json.erb')
target = File.join(base, 'dna.json')
recipes = ENV['recipe'] || %w(packages users gems)
@vvalgis
vvalgis / Capistrano tasks for starting unicorn.rb
Created May 7, 2010 08:13
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
#!/usr/bin/env python
import time
import nose
from nose.plugins.base import Plugin
class NoseTimer(Plugin):
"""
Times each individual test and outputs them in reverse order of
speed (highest first)
x = function()
y = function()
local table = 5
end
local old_table = table
y()
assert(table == old_table and table ~= 5)
end
x()
from threading import Timer
class SuicidalKey(object):
"""
>>> k = SuicidalKey("asdf",30)
>>> k.key
'asdf'
>>> # Before 30 seconds are up
>>> k.reset_expiration(30)
>>> # Wait 30 seconds
@lusis
lusis / wd-gemfile.md
Created April 22, 2011 16:19
wd-gemfile.md
git clone https://github.com/flogic/whiskey_disk.git
cd whiskey_disk
echo -e 'source "http://rubygems.org"\ngemspec' > Gemfile
bundle install
[] me@~/development/whiskey_disk$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.8.7) 
@hedgehog
hedgehog / definition.rb
Created May 4, 2011 01:11 — forked from schisamo/definition.rb
veewee definition for creating a Vagrant box that mirrors the centos5-gems knife bootstrap template
Veewee::Session.declare( {
:cpu_count => '1',
:memory_size=> '384',
:disk_size => '10140',
:disk_format => 'VDI',
:disk_size => '10240' ,
:os_type_id => 'RedHat',
:iso_file => "CentOS-5.5-i386-netinstall.iso",
:iso_src => "http://mirror.bytemark.co.uk/centos/5.5/isos/i386/CentOS-5.5-i386-netinstall.iso",
:iso_md5 => "0172883a3039772165db073693debae5",
@sleekslush
sleekslush / apply-pattern.js
Created July 26, 2011 19:58
Javascript apply pattern
var Public = Public || {};
Public.Namespace = Public.Namespace || {};
(function() {
function concat(s1, s2) {
return s1 + s2;
}
this.sayHello = function(who) {
console.log(concat("Hello ", who));
@mitchellh
mitchellh / gist:1171262
Created August 25, 2011 17:44
They see me wiresharkin'... they hatin'...
#!/usr/bin/env python
"""
This Python scripts listens for all HTTP requests to the
Turntable CDNs and downloads the file requested into the
current directory.
Disclaimer: This is a proof of concept. The author of this
script is not responsible for how this is used.
"""
@louiszuckerman
louiszuckerman / gist:1346387
Created November 7, 2011 22:18
Logstash parser for ModSecurity/CRS entries in the Apache ErrorLog
Logstash Configuration...
input {
file {
format => "plain"
path => "/var/log/apache2/*error.log"
type => "apacheerror"
}
}
filter {