Skip to content

Instantly share code, notes, and snippets.

View mike-thompson-day8's full-sized avatar

Mike Thompson mike-thompson-day8

  • Sydney, Australia
View GitHub Profile
> This Gist is out of date. It has been superseded by
> https://gist.github.com/mike-thompson-day8/d61692451166e206a9c43771c8b389fc
;; WARNING: this code is untested. In fact not even compiled.
;; It is just meant to be indicative of how `regsub` might work/look.
(ns todomvc.subs
(:require-macros [reagent.ratom :refer [reaction]])
(:require [re-frame.core :refer [register-sub]]))
@mike-thompson-day8
mike-thompson-day8 / debug.md
Last active May 23, 2016 16:58
An alternative to the offical re-frame debug middleware
(defn debug-cljs-devtools
  "This is a drop-in alternative for the offical re-frame `debug` middleware
  It is better because: 
    - it writes data, rather than strings, to js/console. This better leverages  
      the power of cljs-devtols.
    - it exploits js/console's ability to colorize text, hopefully making the 
      output easier to grok."
  [handler]
 (fn debug-handler

de-dupe Build Status

The Problem

Persistent Data Strctures use structural sharing to create an efficient in-memory representation, but these same structures can be a problem to serialize/deserialize.

First, the shared parts are duplicated in the serialised output which can lead to a large and inefficient representation.

Second, when the process is reversed, deserialization doesn't recreate the original, shared, effcient in-memory representation because sharing information was lost in the original serialisation.

@mike-thompson-day8
mike-thompson-day8 / gist:76812d5452747bc79aac
Last active June 25, 2018 14:30
Middleware Which Acts Like A reverse reaction
(defn on-changes
"Middleware factory which acts a bit like \"reaction\" (but it flows into db , rather than out)
It observes N inputs (paths into db) and if any of them change (as a result of the
handler being run) then it runs 'f' to compute a new value, which is
then assoced into the given out=path within app-db.
Usage:
(defn my-f
[a-val b-val]
<html lang="en">
<head>
<title>Unit Tests</title>
<!-- Use a monspace font and a dark theme -->
<!-- Colour Palet from http://clrs.cc/ -->
<style>
body {
font-family: Courier, "Courier New", monospace;
font-size: 11;