Skip to content

Instantly share code, notes, and snippets.

const emptyState = null;
// `var` in muKanren.
const v = c => Symbol(c);
// `var?` in muKanren.
const isVar = c => typeof c === 'symbol';
const walk = (u, s) => {
if (s === null) {
return u;
### Keybase proof
I hereby claim:
* I am justinj on github.
* I am jaffray (https://keybase.io/jaffray) on keybase.
* I have a public key ASAbW8fwxoMLnG_Izquu3xSCGLg1F2ZFfR2vI7tR1qsU_Qo
To claim this, I am signing this object:
(ns veyemel)
; ref http://www.cs.nott.ac.uk/~gmh/pearl.pdf
(defn return [v]
(fn [s]
[{:result v
:remaining s}]))
(def fail (fn [_] []))
var classifyToken = function(token) {
var kind;
if (token === "λ") { kind = LAMBDA; }
else if (token === ".") { kind = DOT; }
else if (token === "(") { kind = LPAREN; }
else if (token === ")") { kind = RPAREN; }
else { kind = IDENTIFIER; }
return {
kind: kind,
@justinj
justinj / gist:9263480
Created February 28, 2014 01:33
vim react snippets
snippet cc
React.createClass({
${0}
});
snippet cdm
componentDidMount: function(${1:rootNode}) {
${0}
},
snippet cdu
componentDidUpdate: function(${1:prevProps}, ${2:prevState}, ${3:rootNode}) {
@justinj
justinj / gist:9102674
Last active August 29, 2015 13:56
Vim React Prop Text Object
" React Prop Text Object
" Requires https://github.com/kana/vim-textobj-user
" Given foo={bar}
" ar => |foo={bar}|
" ir => foo=|{bar}|
call textobj#user#plugin('reactprop', {
\ '-': {
\ 'select-a-function': 'ReactPropA',
require "sinatra"
enable :inline_templates
def get_algs(input)
input
.lines
.map(&:chomp)
.reject(&:empty?)
.each_slice(2)
FFFFF..FF.FF
Failures:
1) Indenting single body functions inside do block is declared with fn syntax
Failure/Error: assert_correct_indenting <<-EOF
expected: "def do\n some_func = fn x -> x end\nend"
got: "def do\nsome_func = fn x -> x end\nend"
def valid_move_1?(scramble, move)
if scramble.empty?
true
elsif same_face?(scramble[-1], move)
false
elsif scramble.count == 1
true
elsif same_axis?(scramble[-1], scramble[-2], move)
false
else
def get_scramble
["R","U"].cycle.take(25).map { |m| m + ["","'","2"].sample }.join(" ")
end