This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 1 MB sequentially from memory 250,000 ns 0.25 ms | |
Round trip within same datacenter 500,000 ns 0.5 ms | |
Read 1 MB sequentially from SSD 1,000,000 ns 1 ms 4X memory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git branch -r --merged | | |
grep origin | | |
grep -v -e '>' -e master | | |
xargs -L1 | | |
awk '{split($0,a,"/"); print a[2]}' | | |
xargs git push origin --delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.__ ___. .__ __ .__ .___ | |
| |__ _____ ______ ______ ___.__. \_ |__ |__|_______ _/ |_ | |__ __| _/_____ ___.__. | |
| | \ \__ \ \____ \ \____ \< | | | __ \ | |\_ __ \\ __\| | \ / __ | \__ \ < | | | |
| Y \ / __ \_| |_> >| |_> >\___ | | \_\ \| | | | \/ | | | Y \/ /_/ | / __ \_\___ | | |
|___| /(____ /| __/ | __/ / ____| |___ /|__| |__| |__| |___| /\____ | (____ // ____| | |
\/ \/ |__| |__| \/ \/ \/ \/ \/ \/ | |
_____ ___ ___ ___ ___ ___ | |
/ /::\ / /\ / /\ /__/\ /__/\ /__/| ___ | |
/ /:/\:\ / /:/_ / /:/_ \ \:\ \ \:\ | |:| / /\ | |
/ /:/ \:\ / /:/ /\ / /:/ /\ \ \:\ \ \:\ | |:| / /:/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GC on Template finalize | |
class Template | |
module CompiledTemplates; end | |
def self.garbage_collect_compiled_method(object_id) | |
CompiledTemplates.module_eval do | |
remove_method Template.compiled_method(object_id) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Usage: license | |
# Prints an MIT license appropriate for totin' around. | |
# | |
# $ license > COPYING | |
exec sh -c "tail -n +$(expr $LINENO + 1) < $0 | sed s/DATE/$(date +%Y)/" | |
Copyright (c) DATE Ryan Tomayko | |
Permission is hereby granted, free of charge, to any person ob- | |
taining a copy of this software and associated documentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# Usage: git-amend <commit> | |
# Amend changes staged in the index to <commit>, or edit commit message if | |
# no changes are currently staged. Modifications not staged are stashed and | |
# then reapplied once the amend and rebase operations are complete. | |
# | |
# This command rewrites history. Do not run it after <commit> or its | |
# decendants have been published to the world. | |
# | |
# This version in POSIX sh by Ryan Tomayko <tomayko.com/about> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# test/spec/mini 2 | |
# http://gist.github.com/25455 | |
# [email protected] | |
# file:lib/test/spec/mini.rb | |
# | |
def context(*args, &block) | |
return super unless (name = args.first) && block | |
require 'test/unit' | |
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "sinatra/base" | |
class WhatTheFuck < Sinatra::Base | |
set :raise_errors, false | |
set :dump_errors, true | |
use_in_file_templates! | |
get "/" do | |
erb :wtf | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The code in lib/foobar.rb | |
require 'sinatra/base' | |
class Foobar < Sinatra::Base | |
VERSION = '1.0.0' | |
configure do | |
set :foobar, environment | |
end | |
end | |
# The tests in test/test_foobar.rb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The "registered" module method was added to help ensure that extensions can | |
initialize options in a way that guarantees they can be accessed using | |
"options.option_name" at the request-level or "self.option_name" at the class | |
level. I've rewritten the examples to illustrate the new usage. |
NewerOlder