Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin E. Hunt kevn

View GitHub Profile
@kevn
kevn / gist:1622513
Created Jan 16, 2012
SublimeText 2 Settings
View gist:1622513
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 Jan 3, 2012
Sample Test::Unit
View sample_test.rb
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 Oct 5, 2011
Etherpad-lite ruby gem timeouts
View gist:1263543
~/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 Aug 9, 2011
TinyMCE iframe creation
View gist:1133239
// 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 Jul 23, 2011
memoize ymodule applications
View gist:1100720
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 Jul 20, 2011
Run all tests matching wildcard args
View run_tests
#!/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")
View gist:991935
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
View journaled data
** [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 Jan 17, 2011
Experiment DSL
View gist:783347
# 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
View dbkill
#!/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'
You can’t perform that action at this time.