Skip to content

Instantly share code, notes, and snippets.

View swannodette's full-sized avatar

David Nolen swannodette

View GitHub Profile
@hiredman
hiredman / bench.clj
Created June 2, 2014 18:07
core.logic for joinery
#!/usr/bin/java -jar clojure-1.7.0-master-SNAPSHOT.jar
(let [pom-uber-jar
(str "http://thelibraryofcongress.s3.amazonaws.com/"
"pomegranate-0.0.13-SNAPSHOT-jar-with-dependencies.jar")
cl (java.net.URLClassLoader. (into-array [(java.net.URL. pom-uber-jar)]))
cx (.getContextClassLoader (Thread/currentThread))]
(push-thread-bindings {clojure.lang.Compiler/LOADER cl})
@asolove
asolove / cursor.cljs
Created January 6, 2014 21:43
Om polymorphic cursor
(def map-state { :layers [{:selected true :title "Layer One"}, {:selected false :title "Layer Two" }]})
; I want a way to write reusable components that take and update data from a cursor,
; where the parent decides how the data is calculated and updated.
(defn checkbox [checked]
(om/component
(dom/input {:type "checkbox" :checked checked
:onClick #(om/update! checked (not checked)})))
(defn f []
(-> #{}
(transient)
(conj! -24)
(persistent!)
(conj 0)
(conj 0)
(conj 0)
(conj 0)
(conj 0)
@halgari
halgari / gist:7028120
Last active January 31, 2018 12:32
Async Agents via core.async
(use 'clojure.core.async)
(defprotocol ISendable
(channel [this]))
(defn async-agent [state]
(let [c (chan Long/MAX_VALUE) ;; <<-- unbounded buffers are bad, but this matches agents
a (atom state)]
(go-loop []
(when-let [[f args] (<! c)]
(load "mk.scm")
(define membero
(lambda (elt ls)
(fresh (d a)
(conde
((== `(,elt . ,d) ls))
((== `(,a ., d) ls) (membero elt d))))))
(define on-righto
@kohyama
kohyama / README.md
Last active February 6, 2021 12:41
A minimum setting to use browser REPL of ClojureScript

A minimum setting to use browser REPL of ClojureScript

Assumed that you have set leiningen up and can use it.

1. Prepare files

Copy project.clj, repl-test.cljs and brepl-test.html from this gist or git clone this gist and move or copy repl-test.cljs under src directory.

$ git clone https://gist.github.com/6183122.git
$ cd 6183122/
(ns logic.nono
(:refer-clojure :exclude [==])
(:use [clojure.core.logic])
(:require [clojure.core.logic.fd :as fd]))
(def max-size 25)
(defn count-ones [marks howmany post-marks]
(conde
[(emptyo marks)
@zachallaun
zachallaun / protocols.js
Last active December 19, 2015 02:19
Kinda Clojure-like protocols
// Possibly wacky and useless protocol experiment
var mapObj = function(obj, fn) {
var ret = {}
for (var k in obj) {
var temp = fn(k, obj[k])
ret[temp[0]] = temp[1]
}
return ret
}
@lynaghk
lynaghk / gist:5694320
Created June 2, 2013 18:06
Puzzle agent + core.logic.
(defn sublisto
"The sequence x appears in y."
[x y]
(fresh [a b c]
(appendo a x b)
(appendo b c y)))
(->> (run* [q]
(sublisto [:b :r :r :c] q)
(sublisto [:r :c :c :b] q)
anonymous
anonymous / gist:5600633
Created May 17, 2013 17:33
  • remove -snapshot from version number in both package.json and project.clj
  • probably run the tests one more time to make sure all is well
  • add and commit changes with git
  • create a git tag for to-be-released version
  • push the commits and tag out to github
  • run npm publish . (may need to re/register with npmjs.org)
  • deploy to clojars (maybe?)
  • assuming all goes well, bump the version number and append -snapshot in both package.json and project.clj