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 junit | |
| "could see as a modern replacement for lein-junit, which afaik does junit 4 at most. | |
| find and run some junit tests from clojure. | |
| deps required are junit-jupiter, junit-jupiter-engine, junit-platform-launcher and junit-platform-reporting | |
| " | |
| (:require [clojure.java.io :as io]) | |
| (:import (java.nio.file Paths) | |
| (org.junit.platform.engine.discovery DiscoverySelectors) |
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
| [{"key": "f1", "command": "type", | |
| "args": { "text": "(" }, | |
| "when": "editorTextFocus & !editorReadonly"} | |
| ] |
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 create-zip-archive | |
| (:import (java.net URI) | |
| (java.nio.charset StandardCharsets) | |
| (java.nio.file FileSystem FileSystems Files Paths StandardOpenOption))) | |
| (let [path (Paths/get "test.zip" (make-array String 0)) | |
| uri (URI/create (str "jar:" (.toUri path)))] | |
| (with-open [fs (FileSystems/newFileSystem uri {"create" "true"})] | |
| (let [nf (FileSystem/.getPath fs "new.txt" (make-array String 0))] | |
| (with-open [writer (Files/newBufferedWriter nf, StandardCharsets/UTF_8, (into-array [StandardOpenOption/CREATE]))] |
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 git-analyze | |
| (:require [clojure.java.process :as process] | |
| [clojure.string :as string] | |
| [com.widdindustries.tempo :as tempo])) | |
| (defn changed-files [] | |
| (->> | |
| (process/exec "git" "log" "--pretty=%x0a%cI" "--name-only" "--date=iso") | |
| (string/split-lines) | |
| (remove string/blank?) |
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 flexi-clock | |
| (:import (java.time Clock Duration Instant ZonedDateTime))) | |
| (defn clock | |
| "potential library function (e.g. in tick or tempo). | |
| This just implements the platform Clock - which works because non-test code only uses that API. | |
| Any manipulation of time (which happens in testing code) is done via changing | |
| what get-instant and get-zone return" | |
| [get-instant get-zone] |
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 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 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 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 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 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 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
| <!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 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 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)] |
NewerOlder