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
; Returns a lambda, which for each invocation gives the next Fibbonnaci number | |
fib := { a := 0 | |
b := 1 | |
{ n := a | |
c := a + b | |
a = b | |
b = c | |
n } } | |
seq := fib: |
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
## | |
# Using an index defined in code for model abstraction. | |
## | |
class PostsIndex | |
include Oedipus::RTIndex | |
connection 'sphinx.site.com:3312' | |
index_name :posts_rt |
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
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in `method_missing' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model/property.rb:249:in `method_missing' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:514:in `load_missing_constant' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:192:in `block in const_missing' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `each' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:190:in `const_missing' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/dm-core-1.2.0/lib/dm-core/model.rb:728:in `const_missing' | |
/home/chris/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/dm-core-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
module Flippa | |
module Job | |
# Allow Resque jobs to be instantiated and performed, instead of singleton classes. | |
module Instance | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Default .perform creates an instance and calls perform on that. | |
def perform(*args) | |
new(*args).perform(*args) |
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
# normally | |
idx = conn[:posts_rt] | |
idx.insert( ... ) | |
idx.search( ... ) | |
# distributed | |
idx = conn[:posts_dist, ->(id){ "posts_rt_#{id % 4}" }] | |
idx.insert( ... ) | |
idx.search( ... ) |
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
" actually run as vim, not vi | |
set nocompatible | |
" 256-color terminal | |
set t_Co=256 | |
" utf-8 by default | |
set encoding=utf-8 | |
" vundle requires turning off filetypes momentarily |
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
# Instructions for use | |
# | |
# 1. Execute "time rails runner nil" a few times in your shell, see how long rails takes to boot | |
# 2. Add this monkey patch to the top of config/boot.rb | |
# 3. Repeat step 1. What's the difference? | |
# | |
# This is just an experiment, but it gains me 30% on Rails' start time, which suggests there is something | |
# in Rails that is breaking the "run only once" behaviour of #require. | |
# | |
# Note: You can't override Kernel#require, since Rails by-passes it most of the time. |
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
; Remove a given member from a list | |
(define rember | |
(lambda (a lat) | |
(cond | |
((null? lat) '()) | |
((eq? (car lat) a) (cdr lat)) | |
(else (cons (car lat) | |
(rember a (cdr lat))))))) |
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
" actually run as vim, not vi | |
set nocompatible | |
" 256-color terminal | |
set t_Co=256 | |
" utf-8 by default | |
set encoding=utf-8 | |
" vundle requires turning off filetypes momentarily |
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
;; This was damn hard. | |
;; | |
;; One of the exercises near the end of The Little Schemer requires defining | |
;; a function that uses a collector to remove odd numbers, recursively from | |
;; a list, sum the odd numbers and multiple the even numbers. | |
;; | |
;; This is it. | |
;; | |
;; It requires currying lambdas one inside another to deal with the recursion | |
;; in the collector function. |