Skip to content

Instantly share code, notes, and snippets.

View kevn's full-sized avatar

Kevin E. Hunt kevn

View GitHub Profile
# File: roles/common.rb
name "common"
description "Applied to all servers"
recipes "users"
default_attributes(
:groups => {
:admins => {:gid => 900},
},
:users => {
:kevn => { :password => "*", :comment => "Kevin", :uid => 1001, :group => :admins },
#!/bin/sh
#
# This script is an adaptation from http://www.sqlite.org/cvstrac/wiki?p=ConverterTools
# It expects stdin input from mysqldump with the following params:
# mysqldump --skip-extended-insert --add-drop-table --compatible=ansi --skip-add-locks --skip-comments --skip-disable-keys --skip-set-charset
# Note: Don't use --skip-quote-names as this script expects quoted names
#
# Note: This script imports boolean values as they are stored in Mysql, e.g., as the integers 0 and 1.
# As a result, boolean fields need to be further normalized after this transform step
# such that false field values are 'f' and true field values are 't', which is
#!/usr/bin/env ruby
# encoding: ascii-8bit
require 'rubygems'
require 'mail'
puts "Ruby version: #{RUBY_VERSION}"
puts "Mail gem version: #{Mail::VERSION::STRING}"
address = "josé.cuervo@cactus.com"
#!/usr/bin/env ruby
require 'rubygems'
require 'xmlrpc/client'
require 'yaml'
require 'termios'
require 'pp'
module Jira
end
@kevn
kevn / dbkill
Created September 9, 2010 19:18
#!/usr/bin/env sh
# Kill connections
ps -u postgres|grep "postgres: postgres yam_development"|awk '{print $2}'|xargs sudo -u postgres kill -s SIGQUIT
ps -u postgres|grep "postgres: postgres yam_test" |awk '{print $2}'|xargs sudo -u postgres kill -s SIGQUIT
# Wait for db processes to stop
sleep 5
psql84 -Upostgres -c 'DROP DATABASE yam_development'
@kevn
kevn / gist:783347
Created January 17, 2011 19:50
Experiment DSL
# Simple a/b test
experiment :signup_start_right_now do |exp|
exp.description 'Show a 5th signup step'
exp.ends_at '1 Jul 2011 00:00:00'
exp.control '50%', :with => 'show start step', :returning => false
exp.treat '50%', :with => 'do not show start step', :returning => true
end
** [out :: foo-001.] 87043105 Apr 5 21:33 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-002.] 88476119 Apr 5 21:01 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-003.] 88131289 Apr 5 21:30 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-004.] 86869486 Apr 5 21:26 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-005.] 67529684 Apr 5 20:46 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-006.] 89022804 Apr 5 21:38 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-007.] 88658473 Apr 5 21:00 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-008.] 88145813 Apr 5 20:46 /opt/workfeed/current/log/starboard_journal.log
** [out :: foo-009.] 88741158 Apr 5 21:00 /opt/workfeed/current/log/starboard_journal.log
def fuck_my_transaction
begin
ActiveRecord::Base.connection.begin_db_transaction
# Raise any error except an AR::StatementInvalid, such as an ActiveRecord::Rollback,
# which is generally used to signal a rollback condition
raise ActiveRecord::Rollback.new("Fucking your transaction.")
rescue ActiveRecord::StatementInvalid
puts "Rescued, rolling back..."
ActiveRecord::Base.connection.rollback_db_transaction
end
@kevn
kevn / run_tests
Created July 20, 2011 17:19
Run all tests matching wildcard args
#!/usr/bin/env ruby
require 'rubygems'
# Usage: run_tests user group network
pwd = Dir.pwd
finder_args = ARGV.map{|s| %Q(-name "*#{s}*_test.rb") }.join(' -or ')
test_paths = `find test -type d -maxdepth 1 -mindepth 1`.split("\n")
@kevn
kevn / gist:1100720
Created July 23, 2011 00:08
memoize ymodule applications
TypeError in Groups#show
Showing app/views/layouts/_nav_menu.html.erb where line #207 raised:
class ActiveRecord::Associations::BelongsToAssociation needs to have method `_load'
Extracted source (around line #207):
204:
205: <li>
206: <ul class="ymodules-nav-list yj-hidden-nav">