Skip to content

Instantly share code, notes, and snippets.

View alex-dixon's full-sized avatar
🍁

Alex Dixon alex-dixon

🍁
View GitHub Profile
@jmlsf
jmlsf / js-in-cljs.md
Last active January 25, 2024 23:15
Using JavaScript modules in ClojureScript

Using JavaScript Libraries from ClojureScript

Using JavaScript libraries from ClojureScript involves two distinct concerns:

  1. Packaging the code and delivering it to the browser
  2. Making ClojureScript code that accesses JavaScript libraries safe for advanced optimization

Right now, the only single tool that solves these probems reliably, optimally, and with minimal configuration is shadow-cljs, and so that is what I favor. In paricular, shadow-cljs lets you install npm modules using npm or yarn and uses the resulting package.json to bundle external dependencies. Below I describe why, what alternatives there are, and what solutions I disfavor at this time.

Packaging and Delivering Code

@mfikes
mfikes / lein-tools-deps-cursive.md
Last active October 31, 2020 12:35
Using `lein-tools-deps` from Cursive (on macOS)

Note: These workarounds covered issues in lein-tools-deps 0.3.0-SNAPSHOT. If using 0.4.1 or later, you should not encounter the issues below.

The following provides some workarounds for some issues when using lein-tools-deps from Cursive on macOS.

Path to clojure

By default, the lein-tools-deps plugin won't see /usr/local/bin/clojure when Cursive processes project.clj, as it evidently has a degenerate path.

You will see an error like the following in the IntelliJ Event Log when it tries to process your project.clj file:

@CollinChaffin
CollinChaffin / How_to_disable_ATT_DNS_Redirection.md
Created August 29, 2018 21:26
How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44

How to disable the very little-known AT&T setting that can appear to hijack your home DNS lookups and redirect to 104.239.207.44

Issue

DNS queries on home network suddenly resolving hosts to 104.239.207.44.

Symptoms

You will see SPORADIC mis-resolutions of EVERYTHING to that 104.239.207.44 address if their crappy router happens to hear your PC's DHCP request - EVEN IF ANOTHER DHCP SERVER ON THE NETWORK assigns the ultimate address.

@Azel4231
Azel4231 / core.clj
Last active September 16, 2022 13:31
Using multimethod hierarchies with spec
(ns applesoranges.core
(:require [clojure.spec.alpha :as s]))
;; define the properties
(s/def ::fruit-attribute-spec (s/keys :req [::diameter ::color]))
(s/def ::diameter nat-int?)
(s/def ::color #{:green :orange})
;; define the "type"-hierarchy
;; seemed like a good idea to use a separate spec for the hierarchy (in order to keep things simple)
@saikyun
saikyun / save.clj
Created March 31, 2019 09:49
Save local variables, then load them
(ns miracle.tools.save
(:require [clojure.walk :refer [postwalk]]))
(def ^:dynamic *max-saves* 50)
(defn gensym? [s]
(re-find #"__\d+" s))
(defn fn->var
"Takes a function and returns a var. Works even on function objects."
@robert-stuttaford
robert-stuttaford / notes.md
Last active March 18, 2024 13:52
Datomic 0.9.5927 observations and questions

Query basics

{:db/ident       :meta/tag
 :db/valueType   :db.type/tuple
 :db/tupleAttrs  [:meta/tag-namespace :meta/tag-key :meta/tag-value] ;; all unique strings
 :db/cardinality :db.cardinality/one
 :db/unique      :db.unique/identity}

Then