Skip to content

Instantly share code, notes, and snippets.

Freek Paans FreekPaans

Block or report user

Report or block FreekPaans

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
FreekPaans / find-thread-by-id.clj
Created Feb 18, 2019
find a thread by id in clojure
View find-thread-by-id.clj
(defn find-thread-by-id [thread-id]
(let [ts (make-array Thread 1000)]
(-> (Thread/currentThread) .getThreadGroup .getParent (.enumerate ts))
(->> ts
(filter (comp not nil?))
(filter #(= thread-id (.getId %)))
View caps-to-escape.reg
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,01,00,3a,00,00,00,00,00
FreekPaans /
Created Dec 11, 2017
bash function which generates a json based on arguments
#!/usr/bin/env bash
# Usage: make_event my-event test "hello world" -> {"name":"my-event","test":"hello world","unixtime":123}
make_event() {
if ! (( "$#" % 2)); then
echo "log_event expects an uneven number of arguments"
echo "Usage: $0 <event-name> [[<key> <val>]...]"
exit 1
View start-it.clj
(start-server (fn []
[(LoggingHandler. "proxy" LogLevel/INFO)
(proxy-handler "" 80)
FreekPaans / zfs.conf
Created Jul 27, 2016
zabbix agent configuration file for monitoring zpool health and errors
View zfs.conf
# Adapted from[*],zpool list $1 | grep ONLINE | wc -l
UserParameter=zpool.error-free[*],zpool status $1 | grep ONLINE | grep -v " state" | awk '$$3==0 && $$4==0 && $$5==0 {print}' | wc -l
View csrf.php
//double submit cookies ( CSRF protection
define(__CSRF_TOKEN_INPUT_NAME, "__csrf_token");
function generate_csrf_token() {
View application-service-tests.clj
(ns layered-example.application-service-test
(:require [ :as test-helpers]
[clojure.test :refer :all]
[layered-example.application-service :as app-svc]
[layered-example.domain.cargo.cargo-repository :as cargo-repository]
[ :as mysql-cargo-repository]))
(def db-spec (test-helpers/default-db-spec))
(def the-cargo-repo (mysql-cargo-repository/new-cargo-repository db-spec))
View application-service.clj
(ns layered-example.application-service
(:require [layered-example.domain.cargo.cargo :as cargo]
[layered-example.domain.cargo.cargo-repository :as cargo-repository]))
(defn create-new-cargo! [& args ]
(let [new-cargo (apply cargo/create-new-cargo args)]
(cargo-repository/add! new-cargo)))
(defn book-onto-voyage! [cargo-id & args]
(let [{:keys [version cargo] :as result} (cargo-repository/find cargo-id)
View mysql-cargo-repository.clj
(:refer-clojure :exclude [find])
(:require [layered-example.domain.cargo.cargo-repository :refer [CargoRepository -find -add! -update!]]
[layered-example.domain.cargo.cargo :refer [map->Cargo set-cargo-id]]
[clojure.set :refer [rename-keys]]
[ :as db]))
(defn row->cargo [row]
(-> row
(select-keys [:id :size :voyage_id])
View cargo-repository.clj
(ns layered-example.domain.cargo.cargo-repository
(:refer-clojure :exclude [find]))
(def find nil)
(def add! nil)
(def update! nil)
(defprotocol CargoRepository
(-find [this cargo-id])
(-add! [this a-cargo])
You can’t perform that action at this time.