Skip to content

Instantly share code, notes, and snippets.

View mmmurf's full-sized avatar

Matt Murphy mmmurf

  • San Francisco, CA
View GitHub Profile
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@mmmurf
mmmurf / gist:1313698
Created October 25, 2011 18:10 — forked from rkh/gist:1313690
class DomainSession < Rack::Session::Cookie
def set_cookie(env, headers, cookie)
cookie[:domain] ||= Rack::Request.new(env).host[/(\.[^\.]+){2}$/]
super
end
end
use DomainSession
require 'dm-core'
require 'dm-migrations'
class Foo
include DataMapper::Resource
property :id, Serial
has n, :bars
end
class Bar
@mmmurf
mmmurf / redate.rb
Last active September 15, 2015 23:37
script to fix the created datestamp on files rescued from snapjoy's end of life backup downloads. This makes them show up in the proper order in Carousel
# this script fixed the ordering in carousel of may snapjoy files.
# works on OSX
require 'date'
Dir.glob("./**/*.jpeg").each do |f|
next if f =~ /nknown/
m = /(?<serial>\d{0,6})-(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/.match(f)
d = DateTime.new(m['year'].to_i, m['month'].to_i, m['day'].to_i) + Rational(m['serial'].to_i, 86400)
/projects/5304ecaf565147c7e488$ unicorn
I, [2010-03-28T16:40:14.986279 #27939] INFO -- : listening on addr=0.0.0.0:8080 fd=3
I, [2010-03-28T16:40:15.095040 #27939] INFO -- : worker=0 spawning...
I, [2010-03-28T16:40:15.096947 #27939] INFO -- : master process ready
I, [2010-03-28T16:40:15.098584 #27941] INFO -- : worker=0 spawned pid=27941
I, [2010-03-28T16:40:15.807127 #27941] INFO -- : worker=0 ready
No view class found for layout in .
NoMethodError - undefined method `empty?' for nil:NilClass:
/usr/local/ruby1.9/lib/ruby/gems/1.9.1/gems/mustache-0.9.1/lib/mustache/sinatra.rb:67:in `mustache'
/home/mmmurf/projects/5304ecaf565147c7e488/app.rb:13:in `block in <class:App>'
@mmmurf
mmmurf / carbon.md
Created November 8, 2009 15:55 — forked from defunkt/carbon.md

Vim

autocmd BufWritePre * :%s/\s\+$//e

Emacs

(add-hook 'before-save-hook 'delete-trailing-whitespace)

Textmate

config.after_initialize do
#CACHE
MEMCACHE_SERVER = case RAILS_ENV
when 'development' then 'localhost:11211'
when 'staging' then '127.0.0.1:11211'
when 'production' then '192.168.2.26:11211'
when 'test' then nil
else raise
end
(in /home/mmmurf/projects/penguin_shipping_lab)
/usr/bin/ruby1.8 -Ilib:lib "/usr/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake/rake_test_loader.rb" "test/gateways/penguin_discounted/pdf_test.rb" "test/gateways/penguin_discounted/images_test.rb" "test/gateways/endicia/pdf_test.rb" "test/gateways/endicia/images_test.rb" "test/gateways/ups/pdf_test.rb" "test/gateways/ups/images_test.rb" "test/gateways/usps/images_test.rb"
/usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in `load_missing_constant': uninitialized constant Dependencies (NameError)
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in `const_missing'
from /usr/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:89:in `const_missing'
from ./lib/penguin_shipping_lab.rb:23
from ./init.rb:5:in `require'
from ./init.rb:5
from ./test/gateways/penguin_discounted/../../test_helper.rb:1:in `require'
from ./test/gateways/penguin_discounted/../
require 'spec/spec_helper'
describe "ThinkingSphinx::ActiveRecord (testing total entries results) " do
before :all do
@sphinx.setup_sphinx
@sphinx.start
end
after :all do
$strace zmq_server 5672
execve("/usr/local/bin/zmq_server", ["zmq_server", "5672"], [/* 36 vars */]) = 0
brk(0) = 0x8672000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb800b000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=61344, ...}) = 0
mmap2(NULL, 61344, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7ffc000
close(3) = 0