Skip to content

Instantly share code, notes, and snippets.

View TimoKramer's full-sized avatar

Timo Kramer TimoKramer

View GitHub Profile
@TimoKramer
TimoKramer / core.clj
Last active February 18, 2021 08:41
cljs-ajax issue 257 reproduce
(ns redirect_gist.core
(:require [reitit.ring :as ring]
[reitit.coercion.spec]
[reitit.core :as r]
[ring.adapter.jetty :as jetty]
[ajax.core :refer [GET]]))
(def app
(ring/ring-handler
(ring/router
@TimoKramer
TimoKramer / benchmark.edn
Created February 8, 2021 15:24
benchmark datahike with stuff running on my machine
[{:db-config
{:schema-flexibility :write,
:keep-history? true,
:index :datahike.index/hitchhiker-tree,
:dh-backend :file},
:function :transaction,
:db-size 0,
:tx-size 10,
:mean-time 4.4561443}
{:db-config
@TimoKramer
TimoKramer / fib_backoff.clj
Last active December 16, 2020 18:48
Fibonacci Backoff
(defn fib [a b]
(lazy-seq (cons a (fib b (+ a b)))))
(defn fib-backoff [exec-fn test-fn]
(loop [retries (take 10 (fib 1 2))]
(let [result (exec-fn)]
(if (test-fn result)
result
(when-let [sleep-ms (first retries)]
@TimoKramer
TimoKramer / macroraise.clj
Last active July 14, 2020 11:06
Using Timbre and a Clojure Macro to centralise logging and error handling
(ns macroraise
(:require
[taoensso.timbre :as log]))
(defmacro raise [& fragments]
@TimoKramer
TimoKramer / monads.py
Created April 19, 2020 19:33 — forked from lispyclouds/monads.py
Monads: Simple made Easy.
from functools import reduce
class Maybe(object):
def __str__(self):
return "Maybe"
class Something(Maybe):
def __init__(self, value):
@TimoKramer
TimoKramer / search-geocode.cljs
Created March 29, 2018 10:27
search for geocode with semantic-ui react reagent re-frame
;; https://opensourcery.co.za/2017/02/12/using-semantic-ui-react-with-re-frame/
(def semantic-ui js/semanticUIReact)
(defn component
"Get a component from sematic-ui-react:
(component \"Button\")
(component \"Menu\" \"Item\")"
[k & ks]
(if (seq ks)
(defn set-active-page-handler
"the handler for the event-function :set-active-page"
[db page slug]
(let [set-page (assoc db :page page)]
(case page
:home {:db set-page}
(:login :register :settings) {:db set-page}
:tours {:db set-page
:dispatch [:get-tours]}
:editor {:db set-page
@TimoKramer
TimoKramer / keybase.md
Created April 13, 2017 15:17
keybase proof of ownership

Keybase proof

I hereby claim:

  • I am timokramer on github.
  • I am timokramer (https://keybase.io/timokramer) on keybase.
  • I have a public key ASD2xI8bRkOquchUTszS5wg29DLTq5gYh9uRVBtLVOBPGQo

To claim this, I am signing this object:

@TimoKramer
TimoKramer / mdl_info.fact
Last active March 22, 2016 08:42
a custom facts script that returns a long cluttered string instead of valid json
#!/bin/bash
#{{ ansible_managed }}
### extracting information from moodle instances
cd /home/vhosts/moodle
function getinstances() {
MDL_INSTANCES=`find * -maxdepth 0 -not -name "_*" |xargs echo`
}