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
module MathFunctions | |
include InlineTest | |
def factorial(n) | |
(1..n).inject(1) { |acc, x| acc * x} | |
end | |
unit_test do | |
assert factorial(6) == 720 | |
assert factorial(5) == 120 |
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
function step_std_dev(val) { | |
n += 1 | |
delta = val - mean | |
mean = mean + delta/n | |
M2 = M2 + delta*(val - mean) # This expression uses the new value of mean | |
if (n > 1) { | |
variance_n = M2/n | |
variance = M2/(n - 1) | |
} | |
} |
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
# 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) |
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
module CouchRest | |
class Logger | |
def initialize(app, db=nil) | |
@app = app | |
@db = db | |
end | |
def call(env) | |
log['started_at'] = Time.now |
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
- 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 |
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
1: C | |
2: PHP | |
3: JavaScript | |
4: C++ | |
5: Java | |
6: Ruby | |
7: Emacs Lisp | |
8: Python | |
9: Perl | |
10: C Sharp |
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
Gem::Specification.new do |s| | |
s.name = %q{goaloc} | |
s.version = "0.3.0" | |
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | |
s.authors = ["matt knox"] | |
s.date = %q{2009-01-09} | |
s.default_executable = %q{goaloc} | |
s.description = %q{Generate On A Lot of Crack speeds and extends the early sketching phase of RESTFUL MVC app development} | |
s.email = %q{[email protected]} |
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
Gem::Specification.new do |s| | |
s.name = %q{goaloc} | |
s.version = "0.3.0" | |
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | |
s.authors = ["matt knox"] | |
s.date = %q{2009-01-09} | |
s.default_executable = %q{goaloc} | |
s.description = %q{Generate On A Lot of Crack speeds and extends the early sketching phase of RESTFUL MVC app development} | |
s.email = %q{[email protected]} |
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
bash-3.2$ rake version | |
(in /Users/mknox/hack/ruby/goaloc) | |
Current version: 0.2.3 | |
bash-3.2$ rake version:bump:patch | |
(in /Users/mknox/hack/ruby/goaloc) | |
Current version: 0.2.3 | |
Wrote to VERSION.yml: 0.2.4 | |
bash-3.2$ git status | |
# On branch master | |
nothing to commit (working directory clean) |
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
CONTEXT_STACK = [] | |
DEFAULT_STARTING_SELF = self | |
module Repl | |
def repl | |
DEFAULT_STARTING_SELF.cb self | |
CONTEXT_STACK.push(self) | |
end | |
def stop_repl |