This file contains hidden or 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
#_=> [params][34G[27G[35G | |
#_=> (let [{:keys [user_id | |
#_=> subdomain | |
#_=> addresses][50G[51G}[51G[52G params | |
#_=> access-params {:user_id user_id | |
#_=> :subdomain subdomain | |
ners}[5G[6G | |
-params)[8G[1A[55G[1B[9G | |
#_=> addr-ids (mapv :id addresses)[61G[42G[62G][62G[63G | |
#_=> (db/with-trx |
This file contains hidden or 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 *.pcall | |
(:refer-clojure :exclude [try resolve]) | |
) | |
(bind ) | |
(defprotocol ITry) | |
(defrecord Try [ok result] |
This file contains hidden or 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
(:import java.util.zip.ZipEntry | |
java.util.zip.ZipInputStream)) | |
(defn- ^ZipInputStream get-stream | |
[url] | |
(let [resp (client/get url {:as :stream})] | |
(ZipInputStream. (:body resp)))) | |
(def ^:private |
This file contains hidden or 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- file-name | |
[^java.io.File file] | |
(.getName file)) | |
(defn- is-sql? | |
[^java.io.File file] | |
(-> file file-name (s/ends-with? ".sql"))) | |
(defn- to-migration | |
[^java.io.File file] |
This file contains hidden or 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
+ [usnpi.shell :as shell] | |
+ [clj-time.jdbc] ;; extends SQL protocols | |
[environ.core :refer [env]])) | |
(def ^:private | |
- default-url | |
- "jdbc:postgresql://localhost:5678/usnpi?stringtype=unspecified&user=postgres&password=verysecret") | |
+ url-template | |
+ "jdbc:postgresql://%s:%s/%s?stringtype=unspecified&user=%s&password=%s") | |
+ |
This file contains hidden or 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
cat deploy.tpl.yaml \ | |
| sed 's;<BRANCH>;'"$BRANCH"';g' \ | |
| sed 's;<IMAGE>;'"$IMAGE"';g' \ | |
+ | sed 's;<GIT_COMMIT>;'"$GIT_COMMIT"';g' \ | |
+ | sed 's;<DB_HOST>;'"$DB_HOST"';g' \ | |
+ | sed 's;<DB_PORT>;'"$DB_PORT"';g' \ | |
+ | sed 's;<DB_DATABASE>;'"$DB_DATABASE"';g' \ | |
+ | sed 's;<DB_USER>;'"$DB_USER"';g' \ | |
+ | sed 's;<DB_PASSWORD>;'"$DB_PASSWORD"';g' \ | |
+ | sed 's;<PORT>;'"$PORT"';g' \ |
This file contains hidden or 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 psql | |
"Executes a SQL file using psql utility." | |
[sql-file] | |
(let [pg-keys ["PGHOST" "PGPORT" "PGDATABASE" "PGUSER" "PGPASSWORD"] | |
pg-vals (mapv #(System/getenv %) pg-keys) | |
pg-cred (into {} (map vector pg-keys pg-vals))] | |
(shell/with-env pg-cred | |
(shell/sh "psql" "-f" (from-workdir sql-file))))) |
This file contains hidden or 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 ___.shell | |
(:require [clojure.java.shell :as shell] | |
[___.error :refer [error!]])) | |
(defmacro with-env | |
"The same as `clojure.java.shell/with-sh-env` but updates | |
an existing ENV rather than substitute it completely." | |
[env & forms] | |
`(let [env-old# (into {} (System/getenv)) | |
env-new# (merge env-old# ~env)] |
This file contains hidden or 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
;; | |
;; Workers | |
;; | |
(defn worker-start | |
[cfg topic func] | |
(let [p (promise)] | |
{:p p | |
:f (future | |
(with-consumer c cfg |
This file contains hidden or 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 foo.proxy | |
(:require [hickory.core :as hickory] | |
[hickory.select :as select] | |
[clojure.tools.logging :as log] | |
[clj-http.client :as client])) | |
(defonce proxies (atom [])) | |
(defn get-proxies [] | |
@proxies) |
OlderNewer