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 / presto_jdbc.clj
Last active June 7, 2021 21:33
Presto-JDBC Metabase test data extensions
(ns metabase.test.data.presto-jdbc
"Presto JDBC driver test extensions."
(:require [clojure.string :as str]
[metabase.config :as config]
[metabase.connection-pool :as connection-pool]
[metabase.driver :as driver]
[metabase.driver.sql-jdbc.execute :as sql-jdbc.execute]
[metabase.test.data.interface :as tx]
[metabase.test.data.sql :as sql.tx]
[metabase.test.data.sql-jdbc :as sql-jdbc.tx]
@camsaul
camsaul / presto_jdbc_timezones.clj
Created June 16, 2021 00:28
Testing Presto JDBC Timezone Support
(defn- unwrap-connection ^PrestoConnection [^C3P0ProxyConnection conn]
(.unwrap conn PrestoConnection))
(defn set-timezone! [conn ^String zone-id]
(.setTimeZoneId (unwrap-connection conn) zone-id))
(defn get-timestamp-utc [^com.facebook.presto.jdbc.PrestoResultSet rset ^Integer index]
(let [method (doto (.getDeclaredMethod com.facebook.presto.jdbc.PrestoResultSet
"getTimestamp"
(into-array Class [Integer/TYPE com.facebook.presto.jdbc.internal.joda.time.DateTimeZone]))
@camsaul
camsaul / deps.edn
Created June 21, 2021 20:48
Tree example
{:deps {org.clojure/tools.deps.alpha {:mvn/version "0.11.931"}
clj-http/clj-http {:mvn/version "3.10.3"}}}
@camsaul
camsaul / yes-it-is.md
Created August 16, 2021 23:57
Markdown test

Yes, it is

@camsaul
camsaul / weston.log
Last active August 19, 2021 03:35
weston.log
Date: 2021-08-18 PDT
[18:42:58.437] weston 9.0.0
https://wayland.freedesktop.org
Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Build: 9.0.0-38-g46756d0e
[18:42:58.438] Command line: /usr/bin/weston --backend=rdp-backend.so --xwayland --shell=rdprail-shell.so --logger-scopes=log,rdp-backend,rdprail-shell --log=/mnt/wslg/weston.log
[18:42:58.438] OS: Linux, 5.10.43.3-microsoft-standard-WSL2, #1 SMP Wed Jun 16 23:47:55 UTC 2021, x86_64
[18:42:58.438] Using config file '/home/wslg/.config/weston.ini'
[18:42:58.439] Output repaint window is 7 ms maximum.
[18:42:58.439] Loading module '/usr/lib/libweston-9/rdp-backend.so'
@camsaul
camsaul / x.md
Created August 20, 2021 09:57
WSL Emacs 4k

image

@camsaul
camsaul / data.clj
Created August 25, 2021 18:15
Metabase data permissions graph spec
(ns metabase.models.permissions.graph.data
(:require [clojure.spec.alpha :as s]))
(s/def ::id
(s/and int? pos?))
(s/def :metabase.models.permissions.graph.data.table/read
#{:all :none})
(s/def :metabase.models.permissions.graph.data.table/query
@camsaul
camsaul / profiling.clj
Last active January 13, 2022 00:42
Profiling Results
;; profile everything in a namespace
(doseq [[_ varr] (ns-interns *ns*)] (profile.core/profile-var* varr))
;; run something and get profiling results
(profile.core/profile {} (no-lazyness-test))
@camsaul
camsaul / reify_all.clj
Created January 27, 2022 02:53
Reify all/sneaky proxy
;; we have to do a bit of magic to make the [[ConnectionDataSource]] work -- normally if someone were to use it with
;; `with-open` then the original connection would get closed when someone called `.close` on the one from the
;; `DataSource`. So we need to actually have [[ConnectionDataSource]] return a sneaky special proxy Connection that
;; forwards ALL of its other methods to the original Connection EXCEPT for `.close`, which should just no-op.
;;
;; This is all a little hacky for my tastes and it would be better if we could just eliminate [[ConnectionDataSource]]
;; entirely so we didn't need to use this anymore. It's only used in two places anyway.
(defn- reify-all-method [^java.lang.reflect.Method method original-symb]
(let [method-name (-> (symbol (.getName method))
@camsaul
camsaul / perms.md
Created February 10, 2022 21:57
MB Download Perms
User has full perms e.g. /download/db/1/ User has perms for all MBQL queries e.g. /download/db/1/schema/ User has perms for a specific Table e.g. /download/db/1/schema/public/table/1/
User can download native results? (/download/db/1/native) yes no no
User can download results for Table 1 (/download/db/1/schema/public/table/1)? yes yes yes
User can download results for Table 2 (/download/db/1/schema/public/table/2)? yes yes no