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 guard-nil | |
"Returns `x` unless it is nil, in which case a descriptive exception is raised" | |
[x] | |
`(if-some [v# ~x] | |
v# | |
(throw (AssertionError. (str "Form should not be nil: " (pr-str '~x)))))) |
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
;; An example of `profiles.clj'. You can install it by placing it in the | |
;; ~/.lein/profiles.clj folder | |
;; | |
;; Based on the example given in: https://github.com/zcaudate/vinyasa | |
{:user {:dependencies [[org.clojure/tools.namespace "0.2.4"] | |
[leiningen #=(leiningen.core.main/leiningen-version)] | |
[im.chit/vinyasa "0.3.4"]] | |
:injections | |
[(require '[vinyasa.inject :as inject]) |
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
#!/usr/bin/env bash | |
# | |
# Save to /usr/bin/into | |
# | |
# Usage: into output.txt tac input.txt | |
# | |
set -euo pipefail | |
to="$1" |
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
#!/usr/bin/env bash | |
# | |
# You need gnumeric installed, which provides the | |
# ssconvert tool (on Ubuntu: sudo apt-get install gnumeric) | |
# | |
# Usage: | |
# | |
# generate_csv | csv2xls > out.xls |
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
these derivations will be built: | |
/nix/store/cqqqv7mv1b3v33bjrrvg5xqyf71wa1j5-go1.5-crypto-2015-08-29.drv | |
building path(s) ‘/nix/store/6r1jzp8lvnlg9winakiz96di9ddqjqfd-go1.5-crypto-2015-08-29’, ‘/nix/store/vwxj59hfils0340fz0mibmigrrl157vx-go1.5-crypto-2015-08-29-bin’ | |
unpacking sources | |
unpacking source archive /nix/store/bz8pb5lwcghk9mv8slwxgsykymm4gl0q-crypto-d5c5f1769f2fcd2377be6f29863081f59a4fc80f-src | |
source root is crypto-d5c5f1769f2fcd2377be6f29863081f59a4fc80f-src | |
patching sources | |
configuring | |
building | |
golang.org/x/crypto/blowfish |
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
#!/usr/bin/env bash | |
# nuke-certs | |
# | |
# | |
# This script has been reported to help with errors like | |
# | |
# this: | |
# + xcodebuild -exportArchive -exportOptionsPlist /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-14bt0ur_config.plist -archivePath '/Users/pe/Library/Developer/Xcode/Archives/2016-02-16/016-02-16 12.09.02.xcarchive' -exportPath /var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/gym20160216-41694-17mfck9.gym_output | |
# 2016-02-16 12:10:03.004 xcodebuild[43629:464102] [MT] IDEDistribution: -[IDEDistributionLogging _createLoggingBundleAtPath:]: Created bundle at path '/var/folders/rj/8lnf662s3mlgzv5mcq2r2fnc0000gn/T/016-02-16_12-10-03.003.xcdistributionlogs'. |
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 group-by-keys | |
"Group maps by a set of keys. For each key not grouped, all values are | |
returned as a set" | |
[ms kys] | |
(let [kys (set kys) | |
grouped (group-by #(select-keys % kys) ms)] | |
(map (fn [[pk pv]] | |
(into pk | |
(reduce (fn [a [k v]] (update a k #(conj (or % #{}) v))) | |
{} |
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 background | |
(:require [clojure.tools.logging :as log]) | |
(:import [java.util.concurrent])) | |
(defonce !executor (delay (java.util.concurrent.Executors/newCachedThreadPool))) | |
(defn background | |
"Calls the fn passed in a thread from a thread pool, returning immediately. | |
Unlike future, background does not swallow exceptions." | |
[f] |
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
;; Display arbitrary EDN-like values in a browser | |
;; | |
;; See https://github.com/yogthos/json-html | |
;; | |
;; in project.clj / build.boot: | |
;; [json-html "0.3.9"] | |
;; [hiccup "1.0.5"] | |
(require '[json-html.core :as jh] | |
'[hiccup.page]) |
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
;; Show history of an entity | |
;; | |
;; useful for interactively inspecting what happened to a datomic entity in its lifetime | |
;; | |
;; use `entity-history` to get a list of transactions that have touched the entity (assertions, retractions) | |
;; | |
;; use `explain-tx` to find out what else was transacted in the txs | |
(defn entity-history | |
"Takes an entity and shows all the transactions that touched this entity. |