Skip to content

Instantly share code, notes, and snippets.

View source-c's full-sized avatar
🛡️
I definitely will be slow to respond.

A I source-c

🛡️
I definitely will be slow to respond.
View GitHub Profile
@source-c
source-c / pg-slow-queries.sql
Last active June 9, 2023 10:41
PG list queries that running longer than 1 minute
SELECT
pid,
user,
pg_stat_activity.query_start,
now() - pg_stat_activity.query_start AS query_time,
query,
state,
wait_event_type,
wait_event
FROM pg_stat_activity
@source-c
source-c / brew-list-json
Created September 18, 2022 16:14
List packages locally installed with brew (on MacOS) in JSON format
#!/usr/bin/env bash
JQ=$(which jq)
[[ -n ${JQ} ]] || exit 1
[[ -x ${JQ} ]] || exit 2
brew info --json=v1 --installed | jq "map({name: .name, desc: .desc, version: .installed[].version})"
@source-c
source-c / h2-honeysql-upsert.clj
Last active January 4, 2022 15:54
H2 database upsert implementation
(ns com.myproject.model
(:require [honey.sql :as sql]
[clojure.string :as s]))
;; honeysql clause extension
;; Updates existing rows, and insert rows that don't exist.
;; If no key column is specified, the primary key columns are used to find the row.
;; If more than one row per new row is affected, an exception is thrown.
@source-c
source-c / rsa-sign.clj
Last active January 28, 2022 11:32
SHA-x signature with RSA keys
(ns rsa-sign
(:require [clojure.java.io :as io])
(:import (org.bouncycastle.openssl PEMParser)
(java.security KeyFactory Signature SecureRandom PublicKey)
(java.security.spec PKCS8EncodedKeySpec X509EncodedKeySpec)
(java.util Base64)))
;(java.security.Security/addProvider (org.bouncycastle.jce.provider.BouncyCastleProvider.))
(def _cr "RSA")