Skip to content

Instantly share code, notes, and snippets.

This is a thought experiment, obviously this is not real datomic!

Why do this? I think it would cancel out data transformation boilerplate currently needed to do something like this.

(defn user-uuid-to-user [user-uuid]
  (d/q [:in $ ?user-uuid
        :find ?user .                          ; no pull here, bind it later
        :where [?user :user/uuid ?user-uuid]]
 *$* user-uuid))
(require '[clojure.core.match :refer [match]])
(require '[datascript.parser :refer [parse-query]])
(import (datascript.parser FindRel FindColl FindTuple FindScalar Variable Aggregate Pull))
(def q '[:find [?e ...] :where [?e :db/ident]])
(let [FindColl FindColl ; Create locals for symbols
FindScalar FindScalar
FindRel FindRel
FindTuple FindTuple]
(match [(type (:qfind (parse-query q)))]
[FindRel] :rel ; match searches locals first before binding wildcards
(defn- attr-spec->shape "Take the pull and get rid of everything, even splat, just attrs requested."
[a]
; todo :as
(cond
(keyword? a) a
(#{'* "*"} a) nil
(map? a) (reduce-kv (fn [m k v]
(assoc m (attr-spec->shape k)
(pull-shape v)))
{} a)
;; Copyright (c) Cognitect, Inc.
;; All rights reserved.
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
{:paths ["."]
:deps {com.datomic/datomic-free {:mvn/version "0.9.5561" :exclusions [org.slf4j/slf4j-nop]}}}
@dustingetz
dustingetz / chirpss bookmarklet.js
Created March 17, 2018 15:01
chirpss bookmarklet
javascript: (function() {
previousCount = 0;
previousMilestone = 0;
milestone = 5;
var beepIn = new Audio('http://chirpss.com/sounds/yay.wav');
var beepOut = new Audio('http://chirpss.com/sounds/nay.wav');
var levelUp = new Audio('http://chirpss.com/sounds/levelup.wav');
var gameOver = new Audio('http://chirpss.com/sounds/zero.wav');
check = function(previousCount) {
currentCount = parseInt(document.getElementById('ID-overviewCounterValue').innerHTML);
@dustingetz
dustingetz / cljs eval from markdown.md
Last active February 28, 2018 14:34
cljs eval from markdown

cljs eval from markdown

cljs: ::: (let [ctx hyperfiddle.core/ctx r (-> ctx :result) change! #((:user-with! ctx) (hypercrud.client.tx/update-entity-attr @r :post/title %))] [hypercrud.ui.control.code/code* (:post/title @r) change! {}]) :::

from itertools import islice, imap, ifilter
def ftake(fnext, last):
return [fnext() for _ in xrange(last)]
def gtake(gen, N):
"equivalent to list(islice(gen, N))"
return ftake(lambda: gen.next(), N)
def fib_gen():
@dustingetz
dustingetz / Appendix A. Collected ABNF for URI .txt
Created February 2, 2018 00:29
Appendix A. Collected ABNF for URI
Appendix A. Collected ABNF for URI
URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
hier-part = "//" authority path-abempty
/ path-absolute
/ path-rootless
/ path-empty
URI-reference = URI / relative-ref