Skip to content

Instantly share code, notes, and snippets.

View rewinfrey's full-sized avatar
🏄‍♂️
fix f = let x = f x in x

Rick Winfrey rewinfrey

🏄‍♂️
fix f = let x = f x in x
View GitHub Profile
@rewinfrey
rewinfrey / RecursionSchemesExample.hs
Created May 26, 2017 21:34
Recursion Schemes in Haskell
#!/usr/bin/env stack
-- stack --resolver lts-8.12 script
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeFamilies #-}
import qualified Data.Text as T
import ClassyPrelude
import Data.Functor.Foldable
@rewinfrey
rewinfrey / errors.txt
Created April 26, 2017 22:41
tree-sitter-python parse errors for tensorflow
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/binary_ops_test.py (ERROR [44, 38] - [44, 44])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/clustering_test.py (ERROR [46, 42] - [46, 48])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/conv2d_test.py (ERROR [63, 54] - [63, 55])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/conv3d_test.py (ERROR [63, 26] - [63, 27])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/dynamic_stitch_test.py (ERROR [49, 49] - [49, 50])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/function_test.py (ERROR [53, 42] - [53, 48])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/jit_test.py (ERROR [47, 27] - [47, 66])
Error parsing /Users/rewinfrey/code/python/tensorflow/tensorflow/compiler/tests/lrn_ops_test.py (ERROR [91, 22] - [91, 29])
Error parsing /Users/rew
@rewinfrey
rewinfrey / AsyncServer.hs
Last active April 7, 2017 00:27
A pattern for asynchronous server interaction testing
withAsyncServer $ \(asyncContext, _) -> do
echoResults <- asyncContext $ \ asyncServer -> do
sendToServer "data"
asyncRecv asyncServer
echoResults `shouldBe` "data"
asyncRecv :: Async a -> IO a
asyncRecv = wait
withAsyncServer :: (((Async String -> IO String) -> IO String, Socket) -> IO c) -> IO c
@rewinfrey
rewinfrey / TypeClassConstraintAsTypeAlias.hs
Created October 14, 2016 21:40
Type Class Constraint as a Type Alias
{-# ConstraintKinds #-}
module TypeClassConstraintAsTypeAlias where
type Showable a = (Show a)
example :: Showable a => a -> a
example a = undefined
@rewinfrey
rewinfrey / request.md
Last active August 4, 2016 19:28
Japanese Ryokan reservation request

こんにちは!

アメリカ人のリックです。よろしくお願いします。

すみすみません、予約ができるかお聞きしてもいいですか?

私たちは三人です。別々に予約したいんです。迷惑をかけてすみません。

三人で:

@rewinfrey
rewinfrey / stacks_arrays_trees.md
Created July 30, 2016 19:19
Stacks vs Arrays vs Trees

[[[ [] ], [], []], [node5, node6]]

                                       Binary Tree

                                         "root"

                                      /          \

                                    node1         node2

/ \ / \

@rewinfrey
rewinfrey / Basics.hs
Last active July 5, 2016 18:49
Haskell Derivation Basics
module Basics where
{-
1. What is Semigroup? Define the type class.
2. What is Monoid? Define the type class.
3. What is Functor? Define the type class.
4. What is Applicative? Define the type class.
@rewinfrey
rewinfrey / TilesParametricPolymorphism.hs
Created June 4, 2016 16:32
Parametric Polymorphism example over tiles
module TilesParametricPolymorphism where
class Tile a where
over :: a -> a
instance Tile (Dora Character) where
over MultiSet (Dora Character) -> undefined
instance Tile (Dora Circle) where
over MultiSet (Dora Circle) -> undefined
@rewinfrey
rewinfrey / prepend_example.rb
Created April 15, 2016 18:20
Ruby prepend simple example
module Example
def something
puts "in example"
super
end
end
class Test
prepend Example
def something
@rewinfrey
rewinfrey / powerball.rb
Created January 14, 2016 04:06
something for verifying / calculating powerball numbers
@actual_numbers = [4, 8, 19, 27, 34, 10]
def powerball_match?(numbers)
@actual_numbers.last == numbers.last
end
def white_ball_matches?(numbers, minimum_match_count)
numbers.select { |number| @actual_numbers[0..-2].include? number }.count >= minimum_match_count
end