Skip to content

Instantly share code, notes, and snippets.

@apeckham
apeckham / reflection-linter.sh
Created October 1, 2023 01:44
ci script for lein reflection check
#!/bin/bash
set -euf -o pipefail
get_warnings() {
lein check 2>&1 | grep "Reflection" || { echo "Error in reflection-linter.sh"; exit 1; }
}
parse_line() {
echo $1 | awk -F 'Reflection warning, |:| - ' '{print $2, $3, $4, $5}'
@apeckham
apeckham / clean.sh
Created August 14, 2023 17:11
remove comments, spaces and duplicates from an ads.txt file
sed -e 's/ *#.*$//' -e 's/[ ,]*$//' -e 's/ *, */,/g' | sort | uniq
@apeckham
apeckham / gist:fb2aafc352d07033d915c8915418b078
Created July 19, 2023 02:07
decrypt credentials.yml.enc, etc, on stdin
echo 'your_encrypted_data' | ruby -ractive_support -ractive_support/message_encryptor -e "puts ActiveSupport::MessageEncryptor.new([ENV['DECRYPTION_KEY']].pack('H*'), cipher: 'aes-256-gcm').decrypt_and_verify(STDIN.read)"
@apeckham
apeckham / discord.yml
Created July 7, 2023 22:44
discord openapi spec
openapi: "3.0.0"
info:
title: "Discord API"
version: "1.0.0"
servers:
- url: "https://discord.com/api"
paths:
/oauth2/token:
post:
summary: "Refresh the access token"
@apeckham
apeckham / ack.clj
Created July 7, 2023 00:41
wiremock in clojure
(ns xxx-test
(:require [clojure.test :refer [deftest use-fixtures]]
[clj-http.client :as http]
[cheshire.core :as json])
(:import (com.github.tomakehurst.wiremock.core WireMockConfiguration)
(com.github.tomakehurst.wiremock WireMockServer)
(com.github.tomakehurst.wiremock.client WireMock)))
(def ^:dynamic *server* nil)
@apeckham
apeckham / .sh
Created June 21, 2023 18:02
filter adUnits ruby one-liner
ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(ARGF.read).map { |obj| obj["bids"].select! { |bid| bid["bidder"] == "pubmatic" }; obj })'
@apeckham
apeckham / .clj
Created June 19, 2023 14:19
jdbc jsonb support in clojure
(ns xxxxxx.jsonb-test
(:require
[clojure.test :refer [deftest is use-fixtures join-fixtures]]
[cheshire.core :as json]
[clojure.java.jdbc :as jdbc]
[xxxxxxx.test-db :refer [*db*] :as test-db])
(:import
(org.postgresql.util PGobject)
(clojure.lang IPersistentMap)))
@apeckham
apeckham / invoke.clj
Created June 14, 2023 18:29
invoke authenticated google cloud function from clojure
(ns yyyyyyyyyyaaaaaaaaaaa
(:import
(com.google.auth.oauth2 GoogleCredentials IdTokenCredentials))
(:require
[clj-http.client :as client]))
(def root "https://bang.a.run.app")
(defn get-access-token
[]
@apeckham
apeckham / playback.js
Created May 31, 2023 12:53
speed up youtube video
$('video').playbackRate = 4;
@apeckham
apeckham / jsonb_test.clj
Created May 28, 2023 14:32
clojure.java.jdbc jsonb support for postgresql
(ns xxx.jsonb-test
(:require
[clojure.test :refer [deftest is use-fixtures]]
[clojure.java.jdbc :as jdbc]
[cheshire.core :as json]
[xxx.db :as test-db :refer [*db*]])
(:import
[org.postgresql.util PGobject]
[java.sql PreparedStatement]))