Skip to content

Instantly share code, notes, and snippets.

View nottmey's full-sized avatar

Malte Nottmeyer nottmey

View GitHub Profile
@dustingetz
dustingetz / photon todo demo .cljc
Last active August 15, 2022 21:47
Full stack, multiplayer todo list app in one file
(ns app
"Full stack, multiplayer todo list app in one file"
(:require [datascript.core :as d]
[hyperfiddle.photon :as p]
[hyperfiddle.photon-dom :as dom]
[hyperfiddle.photon-ui :as ui])
#?(:cljs (:require-macros app)))
(defonce !conn #?(:clj (d/create-conn {}) :cljs nil))
@matthewdowney
matthewdowney / sorting-transducer.clj
Created September 6, 2018 19:55
Clojure Sorting Transducer
(defn xf-sort
"A sorting transducer. Mostly a syntactic improvement to allow composition of
sorting with the standard transducers, but also provides a slight performance
increase over transducing, sorting, and then continuing to transduce."
([]
(xf-sort compare))
([cmp]
(fn [rf]
(let [temp-list (java.util.ArrayList.)]
(fn
{: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."
(defmacro datomic-fn
"Creates a datomic function given (fn [db e a ...] code...)"
[[_ args & body]]
`(d/function '{:lang "clojure"
:params ~args
:code (do ~@body)}))
(defn trinity-new
"1. If a is a ref:
Ensures that
@kachayev
kachayev / css-parser.md
Last active November 12, 2022 04:20
Parsing CSS file with monadic parser in Clojure
@john2x
john2x / 00_destructuring.md
Last active June 13, 2025 13:00
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors and Sequences

@natelandau
natelandau / .bash_profile
Last active May 12, 2025 15:55
Mac OSX Bash Profile
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@wvdlaan
wvdlaan / core.clj
Last active March 16, 2018 06:53
Datomic multiple attribute key example
(ns myupsert.core
(require [datomic.api :as d]))
(def schema
[
{:db/id #db/id [:db.part/db]
:db/ident :product/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db.install/_attribute :db.part/db}
@stuarthalloway
stuarthalloway / gist:2002582
Created March 8, 2012 18:39
Datomic extent query
;; Datomic example code
;;
;; The extent of entity ?x is all datoms that are about ?x.
;; Drop this into your rules.
;;
;; Demonstrates
;;
;; 1. recursive query (extent calls itself)
;; 2. disjunction (different extent bodies are ORed)
;; 3. component attributes (e.g. your arm is a component, your brother isn't)