Conceptualized by Alistair Cockburn. Also known as "Ports and Adapters".
In a nutshell:
Application Driver -> Primary Adapter -> Primary Port -> Use Case -> Secondary Port -> Secondary Adapter -> External System/Side Effect
#!/usr/bin/env python3 | |
""" | |
License: MIT License | |
Copyright (c) 2023 Miel Donkers | |
Very simple HTTP server in python for logging requests | |
Usage:: | |
./server.py [<port>] | |
""" | |
from http.server import BaseHTTPRequestHandler, HTTPServer |
Set p Ruby, Bundler and a project-level Jekyll on macOS Catalina and up
This guide is for macOS Catalina and is based on the Jekyll on macOS doc and my experience.
Use the XCode CLI to install dev tools. Recommended so that you can install native extensions when installing gems.
(defn posts-after [post-id] | |
(slurp (str "https://grumpy.website/after/" post-id))) | |
(defn get-post-ids [posts] | |
(->> posts | |
(re-seq #"data\-id=\"(.+?)\"") | |
(map second))) | |
(defn post-ids [start-id] | |
(loop [post-ids [start-id] |
(defn take-first-sorted-by | |
"Performs the same result as (take n (sort-by keyfn comp coll)) | |
but more efficient in terms of time and memory" | |
([n keyfn coll] (take-first-sorted-by n keyfn compare coll)) | |
([n keyfn ^java.util.Comparator comp coll] | |
(if (pos? n) | |
(let [m ^java.util.TreeMap (java.util.TreeMap. comp) | |
m-size (volatile! 0) | |
;; if it is guaranteed that (keyfn v) will be unique for all v in coll | |
;; we can attach :unique? key to keyfn meta and algorythm will use single val map |
#!/usr/bin/env bb | |
(require '[clojure.java.io :as io]) | |
(require '[bencode.core :refer [read-bencode]]) | |
(require '[clojure.walk :refer [prewalk]]) | |
(require '[clojure.pprint :refer [pprint]]) | |
(import 'java.io.PushbackInputStream) | |
(defn bytes->strings [coll] | |
(prewalk #(if (bytes? %) (String. % "UTF-8") %) coll)) |
(defn fizzbuzz [n] | |
(let [fizzes (cycle ["" "" "Fizz"]) | |
buzzes (cycle ["" "" "" "" "Buzz"]) | |
pattern (map str fizzes buzzes) | |
numbers (map str (rest (range)))] | |
(take n (map #(some not-empty %&) pattern numbers)))) ;; another option would be `(partial max-key count)` | |
(run! println (fizzbuzz 100)) |
.vscode/ | |
.lsp/ | |
.calva/ | |
.clj-kondo/cache/ |
// Place your key bindings in this file to overwrite the defaults | |
[ | |
{ | |
"key": "cmd+enter", | |
"command": "clojureVSCode.evalAndShowResult" | |
}, | |
{ | |
"key": "cmd+k cmd+e", | |
"command": "clojureVSCode.eval" | |
}, |