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
@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)
module Json.Decode.Generic where
import Json.Decode as Decode exposing (Decoder, (:=))
import Array exposing (Array)
import Dict exposing (Dict)
type JsonValue = JsonNull
| JsonBool Bool
| JsonString String
| JsonFloat Float
(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.
#! /usr/local/bin/lumo
(ns app.core
"This application watches the a directory <DIR> for screen shots
and applies an OCR to them (`tesseract`). The resulting text file is
saved to a directory called '<DIR>/OCR Screen Shots`.")
(def fs
(js/require "fs"))
@noprompt
noprompt / permutations.clj
Created September 21, 2017 17:19
Permutations in Clojure (based on Heap's algorithm)
(defn swap
"Swap the elements at positions `i` and `j` in `v`."
{:private true}
[v i j]
(-> v
(assoc i (get v j))
(assoc j (get v i))))
;; SEE: https://en.wikipedia.org/wiki/Heap%27s_algorithm
(defn permutations [coll]
def with_repl_friendly_inspect(&block)
x = block.call
case x
# We don't want to and sometimes can't override the #inspect method
# of these classes of values.
when Array,
Class,
FalseClass,
Hash,
(ns conform-case
(:require [clojure.spec :as spec]))
(defn build-clause-form
{:private true}
[expression-form clause else-form]
(let [[spec binding-form & body] clause]
`(let [conform-value# (spec/conform ~spec ~expression-form)]
(if (= conform-value# ::spec/invalid)
@noprompt
noprompt / intero-scratch.el
Last active May 1, 2017 21:11
Intero scratch buffer which provides minimal facilities for sending code to the Intero REPL.
(defun intero-scratch-send-paragraph ()
(interactive)
(let* ((source-code-start (save-excursion
(backward-paragraph)
(point)))
(source-code-end (save-excursion
(forward-paragraph)
(point)))