This Gist shows how you may want to implement a forkable Ring Session Store for development and testing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(set! *warn-on-reflection* true) | |
;; 3 competing implementations which test if a string is uppercase (note that the StringUtils one has some caveats regarding its semantics) | |
(defn p1 [^String s] | |
(= s (str/upper-case s))) | |
(defn p2 [^String s] | |
(every? (fn [^Character c] (Character/isUpperCase c)) s)) | |
(import org.apache.commons.lang3.StringUtils) | |
(defn p3 [^String s] | |
(StringUtils/isAllUpperCase s)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var br1 = process.argv[2]; | |
var br2 = process.argv[3]; | |
var exec = require('child_process').exec; | |
function setDiff(s1, s2){ | |
return s1.filter(function(e){ | |
return s2.indexOf(e) < 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns utils.supdate | |
"A macro for transforming maps (and other data structures) using a spec reflecting the | |
schema of the value to transform.") | |
;; ------------------------------------------------------------------------------ | |
;; Example Usage | |
(comment | |
;;;; nominal cases | |
(supdate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{:db/ident :bsu.fns/reset-to-many-by, | |
:db/doc "Resets the set of entities which are related to `eid` via `ref-attr` to the set given by `val-maps`. | |
Assumptions: | |
* `ref-attr` is a cardinality-many, ref attribute. | |
* `e` is an entity identifier for an _existing_ entity | |
(you have to know whether an entity exists before using this function, | |
and it's pointless to use it on a non-existing entity as opposed to just asserting all the new values.) | |
* `val-maps` is a seq of transaction maps, all of which have the `v-id-attr` key provided. | |
* `retract-target-entity?`: whether to call :db.fn/retractEntity on the old entities which get removed from the relationship. | |
* the old values of the relationship all have the `id-attr` attribute." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn exponential-backoff | |
"Implements exponential backoff. | |
* af is a function which accepts 3 channels (af =success= =error= =retry=), and should do exactly one of the following operations without blocking: | |
- put a successful value in =success= | |
- put an error in =error= (will break the loop) | |
- put an error which causes a retry in =retry=. | |
* the exponential backoff loop can be configured with :get-delay-ms, a function which returns a (potentially infinite) seq of backoff intervals, | |
and :imprecision-ms, a maximim number of milliseconds with which to randomly blurr the backoff intervals. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; # 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. |