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 webserver-ssl-context | |
(:require [clojure.java.io :as io] | |
[clojure.string :as str] | |
) | |
(:import (java.security KeyFactory KeyStore) | |
(java.security.spec X509EncodedKeySpec) | |
[javax.xml.bind DatatypeConverter])) | |
(defn parse-der-from-pem [pem begin-delimiter end-delimiter] |
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 mutable-clock | |
(:import (java.time Clock Duration Instant ZoneId))) | |
(definterface MutableClock | |
(setZone [zone]) | |
(setInstant [instant])) | |
(defn mutable-clock [_instant _zone] | |
(let [instant-atom (atom _instant) | |
zone-atom (atom _zone)] |
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 com.widdindustries.minimal-ssl-context | |
(:import (java.security SecureRandom) | |
(javax.net.ssl SSLContext X509ExtendedTrustManager))) | |
(let [context (SSLContext/getInstance "TLS")] | |
(.init context nil | |
(into-array [(proxy [X509ExtendedTrustManager] [] | |
(checkClientTrusted [& _]) | |
(checkServerTrusted [& _]))]) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>demo</title> | |
</head> | |
<body> | |
<div id="app" style="min-height:100%"> | |
Hello world! |
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 rounding-numbers | |
"teaching my child how to get a computer to do their maths homework" | |
) | |
(defn round-number [original round-to] | |
(let [small-bit (mod original round-to) | |
round-up? (>= small-bit (* 5 (/ round-to 10))) | |
medium-bit (mod original (* 10 round-to)) | |
number-that-goes-up-or-stays-the-same (- medium-bit small-bit) | |
big-bit (- original medium-bit)] |
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 com.widdindustries.kaocha-cljs2-ns-pattern-hook | |
"the only way I can find to filter kaocha-cljs2 tests by pattern. see comment block for usage" | |
(:require [kaocha.core-ext :as core-ext] | |
[kaocha.load :as load])) | |
(defn ns-filter [plan] | |
;(def plan plan) | |
;(println "About to start loading!") | |
(update plan :kaocha.test-plan/tests |
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 protocol-proxy | |
"for when you have an object foo, which satisfies some protocols and you want to make adhoc changes to | |
one or more of the protocol methods, but just on foo. | |
Can be handy for testing. | |
" | |
(:refer-clojure :exclude [proxy]) | |
(:require [clojure.string :as string])) | |
;(remove-ns 'protocol-proxy) |
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 async-play | |
(:require [manifold.stream :as ms] | |
[clojure.core.async :as a])) | |
(comment ; memory leak. puts are queued up indefinitely | |
(def s (ms/stream)) | |
(dotimes [n 100] | |
(ms/put! s n)) | |
(ms/consume println s) |
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 contiguous-spans | |
"takes pre-sorted dates and returns contiguous periods contained therein. | |
see comment block for demo | |
" | |
(:require [tick.core :as t])) | |
(defn contiguous-spans | |
"takes pre-sorted dates and returns contiguous periods contained. | |
dates a and b are contiguous if a plus span-length is equal to b " |
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/local/bin/bb | |
(import '[java.io ByteArrayOutputStream]) | |
(import '[java.util Base64]) ; | |
(import '[java.util.zip Inflater]) ; | |
(defn uncompress [source-bytes] | |
(let [inflater (doto (Inflater.) | |
(.setInput source-bytes)) | |
outputStream (new ByteArrayOutputStream (count source-bytes)) |
NewerOlder