Skip to content

Instantly share code, notes, and snippets.

@apeckham
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
"https://www.bevuta.com/en/blog/using-postgresql-enums-in-clojure/"
(:require
[clojure.string :as str]
[clojure.java.jdbc :as jdbc])
(:import
(org.postgresql.util PGobject)
(clojure.lang Keyword)
(java.sql ResultSetMetaData)))
@apeckham
apeckham / fake-now.clj
Created Sep 5, 2020
Fake now() in Postgres for testing, in clojure.java.jdbc
View fake-now.clj
(ns sql.fake-now
"https://www.slideshare.net/justatheory/test-drivern-database-development slide 498"
(:require
[clojure.java.jdbc :as jdbc])
(:import
(org.joda.time DateTime)))
(defn set-now
[db ^DateTime date]
(jdbc/execute!
@apeckham
apeckham / .sh
Created May 28, 2020
convert csv to json
View .sh
ruby -rjson -rcsv -e 'print JSON.pretty_generate(CSV.new(STDIN, headers: true).map(&:to_h))'
@apeckham
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
apeckham / lucene-dash.md
Last active Aug 9, 2020
Add Lucene Javadocs to Kapeli Dash
View lucene-dash.md

Install j2d

  • wget https://github.com/iamthechad/javadoc2dash/releases/download/1.1.0/j2d-cli-1.1.0.zip
  • unzip j2d-cli-1.1.0.zip

Build Javadocs

  • wget https://archive.apache.org/dist/lucene/java/8.5.1/lucene-8.5.1-src.tgz
  • brew install ant
View udp-server.clj
(ns what.udp-server
(:import
(java.net DatagramSocket DatagramPacket)))
(def packet-size 1024)
(defn create [] {:data (atom []) :socket (DatagramSocket.)})
(defn port [{:keys [socket]}] (.getLocalPort socket))
@apeckham
apeckham / .gitignore
Last active Aug 27, 2019
clojurescript/lumo + bash multiline shebang shell script
View .gitignore
node_modules
View gist:54d39e0f2c1892eaf0132b8df14c5635
# https://www.reddit.com/r/sysadmin/comments/cavaw6/zoom_zero_day_exploit_found/etcgorq/
(echo >/dev/tcp/localhost/19421) &>/dev/null && echo “Zoom Server Found, CVE 2019-13450 open” || echo “No Zoom Server, system is safe”
# https://www.reddit.com/r/sysadmin/comments/cavaw6/zoom_zero_day_exploit_found/etcgghl/
kill -9 $(lsof -t -i:19421) && rm -rf ~/.zoomus/ && touch ~/.zoomus
@apeckham
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
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.