Skip to content

Instantly share code, notes, and snippets.

View emilpetkov's full-sized avatar

Emil Petkov emilpetkov

View GitHub Profile
module DelayedJob
module Matchers
def enqueue_delayed_job(handler)
DelayedJobMatcher.new handler
end
class DelayedJobMatcher
def initialize(handler)
@handler = handler
@attributes = {}
@ichernev
ichernev / .gitconfig
Created July 26, 2012 11:41
shared scripts
[user]
email = [email protected]
name = Iskren Chernev
[alias]
st = status
co = checkout
ci = commit
br = branch
df = diff
dc = diff --cached
@gcatlin
gcatlin / ncurses.diff
Created July 12, 2012 14:28
Homebrew Ncurses clang patch
diff --git a/ncurses.rb b/ncurses.rb
index 1067083..8cc12bc 100644
--- a/ncurses.rb
+++ b/ncurses.rb
@@ -23,4 +23,9 @@ class Ncurses < Formula
system "make"
system "make install"
end
+
+ def patches
@xdite
xdite / gist:3072362
Created July 8, 2012 19:10
deploy/asset.rb
# -*- encoding : utf-8 -*-
set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
namespace :deploy do
namespace :assets do
desc <<-DESC
Run the asset precompilation rake task. You can specify the full path \
to the rake executable by setting the rake variable. You can also \
@mikhailov
mikhailov / 0. nginx_setup.sh
Last active January 21, 2025 08:21
NGINX+SPDY with Unicorn. True Zero-Downtime unless migrations. Best practices.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@mperham
mperham / after.rb
Created July 4, 2012 19:30
Thread-friendly shared connection
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || ConnectionPool::Wrapper.new(:size => 1) { retrieve_connection }
end
end
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
@AndrewRadev
AndrewRadev / grep.vim
Last active October 6, 2015 10:28
A simple :Grep
" Can be called in several ways:
"
" :Grep <something> " -> Grep for the given search query
" :Grep " -> Grep for the word under the cursor
" :'<,'>Grep " -> Grep in visual mode
"
command! -count=0 -nargs=* Grep call s:Grep(<count>, <q-args>)
function! s:Grep(count, args)
try
let original_grepprg = &grepprg
@ihassin
ihassin / Reconnect
Created June 3, 2012 14:51
Reconnect to a lost database connection using an exception block trick (ruby, rails, mysql, activerecord)
def my_task
while(true) do
begin
database_access_here
rescue Exception => ex
begin
ActiveRecord::Base.connection.reconnect!
rescue
sleep 10
retry # will retry the reconnect
@jboner
jboner / latency.txt
Last active April 19, 2025 21:29
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@Svel
Svel / gist:2288892
Created April 3, 2012 02:34
git workflow production commit
# Inspired from https://www.braintreepayments.com/braintrust/our-git-workflow
# and some https://www.google.com/search?q=git%20workflow&hl=en searching
#
git checkout master
git merge --squash dev
msg="Version XXX";log=$(git log --format=" * %s" dev ^$(git log --merges -n 1 dev --format="%H")); echo -e "$msg\n\n$log" | git commit -F-
git checkout dev && git merge master