Skip to content

Instantly share code, notes, and snippets.

View noprompt's full-sized avatar
💭
The choice to have discipline is a programmer's worst enemy.

Joel Holdbrooks noprompt

💭
The choice to have discipline is a programmer's worst enemy.
View GitHub Profile
(defn mix*
"Helper function for mix."
{:private true}
[colls]
(if (seq colls)
(if (seq (first colls))
(lazy-seq (cons (ffirst colls)
(mix* (conj (subvec colls 1)
(rest (first colls))))))
(recur (subvec colls 1)))
(require '[meander.epsilon :as m])
(m/rewrite (read-string (slurp "project.clj"))
(defproject _ _ . !key !value ...)
(m/cata [:DEPS_EDN (m/map-of !key !value)])
[:DEPS_EDN {:dependencies ?dependencies
:profiles ?profiles
:source-paths !paths
:resource-paths !paths}]
@noprompt
noprompt / deps.edn
Last active May 22, 2019 16:33
Implementing L-System examples from the "Algorithmic Beauty of Plants" with Meander
{:paths ["src"]
:deps {org.clojure/clojure {:mvn/version "1.10.0"}
org.clojure/clojurescript {:mvn/version "1.10.439"}
org.clojure/test.check {:mvn/version "0.10.0-alpha3"}
com.google/clojure-turtle {:mvn/version "0.3.0"}
meander/delta {:mvn/version "0.0.85"}
quil/quil {:mvn/version "3.0.0"}}
:aliases {:test {:extra-paths ["test"]
:extra-deps {org.clojure/test.check {:mvn/version "0.10.0-alpha3"}
com.cognitect/test-runner {:git/url "https://github.com/healthfinch/test-runner"
(ns meander.interpret.delta
(:require [meander.match.delta :as r.match]
[meander.syntax.delta :as r.syntax]
[meander.util.delta :as r.util]))
(defn genmut
[]
{:tag :mut
:symbol (gensym "*m__")})
(defn swap
"Swap the elements at positions `i` and `j` in `v`."
{:private true}
[v i j]
(-> v
(assoc i (nth v j))
(assoc j (nth v i))))
;; SEE: https://en.wikipedia.org/wiki/Heap%27s_algorithm
(defn permutations
(ns scratch
(:require
[clojure.data.json :as json]
[clojure.string :as string]
[meander.strategy.alpha :as r]
[meander.match.alpha :as r.match]))
(def service-2-json
(json/read-str
(slurp "https://raw.githubusercontent.com/aws/aws-sdk-java-v2/master/services/batch/src/main/resources/codegen-resources/service-2.json")))
@noprompt
noprompt / sql_auto_shout.el
Last active February 22, 2019 05:55
Automatically shout SQL keywords and builtins
(defun ~/end-of-previous-face-change (face-name)
(save-excursion
(let ((continue t)
(answer nil))
(while continue
(let ((p (or (previous-single-property-change (point) 'face)
1)))
(if (= p 1)
(progn
(setq continue nil)
(require '[spec-provider.provider :as sp])
(defn derive-specs [var & args]
(let [ns-sym (ns-name (:ns (meta var)))
ns-name (name ns-sym)
derived-specs (atom [])
fn-var-info (into [] (keep (fn [[var-sym var]]
(let [x (deref var)]
(when (fn? x)
[var var-sym x]))))
(ns if-not.bench
(:require [criterium.core]))
(defmacro if-not*
([test then] `(if ~test nil ~then))
([test then else]
`(if ~test ~else ~then)))
(criterium.core/bench (if-not false 1 2))
;; Evaluation count : 5375474880 in 60 samples of 89591248 calls.
@noprompt
noprompt / example-out.txt
Created March 14, 2018 17:50
Write all public documentation for the ns named ns-sym to *out*.
datomic.client.api
Synchronous client library for interacting with Datomic.
This namespace is a wrapper for datomic.client.api.async.
Functions in this namespace that communicate with a separate
process take an arg-map with the following optional keys:
:timeout Timeout in msec.