Skip to content

Instantly share code, notes, and snippets.

$ cap staging deploy
@fuse
fuse / unicorn.rb
Created November 15, 2011 10:43
Unicorn configuration
# unicorn_rails -c config/unicorn.rb -E production -D
worker_processes 4
user "synbioz", "users"
working_directory "/var/www/fake/current"
listen "/var/www/fake/shared/sockets/unicorn.sock", :backlog => 1024
pid "/var/www/fake/shared/pids/unicorn.pid"
# nuke workers after 30 seconds instead of 60 seconds (the default)
@fuse
fuse / nginx
Created November 15, 2011 10:59
server {
listen 80;
server_name fake.server;
access_log /var/log/nginx/fake.access.log;
error_log /var/log/nginx/fake.error.log;
# direct to maintenance if this file exists
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html last;
$ cap staging maintenance:start
upstream fake {
server unix:/www/fake/shared/sockets/unicorn.sock;
}
@fuse
fuse / mysql2
Created January 19, 2012 09:49
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Users/fuse/Dropbox/code/ladw/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Users/fuse/Dropbox/code/ladw/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Last 10 log lines:
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -Wl,-flat_namespace
SOLIBS =
compiling main.c
In file included from /usr/include/string.h:190,
from ./include/ruby/ruby.h:48,
from ./include/ruby.h:32,
from main.c:13:
/usr/include/secure/_string.h: In function ‘__inline_stpncpy_chk’:
/usr/include/secure/_string.h:118: error: implicit declaration of function ‘__builtin___stpncpy_chk’
@fuse
fuse / gist:1759079
Created February 7, 2012 10:51 — forked from tight/gist:1758913
for vs each
i = "foo"
for i in 1..5 do
puts i
j = "bar"
end
i # => 5
j # => "bar"
i = "foo"
(1..5).each do |i|
@fuse
fuse / named_capture.rb
Created July 3, 2012 12:39
Ruby regex named capture
[1] pry(main)> str = "Candy bar"
=> "Candy bar"
[2] pry(main)> /(?<word>\w+)/ =~ str
=> 0
[3] pry(main)> word
=> "Candy"
[4] pry(main)> str =~ /(?<w>\w+)/
=> 0
[5] pry(main)> w
NameError: undefined local variable or method `w' for main:Object
require 'benchmark'
n = 5000000
class A
def initialize(attribute)
@attribute = attribute
end