Skip to content

Instantly share code, notes, and snippets.


Jochen Bedersdorfer beders

View GitHub Profile
rickerbh / octopress-to-cryogen.clj
Created July 26, 2020 06:40
Babashka script to port posts from jekyll/octopress format to cryogen
View octopress-to-cryogen.clj
(require '[ :as io]
'[clojure.string :as string]
'[ :refer [parse-opts]])
(def cli-options
[["-o" "--out DIR" "Output directory"
:default "out"]
["-s" "--source SOURCE" "Source directory"
:default "source/_posts"]
["-h" "--help"]])
zoren / download-blob.cljs
Created June 18, 2020 15:21
Download a BLOB via a object URL in ClojureScript
View download-blob.cljs
;; heavily inspired by Mariano Guerra
(defn download-blob [file-name blob]
(let [object-url (js/URL.createObjectURL blob)
(doto (js/document.createElement "a")
(-> .-href (set! object-url))
(-> .-download (set! file-name)))]
(.appendChild (.-body js/document) anchor-element)
(.click anchor-element)
lispyclouds / monads.clj
Last active May 17, 2020 02:37
Monads, simple made easier
View monads.clj
; A simple demo of monadic composition of side effects
; Program to take 3 nubers as input and print their sum.
(defn read-and-add!
(print "Enter a number: ")
(+ prev (do (flush)
(Integer/parseInt (read-line)))))
(defn bind
sudodoki / flatten-maps.clj
Last active June 9, 2020 17:33
Flatten nested maps using clojure / clojurescript using compound keys
View flatten-maps.clj
(defn get-key
[prefix key]
(if (nil? prefix)
(str prefix "-" key)))
(defn flatten-map-kvs
([map] (flatten-map-kvs map nil))
([map prefix]
(fn [memo [k v]]
ravihara / jjs-require.js
Created January 13, 2016 13:23
CommonJS require function implementation for Nashorn / Java8
View jjs-require.js
// Based on
"use strict";
(function() {
var System = java.lang.System,
File =,
FileInputStream =,
StringBuilder = java.lang.StringBuilder,
BufferedReader =,
InputStreamReader =;
CraZySacX / git.clj
Last active November 24, 2020 19:23
Clojure git wrapper
View git.clj
(ns org.ozias.git
(:require [me.raynes.conch :refer (with-programs)]))
(def ^:private git-porcelain
["add" "am" "bisect" "branch" "bundle" "checkout" "cherry-pick" "citool"
"clean" "clone" "commit" "describe" "diff" "fetch" "format-patch"
"gc" "grep" "gui" "init" "log" "merge" "mv" "notes" "pull" "push"
"rebase" "reset" "revert" "rm" "shortlog" "show" "stash" "status"
"submodule" "tag"])
hiredman / boot.cljs
Created March 15, 2013 04:43
clojurescript drag and drop
View boot.cljs
(defn handle-file-select [evt]
(.stopPropagation evt)
(.preventDefault evt)
(let [files (.-files (.-dataTransfer evt))]
(dotimes [i (.-length files)]
(let [rdr (js/FileReader.)
the-file (aget files i)]
(set! (.-onload rdr)
(fn [e]
(let [file-content (.-result (.-target e))
jboner / latency.txt
Last active March 30, 2023 19:11
Latency Numbers Every Programmer Should Know
View latency.txt
Latency Comparison Numbers (~2012)
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
jneira / express-sample.cljs
Created August 25, 2011 20:07
Clojurescript / node.js basic examples
View express-sample.cljs
(ns express_sample
(:require [cljs.nodejs :as node]))
(def express (node/require "express"))
(def app (. express (createServer)))
(defn -main [& args]
(doto app
(.use (. express (logger)))
(.get "/" (fn [req res]