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 / sudoku.clj
Last active July 24, 2023 17:25
Sudoku Board for testing purposes
(ns sudoku.core
(:require [clojure.test :refer :all]))
;; sample correctly-solved board
(def solved-board
[[5 3 4 6 7 8 9 1 2]
[6 7 2 1 9 5 3 4 8]
[1 9 8 3 4 2 5 6 7]
[8 5 9 7 6 1 4 2 3]
@camsaul
camsaul / sudoku_2.clj
Created July 21, 2020 22:44
Sudoku Part 2
(def ? '?)
(def unsolved-board
[[5 3 ? ? 7 ? ? ? ?]
[6 ? ? 1 9 5 ? ? ?]
[? 9 8 ? ? ? ? 6 7]
[8 ? ? ? 6 ? ? ? 3]
[4 ? ? 8 ? 3 ? ? 1]
[7 ? ? ? 2 ? ? ? 6]
@camsaul
camsaul / .Xmodmap
Created September 3, 2020 21:37
Xmodmap to make Right Alt = Alt, Menu Button = Super, Right Control = Hyper
! Use these commands to determine original values:
!
! xmodmap -pke
! xmodmap -pm
! original values
!
! keycode 37 = Control_L NoSymbol Control_L
! keycode 64 = Alt_L Meta_L Alt_L Meta_L
! keycode 109 = Control_R NoSymbol Control_R
@camsaul
camsaul / mb_settings.clj
Last active October 20, 2020 22:16
Metabase Settings as of EE 1.36.x
(doseq [[setting-name {:keys [visibility sensitive?]}] (sort-by first @registered-settings)]
(println (str (format "%s (visibility: %s)" setting-name (name visibility)) (when sensitive? " (sensitive)"))))
abandonment-email-sent (visibility: internal)
admin-email (visibility: authenticated)
anon-tracking-enabled (visibility: public)
api-key (visibility: internal)
application-colors (visibility: public)
application-favicon-url (visibility: public)
application-logo-url (visibility: public)
@camsaul
camsaul / deps.sh
Created December 1, 2020 00:02
Clojure CLI deps.edn show deps tree
clojure -X:deps tree
@camsaul
camsaul / Dockerfile
Created December 3, 2020 01:49
SBCL Dockerfile with Quicklisp
FROM alpine:edge
MAINTAINER Cam Saul <[email protected]>
WORKDIR /app
RUN apk add --update curl sbcl
# create a unpriviledged user
RUN addgroup -S lisp
@camsaul
camsaul / multiple.clj
Created December 3, 2020 22:10
MultiQP
(ns metabase.query-processor.multiple
(:require [clojure.core.async :as a]
[metabase.query-processor :as qp]
[metabase.query-processor.context :as qp.context]
[metabase.query-processor.context.default :as context.default]))
(defn- process-query-append-results
"Reduce the results of a single `query` using `rf` and initial value `init`."
[query rf init context]
(if (a/poll! (qp.context/canceled-chan context))
@camsaul
camsaul / save-load-switch-to-repl.el
Created January 5, 2021 21:37
Save, load, and switch to CIDER REPL buffer Emacs Lisp snippet
(cl-defun cam/visible-buffer-matching (pred &optional return-multiple-values?)
"Return the first buffer visible in any window on any frame that satisfies PRED."
(dolist (frame (frame-list))
(dolist (window (window-list frame))
(let ((buffer (window-buffer window)))
(when (funcall pred buffer)
(cl-return-from cam/visible-buffer-matching (if return-multiple-values?
(list buffer window frame)
buffer)))))))
@camsaul
camsaul / clean-everything.el
Last active January 6, 2021 15:57
Run cljr-clean-ns on every file in project
;;; -*- lexical-binding: t; -*-
(defun cam/clean-file (file &optional callback)
(save-current-buffer
(find-file file)
(save-buffer)
(condition-case err
(cider-load-buffer
(current-buffer)
(cider-load-file-handler
@camsaul
camsaul / make_change.clj
Last active April 18, 2023 09:23
Make change (core.logic) with lots of comments
(ns make-change
(:refer-clojure :exclude [==])
(:require [clojure.core.logic :refer :all]
[clojure.core.logic.fd :as fd]))
(def common-us-coins
{:penny 1
:nickel 5
:dime 10
:quarter 25})