Skip to content

Instantly share code, notes, and snippets.

View olivergeorge's full-sized avatar

Oliver George olivergeorge

  • Tasmania, Australia
View GitHub Profile
(rf/reg-fx ::navigate (fn [a] (navigation/dispatch (navigation/navigate-action a))))
(rf/reg-fx ::navigate2 (fn [[a b]] (navigation/navigate a b)))
(rf/reg-fx ::back (fn [] (navigation/dispatch (navigation/go-back-action))))
(rf/reg-fx ::reset-stack-by-key (fn [m] (navigation/dispatch (navigation/reset-action m))))
(rf/reg-fx ::pop (fn [n] (navigation/dispatch (navigation/pop-action n))))
(rf/reg-fx ::pop-to-top #(navigation/dispatch (navigation/pop-to-top-action)))
(ns canidatalogtocte
(:require [clojure.java.jdbc :as jdbc]
[clojure.string :as str]
[clojure.spec.alpha :as s]
[datascript.core :as d]
[clojure.test :refer [is]]))
(s/check-asserts true)
(def sqlite-db
@olivergeorge
olivergeorge / debug_settings.py
Created June 10, 2020 06:29
Log Django Queries
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s '
'%(process)d %(thread)d %(message)s'
},
},
@olivergeorge
olivergeorge / repro.md
Last active May 15, 2020 00:05
REPL not considering namespace aliases if pre-compiled

Setup is based on clojurescript getting started guide. I've added a require statement to the core ns and using the latest master sha

deps.edn

{:deps {org.clojure/clojurescript {:git/url "https://github.com/clojure/clojurescript.git"
                                   :sha "ec0fc33030ae1858a29c52f38e81fba4180d492b"}}}

src/hello_world/core.cljs

@olivergeorge
olivergeorge / krell-vs-error-boundaries.md
Last active May 10, 2020 20:40
Some notes on React error boundaries

Based on: https://reactjs.org/docs/error-boundaries.html

Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed.

As of React 16, errors that were not caught by any error boundary will result in unmounting of the whole React component tree.

Reagent gives us access to the error boundary features

  • Returning true from :component-did-catch stops the unmounting behaviour

This was close to useful but the SQL generated has problems with ORDER BY clauses.

The subquery was necessary to avoid GROUP BY problems.

class AG_DATES_OVERLAP(Func):
    function = 'dbo.AG_DATES_OVERLAP'
    template = "%(function)s(%(expressions)s)"
(ns app.test-runner
(:require [clojure.test :refer [deftest is run-tests]]))
(deftest is-this-working?
(is (= 1 2)))
(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
(when-not (cljs.test/successful? m)
(throw "Test failed")))
@olivergeorge
olivergeorge / v1.clj
Created January 3, 2020 05:45
WIP generating relational db content using clojure.test.check
(ns v1
(:require [clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.spec.alpha :as s]))
(defn gen-char [n]
(gen/fmap #(apply str %) (gen/vector gen/char-alphanumeric n)))
(defn gen-varchar [n]
function XG(n, l, t) {
return Qa(fu([Sc, t])),
KG(l) || BG(n, l, pS) ? Array.isArray(t) || Nu(t) && !Mu(t) ? Tt.h(bu(t), 2) && BG(n, qt(t), $h) ? (Qa(fu([lw, "probably lookup ref", Wa.w(fu([new os(null, 5, ["vs", t, "(type vs)", Yn(t), "(count vs)", bu(t), "(first vs)", qt(t), "(is-attr? db (first vs) :db.unique/identity)", BG(n, qt(t), $h)], null)]))])),
new Ri(null, 1, 5, _i, [t], null)) : (Qa(fu([Lk])),
t) : (Qa(fu([xh, "not a collection at all, so definitely a single value", Wa.w(fu([new os(null, 6, ["vs", t, "(type vs)", Yn(t), "(arrays/array? vs)", Array.isArray(t), "(coll? vs)", Nu(t), "(vector? vs)", Hu(t), "(map? vs)", Mu(t)], null)]))])),
Qa(fu([Yo, "(satisfies? ICollection x)", null != t ? !!(8 & t.A || Rn === t.vg) || !t.A && Wn(ol, t) : Wn(ol, t)])),
new Ri(null, 1, 5, _i, [t], null)) : (Qa(fu([Fb, "not a multival context", new os(null, 4, ["a", l, "(type a)", Yn(l), "(reverse-ref? a)", KG(l), "(multival? db a)", BG(n, l, pS)], null)])),
(ns app.a-trackers
(:require [reagent.core :as r]))
(defonce reg-trackers (atom {}))
(defn reg-tracker
([k signal]
(reg-tracker k signal #(rf/dispatch [k %])))
([k signal effect]
(when-let [{:keys [tracker]} (get @reg-trackers k)]