Skip to content

Instantly share code, notes, and snippets.

@vaughnd
vaughnd / gist:3705861
Created September 12, 2012 10:40
Datomic user -> group memberships with extra data using many-to-many
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://user-groups3")
(d/create-database uri)
(def conn (d/connect uri))
(d/transact
conn
[{:db.install/_attribute :db.part/db
:db/id #db/id[:db.part/db]
:db/ident :user/name
<html>
<head>
</head>
<body>
</body>
</html>
(ns user
(:require [clojure.java.io :as io]
[datomic.api :as d]))
(defn order-schema []
(read-string (slurp (io/resource "schema.edn"))))
(defn start-datomic! [uri schema]
(d/create-database uri)
(let [conn (d/connect uri)]
(defn words-proc [words button interval interval-control scrub]
(go (loop [idx 0]
(show-word! words idx)
(let [[v c] (alts! [button interval scrub])
(condp = c
button (do (>! interval-control v)
(recur idx))
interval (recur (inc idx))
scrub (do (>! interval-control :stop)
(recur v)))))))
@danielsz
danielsz / pushState.cljs
Last active July 15, 2016 15:13
PushState (via Html5History from google closure) with secretary, a client-side routing library for clojurescript. Allows to map absolute urls with routes without the hash-bang hackery.
(def history (Html5History.))
(.setUseFragment history false)
(.setPathPrefix history "")
(.setEnabled history true)
(let [navigation (listen history EventType/NAVIGATE)]
(go
(while true
(let [token (.-token (<! navigation))]
(secretary/dispatch! token)))))
@stuarthalloway
stuarthalloway / schema_history.clj
Last active March 31, 2017 21:40
Complete schema history of a live Datomic database
;; Complete schema history for a live Datomic database.
(require
'[clojure.pprint :as pp]
'[clojure.set :as set]
'[datomic.api :as d])
;; fill this in with your own database connection
(def uri "datomic:dev://localhost:4334/my-db")
(def conn (d/connect uri))
(def db (d/db conn))
@stuarthalloway
stuarthalloway / gist:2158138
Created March 22, 2012 12:54
Many to Many Datomic example
;; Datomic example code
;; make in memory database
(use '[datomic.api :only (q db) :as d])
(def uri "datomic:mem://matches")
(d/create-database uri)
(def conn (d/connect uri))
;; add the match attribute
(d/transact
(ns blog.errors.core
(:require-macros
[cljs.core.async.macros :refer [go]]
[blog.utils.macros :refer [<?]])
(:require
[cljs.core.async :refer [>! <! chan close!]]))
;; convert Node.js async function into a something
;; that returns a value or error on a channel
(defn run-task [f & args]
@stuartsierra
stuartsierra / errors.clj
Created April 20, 2012 14:27
Example error messages from common mistakes with Datomic
;; Some example error messages resulting from common mistakes
;; using Datomic 0.8.4138
(ns errors
(:use [datomic.api :as d :only (db q)]))
(def uri "datomic:mem://database")
(d/create-database uri)
@PixnBits
PixnBits / md5.js
Last active May 27, 2022 07:51 — forked from jhoff/md5.js
invalid reference fix
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function (global) {
var md5cycle = function (x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];