Skip to content

Instantly share code, notes, and snippets.

View jneen's full-sized avatar

Jeanine Adkisson jneen

View GitHub Profile
#!/bin/bash
blanking() {
local mode="$1"; shift
case "$mode" in
-|stop) xset -dpms; xset s off ;;
+|start) xset +dpms; xset s on ;;
sus|suspend)
wake-loop &
ensure kill $!
open Batteries.Printf
open Batteries
type 't tokstate = Start | Tok of 't | Err of string | Eof
type 't state = {
mutable index : int ;
mutable head : 't tokstate ;
mutable behind : 't tokstate list ;
mutable ahead : 't tokstate list ;
var Dynamic = function() {
var context = {}
var defaults = {}
function bind(name, val, fn) {
try {
var save = context[name];
context[name] = val;
var out = fn();
}
@jneen
jneen / testy.sh
Last active December 16, 2015 19:22
#!/bin/bash
echo == example the first ==
f1() {
local v=1
echo f1: $v
f2
}
(defn frybo [fname]
(def raf (java.io.RandomAccessFile. fname "r"))
(def out-chan (chan 10))
(go-loop [] (>!! out-chan (.readByte raf)))
out-chan)
@jneen
jneen / order.md
Created June 16, 2015 03:40
Tulip evaluation order (DRAFT)

In tulip, a function call is expressed as a sequence of expressions, with parentheses appearing freely:

f arg1 (arg2) (g arg3)

If a function receives fewer arguments than its arity, the result is a curried function expecting the remaining arguments. If it receives more, it consumes its arity and calls the return value with the rest. The order of evaluation for a function call is:

  • The function expression is evaluated
  • Each argument is evaluated
#!/usr/bin/env ruby
require 'gtk3'
fname = ARGV[0]
def window(&b)
w = Gtk::Window.new
proc { w.instance_eval(&b) }
end
@jneen
jneen / cases.rb
Last active August 29, 2015 14:10
module Kernel
def cases(o, cases={})
o = [o] unless o.is_a? Array
raise "invalid" unless o[0].is_a? Keyword
selection = cases[o[0]] || cases[:else] || raise("non-exhaustive cases!")
selection.call(*cases[1..-1])
end
end
class Variant
class Caser
attr_reader :value
def initialize(variant)
@variant = variant
@invoked = false
end
def try_case(tag, &b)
if @variant.tag == tag
(defmacro defvariant
[name [[tag & variant-binders] & other-binders] body]
`(defmethod ~name ~tag [[_# ~@variant-binders]
~@other-binders]
~body)
[name [tag & binders] body]
`(defmethod ~name ~tag [[_# ~@binders]] ~body))
; CompilerException java.lang.RuntimeException: Unable to resolve symbol: & in this context, compiling:(/tmp/form-init8620656005427572977.clj:1:1)