Skip to content

Instantly share code, notes, and snippets.

View camsaul's full-sized avatar
💭
I am Cam

Cam Saul camsaul

💭
I am Cam
View GitHub Profile
@camsaul
camsaul / stack_trace.txt
Created July 13, 2023 21:04
Stack Trace
java.lang.StackOverflowError:
...
clojure.core/partial/fn core.clj: 2641
...
clojure.core/comp/fn core.clj: 2586
@camsaul
camsaul / decode_mbql.cljc
Created March 11, 2023 04:53
MBQL clause decoding with Malli
(mbql-clause/define-tuple-mbql-clause :foo :- :type/Boolean
#_number int?)
(malli.core/validate
:mbql.clause/foo
[:foo {:lib/uuid (str (random-uuid))} 1])
;; => true
(malli.core/validate :mbql.clause/foo [:foo 1])
;; => false
@camsaul
camsaul / mbql_clause.cljc
Last active March 8, 2023 20:51
Malli MBQL Clause Schemas improvements PoC
(ns metabase.lib.schema.mbql-clause
(:require
[metabase.lib.schema.common :as common]
[metabase.util.malli.registry :as mr]))
(defonce ^:private ^{:doc "map of clause keyword -> schema"} clause-schema-registry
(atom {}))
(defn- keyword-schema
"Build the schema for `::keyword`, for a valid MBQL clause type keyword."
@camsaul
camsaul / capture.clj
Last active March 2, 2023 01:58
Amazing Clj/Cljs thread-safe log message capturing
(ns metabase.util.log.capture
(:require [clojure.string :as str]))
(def ^:dynamic *capture-logs-fn*
(constantly nil))
(defn level->int [level]
(case level
:explode 0
:fatal 1
@camsaul
camsaul / gist:14b50563027c377c4aa510c3442845da
Created February 10, 2023 00:09
Clojure action .github/actions/clojure/action.yml
name: Set up Java & Clojure
inputs:
cache-key:
required: true
runs:
using: composite
steps:
- uses: actions/setup-java@v3
@camsaul
camsaul / dox.md
Created February 8, 2023 18:43
Hydrate dox example

toucan2.tools.hydrate/simple-hydrate [model₁ k₂ instance] Implementations should return a version of map instance with the key k added.

simple-hydrate is defined in toucan2.tools.hydrate (toucan2/tools/hydrate.clj:483).

It caches methods using a methodical.impl.cache.watching.WatchingCache.

It uses the method combination methodical.impl.combo.threaded.ThreadingMethodCombination with the threading strategy :thread-last.

@camsaul
camsaul / test-data.sql
Last active January 20, 2023 21:52
Postgres test data (SQL
DROP TABLE IF EXISTS checkins;
DROP TABLE IF EXISTS venues;
DROP TABLE IF EXISTS categories;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
id serial PRIMARY KEY NOT NULL,
@camsaul
camsaul / db.clj
Created December 7, 2022 17:40
Dynamic app DB
(ns waterfront.db
(:require
[waterfront.config :as config]
[waterfront.db.migrations :as db.migrations]
[toucan.db :as t.db])
(:import
(com.mchange.v2.c3p0 DataSources)))
(set! *warn-on-reflection* true)
@camsaul
camsaul / x.clj
Created November 29, 2022 20:27
Sample Dataset Profiling (ZIP/JAR vs file)
(ns metabase.x
(:require
[metabase.sync :as sync]
[toucan.db :as db]))
(defmulti ^:private info
{:arglists '([location])}
keyword)
(defmethod info :jar
@camsaul
camsaul / pom.xml
Created November 8, 2022 20:20
Athena driver pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Athena</groupId>
<artifactId>AthenaJDBC${env.JDBC_V}</artifactId>
<version>${env.MAJOR_V}.${env.MINOR_V}.${env.REVISION_V}.${env.BUILD_V}</version>
<packaging>jar</packaging>
<name>AthenaJDBC${env.JDBC_V}</name>
<url>http://maven.apache.org</url>