Skip to content

Instantly share code, notes, and snippets.

View claj's full-sized avatar

Linus Ericsson claj

  • Sweden
  • 15:46 (UTC +02:00)
View GitHub Profile
@claj
claj / datomic_util.cljc
Created September 3, 2024 08:34 — forked from tomconnors/datomic_util.cljc
kc datomic util
(ns kc.datomic
"Datomic utility functions
Usage Notes:
Some functions in this namespace take sequences of facts and return them modified in some way. Some up-front modifications are useful for those functions, like replacing all map-form facts with vector-form facts. In order to avoid doing these modifications repeatedly to same the same set of facts (which would be harmless but wasteful), two versions of these functions exist: a \"safe\" version that does those up-front modifications, and an \"unsafe\" version that expects those modifications to already have been performed. The unsafe versions are named like the safe ones, but with a single quote appended.
TODO:
- consider implementing all fns that branch based on operation as multimethods
These fns mostly support :db/add, :db/retract :db.fn/retractEntity, :db.fn/cas,
@claj
claj / redacted-log.log
Created April 15, 2020 12:35
crashing datomic ddb-local
This file has been truncated, but you can view the full file.
2020-04-06 18:51:31.333 DEBUG default com.amazonaws.AmazonWebServiceClient - Internal logging succesfully configured to commons logger: true
2020-04-06 18:51:31.432 DEBUG default c.a.internal.config.InternalConfig - Configuration override awssdk_config_override.json not found.
2020-04-06 18:51:31.570 DEBUG default com.amazonaws.metrics.AwsSdkMetrics - Admin mbean registered under com.amazonaws.management:type=AwsSdkMetrics
2020-04-06 18:51:31.621 INFO default datomic.slf4j.bridge - SLF4J Bridge installed
@claj
claj / kombucha.md
Created May 2, 2017 18:45
Kombucharecept.md

Kombucha

Ingredienser

  • 3 l vatten
  • 5 tsk grönt, rött eller svart te (viktigt att det inte har smaksättning)
  • 2 dl rårörsocker
  • Bär eller fruktpuré (helst syrligt, typ hallon)
  • 2 st smala glasbehållare, 1,5-2,0 l (tips är 3-litersburkar från Cordon Bleu)
  • Bomullstyg (t.ex. gammalt lakan)
@claj
claj / db-fn-tx-error-reproduce.clj
Last active March 3, 2017 13:29
datomic db/fn transactional behaviour (datomic 0.9.554)
;; transact a db-fn using io.pedestal.log, but forget to add require!
user> (d/transact conn [{:db/id (d/tempid :db.part/user)
:db/ident :some-dbfn
:db/fn (d/function
'{:lang "clojure"
:params [db params]
:code (io.pedestal.log/error :some-dbfn "hello")})}])
#<promise$settable_future$reify__3565@738ad462:
{:db-before datomic.db.Db@e6de0f53,
:db-after datomic.db.Db@87233408,
(ns example.service-test
"Assuming we have a example.service returning a component system (with using... etc)
starts this, stops it etc."
(:require
[clojure.test :refer :all]
[example.service :refer :all]
[com.stuartsierra.component :as component]) )
(defn first-free-port
"Returns first free ephemeral port
{:db/id #db/id [db.part/user 100001]
:question "what is your favourite animal?"
:question-type :single-option ;; could actually can be deduced from the fact below
:single-options ;; components or something.
[{:answer "cat"
:db/id #db/id [db.part/user 100002]}
{:answer "dog"
:db/id #db/id [db.part/user 100003]}
{:answer "rhino"
:db/id #db/id [db.part/user 100004]}]}
@claj
claj / core.clj
Last active March 17, 2016 10:38
state in go-loop
(ns world.core
(:require [clojure.core.async :refer [go chan >! <! <!! put! timeout close!]]))
(defn apply-to-fsm
[[state _] event]
(case [state event]
[:init :create] [:running [:allocate :run]]
[:running :stop] [:stopped [:stop]]
[:running :start] [:running []]
(ns path-with-enlive-example
(:require [net.cgrand.xml :as xml]
[clojure.zip :as z]))
;; This is meant to be answer to the question
;; "Enlive as a hammer" posted in the enlive mailing list:
;; https://groups.google.com/forum/#!topic/enlive-clj/Da0l_Vpu05U
;; div
;; | :content
@claj
claj / cas_enum_error.clj
Created June 1, 2015 15:09
CAS/enum error in Datomic 0.9.5173
(ns traktor.error
(:require [datomic.api :as d :refer [db q]]))
(d/create-database "datomic:mem://casenum")
(def conn (d/connect "datomic:mem://casenum"))
;; simple schema
@(d/transact conn [{:db/id #db/id [:db.part/db]
@claj
claj / init.el
Created May 25, 2015 11:26
emacs clojure toolbox setup
;; put this in ~/.emacs.d/init.el :
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)
(package-initialize)