Skip to content

Instantly share code, notes, and snippets.

View OpenCoderX's full-sized avatar
💭
Open to new projects

OpenCoderX OpenCoderX

💭
Open to new projects
View GitHub Profile
@OpenCoderX
OpenCoderX / latency.txt
Created May 31, 2012 12:56 — forked from jboner/latency.txt
Latency numbers every programmer should know
L1 cache reference 0.5 ns || 5.0 × 10^-10 seconds
Branch mispredict 5 ns || 5.0 × 10^-9 seconds
L2 cache reference 7 ns || 7.0 × 10^-9 seconds
Mutex lock/unlock 25 ns || 2.5 × 10^-8 seconds
Main memory reference 100 ns || 1.0 × 10^-7 seconds
Compress 1K bytes with Zippy 3,000 ns || 3.0 × 10^-6 seconds
Send 2K bytes over 1 Gbps network 20,000 ns || 2.0 × 10^-5 seconds
Read 1 MB sequentially from memory 250,000 ns || 0.00025 seconds
Round trip within same datacenter 500,000 ns || 0.00050 seconds
Disk seek 10,000,000 ns || 0.01 seconds
require 'action_view'
module ActionView
module Template::Handlers
class NokogiriBuilder
class_attribute :default_format
self.default_format = Mime::XML
def call(template)
"xml = ::Nokogiri::XML::Builder.new { |xml|" +

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
# Tested on DelayedJob 2.1
class MyRecurringDelayedJob
def perform
# ...some slow code
end
def success(job)
MyRecurringDelayedJob.schedule_job(job)
end
@OpenCoderX
OpenCoderX / zsh.md
Created January 12, 2013 02:55 — forked from tsabat/zsh.md

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

chsh -s `which zsh`

and then restart

set :test_log, "logs/capistrano.test.log"
namespace :deploy do
before 'deploy:update_code' do
puts "--> Running tests, please wait ..."
unless system "bundle exec rake > #{test_log} 2>&1" #' > /dev/null'
puts "--> Tests failed. Run `cat #{test_log}` to see what went wrong."
exit
else
puts "--> Tests passed"
class ETLJob
include Sidekiq::Worker
sidekiq_options :queue => :ETLTasks, :backtrace => true, :retry => false
def perform(control_file)
ETL::Engine.init({:execution_dbname=>"etl_execution_prod"})
ETL::Engine.process("#{Dir.pwd}/control/#{control_file}.ctl")
end
end
1,2012-01-02,New Year Day
2,2012-01-16,Martin Luther King Jr. Day
3,2012-02-20,Presidents Day (Washingtons Birthday)
4,2012-05-28,Memorial Day
5,2012-07-04,Independence Day
6,2012-09-03,Labor Day
7,2012-10-08,Columbus Day
8,2012-11-12,Veterans Day
9,2012-11-22,Thanksgiving Day
10,2012-12-25,Christmas Day
<VirtualHost *:80>
ServerName diaspora.example.org
RedirectPermanent / https://diaspora.example.org/
</VirtualHost>
<VirtualHost *:443>
ServerName diaspora.example.org
DocumentRoot /path/to/diaspora/public
RewriteEngine On
# deploy.rb
namespace :ts_remote do
task :conf do
run <<-CMD
cd #{current_release}
&&
RAILS_ENV=#{rails_env} rake ts:conf
&&
rsync --progress #{current_release}/config/#{rails_env}.sphinx.conf sphinxsearch@db-server:/home/sphinxsearch/