Skip to content

Instantly share code, notes, and snippets.

View sparkofreason's full-sized avatar

Dave Dixon sparkofreason

View GitHub Profile
@sparkofreason
sparkofreason / util.cljx
Last active January 20, 2016 17:44
Utility functions for bridging Datomic/Datascript
(ns allgress.datascript.util
(:require [clojure.walk :refer [postwalk]]))
;;; Datomic pull API will return :db/idents as references, like {:my-enum-att {:db/ident :enum-value}}.
;;; This function replaces with the Datascript equivalent {:my-enum-att :enum-value}. Only works
;;; for true "enums", whose only attribute in the entity map is :db/ident.
defn replace-enum-refs [entity-map]
(postwalk
(fn [arg]
(if (and (coll? arg) (map? (second arg)) (= 1 (count (second arg))) (contains? (second arg) :db/ident))
@sparkofreason
sparkofreason / freactive-sandbox.cljs
Created April 21, 2015 14:16
add-watch on freactive rx expression not working?
(ns freactive-sandbox.core-test
(:require-macros [freactive.macros :refer [rx]])
(:require [freactive.core :refer [atom cursor]]))
(enable-console-print!)
(def x (atom {:a 1 :b {:c 2 :d 3}}))
(def b (cursor x
(fn [x] (:b x))
@sparkofreason
sparkofreason / rx-test.cljs
Last active August 29, 2015 14:19
rx-expression with child cursor does not update correctly
(ns freactive-sandbox.rx-test
(:require-macros [freactive.macros :refer [rx debug-rx]])
(:require [freactive.core :refer [atom cursor]]
[freactive.dom :as dom]))
#_(enable-console-print!)
(def state (atom {:a 1 :b {:c 2 :d 3}}))
(def b (cursor state :b))
(def d (cursor state [:b :d]))
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<script src="/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="/paper-button/paper-button.html">
</head>
<body>
<div>
@sparkofreason
sparkofreason / gss-polymer.html
Created June 9, 2015 00:24
Exception when using GSS with Polymer elements
<!DOCTYPE html>
<html>
<head>
<link rel="import" href="/paper-slider/paper-slider.html">
</head>
<body>
<div>
<style type="text/gss">
#d1 {
@sparkofreason
sparkofreason / lens-cursor-inconsistency
Last active August 29, 2015 14:23
Inconsistencies in freactive lens-cursor and cursor behavior
(ns freactive-sandbox.rx-test
(:require-macros [freactive.macros :refer [rx debug-rx]])
(:require [freactive.core :refer [atom cursor lens-cursor]]
[freactive.dom :as dom]))
(enable-console-print!)
(def state (atom {:a 1 :b {:c 2 :d 3}}))
(def lc
(lens-cursor state :b))
(ns provisdom.examples.truth-maintenance
(:require [clojure.spec.alpha :as s]
[provisdom.maali.rules :refer [defrules defqueries defsession def-derive] :as rules]
[clara.rules.accumulators :as acc]
[clojure.pprint :refer [pprint]]))
;;; Attribute specs
(s/def ::location string?)
(s/def ::temperature number?)
(s/def ::high ::temperature)
{
"legends": [
{
"fill": "color",
"type": "gradient"
}
],
"config": {
"range": {
"heatmap": {
@sparkofreason
sparkofreason / gist:efaf545b1a697af9a5c2cf3dee12680c
Created September 10, 2018 17:19
Exception thrown importing Clojure gen-class impl of Kafka SourceConnector
#error{:cause "Implementing class",
:via [{:type clojure.lang.Compiler$CompilerException,
:message "java.lang.IncompatibleClassChangeError: Implementing class, compiling:(C:/Users/dave/Projects/Compute/metrics-kafka-connector/test/compute/metrics_kafka_connector_test.clj:1:1)",
:at [clojure.lang.Compiler load "Compiler.java" 7526]}
{:type java.lang.IncompatibleClassChangeError,
:message "Implementing class",
:at [java.lang.ClassLoader defineClass1 "ClassLoader.java" -2]}],
:trace [[java.lang.ClassLoader defineClass1 "ClassLoader.java" -2]
[java.lang.ClassLoader defineClass "ClassLoader.java" 763]
[java.security.SecureClassLoader defineClass "SecureClassLoader.java" 142]