Skip to content

Instantly share code, notes, and snippets.

@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
@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
@bellbind
bellbind / index.html
Last active September 5, 2018 09:26
[react][redux]Reversi Game with React/Redux and React-Redux
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<script src="https://unpkg.com/react@15.3.1/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.3.1/dist/react-dom.js"
></script>
<script src="https://unpkg.com/redux@3.6.0/dist/redux.js"></script>
<script src="https://unpkg.com/react-redux@4.4.5/dist/react-redux.js"
></script>
# 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.
@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'