Skip to content

Instantly share code, notes, and snippets.

@saimonmoore
saimonmoore / warn_with_timestamp.rb
Created December 21, 2012 09:48
warn with timestamp
class WarnTS
def self.warn_now(msg='')
msg = Time.now.to_s(:db) + msg
warn msg
end
end
@saimonmoore
saimonmoore / resque_dev_tools.rake
Created December 21, 2012 09:45
Handy tools for resque
# see http://stackoverflow.com/questions/5880962/how-to-destroy-jobs-enqueued-by-resque-workers - old version
# see https://github.com/defunkt/resque/issues/49
# see http://redis.io/commands - new commands
namespace :carefully do
namespace :resque do
task :redis_available do
unless $redis
warn "Redis not available..."
exit(1)
@saimonmoore
saimonmoore / blackhole.rb
Created December 21, 2012 09:44
# A class that swallows any and # all calls to itself or it's objects.
# A class that swallows any and
# all calls to itself or it's objects.
#
class BlackHole < BasicObject
class << self
def method_missing(*args)
end
end
def method_missing(*args)
@saimonmoore
saimonmoore / gist:3782040
Created September 25, 2012 13:49
activerecord 3-1-stable failures
Finished tests in 91.886982s, 33.9221 tests/s, 105.4883 assertions/s.
1) Failure:
test_should_serialize_binary(NilXmlSerializationTest) [/Volumes/Media/Development/OpenSource/forks/rails/activerecord/test/cases/xml_serialization_test.rb:124]:
Failed assertion, no message given.
2) Failure:
test_should_serialize_boolean(NilXmlSerializationTest) [/Volumes/Media/Development/OpenSource/forks/rails/activerecord/test/cases/xml_serialization_test.rb:139]:
Failed assertion, no message given.
tb4-staging1:/data/teambox/current$ make stop
kill -s QUIT `cat tmp/pids/unicorn.pid`
tb4-staging1:/data/teambox/current$ ps aux | grep uni
teambox 619 0.0 0.0 3004 1164 ? Ss Jul04 0:00 su - teambox -c cd /data/teambox-enterprise/current; export PORT=5000; bundle exec unicorn -p $PORT -c /data/teambox-enterprise/shared/config/unicorn.rb >> /var/log/teambox-enterprise/web-1.log 2>&1
teambox 756 0.0 0.0 4464 704 ? S Jul04 0:00 -su -c cd /data/teambox-enterprise/current; export PORT=5000; bundle exec uncorn -p $PORT -c /data/teambox-enterprise/shared/config/unicorn.rb >> /var/log/teambox-enterprise/web-1.log 2>&1
teambox 997 0.0 1.0 33844 19648 ? Sl Jul04 0:17 unicorn master -p 5000 -c /data/teambox-enterprise/shared/config/unicorn.rb
teambox 1298 0.0 5.2 147332 95120 ? Sl Jul04 0:24 unicorn worker[0] -p 5000 -c /data/teambox-enterprise/shared/config/unicorn.rb
@saimonmoore
saimonmoore / gist:3057408
Created July 6, 2012 01:05
Run an activerecord migration programmatically from irb
irb(main):013:0* class AddStateToIncomingEmails < ActiveRecord::Migration
irb(main):014:1> def up
irb(main):015:2> add_column :incoming_emails, :state, :string
irb(main):016:2> end
irb(main):017:1>
irb(main):018:1* def down
irb(main):019:2> end
irb(main):020:1> end
=> nil
irb(main):021:0> AddStateToIncomingEmails.migrate(:up)
set -g prefix C-x
unbind C-b
bind C-x send-prefix
# set -sg escape-time 1
# set -g base-index 1
bind r source-file ~/.tmux.conf; display "Reloaded!"
bind | split-window -h
bind - split-window -v
@saimonmoore
saimonmoore / gist:2021250
Created March 12, 2012 11:14
grep emails from openid logs
sudo grep "openid.sreg.email" /var/log/messages | tr "&" "\n" | grep email= | cut -d= -f2
#add group duplicates
sudo grep "openid.sreg.email" /var/log/messages | tr "&" "\n" | grep email= | cut -d= -f2 | sort | uniq -c | sort -r
require 'term/ansicolor'
# yeilds a stacktrace for each SQL query
# put this file in config/initializers
class QueryTrace < ActiveSupport::LogSubscriber
include Term::ANSIColor
attr_accessor :trace_queries
def sql(event) #:nodoc:
return unless QueryTrace.enabled? && logger.debug? && Rails.env.development?
set nocompatible
filetype off
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" let Vundle manage Vundle
" required!
Bundle 'gmarik/vundle'