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 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 |
A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.
How to use:
Summary
package parse; | |
import com.fasterxml.jackson.core.JsonFactory; | |
import com.fasterxml.jackson.core.JsonParser; | |
import com.fasterxml.jackson.core.JsonToken; | |
import com.fasterxml.jackson.databind.JsonNode; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import java.io.File; | |
import java.io.IOException; |
(ns react-fun.part1) | |
;;Deconstructing React | |
;; v = f (d) | |
----- Esc ----- | |
Quick change directory: Esc + c | |
Quick change directory history: Esc + c and then Esc + h | |
Quick change directory previous entry: Esc + c and then Esc + p | |
Command line history: Esc + h | |
Command line previous command: Esc + p | |
View change: Esc + t (each time you do this shortcut a new directory view will appear) | |
Print current working directory in command line: Esc + a | |
Switch between background command line and MC: Ctrl + o | |
Search/Go to directory in active panel: Esc + s / Ctrl + s then start typing directory name |
#!/usr/bin/env bash | |
size=1024 # MB | |
mount_point=$HOME/tmp | |
name=$(basename "$mount_point") | |
usage() { | |
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \ | |
"(default: mount)" >&2 | |
} |
from bottle import route, run, install | |
from bottle_sqlite import SQLitePlugin | |
install(SQLitePlugin(dbfile='bottle.db')) | |
@route('/db/') | |
def database(db): | |
data = db.execute('SELECT SQLITE_VERSION()').fetchone() | |
print "SQLite version: %s" % data |