Skip to content

Instantly share code, notes, and snippets.

View dogenpunk's full-sized avatar

Matthew M. Nelson dogenpunk

  • Parenthetically Unbalanced
  • Madison, WI
View GitHub Profile
@dogenpunk
dogenpunk / hugsql-debug-logging.clj
Created March 11, 2020 19:47
Debug logging sql commands in HugSQL
;; Cribbed from https://stackoverflow.com/questions/47035273/log-sql-statments-queries-executed-by-hugsql
(defn log-sqlvec [sqlvec]
(log/info (->> sqlvec
(map #(clojure.string/replace (or % "") #"\n" ""))
(clojure.string/join " ; "))))
(defn log-command-fn [this db sqlvec options]
(log-sqlvec sqlvec)
(condp contains? (:command options)
@dogenpunk
dogenpunk / data-modeling.md
Created October 13, 2019 13:37 — forked from levand/data-modeling.md
Advice about data modeling in Clojure

Since it has come up a few times, I thought I’d write up some of the basic ideas around domain modeling in Clojure, and how they relate to keyword names and Specs. Firmly grasping these concepts will help us all write code that is simpler, cleaner, and easier to understand.

Clojure is a data-oriented language: we’re all familiar with maps, vectors, sets, keywords, etc. However, while data is good, not all data is equally good. It’s still possible to write “bad” data in Clojure.

“Good” data is well defined and easy to read; there is never any ambiguity about what a given data structure represents. Messy data has inconsistent structure, and overloaded keys that can mean different things in different contexts. Good data represents domain entities and a logical model; bad data represents whatever was convenient for the programmer at a given moment. Good data stands on its own, and can be reasoned about without any other knowledge of the codebase; bad data is deeply and tightly coupled to specific generating and

Experiment to setup a single step deploy process for Datomic Ions including setting up the AWS API Gateway.

Next experiment will be generating a CloudFormation template for the app.

@dogenpunk
dogenpunk / datomic-entity-history.clj
Created April 6, 2019 00:50 — forked from pesterhazy/datomic-entity-history.clj
Inspect a datomic entity's history
;; Show history of an entity
;;
;; useful for interactively inspecting what happened to a datomic entity in its lifetime
;;
;; use `entity-history` to get a list of transactions that have touched the entity (assertions, retractions)
;;
;; use `explain-tx` to find out what else was transacted in the txs
(defn entity-history
"Takes an entity and shows all the transactions that touched this entity.
@dogenpunk
dogenpunk / Makefile
Created January 10, 2019 13:28 — forked from olivergeorge/Makefile
Devops tools for simple Datomic Ions app
cloud-on:
clojure -A:dev -m devops cloud-on
cloud-off:
clojure -A:dev -m devops cloud-off
release-rev:
clojure -A:dev -m devops release '{}'
@dogenpunk
dogenpunk / cljs-quil-emacs-figwheel-setup.md
Created December 15, 2018 05:09 — forked from mmzsource/cljs-quil-emacs-figwheel-setup.md
Setup dynamic Clojurescript and Quil environment with emacs and figwheel

My environment

  • emacs 26.1
  • cider 0.17.0
  • leiningen 2.8.1 on Java 1.8.0_05
  • ~/.lein/profiles.clj : {:user {:plugins []}}

Project setup

In a terminal, run these commands:

@dogenpunk
dogenpunk / README.md
Created November 9, 2018 19:11 — forked from kennyjwilli/README.md
Delete leftover Datomic resources

Delete Leftover Datomic Cloud Resources

If you delete a Datomic Cloud system, it will leave some resources in AWS. To entirely delete all resources created by Datomic Cloud, you must follow these steps. Because we love automation, this script performs all these steps for you so you don't need to navigate the AWS Console UI.

Prerequisites

@dogenpunk
dogenpunk / nginx.conf
Created October 10, 2018 21:24 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@dogenpunk
dogenpunk / flatten.rb
Created December 14, 2016 03:11
Ruby implementation of 'flatten'
=begin rdoc
Takes any nested combination of Arrays and returns their contents as a
single Array. my_flatten(nil) returns an empty Array.
=end
def my_flatten values=[]
raise "`my_flatten' requires an Array argument." unless values.is_a?(Array)
result = []
values.each do |v|