Skip to content

Instantly share code, notes, and snippets.

Avatar

Lar Van Der Jagt supaspoida

View GitHub Profile
@supaspoida
supaspoida / package.json
Created Dec 1, 2021 — forked from kentcdodds/package.json
setup script for my workshops
View package.json
{
"name": "workshop-setup",
"version": "1.0.0",
"description": "This is the common setup script for most of my workshops",
"bin": "./setup.js"
}
View keybase.md

Keybase proof

I hereby claim:

  • I am supaspoida on github.
  • I am supaspoida (https://keybase.io/supaspoida) on keybase.
  • I have a public key ASBKoqZkerJrbG5V94B4ECPiNI4hvBFyKkqsUk_FYTZaFQo

To claim this, I am signing this object:

@supaspoida
supaspoida / pig_latin_spec.rb
Created Jun 28, 2017
Translate Phrases to Pig Latin
View pig_latin_spec.rb
require 'spec_helper'
module PigLatin
extend self
def translate(phrase)
words = phrase.scan(/\w+/)
translations = words.map { |word| [word, Translate[word]] }
translations.inject(phrase) do |template, (original, translated)|
template.gsub(original, translated)
@supaspoida
supaspoida / named_block.rb
Last active Dec 17, 2015
Symbol#to_proc_with_hash_support
View named_block.rb
def key(k)
->(obj) { obj[k] }
end
[{ this: 'that' }].map &key(:this)
@supaspoida
supaspoida / hanoi.rb
Created Feb 2, 2013
brute force towers of hanoi
View hanoi.rb
towers = [[nil,4,3,2,1],[nil],[nil]]
valid = [[nil],[nil],[nil,4,3,2,1]]
moves = []
record = ->(disc, from, to) {
names = { 0 => 'left ', 1 => 'center', 2 => 'right ' }
moves << "disc %s: %s -> %s" % [disc, names[from], names[to]]
}
View funcbuzz.rb
mod3 = ->(i) { (i % 3).zero? }
mod5 = ->(i) { (i % 5).zero? }
both = ->(i) { mod3[i] && mod5[i] }
rules = {
'FizzBuzz' => ->(i) { both[i] },
'Fizz' => ->(i) { mod3[i] },
'Buzz' => ->(i) { mod5[i] }
}
@supaspoida
supaspoida / view_models.rb
Created Oct 15, 2012
Trivial example of a view model using dependency injection to access view context
View view_models.rb
class Controller
expose(:person) { PersonView.new(Person.first, self) }
end
class Decorator
attr_reader :controller, :object
def initializer(object, controller)
@object, @controller = object, controller
end
View .tmux.conf.local
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
bind r source-file ~/.tmux.conf
@supaspoida
supaspoida / donors_choose_spec.rb
Created Feb 14, 2012
How I'd express the donors choose spec
View donors_choose_spec.rb
describe DonorsChoose do
describe "requesting data" do
let(:test_title) { "A test project" }
def mock_request(args)
request = double(:fetch => %Q/{"proposals": [{"title": "#{test_title}"}]}/)
DonorsChoose::Request.should_receive(:new).with(args).and_return(request)
end
context "via lat & lng" do