Skip to content

Instantly share code, notes, and snippets.

Jon Distad jondistad

Block or report user

Report or block jondistad

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View package.json
{
"name": "streamy",
"version": "0.0.1",
"dependencies": {
"most": "1.5.0"
},
"devDependencies": {
"@types/node": "^8.0.18"
}
}
@jondistad
jondistad / rlock.go
Last active May 26, 2017
A re-entrant lock with sync wrapper
View rlock.go
package main
import (
"fmt"
"sync"
"sync/atomic"
"unsafe"
)
type Owner unsafe.Pointer
@jondistad
jondistad / evenodd.scala
Created Sep 22, 2016
Even/odd addition proof in scala
View evenodd.scala
// See https://brianmckenna.org/blog/evenodd_agda_idris_haskell_scala
sealed trait Nat
trait Z extends Nat
case object Z extends Z
case class S[N <: Nat](n: N) extends Nat
sealed trait Even[N <: Nat]
trait EvenZ extends Even[Z]
case object EvenZ extends EvenZ
@jondistad
jondistad / squashtrouble.sh
Last active Apr 4, 2016
Trouble with squash merges
View squashtrouble.sh
# Create a fresh repo
$ git init testsquash
Initialized empty Git repository in /Users/jon/Code/Sterf/testsquash/.git/
$ cd testsquash
# Commit a file to master
$ echo foo >> file
$ git add .
View Interpreter.idr
module Interpreter
import Data.Fin
import Data.Vect
data Ty = TyInt
| TyBool
| TyStr
| TyFun Ty Ty
@jondistad
jondistad / Concat.java
Created Aug 15, 2015
Clojure lazy concat without stack overflow
View Concat.java
/**
* Copyright (c) Rich Hickey. All rights reserved.
* The use and distribution terms for this software are covered by the
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
* which can be found in the file epl-v10.html at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
View clojure-setup.md

Getting Clojure set up

Leiningen

Leiningen is the de facto clojure project and package manager. It can be installed via homebrew on OS X

brew install leiningen

or just download the shell script and put it on your path. If ~/bin is on your path, then you would do:

@jondistad
jondistad / coffee
Last active Aug 29, 2015
Coffeescript Nave shim
View coffee
#!/usr/bin/env zsh
set -e
function nave_version_file {
file="$(pwd)/.nave-version"
if [ -f "$file" ]; then
echo "$file"
elif `git rev-parse &>/dev/null`; then
file="$(git rev-parse --show-toplevel)/.nave-version"
View genasync.coffee
fs = require 'fs'
#request = require 'request'
#
request = ({uri}, done) ->
done null, uri
reqreq = (uris) ->
for uri in uris
yield ( (done) -> done null, uri )
@jondistad
jondistad / genseq.coffee
Last active Aug 29, 2015
genseq.coffee
View genseq.coffee
isGen = (f) ->
f? and f.constructor.name is 'GeneratorFunction'
isIter = (f) ->
f? and f.constructor.name is 'GeneratorFunctionPrototype'
class Seq
constructor: (it) ->
if isGen it
@_it = it()
You can’t perform that action at this time.