Skip to content

Instantly share code, notes, and snippets.

@nebiros
nebiros / unicorn.rake
Created June 5, 2012 17:26
rails rake tasks for managing unicorn server instances + rbenv
ENV["RAILS_ENV"] ||= "production"
module UnicornServer
# http://unicorn.bogomips.org/Unicorn/Configurator.html
CONFIG_PATH = File.join(Rails.root, "config", "unicorn.rb")
PID_PATH = File.join(Rails.root, "tmp", "pids", "unicorn.pid")
RBENV = %x[which rbenv].strip
DAEMON = "bundle exec unicorn_rails"
DAEMON_OPTS = "-c #{CONFIG_PATH} -E #{ENV["RAILS_ENV"]} -D"
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@jboner
jboner / latency.txt
Last active June 1, 2024 18:05
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
@nebiros
nebiros / Gemfile
Created May 23, 2012 15:58
rails + unicorn + rbenv + init.d daemon
group :production do
gem "unicorn"
end
@FichteFoll
FichteFoll / prettify_markdown_table.py
Created May 12, 2012 02:09
Plugin for Sublime Text 2 that "prettifies" MultiMarkdown tables and aligns their vertical separators
from sublime import Region
import sublime_plugin
"""
This plugin for Sublime Text 2 searches for tables with a style like:
| I'm a header | I'm second|lolol|
|:-|-:|::|
| I'm a cell | yeah, you bet ||
@daveworth
daveworth / git selective merge
Created May 9, 2012 19:20 — forked from katylava/git-selective-merge.md
git selective merge
Example: You have a branch 'refactor' that is quite different from master. You can't merge all of the
commits, or even every hunk in any single commit or master will break, but you have made a lot of
improvements there that you would like to bring over to master.
# on master
> git branch -m original_refactor refactor # <== completely optional but part of my flow
> git co -b temp
# on temp
> git merge --no-commit --no-ff refactor
@kulesa
kulesa / gist:2507892
Created April 27, 2012 09:44 — forked from dhh/gist:2492118
nested routes for namespaces
class ActionDispatch::Routing::Mapper
def draw(routes_name)
instance_eval(File.read(Rails.root.join("config/routes", "#{@scope[:shallow_prefix]}", "#{routes_name}.rb")))
end
end
BCX::Application.routes.draw do
draw :projects # => config/routes/projects.rb
namespace :admin do
@eungjun-yi
eungjun-yi / gfm.coffee
Created April 10, 2012 08:53
Coffeescript port of gfm at https://gist.github.com/118964
crypto = require 'crypto'
gfm = (text) ->
# Extract pre blocks
extractions = {}
text = text.replace /<pre>(\n|.)*?<\/pre>/gm, (match) ->
md5 = crypto.createHash('md5').update(match).digest('hex')
extractions[md5] = match
'{gfm-extraction-' + md5 + '}'
anonymous
anonymous / minimal_todo.sh
Created January 14, 2012 13:21
Minimally Awesome Todos for Mac OS X
# Reference: http://blog.jerodsanto.net/2010/12/minimally-awesome-todos/
#
# Improvements:
#
# *) It now supports tracking multiple projects/todo files.
# *) Use 'cat -b' to get task order instead of hard-coding line number in files.
#
# 3 actions available:
# - Create a new task in project "prj": td prj task
# - Delete third task: tddone prj 3
# Updated version is always at: https://gist.github.com/febuiles/1549991
#!/bin/bash
artist=`osascript -e'tell application "iTunes"' -e'get artist of current track' -e'end tell'`
title=`osascript -e'tell application "iTunes"' -e'get name of current track' -e'end tell'`
song=`curl -s --get "https://makeitpersonal.co/lyrics" --data-urlencode "artist=$artist" --data-urlencode "title=$title"`
echo -e "$artist - $title\n$song"