Skip to content

Instantly share code, notes, and snippets.

apeckham / enum.clj
Created Sep 5, 2020
Convert Postgres enums to and from namespaced Clojure keywords (enum types must end in "_enum")
View enum.clj
(ns sql.enum
[clojure.string :as str]
[ :as jdbc])
(org.postgresql.util PGobject)
(clojure.lang Keyword)
(java.sql ResultSetMetaData)))
apeckham / fake-now.clj
Created Sep 5, 2020
Fake now() in Postgres for testing, in
View fake-now.clj
(ns sql.fake-now
" slide 498"
[ :as jdbc])
(org.joda.time DateTime)))
(defn set-now
[db ^DateTime date]
apeckham / .sh
Created May 28, 2020
convert csv to json
View .sh
ruby -rjson -rcsv -e 'print JSON.pretty_generate(, headers: true).map(&:to_h))'
apeckham / .sh
Created May 26, 2020
Add cost tagging to all S3 buckets
View .sh
for i in `aws s3 ls | awk '{ print $3 }'`; do echo $i; aws s3api put-bucket-tagging --bucket $i --tagging "TagSet=[{Key=S3-Bucket-Name,Value=$i}]"; done
apeckham /
Last active Aug 9, 2020
Add Lucene Javadocs to Kapeli Dash

Install j2d

  • wget
  • unzip

Build Javadocs

  • wget
  • brew install ant
View udp-server.clj
(ns what.udp-server
( DatagramSocket DatagramPacket)))
(def packet-size 1024)
(defn create [] {:data (atom []) :socket (DatagramSocket.)})
(defn port [{:keys [socket]}] (.getLocalPort socket))
apeckham / .gitignore
Last active Aug 27, 2019
clojurescript/lumo + bash multiline shebang shell script
View .gitignore
View gist:54d39e0f2c1892eaf0132b8df14c5635
(echo >/dev/tcp/localhost/19421) &>/dev/null && echo “Zoom Server Found, CVE 2019-13450 open” || echo “No Zoom Server, system is safe”
kill -9 $(lsof -t -i:19421) && rm -rf ~/.zoomus/ && touch ~/.zoomus
apeckham / 1-dag.hy
Last active Apr 27, 2019
Airflow DAG in Hy, synced from git repo with google cloud build
View 1-dag.hy
(import [airflow [DAG]]
[airflow.operators.dummy_operator [DummyOperator]]
[airflow.operators.python_operator [PythonOperator]]
[airflow.hooks.base_hook [BaseHook]]
[airflow.contrib.operators.slack_webhook_operator [SlackWebhookOperator]]
[datetime [datetime]])
(defn print-hello [] "Hello world")
(with [dag (DAG "hello_worl2" :description "Simple DAG"
apeckham / useragents.rb
Created Mar 28, 2018
count useragents with specific versions
View useragents.rb
hits = 0
total = 0
require 'csv'
CSV.foreach("useragents.csv") do |row|
count = row[0].to_i
total += count
if row[1] !~ /Edge/i && row[1] =~ /Chrome\/([0-9]+)/i
You can’t perform that action at this time.