This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
require "rubygems" | |
require "rbench" | |
require "set" | |
RANGE = (1..1000) | |
ARRAY = RANGE.to_a | |
SET = Set.new(ARRAY) | |
HASH = ARRAY.inject({}) {|m, x| m[x] = true; m} | |
WORST_CASE_COMPLEXITY = ARRAY.size + 1 |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
# source 'http://rubygems.org' | |
source :gemcutter | |
gem 'rails', '3.1.0.beta1' | |
# Asset template engines | |
gem 'json' | |
gem 'sass' | |
gem 'coffee-script' | |
gem 'uglifier' |
/* | |
* Fabrizio Calderan, twitter @fcalderan, 2010.11.02 | |
* I had an idea: could Inception movie be explained by a few javascript closures | |
* and variable resolution scope (just for fun)? | |
* | |
* Activate javascript console =) | |
*/ | |
<script> | |
console.group("inception movie"); |
module Stop | |
module CantTouchThis | |
def self.included(mod) | |
%w[instance_variable_get instance_variable_set].each do |m| | |
send(:protected, m) | |
end | |
eigenclass = class << mod; self; end | |
%w[const_set class_variable_get class_variable_set public_class_method attr attr_reader attr_writer].each do |m| |
;; Helpful macro function | |
(defun my-macro-query (arg) | |
"Prompt for input using minibuffer during kbd macro execution. | |
With prefix argument, allows you to select what prompt string to use. | |
If the input is non-empty, it is inserted at point." | |
(interactive "P") | |
(let* ((query (lambda () (kbd-macro-query t))) | |
(prompt (if arg (read-from-minibuffer "PROMPT: ") "Input: ")) | |
(input (unwind-protect | |
(progn |
# inject our logger into CouchRest HTTP abstraction layer | |
module HttpAbstraction | |
def self.get(uri, headers=nil) | |
start_query = Time.now | |
log = {:method => :get, :uri => uri, :headers => headers} | |
response = super(uri, headers=nil) | |
end_query = Time.now | |
log[:duration] = (end_query - start_query) | |
CouchRest::Logger.record(log) |
module CouchRest | |
class Logger | |
def initialize(app, db=nil) | |
@app = app | |
@db = db | |
end | |
def call(env) | |
log['started_at'] = Time.now |
- simple | |
- public over private | |
- personal vanity | |
- internet is global | |
- permalinks | |
- one important item per page | |
- don't break the browser | |
- don't wanker in technology | |
- a medium is not a grande | |
- break convention for your users |
1: C | |
2: PHP | |
3: JavaScript | |
4: C++ | |
5: Java | |
6: Ruby | |
7: Emacs Lisp | |
8: Python | |
9: Perl | |
10: C Sharp |