Skip to content

Instantly share code, notes, and snippets.

Avatar

Jacob O'Bryant jacobobryant

View GitHub Profile
@jacobobryant
jacobobryant / bookmarklet.js
Last active May 19, 2022 20:14
How to make your own airtable bookmark bookmarklet
View bookmarklet.js
// 1. Create a table on Airtable, and make URL/text columns with these names:
// URL, Title, Description, Image, Feed
//
// 2. Add a Form view. Click "Open form", then copy the URL. Set `airtable_form_url`
// below to that URL.
//
// 3. Create a new bookmark in your web browser, and paste in the code below. Whenever
// you're on a page you want to save, click the bookmark ("bookmarklet", technically).
// You'll go to the airtable form, and the columns listed above will be prefilled.
//
View knn_baseline.py
from surprise import KNNBaseline
from surprise import Dataset
from surprise import Reader
import time
import threading
import sys
import json
def synchronized(func):
func.__lock__ = threading.Lock()
@jacobobryant
jacobobryant / gist:deeb5b69c3ad5093eff17e86c00b3518
Last active June 12, 2020 04:26
Biff-style txes + rules with Datomic
View gist:deeb5b69c3ad5093eff17e86c00b3518
; Code snippet from a previous version of Findka that used Datomic + Biff-style transactions & rules.
; See trident.datomic-cloud/tx: https://github.com/jacobobryant/trident/blob/9516dcd9ac8fb48f7438e6f5a9519bc832c57d48/src/trident/datomic_cloud.clj#L87
(s/def :user.integration/goodreads-id #(or (empty? %)
(->> %
(str "https://www.goodreads.com/review/list_rss/")
http/head
u/catchall
:status
(= 200))))
@jacobobryant
jacobobryant / vim-commands.md
Last active November 18, 2019 16:01
common vim commands
View vim-commands.md
MOVEMENT
j k h l
b B w W
C-u C-d ("control-u")
gg G 10G
C-e C-f
%
0 $
C-o <tab>
@jacobobryant
jacobobryant / logs-datomic-cloud-ions.md
Last active July 13, 2019 16:45
Better logs for Datomic Cloud Ions
View logs-datomic-cloud-ions.md

You may discover soon after adding logging to your Ions that CloudWatch really sucks. Fortunately you can forward your logs to Loggly instead. See here.

@jacobobryant
jacobobryant / modify-composite-tuples.md
Last active November 10, 2020 11:57
Modifying Datomic schema for composite tuples
View modify-composite-tuples.md

Say you define a composite tuple like so:

#:db{:ident :foo,
     :valueType :db.type/tuple,
     :unique :db.unique/identity,
     :tupleAttrs [:bar :baz],
     :cardinality :db.cardinality/one}

Now suppose you want to change [:bar :baz] to [:bar :quux]. The [Datomic

@jacobobryant
jacobobryant / data-readers.md
Last active March 25, 2022 16:06
refreshing namespaces breaks *data-readers*
View data-readers.md

If you call clojure.tools.namespace.repl/refresh before requiring any namespaces referenced in data_readers.clj, then *data-readers* gets messed up somehow. The readers you define in data_readers.clj won't work even if you require their namespaces. For example:

$ find -type f
./src/foo/core.clj
./src/data_readers.clj
./src/user.clj
@jacobobryant
jacobobryant / local-root.md
Last active May 24, 2019 22:01
tools.deps bug with :local/root?
View local-root.md

On a project I'm working on, this gives me an error:

$ clj -Sdeps '{:deps {trident/build {:local/root "/home/arch/dev/trident/target/build"}}}' \
>     -m trident.build reset
Exception in thread "main" Syntax error compiling at (trident/build/util.clj:1:1).
...
Caused by: java.lang.ClassNotFoundException: jnr.posix.POSIXFactory
...

(I have (:import (jnr.posix POSIXFactory))) in that file).

@jacobobryant
jacobobryant / deploy.cljs
Created May 10, 2019 19:31
Script for automating Datomic Cloud Ion push + deploy
View deploy.cljs
#!/usr/bin/planck
(ns deploy.core
(:require [cljs.reader :refer [read-string]]
[planck.shell :as shell]))
(defn sh [& args]
(let [result (apply shell/sh args)]
(if (= 0 (:exit result))
(:out result)
(throw (ex-info (:err result) {})))))