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
package com.example; | |
import static java.util.Collections.*; | |
import java.util.Collection; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Set; | |
import java.util.concurrent.TimeUnit; |
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 dynamic.test | |
(:require [clojure.test :refer :all])) | |
;; This example shows how tests can be generated dynamically, by | |
;; creating new vars with the correct metadata. | |
(defn add-test | |
"Add a test to the given namespace. The body of the test is given as | |
the thunk test-fn. Useful for adding dynamically generated deftests." | |
[name ns test-fn & [metadata]] |
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 | |
# Generates this kind of thing: | |
# https://github.com/joelittlejohn/jsonschema2pojo/blob/master/CHANGELOG.md | |
# | |
# If your issue has 'breaking' label, the issue will be shown in the changelog with bold text | |
# | |
# All versions of this script are dedicated to the Public Domain, no rights reserved, | |
# as per https://creativecommons.org/publicdomain/zero/1.0/ | |
# | |
if [ "$#" -ne 2 ]; then |
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 | |
for f in $(egrep -o -R "defn?-? [^ ]*" * --include '*.clj' | cut -d \ -f 2 | sort | uniq); do | |
echo $f $(grep -R --include '*.clj' -- "$f" * | wc -l); | |
done | grep " 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
[ "$(find ~/.rotate -mtime -7 2>/dev/null)" ] || (for p in $(aws-vault list --profiles | grep -v default | grep -v mfa); do aws-vault rotate -n $p; done && touch ~/.rotate) |
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
(def t | |
"trie containing the 100,000 most common english words" | |
(with-open [r (clojure.java.io/reader "/tmp/words-100000")] | |
(reduce #(assoc-in %1 %2 (sorted-map \0 nil)) (sorted-map) (line-seq r)))) | |
(defn search [p m] | |
"return a sorted sequence of all words in the trie m that start with the given prefix p" | |
(let [n (get-in m p) | |
next (mapcat #(search (str p (key %)) m) (dissoc n \0))] | |
(if (contains? n \0) (cons p next) next))) |
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
<?php | |
$wgExtensionCredits['parserhook'][] = array( | |
'name' => 'WebServiceSequenceDiagram', | |
'version' => '1.0', | |
'author' => 'Eddie Olsson', | |
'url' => 'http://www.mediawiki.org/wiki/Extension:WebSequenceDiagram', | |
'description' => 'Render inline sequence diagrams using websequencediagrams.com' | |
); | |
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { |
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
echo "# Contributors" > CONTRIBUTORS.md && git log --pretty=tformat:"* %an <%ae>" | tac | awk ' !x[$0]++' >> CONTRIBUTORS.md |
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
(let [digits (into [] (map char (concat (range 48 58) (range 65 91) (range 97 123)))) ;; 0-9,A-Z,a-z | |
base (biginteger (count digits)) | |
entropy 64] | |
(defn id [] | |
(loop [id10 (BigInteger. entropy (java.security.SecureRandom.)) | |
id62 ""] | |
(if (and (<= id10 (BigInteger/ZERO)) (seq id62)) | |
id62 | |
(let [[d r] (.divideAndRemainder id10 base)] | |
(recur d (str id62 (digits (.intValue r))))))))) |
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 merge-ascii | |
(:require [clojure.java.io :refer [reader writer]])) | |
(defn choose-char [a b] | |
(cond (nil? a) b | |
(nil? b) a | |
(not= b \space) b | |
:else a)) | |
(defn merge [a b out] |
NewerOlder