Skip to content

Instantly share code, notes, and snippets.

View manicolosi's full-sized avatar

Mark A. Nicolosi manicolosi

View GitHub Profile
@manicolosi
manicolosi / gist:6290355
Created August 21, 2013 04:35
Better Clojure code for file system watching...
(ns manico.utils.fs-watch
(:require [clojure.set :as set]
[lwjgl-spike.utils.interop :as interop])
(:import [java.nio.file Paths WatchEvent$Kind
StandardWatchEventKinds]))
(def ^:private keywords->event-kinds
{:create StandardWatchEventKinds/ENTRY_CREATE
:modify StandardWatchEventKinds/ENTRY_MODIFY
:delete StandardWatchEventKinds/ENTRY_DELETE})
@manicolosi
manicolosi / saysh
Last active August 29, 2015 14:04
Troll tool for Mark B.
# Source this thing from bash
trap 'preexec_invoke_exec' DEBUG
preexec () { :; }
preexec_invoke_exec () {
[ -n "$COMP_LINE" ] && return # do nothing if completing
[ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return # don't cause a preexec for $PROMPT_COMMAND
local this_command=`history 1 | sed -e "s/^[ ]*[0-9]*[ ]*//g"`;
preexec "$this_command"
@manicolosi
manicolosi / gist:b8aade87adc85b5f95e2
Created February 10, 2015 20:34
Broken github syntax hilighting for clojure
(defn this-is-good []
(println "GOOD"))
(def foo \")
(defn this-is-wrong []
(println foo))
(ns my.promise-ring
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require
[cljs.core.async :refer [promise-chan put! <! chan close!] :as async]))
; You Only Put Once
; YOPO
(enable-console-print!)
;; Async Lifecycle
(defn lifecycle-channel [component]
(.-lifecycleChannel component))
(defn with-lifecycle [klass]
(let [ch (async/chan)
handle (fn [event]
(fn [& args]
(async/put! ch event)
;; Produces maps from let-like bindings. And yes: we are not proud of this.
(defmacro bindmap [bindings]
`(let [~@bindings]
~(reduce
(fn [m# [binding-form# _#]]
(let [binding-symbol# (cond
(map? binding-form#)
(:as binding-form#)