Skip to content

Instantly share code, notes, and snippets.


Bran van der Meer branneman

View GitHub Profile
branneman / http-easy.rkt
Last active Jun 29, 2021
Racket: How to do HTTP requests
View http-easy.rkt
#lang racket/base
(define (base-url path)
(string-append "" path))
; request: GET
; response: plain string body
branneman / 1-web-server.rkt
Last active Jun 21, 2021
Racket: Example web-server which renders markdown
View 1-web-server.rkt
#lang racket/base
branneman / 0-syntax.rkt
Last active May 24, 2021
Racket: Macro's
View 0-syntax.rkt
#lang racket/base
(require (for-syntax racket/base))
; Reading Quotes
; see:
; ' quote #' syntax
; ` quasiquote #` quasisyntax
; , unquote #, unsyntax
; ,@ unquote-splicing #,@ unsyntax-splicing

Automate backups: Nextcloud to S3


  • Disk space: at least 3× the size of the /var/www/nextcloud directory is available on /var/backups
  • Nextcloud is installed into /var/www/nextcloud as user www-data
  • AWS cli is installed and configured with credentials
  • mysqldump is installed
  • rsync is installed


branneman / radicals.json
Created Jun 9, 2020
JSON list of 214 Simplified Chinese Radicals, data contains radical number, pinyin, english translation, stroke count
View radicals.json
"id": 1,
"radical": "",
"pinyin": "",
"english": "one",
"strokeCount": 1
"id": 2,
View snake.clj
(ns main (:gen-class))
;; Snake :: [[int int]…]
;; vector of x,y tuples
;; head is first, tail is last
;; out-of-bounds? :: (int int int) -> bool
;; grid-size is 1-indexed, x+y are 0-indexed
(defn out-of-bounds? [grid-size x y]
(or (neg? x) (neg? y) (>= x grid-size) (>= y grid-size)))

List of all Clojure Predicate functions

A predicate function returns a boolean true or false, and it's name ends with a ?. Ran against Clojure 1.10.0.

({:ns clojure.string,
  ({:fn ends-with?, :arglists ([s substr])}
   {:fn starts-with?, :arglists ([s substr])}
   {:fn includes?, :arglists ([s substr])}
branneman / solution1.js
Last active Aug 5, 2019
Declarative asynchonous control flow: promises, observables, futures
View solution1.js
const wrapPromise = fn => (...args) =>
new Promise(resolve => setTimeout(
() => resolve(fn(...args)),
Math.floor(Math.random() * 1500) + 250)
const upper = wrapPromise(str => str.toUpperCase())
const underline = str => `__${str}__`
const exclamate = wrapPromise(str => str + '!')
// Util: Create promise chain
branneman / coupling.js
Last active Jul 4, 2021
JavaScript examples: No coupling, Loose coupling, Tight coupling
View coupling.js
// Tight coupling from A to B => A needs B to be defined, callable and adhere to an interface
// No coupling from B to A => B does not need A in any way (pure fn)
function a() { b() }
function b() {}
// No coupling from A to B => A and B work independently,
branneman /
Last active Apr 23, 2019
Run Debian as docker container

Run Debian as docker container


Start a container in detached mode:

docker run -dit --name deb -e "LANG=C.UTF-8" -w "/root" debian:latest bash

Connect to it and do initial setup: