Skip to content

Instantly share code, notes, and snippets.

View dvingo's full-sized avatar

Daniel Vingo dvingo

View GitHub Profile
@dvingo
dvingo / malli_instrument.helix.cljc
Last active May 24, 2023 12:21
helix defnc with malli instrumentation support
(ns space.matterandvoid.helix
#?(:cljs (:require-macros space.matterandvoid.helix))
#?(:clj
(:require
[helix.core :as h]
[helix.impl.analyzer :as hana]
[helix.impl.props :as impl.props]
[clojure.string :as string]))
#?(:cljs (:require [helix.core :as h])))
@dvingo
dvingo / malli-schema->pathom.cljc
Created September 13, 2022 19:28
given a malli schema for a domain entity (a hashmap) produce a pathom output vector.
(ns my-app.malli.transform.pathom
(:refer-clojure :exclude [uuid])
(:require
[malli.core :as m]
[taoensso.timbre :as log]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@dvingo
dvingo / pathom-sieppari.cljc
Last active September 7, 2022 23:12
Using sieppari to handle the logic in pathom resolvers and mutations
(ns space.matterandvoid.pathom-sieppari
(:require
[sieppari.context]
[sieppari.core :as s]
[taoensso.timbre :as log]))
(defn terminate-if
"Takes a function that will be passed the pathom enviroment, if that function returns a non-falsey value
the sieppari chain is terminated and whatever is returned from `f` is the response of the chain.
@dvingo
dvingo / new_mac_software_install.md
Last active July 12, 2020 11:56
new mac software install

mkdir -p ~/.local/bin

chsh -s /bin/bash

add this to ~/.bash_profile

export BASH_SILENCE_DEPRECATION_WARNING=1

system prefs -> displays -> update resolution

@dvingo
dvingo / websocket.clj
Created June 12, 2020 18:32 — forked from hindol/websocket.clj
Access WebSocket session in Pedestal
(defn ws-listener
[_request _response ws-map]
(proxy [WebSocketAdapter] []
(onWebSocketConnect [^Session ws-session]
(proxy-super onWebSocketConnect ws-session)
(when-let [f (:on-connect ws-map)]
(f ws-session)))
(onWebSocketClose [status-code reason]
(when-let [f (:on-close ws-map)]
(f (.getSession this) status-code reason)))
@dvingo
dvingo / crux-pull.clj
Created May 5, 2020 16:22
pull api support for crux
(ns datascript-crux.pull-api
(:require
[crux.api :as crux]
[datascript.pull-parser :as dpp]
[my-app.crux-node :refer [crux-node]])
(:import [datascript.pull_parser PullSpec]))
;; lightly adapted from:
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_api.cljc
;; https://github.com/tonsky/datascript/blob/master/src/datascript/pull_parser.cljc
@dvingo
dvingo / crux-pull.clj
Created April 29, 2020 18:45
limited datomic pull api in crux.
(ns crux-pull
(:require
[edn-query-language.core :as eql]
[crux.api :as crux]
[my-app.crux-node :refer [crux-node]]))
(defn entity
([entity-id] (entity crux-node entity-id))
([crux-node entity-id]
(crux/entity (crux/db crux-node) entity-id)))
@dvingo
dvingo / .bash_aliases
Last active May 4, 2023 00:32
.bash_aliases
# Put on the last line of .bashrc:
# [ -f ~/.bash_aliases ] && source ~/.bash_aliases
# In ~/.bash_profile:
# [[ -f ~/.bashrc ]] && . ~/.bashrc
#
os=$(uname -s)
is_linux() {
@dvingo
dvingo / map-zipper.clj
Last active May 9, 2022 09:45
Clojure zipper for recursively traversing a map
;; inspired by: https://clojuredocs.org/clojure.zip/zipper#example-54d91161e4b081e022073c72
(defn map-zipper
[m ref-keys]
{:pre [(set? ref-keys)]}
(z/zipper
(fn is-branch? [x]
(let [ret
(cond
(not (coll? x))