Skip to content

Instantly share code, notes, and snippets.

@remcopeereboom
remcopeereboom / factorial.rb
Created February 20, 2015 14:40
Enabling tail recursion in ruby
require_relative 'tail_call_optimization' # All files loaded AFTER this file with have tail-recursion enabled.
require_relative 'tail_factorial'
# Multiple inheritance with Modules as an alternative to injected composition
# from Sandi Metz's talk [Nothing is Something](http://confreaks.tv/videos/bathruby2015-nothing-is-something)
# Like Sandi's 'direct' DI method this has behavior outside of the base class
# that gets composed together. However in this gist I compose modules in class
# definitions instead of injecting collaborators.
# Tradeoffs between this and Sandi's version are that in this case the API consumer doesn't
# have to know how to make a RandomEchoHouse (no `house = House.new(formatter: Whatever.new)`),
# but also the API consumer can't make anything not already accounted for either.
@bellbind
bellbind / index.html
Last active November 2, 2024 00:19
[react][redux]Reversi Game with React/Redux and React-Redux
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://unpkg.com/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.js"
></script>
<script src="https://unpkg.com/[email protected]/dist/redux.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-redux.js"
></script>
@petertseng
petertseng / exercism-teams.rb
Last active May 10, 2017 06:48
Exercism teams
require 'json'
require 'set'
# Create a personal access token at https://github.com/settings/tokens
# It needs only one scope: read:org ("Read org and team membership").
TOKEN_FILE = 'secrets/token.txt'.freeze
SLEEP_TIME = 2
global_name = 'track-maintainers'.freeze
@byorgey
byorgey / FastForwardLCG.hs
Created August 8, 2018 03:53
Proof-of-concept Haskell implementation of LCG fast-forwarding
-- An LCG consists of three values: a multiplier, an offset, and a
-- modulus.
data LCG = LCG
{ multiplier :: Integer
, offset :: Integer
, modulus :: Integer
}
deriving Show