Skip to content

Instantly share code, notes, and snippets.

View whacked's full-sized avatar

whacked

  • let's do something cool together.
  • sillycon belly
View GitHub Profile
@whacked
whacked / adaptive.sib
Created August 28, 2016 19:13
[dump] adaptive ui buttons test using Immutable / Mithril / sibilant
(scoped
;; adaptive button panel test
(def gen-panel (label action)
{ label: label
xlen: 1
ylen: 1
action: action })
(def calculate-strength (item-key world)
;; naive calculator, take previous usage time;
@whacked
whacked / browser.js
Created August 18, 2016 19:53
Sibilant code preprocessor for in-browser sibilant code in <script>
//# sourceMappingURL=../maps/browser.map
;
this.sibilant = (function() {
/* src/browser.sibilant:4:5 */
var sibilant = { },
exports = sibilant;
var error = (function error$(str) {
/* error src/browser.sibilant:6:6 */
@whacked
whacked / browser.js
Created August 18, 2016 19:53
Sibilant code preprocessor for in-browser sibilant code in <script>
//# sourceMappingURL=../maps/browser.map
;
this.sibilant = (function() {
/* src/browser.sibilant:4:5 */
var sibilant = { },
exports = sibilant;
var error = (function error$(str) {
/* error src/browser.sibilant:6:6 */
@whacked
whacked / example.sib
Last active July 24, 2016 23:58
d3 v4 scatter plot with mithril.js (sibilant js)
;; based on http://jsfiddle.net/ramnathv/kmkL2gvr/6/
;; assumes d3.js, d3-scale.js, d3-selection-multi.js included in html with <div id="container"></div>
(scoped
(var
data [ {x: 0.1 y: 0.1}
{x: 0.2 y: 0.2}
{x: 0.4 y: 0.3}
{x: 0.6 y: 0.4} ]
Chart { controller: (#(args)
{ draw: (#(el isinit context)
@whacked
whacked / reload-css.sibilant
Last active April 29, 2016 23:27
dynamic css reloader in sibilant
;; reload css
(scoped
(var all-link (document.getElementsByTagName "link")
i 0)
(while (< i all-link.length)
(var link (get all-link i))
(when (< -1 (|> (link.getAttribute "type")
(.indexOf "css")))
(console.log "reload " link)
(assign link.href (+ link.href "?t=" (|> (new Date)
@whacked
whacked / console.log.sibilant
Created April 29, 2016 15:02
example sibilant macro to turn console.log calls into comments at compile time
(var DEBUG-LEVEL 10
console-log-orig console.log)
(assign console.log
(#(...argv)
(when (< 0 DEBUG-LEVEL)
(console-log-orig.apply console argv))))
;; comment this out to preserve console.log in js output
(macro console.log (...body) `(comment ...@body))
@whacked
whacked / metronome.cljs
Last active February 21, 2016 04:12
ClojureScript port of @cwilso's JavaScript metronome with inline Worker
(ns cwilso.metronome)
;; ref https://github.com/cwilso/metronome/blob/master/js/metronome.js
;; with the metronomeworker.js inlined directly.
;; it is not a completely swappable port.
;; in particular, it assumes WebAudio compliance (thus does not assume cwilso's monkey patch is applied)
;; also, init() expects an existing AudioContext which is initialized elsewhere; the assumed use-case is
;; to use the scheduling technique as a part of a larger setup, where the context is managed separately.
@whacked
whacked / index2.esl
Created September 27, 2015 16:54
reader fails on `(return null)`
(var myState (object inArray false))
(var myStack (array))
(var rxOpenBracket (regex ^\\[))
(var rxCloseBracket (regex \\]$))
(var strTail
(function (s)
(return ((. s substring) 1))))

setup

vagrant box add ubuntu/trusty64
@whacked
whacked / wftest.py
Last active August 29, 2015 14:19
nipype JoinNode test
import nipype.pipeline.engine as pe
from nipype.interfaces.utility import Function
def func_A(subject):
return '%s --> [A]'%subject
def func_B(subject, in_file):
return '%s --> B[%s]'%(subject,in_file)
def func_C(in_file):
return '%s --> [C]'%in_file
def func_D(in_files):