Skip to content

Instantly share code, notes, and snippets.

View ordnungswidrig's full-sized avatar

Philipp Meier ordnungswidrig

View GitHub Profile
@ordnungswidrig
ordnungswidrig / babash.bb
Last active November 16, 2023 01:52
A very basic shell implemented in babashka
#!/usr/bin/env rlwrap bb -i
;; needs babashka beta
(defn ^sun.misc.Signal ->signal
"Convert a keyword to an appropriate Signal instance."
[signal]
(sun.misc.Signal. (-> signal name .toUpperCase)))
(defn ^Long signal->number
@ordnungswidrig
ordnungswidrig / .git_hooks_commit-msg
Created May 26, 2014 19:59
Git commit-msg hook to check for maximum line lengths
#!/bin/sh
#
# .git/hooks/commit-msg
#
# Check for maximum line lengths
#
# A git hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
@ordnungswidrig
ordnungswidrig / day-01.sh
Last active December 4, 2021 17:21
AoC-2021 - pointfree - threading
# part one
pbpaste | bb -I -e '(->> (-> *input* (#(vector % %)) (update 1 rest)) (apply map <) (filter true?) count)'
# part two
pbpaste | bb -I -e ' (->> *input* (iterate rest) (take 3) (apply map +) (#(vector % %)) (#(update % 1 rest)) (apply map <) (filter true?) count)'
@ordnungswidrig
ordnungswidrig / microweb.cljs
Created December 10, 2019 11:12
Webserver in clojurescript on espruino
(set! *warn-on-infer* true)
(def ^js wifi (js/require "Wifi"))
(def ^js http (js/require "http"))
(def n (atom 0))
(defn build-response []
(str
"<html>"
@ordnungswidrig
ordnungswidrig / compile-upload.sh
Created November 26, 2019 02:23
clojurescript on esp32
clj -m cljs.main -O advanced -co '{:infer-externs true}' --output-to main.js
echo "Upload with"
echo "espruino main.js"
echo "Or use the Espruino web IDE"
{-# LANGUAGE DuplicateRecordFields #-}
-- how to resolve the duplication in CreateUser, BasicUser and UpdateUser
-- without changing everything to `Maybe String`?
data Address = Address { street :: String
, zip :: String
, city :: String
, state :: String
} deriving (Show)
@ordnungswidrig
ordnungswidrig / pres.el
Created December 4, 2018 19:46
presentation helper for live demo in emacs
(defun c6e/pres-forward ()
(interactive)
(let ((saved (point)))
(forward-line)
(let ((beg (point)))
(search-forward-regexp "^;;; " nil t)
(if (= beg (point))
(goto-char saved)
(progn
(recenter 0)
@ordnungswidrig
ordnungswidrig / gherkinqqwertzde7.json
Created June 27, 2017 13:13
Gherkin german QWERTZ layout
{"version":1,"keyboard":{"keys":[{"id":0,"legend":"Q","state":{"x":0,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":0,"keycodes":[{"id":"LT()","fields":[1,{"id":"KC_Q","fields":[]}]},{"id":"KC_F1","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_NO","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]}]},{"id":1,"legend":"W","state":{"x":1,"y":0,"r":0,"rx":0,"ry":0,"w":1,"h":1,"x2":0,"y2":0,"w2":0,"h2":0},"row":0,"col":1,"keycodes":[{"id":"LT()","fields":[3,{"id":"KC_W","fields":[]}]},{"id":"KC_F2","fields":[]},{"id":"KC_MSTP","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","fields":[]},{"id":"KC_TRNS","f
@ordnungswidrig
ordnungswidrig / handler-protocol.clj
Created June 22, 2011 22:27
Define events a protocol methods
;; On my journey into event sourcing in clojure I'm trying different approaches
;; of modeling events and event handling in clojure.
;; A little ceremony to pay homage to the gods of clojure:
(ns handler-protocol
(:use clojure.contrib.trace)
(:use clojure.pprint)
(:use clojure.test))
;; My example problem domain for this will be a very simple sketch of twitter.
#include "bootloader.h"
#include "keymap_common.h"
const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KEYMAP( // Layer 0
ESC, 1, 2, 3, 4, 5, EQL, // 7
TAB, Q, W, E, R, T, FN1, // 7
LCTRL, A, S, D, F, G, // 6
LSFT, Z, X, C, V, B, FN2, // 7
FN3, NONUS_BSLASH, LCTRL, LALT, LGUI, // 5 L3