This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn create-index [distance-fn] | |
(with-meta {} {:distance-fn distance-fn})) | |
(defn index->root [index] | |
(-> index meta :root)) | |
(defn index->distance-fn [index] | |
(-> index meta :distance-fn)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns auth | |
(:import (com.zaxxer.hikari HikariDataSource HikariConfig) | |
(com.amazonaws.services.rds.auth RdsIamAuthTokenGenerator GetIamAuthTokenRequest) | |
(com.amazonaws.auth DefaultAWSCredentialsProviderChain) | |
(com.amazonaws.regions DefaultAwsRegionProviderChain) | |
(java.util Properties) | |
(java.time Duration))) | |
(defn parse-jdbc-url [jdbc-url] | |
(let [matcher (re-matcher #"//(?<host>[^:]+):(?<port>\d+)/(?<database>[^\\?]+)" jdbc-url)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn diff-branches [repo branch1 branch2] | |
(letfn [(tree-iterator [^Repository repo branch] | |
(let [head (.exactRef repo branch)] | |
(with-open [walk (RevWalk. repo)] | |
(let [commit (.parseCommit repo (.getObjectId head)) | |
tree (.parseTree walk (.getId (.getTree commit))) | |
parser (CanonicalTreeParser.)] | |
(with-open [reader (.newObjectReader repo)] | |
(.reset parser reader (.getId tree))) | |
(.dispose walk) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro workseq [bindings & body] | |
(let [bind (first (partition 2 bindings))] | |
(if (empty? bindings) | |
`(do ~@body nil) | |
`(let [right# ~(second bind) | |
value# (first right#) | |
workers# (second right#) | |
num-values# (count value#)] | |
(if (and (< 1 workers#) (< 1 num-values#)) | |
(let [thread-pool# (Executors/newFixedThreadPool workers#) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:latest | |
ENV DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update && apt-get install -y build-essential cmake wget libgd-dev | |
RUN wget https://github.com/ansilove/libansilove/archive/1.2.8.tar.gz \ | |
&& tar -xvf 1.2.8.tar.gz \ | |
&& cd libansilove-1.2.8 \ | |
&& mkdir build \ | |
&& cd build \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns piped.tools | |
(:require [amalloy.ring-buffer :as rb])) | |
(defprotocol Timer | |
(start [this key] "Given some key, start timing it.") | |
(stop [this key] "Given some key, stop timing it.") | |
(avg [this] "Get the weighted average of timings tracked thus far with this timer. Recent timings are weighted more.")) | |
(defn weighted-average | |
"Calculates the weighted average of numbers. Each subsequent number is weighted one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Less.js v1.7.5 RHINO | Copyright (c) 2009-2014, Alexis Sellier <self@cloudhead.net> */ | |
/*global name:true, less, loadStyleSheet, os */ | |
function readFile(url) { | |
var result = ""; | |
var imports = new JavaImporter(java.net, java.lang, java.io); | |
with (imports) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn teed-writer [^Writer source ^Writer fork] | |
(proxy [Writer] [] | |
(write | |
([c] | |
(cond | |
(int? c) | |
(do (.write source (int c)) | |
(.write fork (int c))) | |
(string? c) | |
(do (.write source ^String c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn tree-seq-bf [branch? children root] | |
(letfn [(walk [node] | |
(when (branch? node) | |
(lazy-seq | |
(let [children (children node)] | |
(lazy-cat children (mapcat walk children))))))] | |
(cons root (walk root)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
brew cask install basictex | |
find /Library/TeX/texbin/* -type f | xargs -L1 -I{} sh -c "base=$(basename {}); ln -sf {} /usr/local/bin/$base" |
NewerOlder