Skip to content

Instantly share code, notes, and snippets.

@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',
@apeckham
apeckham / .gitpod.yml
Created December 26, 2022 21:16
hyperview app on gitpod
tasks:
- init: yarn
command: yarn test:xmlserver
- init: |
cd demo
yarn
npm install -g expo-cli
command: |
cd demo
sed -i 's|http://0.0.0.0:8085|'"$(gp url 8085)"'|g' constants.js
@apeckham
apeckham / deadfiles.sh
Last active November 26, 2022 20:20
list files that tests don't require, one file at a time
#!/bin/env bash
set -uf -o pipefail
if [ -n "$(git status --porcelain)" ]; then
echo "git status is not clean"
exit 1
fi
if [ $# -eq 0 ]; then
@apeckham
apeckham / picomock_test.clj
Created November 25, 2022 22:25
picomock - for clojure mocks
(ns util.picomock-test
"https://github.com/audiogum/picomock"
(:require
[clojure.test :refer [deftest is testing]]
[picomock.core :as pico]))
(deftest picomock-test
(testing "without a function"
(let [mock (pico/mock)]
(is (nil? (mock)))
@apeckham
apeckham / custom_tags.clj
Created November 25, 2022 20:24
custom tags in hiccup/clojure
(ns www.custom-tags
(:require
[clojure.walk :refer [postwalk]]))
(defn walk
[input fns]
(postwalk (fn [node]
(if (vector? node)
(if-let [f (fns (first node))]
(apply f (rest node))
@apeckham
apeckham / .gitlab-ci.yml
Created November 23, 2022 19:57
gitlab clojure zprint assert files are formatted
Format:
needs: []
image: an-image-with-zprint
script:
- zprintl -fsc $(cat list-of-files-that-should-be-formatted)