Skip to content

Instantly share code, notes, and snippets.

@rorcraft
rorcraft / Base File.sublime-settings
Last active September 27, 2015 18:38 — forked from jaredatron/Base File.sublime-settings
Default (OSX).sublime-keymap
{
"color_scheme": "Packages/Color Scheme - Default/Sunburst.tmTheme",
"detect_indentation": false,
"ensure_newline_at_eof_on_save": true,
"font_face": "Menlo",
"font_size": 11.0,
"ignored_packages":
[
"Vintage"
],
export BASH_COMMON_PATH=~/.bash_common
source $BASH_COMMON_PATH/bashrc
export PROMPT_COLOR=32
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # rvm
# [ -f ~/.bundler-exec.sh ] && source ~/.bundler-exec.sh
alias gs="git status"
alias e="subl"
@rorcraft
rorcraft / gist:1637279
Created January 19, 2012 02:23
ActiveRecord changes attributes in a rolled back transaction
class User < ActiveRecord::Base
after_create :deadlock_on_first_try
def deadlock_on_first_try
raise ActiveRecord::StatementInvalid.new("Lock wait timeout exceeded") if @deadlocked.nil?
ensure
@deadlocked = true
end
end
@rorcraft
rorcraft / gist:1644150
Created January 20, 2012 00:54
magic debug trace
# set_trace_func proc { |event,file,line,id,binding,classname| printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname }
@rorcraft
rorcraft / gist:3967583
Created October 28, 2012 04:56
rubymotion console methods
UIScreen.mainScreen
sessions
app = UIApplication.sharedApplication
delegate = app.delegate
repl(delegate)
quit
@rorcraft
rorcraft / gist:4640854
Last active December 11, 2015 18:19
Golang Tutorial Exercies. http://tour.golang.org
/* #44 */
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(1)
@rorcraft
rorcraft / crawler.go
Created February 20, 2013 03:02
Golang Tutorial: Crawler
package main
import (
"fmt"
"sync"
)
type Fetcher interface {
// Fetch returns the body of URL and
// a slice of URLs found on that page.
require 'digest/md5'
require 'fileutils'
require 'leveldb'
# no_of_keys = 20_000_000
no_of_keys = 20_000_000
# 1.upto(no_of_keys) do |i|
# digest = Digest::MD5.hexdigest(i.to_s)
# head = digest[0..1]
# key = digest[2..-1]
@rorcraft
rorcraft / .cane
Created May 2, 2013 01:04
Custom CaneLintSpec
--no-doc
--no-abc
--style-glob {app,lib}/**/*.rb
--require spec/cane_lint_spec.rb
--check CaneLintSpec
--lint-spec-glob {app,lib}/**/*.rb

HTTP Caching

  1. Cache by expiration time.
  2. Conditional Get by versioning.

Cache by expiration time.

Tells the client and intermediary cache what to cache.

HTTP 1.0: