Skip to content

Instantly share code, notes, and snippets.

@jsl
jsl / gist:8662748
Created January 28, 2014 05:34
Failing microKanren tests in Ruby port
justin ~/Code/ruby_ukanren $ rake
Run options: --seed 3533
# Running tests:
F...F.........................
Finished tests in 0.025549s, 1174.2143 tests/s, 1330.7762 assertions/s.
1) Failure:
@jsl
jsl / gist:8445230
Created January 15, 2014 21:39
My sublime config
{
"auto_complete_commit_on_tab": true,
"color_scheme": "Packages/Color Scheme - Default/Pastels on Dark.tmTheme",
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_size": 12.0,
"hot_exit": false,
"ignored_packages":
[
"Vintage"
@jsl
jsl / gist:8442724
Created January 15, 2014 19:27
Testing Ruby's tail-call optimization
def test_stack_size(call_count = 0)
puts "Current call count: #{call_count}"
test_stack_size(call_count + 1)
end
RubyVM::InstructionSequence.compile_option = {
:tailcall_optimization => true,
:trace_instruction => false
}
class Person
attr_reader :name
def initialize(name)
@name = name
end
def reverse_name
funreverse
end
@jsl
jsl / NewYears.elm
Last active January 1, 2016 21:18
Happy (functional) 2014!
-- Hope you have a functional 2014!
-- Author: Justin Leitgeb
-- Web: http://justinleitgeb.com
-- Twitter: @justinleitgeb
-- Consulting: http://stackbuilders.com
-- Try Elm: http://elm-lang.org
render time =
@jsl
jsl / sbcoding.md
Last active January 1, 2016 01:19
Stack Builders' commit guidelines

Moving to the internal SB wiki.

to star
repeat 5 [ fd 100 rt 144 ]
end
clearscreen
star
to square :length
repeat 4 [ fd :length rt 90 ]
end
clearscreen
@jsl
jsl / gist:7294493
Last active December 27, 2015 08:09
Deserialization breaking the way that Haskell looks up keys in Maps?
λ: import qualified Data.Map as M
λ: :t M.keys Metadata.Prelude.interfaces
M.keys Metadata.Prelude.interfaces :: [String]
λ: M.keys Metadata.Prelude.interfaces
["Automaton","Basics","Bitwise","Char","Color","Date","Dict","Either","Http","JavaScript","Json","Keyboard","List","Maybe","Mouse","Prelude","Random","Regex","Set","Signal","String","Text","Time","Touch","Transform2D","WebSocket","Window","Graphics.Collage","Graphics.Element","Graphics.Input","JavaScript.Experimental"]
λ: M.member "Graphics.Element" Metadata.Prelude.interfaces
False
λ: M.member "Graphics.Element" $ M.fromList $ M.toList Metadata.Prelude.interfaces
True
@jsl
jsl / gist:7205851
Created October 28, 2013 22:21
Output of `STRINGS(1)` on the elmi file for Pong.
Main
Main.$gameHeightgameWidth
_Tuple2
number
number
Main.$halfHeighthalfWidth
_Tuple2
number
number
Main.Ball
import Test.HUnit
import Control.Applicative
data Piece = Cross | Circle deriving (Show, Eq)
isWon :: [Maybe Piece] -> Bool
isWon [] = False
isWon (x:xs)
| x == Nothing = False
| null xs = True