Skip to content

Instantly share code, notes, and snippets.

@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]))
@apeckham
apeckham / prebuild.sh
Created February 12, 2023 00:44
check out Prebid and build a specific version with a list of modules
#!/usr/bin/env bash
set -euf -o pipefail
[ -d Prebid.js ] || git clone https://github.com/prebid/Prebid.js.git
cd Prebid.js
git checkout 7.36.0
npm ci
npx gulp build --modules=x,\
(defn partition-before
"Partition the input before (pred this-partition) returns true"
[pred items]
(if (seq items)
(reduce (fn [lists item]
(if (pred (concat (last lists) [item]))
(concat lists [[item]])
(concat (butlast lists) [(concat (last lists) [item])])))
[[(first items)]]
(rest items))
#!/usr/bin/env bash
set -exuf -o pipefail
for namespace in $(kubectl get -o name ns | grep -v namespace/kube- | sed 's/namespace\///')
do
for resource in $(kubectl get -o=name pvc,configmap,serviceaccount,secret,ingress,service,deployment,statefulset,hpa,job,cronjob --namespace "$namespace")
do
mkdir -p "$namespace/$(dirname "$resource")"
kubectl neat get -- -o=yaml --namespace "$namespace" "$resource" > "$namespace/$resource.yaml"
@apeckham
apeckham / import.rb
Last active December 30, 2022 23:18
Import all GCP resources into Pulumi
require 'yaml'
require 'json'
assets = YAML.load_stream(STDIN.read)
type_map = {
'compute.googleapis.com/BackendService' => 'gcp:compute/backendService:BackendService',
'compute.googleapis.com/NetworkEndpointGroup' => 'gcp:compute/regionNetworkEndpointGroup:RegionNetworkEndpointGroup',
'compute.googleapis.com/UrlMap' => 'gcp:compute/uRLMap:URLMap',
'iam.googleapis.com/ServiceAccount' => 'gcp:serviceAccount/account:Account',