Skip to content

Instantly share code, notes, and snippets.

Dustin Getz dustingetz

Block or report user

Report or block dustingetz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View .md
    (def s (r/atom 0))

    (defn foo []
      [:input {:type "text" 
               :value @s 
               :on-click #(reset! s (.-target.value %)}]) ; unstable closure reference
    (defn change [e] (reset! s (.-target.value e)) ; you're suggesting we name it
(defn foo! [i]
  (rand-nth (concat
              (range 20)
              [{:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/unavailable}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/busy}}
               {:cognitect.anomalies/anomaly {:cognitect.anomalies/category :cognitect.anomalies/forbidden}}])))

(map foo! (range 15))

Unbalanced if with effect

(defn- pprint-list [alis]
  (if-not (pprint-reader-macro alis)
    (pprint-simple-list alis)))

When without effect

(defn- diff-associative-key
View redux.js
var Mocha = require('mocha')
var assert = require('assert')
var _ = require('lodash')
var mocha = new Mocha()
mocha.suite.emit('pre-require', this, 'solution', mocha)
describe('Test suite', function() {
it('should work', function() {
View datomic-query-is-data.clj
'[:find ?e
[?e :db/ident ?i]
[(namespace ?i) ?ns]
[(ground "dustingetz.gender") ?ns]]

This is probably going to be the next iteration of the declarative CRUD metamodel that powers Hyperfiddle. It's just a design sketch, the current metamodel in prod is different. Hyperfiddle is an easy way to make a CRUD app. Hyperfiddle is based on Datomic, a simple graph database with the goal of "enabling declarative data programming in applications."

CRUD UI definition

This extends Datomic pull syntax into something that composes in richer ways. The key idea is that Pull notation expresses implicit joins and thus can be used to declare data dependencies implicitly, without needing to name them. We also handle tempids, named transactions, and hyperlinks to other pages. We satisfy the hypermedia constraint, like HTML and the web.

{identity                                                   ; Pass through URL params to query
 [{:dustingetz/event-registration                           ; virtual attribute identif
View metamodel.clj
{identity ; pass through query params, decoded from URL
[{:hfnet/domains ; virtual attribute, resolves to a collection queried
[(:domain/ident {:hf/a :domains/edit}) ; :hf/a means hyperlink to a detail view, not specified here
{(hf/new $domains) ; allocates a tempid for a new entity to be created in database $domains
View datomic-reset-attributes.clj
(def tx-fns
[{:db/ident :db.fn/reset-attribute-values
:db/doc "Transaction function which accepts an entity identifier, attribute identifier
and set of values and expands to any additions and retractions necessary to
make the final post-transaction value of the attribute match the provided
values. Attribute values must be scalars.
If multiple values are provided on a cardinality-one attribute you will get a
datom conflict exception at transaction time."
:db/fn (d/function
dustingetz / ordering.clj
Created May 30, 2019 — forked from joinr/ordering.clj
examples of composeable ordering functions
View ordering.clj
(ns ordering)
;;We want to pack some information along with
;;our functions so that when our interpreter picks them
;;up, we can determine if the function should be applied
;;directly as a comparator, or if we need to "lift"
;;it into the comparator domain.
(defn ordering? [x] (get (meta x) :ordering))
;;convenience macro to help us create functions with
;;ordering specified in meta
dustingetz / .cljs
Created May 12, 2019
react virtualized data grid clojurescript
View .cljs
(defn row [ctx k]
^{:key (pr-str k)}
[:> js/ReactVirtualized.Column
{:label (reagent.core/as-element [hyperfiddle.ui/field [k] ctx])
:dataKey (hypercrud.transit/encode k)
(fn [m]
(let [k (hypercrud.transit/decode (aget m "dataKey"))
ctx (aget m "rowData")
#_#_ctx (hypercrud.browser.context/attribute ctx k)]
You can’t perform that action at this time.