Skip to content

Instantly share code, notes, and snippets.

@dazld
dazld / gist:c580943dbe638a6faa735b54edd19c29
Created January 13, 2022 09:16 — forked from daviesian/gist:4517859
Code to redirect output nrepl output to a particular client repl.
;; After connecting an nrepl client repl to an nrepl server, some
;; output will still appear on stdout from the server.
;; Try these snippets - they will both produce output on the nrepl server
;; Java libraries commonly do both these things.
(.println System/out "Hello stdout.")
(.start (Thread. #(println "Hello from a new thread.")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@dazld
dazld / datomic-reset-attributes.clj
Created May 13, 2017 08:15 — forked from favila/datomic-reset-attributes.clj
Datomic transaction functions to "reset" attributes: i.e. make them have a post-transaction value you specify without having to enumerate the retractions.
(def tx-fns
[{:db/ident :db.fn/reset-attribute-values
:db/doc "Transaction function which accepts an entity identifier, attribute identifier
and set of values and expands to any additions and retractions necessary to
make the final post-transaction value of the attribute match the provided
values. Attribute values must be scalars.
If multiple values are provided on a cardinality-one attribute you will get a
datom conflict exception at transaction time."
:db/fn (d/function
@dazld
dazld / news-votes.clj
Created March 18, 2017 10:26 — forked from stuarthalloway/Datomic News Updates
Datomic update examples against a social news database
;; Datomic example code
;; demonstrates various update scenarios, using a news database
;; that contains stories, users, and upvotes
;; grab an in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://foo")
(d/create-database uri)
(def conn (d/connect uri))
@dazld
dazld / gist:c86b2cadfeacfa4a67d2
Created November 1, 2014 19:13 — forked from anonymous/gist:10675250
processing motion blur & chromatic glitching
// by dave @ beesandbombs.tumblr.com >:)
void setup() {
setup_();
result = new int[width*height][3];
result_ = new int[width*height][3];
}
int[][] result, result_;
float time;

fireplace

  • cpr => (require ... :reload)
  • cpR => (require ... :reload-all)

Evaluation

  • :Eval (clojure code) => runs (clojure code) in repl
  • cpp => evaluate inn-most expessions under cursor
  • cp\<movement> => evaluate text described by <movement>
  • cqp => opens quasi-repl
  • cqc => quasi-repl command line window
[
{"name": "Afghanistan", "code": "AF"},
{"name": "Åland Islands", "code": "AX"},
{"name": "Albania", "code": "AL"},
{"name": "Algeria", "code": "DZ"},
{"name": "American Samoa", "code": "AS"},
{"name": "AndorrA", "code": "AD"},
{"name": "Angola", "code": "AO"},
{"name": "Anguilla", "code": "AI"},
{"name": "Antarctica", "code": "AQ"},
@dazld
dazld / index.js
Last active December 22, 2015 17:38 — forked from othiym23/index.js
'use strict';
var assert = require('assert'),
director = require('director'),
EventEmitter = require('events').EventEmitter,
ns = require('continuation-local-storage').createNamespace('testing'),
express = require('express'),
app = express();
@dazld
dazld / cls-example.js
Last active December 22, 2015 03:59 — forked from tooxie/cls-example.js
var local = require('./namespace-module');
var http = require('http');
var uuid = require('uuid').v4;
http.createServer(function(req, res) {
req._id = uuid();
local.run(function() {
local.set('id', req._id);
next(req, res);
@dazld
dazld / _about.md
Last active December 21, 2015 03:08 — forked from TimBeyer/_working-using-domains.md
Working with Domains

Working with domains

// In this example we'd like to have a factory that works per request and allows to keep track of created Models
// We create a factory per request and pass it around to the parts of the code that need access
// This can quickly lead to hard to messy code
// factory.js
//
// Basically a factory for factories
// For every request we create a new one
var Model = require('backbone').Model;