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 valid-window? | |
[terms m] | |
(every? #(>= (get m % 0) 1) terms)) | |
(defn full-position | |
[coll idx] | |
(first (nth coll idx))) | |
(defn min-window | |
"Given a set of terms and sequence of tokens, find the minimum window (in |
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
-module(ring). | |
-export([start/2]). | |
%% Write a ring benchmark. Create N processes in a ring. Send a message round | |
%% the ring M times so that a total of N * M messages get sent. Time how long | |
%% this takes for different values of N and M. | |
start(M, N) -> | |
[P|_] = create_ring(N), | |
T1 = erlang:monotonic_time(microsecond), |
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
(require 'cl-lib) | |
(require 'subr-x) | |
(defun *-ini-sort () | |
"Sort an INI buffer by sections and properties. | |
Combines repeated sections. E.g. | |
[b] | |
b1=1 | |
b3=3 |
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
(require 'cl-lib) | |
(require 'cider-test) | |
(defcustom carpenter-threshold 3 | |
"Number of times a CIDER test can fail consecutively before | |
you're told to become a carpenter." | |
:type 'integer) | |
(defvar carpenter-fail-counts (make-hash-table :test #'equal)) |
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
function rm-old-images() { | |
IMAGESINFO=$(sudo docker images --no-trunc --format '{{.ID}} {{.Repository}} {{.Tag}} {{.CreatedSince}}' |grep -E " (weeks|months|years)") | |
TAGS=$(echo "$IMAGESINFO" | awk '{ print $2 ":" $3 }' ) | |
IDS=$(echo "$IMAGESINFO" | awk '{ print $1 }' ) | |
for t in $TAGS; do sudo docker rmi $t; done | |
for i in $IDS; do sudo docker rmi $i; done | |
} |
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 two-deep [_] | |
"two-deep") | |
(defn other-two-deep [_] | |
"other-two-deep") | |
(defn one-deep [& args] | |
(map two-deep args)) | |
(defn foo [] |
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
(defun *-markdown-table-align (beg end) | |
(interactive (list (org-table-begin) (org-table-end))) | |
(save-excursion | |
(align-regexp beg end "\\(\\)|" 1 0 t) | |
(goto-char beg) | |
(re-search-forward "|---" end t) | |
(subst-char-in-region (line-beginning-position) | |
(line-end-position) | |
?\s ?- t))) |
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
;; Debugger == interactive restarter | |
;; If we try to open a non-existent file, we are put into the debugger | |
(with-open-file (in "nonexistent-file.txt") | |
(format t "~A~%" (read-line in nil))) | |
;; The debugger offer a restart that retries the evaluation | |
(with-open-file (str "nonexistent-file.txt" | |
:direction :output) | |
(format str "This file now exists.")) |