Skip to content

Instantly share code, notes, and snippets.

@cigitia
cigitia / gist:feafd70768fcd551cd16
Last active August 29, 2015 14:15
DataScript 0.9.0 demonstration of possible bug in entity-ID generation when creating new component entities within transaction
(ns demo.main
(:require [datascript :as ds]))
(def schema
{:x/component {:db/valueType :db.type/ref ; Required to demonstrate bug.
:db/isComponent true ; Required to demonstrate bug.
:db/cardinality :db.cardinality/many
; Not required but demonstrates what happens to ID numbering
; after first component.
}})
@cigitia
cigitia / gist:c1f1fc48ebc041c979c5
Last active August 29, 2015 14:15
Infinite loop when using pull API on circular component reference (DataScript 0.9.0)
(ns demo.main
(:require [datascript :as ds]))
(def schema
{:x/component {:db/valueType :db.type/ref ; Required to demonstrate bug.
:db/isComponent true ; Required to demonstrate bug.
}})
(def conn
(ds/create-conn schema))
@cigitia
cigitia / gist:106e95c3824783442c5b
Created March 29, 2015 23:54
Demo of DataScript 0.10.0 circular entity-ID generation when creating new component entities within transaction
(ns demo.main
(:require [datascript :as ds]))
(def schema
{:x/component {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many
:db/isComponent true}})
(def conn
(ds/create-conn schema))
(require '[clojure.java.jdbc :as jdbc])
(def db
{:classname "org.sqlite.JDBC"
:subprotocol "sqlite"
:subname "test.db"})
(jdbc/db-do-commands db
(jdbc/create-table-ddl :people [:name "text"]))
clojure.lang.ExceptionInfo: java.lang.OutOfMemoryError: PermGen space
data: {:file
"/var/folders/rb/dht96n1j4mj5c3djm170ptpw0000gn/T/boot.user6032180797257116111.clj",
:line 17}
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
java.lang.OutOfMemoryError: PermGen space
...
clojure.core/bean core_proxy.clj: 378
boot.from.io.aviso.exception/expand-exception exception.clj: 58
boot.from.io.aviso.exception/analyze-exception exception.clj: 107
#error {
:cause "Address already in use"
:via
[{:type java.util.concurrent.ExecutionException
:message "java.net.BindException: Address already in use, compiling:(NO_SOURCE_FILE:0:0)"
:at [java.util.concurrent.FutureTask report "FutureTask.java" 122]}
{:type clojure.lang.Compiler$CompilerException
:message "java.net.BindException: Address already in use, compiling:(NO_SOURCE_FILE:0:0)"
:at [clojure.lang.Compiler$InvokeExpr eval "Compiler.java" 3628]}
{:type java.net.BindException
@cigitia
cigitia / test.cljs
Last active January 27, 2016 18:41
om.next db->tree underscore test
(deftest db->tree-underscore-test
(let [db {:x {nil {:a 2, :b 3}}
:y {:a 2, :b 3}}]
(is (= (om/db->tree '[{[:x nil] [:a :b]}] db db)
{[:x nil] {:a 2, :b 3}})
"X1")
(is (= (om/db->tree '[[:x nil]] db db)
{[:x nil] {:a 2, :b 3}})
@cigitia
cigitia / databases_using_singletons.cljs
Last active January 27, 2016 21:50
Examples of singleton idents being useful within data in the om.next default database format
(def db-1
{:ui.active-tab
[:ui.accounts-tab/by-id nil] ; May also be [:ui.post-tab/by-id :_2329cc] or [:ui.post-tab/by-id :_a73f92]
:ui.tab/order
[[:ui.post-tab/by-id :_2329cc] [:ui.accounts-tab/by-id nil] [:ui.post-tab/by-id :_a73f92]]
:ui.accounts-tab/by-id
{nil {:ui.accounts-tab/x "The accounts tab"}}
Mouse press X=14 Y=50 B=1
Mouse move X=16 Y=49 B=1
Mouse move X=37 Y=44 B=1
Mouse move X=69 Y=41 B=1
Mouse move X=86 Y=40 B=1
Mouse move X=105 Y=40 B=1
Mouse move X=125 Y=40 B=1
Mouse move X=144 Y=40 B=1
Mouse move X=164 Y=39 B=1
Mouse move X=182 Y=37 B=1
Mouse press X=65 Y=32 B=1
Mouse move X=92 Y=32 B=1
Mouse move X=130 Y=32 B=1
Mouse move X=178 Y=34 B=1
Mouse move X=202 Y=35 B=1
Mouse move X=224 Y=36 B=1
Mouse move X=230 Y=36 B=1
Mouse move X=245 Y=37 B=1
Mouse move X=262 Y=38 B=1
Mouse move X=266 Y=39 B=1