Skip to content

Instantly share code, notes, and snippets.

View kevn's full-sized avatar

Kevin E. Hunt kevn

View GitHub Profile
@kevn
kevn / gist:1622513
Created January 16, 2012 19:28
SublimeText 2 Settings
File Settings - User:
{
"caret_style": "blink",
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme",
"draw_indent_guides": true,
"indent_guide_options": ["draw_normal", "draw_active", "draw_stack",
"normal_stippled", "stack_stippled", "active_stippled"],
"draw_white_space": "all",
"font_face": "Menlo",
"font_size": 16,
@kevn
kevn / sample_test.rb
Created January 3, 2012 20:26
Sample Test::Unit
require 'test/unit'
class FooTest < Test::Unit::TestCase
def setup
# puts "Do stuff before tests"
@foo = 'messages.csv'
@lines = download_export('a', 'b', 'c')
end
@kevn
kevn / gist:1263543
Created October 5, 2011 03:23
Etherpad-lite ruby gem timeouts
~/dev/ruby-etherpad-lite% rspec spec [master]
*****************************************************************
DEPRECATION WARNING: you are using a deprecated constant that will
be removed from a future version of RSpec.
/opt/ruby-enterprise-1.8.7-2011.03/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
* Rspec is deprecated.
* RSpec is the new top-level module in RSpec-2
***************************************************************
@kevn
kevn / gist:1133239
Created August 9, 2011 01:39
TinyMCE iframe creation
// Create iframe
// TODO: ACC add the appropriate description on this.
n = DOM.add(o.iframeContainer, 'iframe', {
id : t.id + "_ifr",
src : u || 'javascript:""', // Workaround for HTTPS warning in IE6/7
frameBorder : '0',
allowTransparency : "true",
title : s.aria_label,
style : {
width : '100%',
@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">
@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")
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
** [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
@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
@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'