Skip to content

Instantly share code, notes, and snippets.

View dvingo's full-sized avatar

Daniel Vingo dvingo

View GitHub Profile
@dvingo
dvingo / recursive_js_reader.cljc
Created September 5, 2024 13:36
Recursive clojure reader literal for JS objects and arrays with a variant for css key conversion.
(ns levier.js-reader
#?(:cljs (:require-macros [levier.js-reader]))
(:require [cljs.tagged-literals :as cljs-tl]
[clojure.string :as str])
#?(:clj (:import [cljs.tagged_literals JSValue])))
(defn map-keys [m f] (into (empty m) (map (juxt (comp f key) val) m)))
(defn map-vals [m f] (into (empty m) (map (juxt key (comp f val)) m)))
(defn map->js* [m]
@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() {