Small dev utility for copying REPL output to the clipboard.
Via deps.edn
, typically in an alias:
{:deps
;; Synchronous Clojure trained us to use Exceptions, while asynchronous JavaScript has trained us to use Promises. | |
;; In contexts where we work asynchronously in Clojure (in particular ClojureScript), it can be difficult to see a definite way of managing failure. Here are some proposals. | |
;; OPTION 1: adapting exception handling to core.async CSPs | |
;; As proposed by David Nolen, with some macro sugar we use Exceptions in go blocks with core async in the same way we would do with synchronous code. | |
(require '[clojure.core.async :as a :refer [go]]) | |
;; defining some helper macros | |
(defn throw-err "Throw if is error, will be different in ClojureScript" |
(require '[clojure.core.async :as a]) | |
(defn- seq-of-chan "Creates a lazy seq from a core.async channel." [c] | |
(lazy-seq | |
(let [fst (a/<!! c)] | |
(if (nil? fst) nil (cons fst (seq-of-chan c)) )))) | |
(defn map-pipeline-async "Map for asynchronous functions, backed by clojure.core.async/pipeline-async . | |
From an asynchronous function af, and a seq coll, creates a lazy seq that is the result of applying the asynchronous function af to each element of coll. |
(ns utils.keywordize-at-keys | |
(:require [clojure.walk :as walk])) | |
(defn- coerced-to-keyword | |
[k] | |
(when (string? k) | |
(keyword k))) | |
(defn keywordize-at-keys |
;; # EMULATING DATOMIC EXCISION VIA MANUAL DATA MIGRATION | |
;; ************************************* | |
;; ## Introduction | |
;; ************************************* | |
;; This Gist demonstrates a generic way to migrate an entire Datomic database | |
;; from an existing 'Origin Connection' to a clean 'Destination Connection', | |
;; while getting rid of some undesirable data and otherwise preserving history. |
import java.io.File | |
import java.util.* | |
import java.util.concurrent.atomic.AtomicInteger | |
data class Coordinate(val x: Int, val y: Int) | |
data class Point(val label: Int, val coordinate: Coordinate) | |
data class area(val associatedToPoint: Point, val size: Int = 0) | |
var seqId = AtomicInteger(1) |
(ns bs.utils.mock-connection | |
"Utilities for using Datomic" | |
(:require [datomic.api :as d]) | |
(:use clojure.repl clojure.pprint) | |
(:import (java.util.concurrent BlockingQueue LinkedBlockingDeque) | |
(datomic Connection))) | |
(defrecord MockConnection | |
[dbAtom, ^BlockingQueue txQueue] |
log4j.rootLogger=INFO, syslog | |
log4j.appender.syslog=org.apache.log4j.net.SyslogAppender | |
log4j.appender.syslog.Facility=LOCAL7 | |
log4j.appender.syslog.FacilityPrinting=false | |
log4j.appender.syslog.Header=true | |
log4j.appender.syslog.SyslogHost=<PAPERTRAIL_HOST>.papertrailapp.com:<PAPERTRAIL_PORT> | |
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout | |
log4j.appender.syslog.layout.ConversionPattern==%p: (%F:%L) %x %m %n |
(defn pprint-to-clipboard | |
"Copies a pretty-printed representation of value `v` to the clipboard. | |
When `v` is not supplied, copies the last REPL output (*1). | |
Useful for copying and pasting REPL output to an editor buffer." | |
([] | |
(pprint-to-clipboard *1)) | |
([v] | |
(-> (java.awt.Toolkit/getDefaultToolkit) | |
.getSystemClipboard | |
(.setContents |