Skip to content

Instantly share code, notes, and snippets.

View durran's full-sized avatar

Durran Jordan durran

View GitHub Profile
@durran
durran / unicorn.monitrc
Created December 1, 2011 14:12
Unicorn Monit Config
check process unicorn
with pidfile "/var/run/unicorn/server.pid"
start program = "/etc/init.d/unicorn start"
stop program = "/etc/init.d/unicorn stop"
if failed unixsocket /var/run/unicorn/http.sock then restart
@durran
durran / mongodb.monitrc
Created December 1, 2011 14:14
MongoDB Monit Config
check process mongodb
with pidfile "/var/lib/mongodb/mongod.lock"
start program = "/sbin/start mongodb"
stop program = "/sbin/stop mongodb"
if failed port 28017 protocol http
and request "/" with timeout 10 seconds then restart
if 5 restarts within 5 cycles then timeout
@durran
durran / .watchr
Created December 2, 2011 11:27
Watchr script
trap 'INT' do
start_fresh "Done running tests."
exit! 0
end
def run_spec(file)
return unless file.include?(" ") || File.exist?(file)
start_fresh "Running specs..."
system("time rspec --fail-fast -c #{file}")
end
require "java"
import java.util.concurrent.RecursiveAction
class Scorer < RecursiveAction
attr_reader :documents
def compute
if documents.size <= 10000
score_each
Failures:
1) Engine
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `invokeAll' for #<Scorer:0x2224a128>
# ./spec/../app/engine.rb:25:in `compute'
@durran
durran / error.txt
Created December 7, 2011 10:19
Bundler error with frozen version in gemspec
dev@greedos-imac:~/Projects/yoda(master+*)$ bundle install
Updating git@github.com:mwarren/kirk.git
Unfortunately, a fatal error has occurred. Please report this error to the Bundler issue tracker at https://github.com/carlhuda/bundler/issues so that we can fix it. Thanks!
RuntimeError: can't modify frozen string
strip! at org/jruby/RubyString.java:5680
initialize at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/version.rb:191
create at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/version.rb:178
version= at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/specification.rb:2092
load_gemspec at /Users/dev/.rvm/gems/jruby-1.6.5@yoda/bundler/gems/kirk-44f41be56222/kirk.gemspec:9
initialize at /Users/dev/.rvm/rubies/jruby-1.6.5/lib/ruby/site_ruby/1.8/rubygems/specification.rb:1346
@durran
durran / errors.txt
Created December 7, 2011 11:40
JRuby test compilation errors.
@mode ➜ jruby rvm:(-ruby-1.9.2) git:(master) ✗ ant spec
Buildfile: /Users/durran/work/jruby/build.xml
init:
prepare-bin-jruby:
jar:
init:
@durran
durran / perf.txt
Created December 7, 2011 20:27
Profile with devise auth in engine
Profile Report
Thread ID Total Time
70123360768620 0.184724
70123369188820 0.073909
Thread 70123360768620
%Total %Self Total Self Wait Child Calls Name Line
100.00% 0.06% 0.18 0.00 0.00 0.18 1 Phoenix::SessionsController#create 12
0.11 0.00 0.00 0.11 1/1 Devise::Controllers::Helpers#user_signed_in? 16
0.07 0.00 0.00 0.07 1/1 ActionController::Instrumentation#render 25
0.00 0.00 0.00 0.00 2/5 ActiveSupport::BufferedLogger#debug 27
@durran
durran / version.txt
Created December 7, 2011 21:21
Java version
@mode ➜ jruby rvm:(system) git:(master) ✗ java -version
openjdk version "1.7.0-ea"
OpenJDK Runtime Environment (build 1.7.0-ea-b220)
OpenJDK 64-Bit Server VM (build 21.0-b17, mixed mode)
@durran
durran / query.rb
Created December 9, 2011 09:40
ML query
# Get the count of notifications for this user
# and this post that need to be sent or have *not*
# been sent in the past 24 hours
User.
where({ _id: user._id, "notifs.post_id" => post_id }).
any_of(
{ "notifs.needs_send" => true },
{ "notifs.last_send" => { '$exists' => false }},
{ "notifs.last_send" => { "$lt" => 1.days.ago.utc }}