Skip to content

Instantly share code, notes, and snippets.

@fronx
fronx / gist:867312
Created March 12, 2011 15:30
couples
Q: i want to choose 4 people out of 4 couples. i want a group with at least 1 couple.
4 couples:
ab
cd
ef
gh
non-couples:
6:a(c,d,e,f,g,h)
# list all changed spec files
alias d_specs='git diff --name-only | grep _spec.rb|sed -E "s/(.*)/\.\/\1/"'
# list all changed *.rb filenames without path and extension
alias diffrb='git diff --name-only|grep "\/[^/\.]*\.rb$" -o |grep -v _spec|cut -d . -f 1'
# diffrb.map { |s| "#{s}_spec"}.join('|')
alias any_diffrb="diffrb | tr '\n' '|'|sed -E \"s/^(.*).$/\1_spec/\""
# list all spec files that correspond to changed *.rb files (assuming they share the same prefix)
alias d_specs_more='find ./spec -name *_spec.rb|grep -E "(`any_diffrb`)"'
# find a spec by path-less name
function find_spec() {
document.body.addEventListener('keydown', function(e) {
([37, 39].indexOf(e.keyCode) > -1) && pres[{37:'prev',39:'next'}[e.keyCode]]();
});
// VERSUS
document.body.addEventListener('keydown', function(e) {
switch(e.keyCode) {
case 37: pres.prev(); break;
case 39: pres.next(); break;
--type-add=ruby=.haml,.rake
--type-set=css=.css,.sass
def _?(o, method, &block)
o.respond_to?(method) ? o : block.call(o)
end
def eachize(one_or_more)
_?(one_or_more, :each) { |o| [o] }
end
def foo(one_or_more)
eachize(one_or_more).each do |o|

premises

  • people expect others to be close to the statistical average
  • this expectation is often wrong
  • people don't adjust their models for deviating individuals very quickly and sometimes never

question

  • why?

-- WORK IN PROGESS

demo

play a 440 hz tone

  • as sine wave
  • on a guitar
  • sing it

notice the differences

require 'spec_helper'
describe SharesController do
render_views
describe '#create' do
let(:share_params) { :facebook_id => 'abc', :address_id => 7 }
it "redirects to login" do
post :create, :share => share_params
class Hash
alias :/ :[]
end
h = {:a => {:b => 'foo'}}
h/:a/:b #=> 'foo'
; user=> (source source)
(defmacro source
"Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
namespace for which the .clj is in the classpath.
Example: (source filter)"
[n]
`(println (or (source-fn '~n) (str "Source not found"))))