Skip to content

Instantly share code, notes, and snippets.

@pjstadig
pjstadig / authorized_keys.bash
Last active April 12, 2023 10:27
Small script to install authorized_keys on a host
#!/usr/bin/env bash
mkdir -p ~/.ssh
curl https://github.com/pjstadig.keys >~/.ssh/authorized_keys
@pjstadig
pjstadig / focus-mfa.js
Last active February 20, 2023 21:05
Focus MFA: if a page has a single text or password field (usually an MFA page), then focus on it
// ==UserScript==
// @name Focus MFA
// @namespace http://paul.stadig.name/
// @version 0.5
// @description if a page has a single text or password field (usually an MFA page), then focus on it
// @author Paul Stadig
// @match *://*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
@pjstadig
pjstadig / connect.clj
Created February 25, 2022 14:25
Connect example
(defmulti connect (fn [& _] (config :storage :backend)))
@pjstadig
pjstadig / main.clj
Created February 25, 2022 14:21
Protocol + client + multimethod
(ns stadig.main
(:require
[stadig.storage :as storage]))
(defn -main
[& args]
;; ... initialize some things ...
(let [access-key (System/getenv "AWS_ACCESS_KEY_ID")
secret-key (System/getenv "AWS_SECRET_ACCESS_KEY")
storage-conn (storage/connect {:backend :s3
@pjstadig
pjstadig / widget.clj
Created February 25, 2022 14:21
Protocol + client + multimethod
(ns stadig.widget
(:require
[stadig.storage :as storage]))
(defn store-widget
[storage-conn widget-name]
(storage/put storage-conn
"widgets"
widget-name
(pr-str {:type :widget :name widget-name})))
@pjstadig
pjstadig / storage.clj
Created February 25, 2022 14:20
Protocol + client + multimethod
(ns stadig.storage
(:refer-clojure :exclude [get])
(:require
[stadig.storage.azure]
[stadig.storage.cloudfiles]
[stadig.storage.protocol :as proto]
[stadig.storage.s3]))
(defn connect
[options]
@pjstadig
pjstadig / s3.clj
Created February 25, 2022 14:19
Protocol + client + multimethod
(ns stadig.storage.s3
(:require
[aws.sdk.s3 :as s3]
[stadig.storage.protocol :as proto]))
(defrecord S3Storage
[access-key secret-key]
proto/IStorage
(get [this bucket key]
(s3/get-object this bucket key))
@pjstadig
pjstadig / protocol.clj
Created February 25, 2022 14:18
Protocol + client + multimethod
(ns stadig.storage.protocol
(:refer-clojure :exclude [get]))
(defprotocol IStorage
(get [this bucket key])
(put [this bucket key value])
(delete [this bucket key])
(close [this]))
(defmulti connect :backend)
@pjstadig
pjstadig / main.clj
Created February 25, 2022 14:18
Protocol + client
(ns stadig.main
(:require
[stadig.storage :as storage]
[stadig.storage.s3 :refer [->S3Storage]]))
(defn -main
[& args]
;; ... initialize some things ...
(let [access-key (System/getenv "AWS_ACCESS_KEY_ID")
secret-key (System/getenv "AWS_SECRET_ACCESS_KEY")
@pjstadig
pjstadig / widget.clj
Created February 25, 2022 14:17
Protocol + client
(ns stadig.widget
(:require
[stadig.storage :as storage]))
(defn store-widget
[storage-conn widget-name]
(storage/put storage-conn
"widgets"
widget-name
(pr-str {:type :widget :name widget-name})))