Skip to content

Instantly share code, notes, and snippets.

View Kah0ona's full-sized avatar

Marten Sytema Kah0ona

View GitHub Profile
@Kah0ona
Kah0ona / uppy.cljs
Created December 9, 2021 19:08
Uppy example in clojurescript
(ns my.namespace.uppy
(:require [re-frame.core :as rf]
[reagent.core :as r]
[cs2.handlers :refer [debug-panel]]
[cs2.i18n :refer [tr]]
[clojure.string :as string]
[cs2.util :as util]
[cs2.components.widgets.modal :as modal]
[taoensso.timbre :refer [debug info error fatal warn]]))
@Kah0ona
Kah0ona / fails.clj
Created March 9, 2021 08:42
catching asserts inside a future body fails silently, but why?
(future
(try
(println "inside future body")
(assert false) ;;
(catch Exception e
(println "error" (.getMessage e))))) ;; no error printed
(try ;; not in a future, but just normal
(println "inside future body")
(ns user
(:require [clojure.string :as string]))
(defn ⁵
"Returns n to the fifth power.
Note we use the UTF-character of superscript-5 as function name, because we can. ;-)"
[n]
(let [sq (* n n)]
(* sq sq n)))
@Kah0ona
Kah0ona / script.clj
Created March 29, 2020 15:09
Clojure script to count number of chats per person from WhatsApp export
(ns user
(:require [clojure.string :refer [lower-case includes? trim]]))
(defn parse-line
"Returns the name of the message, or nil if it can't be found"
[l]
(->> l
trim
(re-find #"\[.{19}\].(.[A-Za-z\ \-]+):")
second))
@Kah0ona
Kah0ona / half_marathon.txt
Created November 21, 2019 10:55
paces halve marathon
| :time | :pace | :speed |
|----------+-------------+-----------|
| 01:20:00 | 3:47 min/km | 15.8 km/h |
| 01:20:11 | 3:48 min/km | 15.8 km/h |
| 01:20:32 | 3:49 min/km | 15.7 km/h |
| 01:20:53 | 3:50 min/km | 15.6 km/h |
| 01:21:14 | 3:51 min/km | 15.6 km/h |
| 01:21:35 | 3:52 min/km | 15.5 km/h |
| 01:21:56 | 3:53 min/km | 15.4 km/h |
| 01:22:17 | 3:54 min/km | 15.4 km/h |
@Kah0ona
Kah0ona / marathonpaces.txt
Created November 10, 2019 13:06
Marathon paces
| 02:48:47 | 4:00 min/km | 15.0 km/h |
| 02:49:29 | 4:01 min/km | 14.9 km/h |
| 02:50:11 | 4:02 min/km | 14.9 km/h |
| 02:50:54 | 4:03 min/km | 14.8 km/h |
| 02:51:36 | 4:04 min/km | 14.8 km/h |
| 02:52:18 | 4:05 min/km | 14.7 km/h |
| 02:53:00 | 4:06 min/km | 14.6 km/h |
| 02:53:42 | 4:07 min/km | 14.6 km/h |
| 02:54:25 | 4:08 min/km | 14.5 km/h |
| 02:55:07 | 4:09 min/km | 14.5 km/h |
| :time | :pace | :speed |
|----------+-------+------------|
| 02:30:00 | 3:33 | 16.88 km/h |
| 02:30:30 | 3:34 | 16.82 km/h |
| 02:31:12 | 3:35 | 16.74 km/h |
| 02:31:54 | 3:36 | 16.67 km/h |
| 02:32:37 | 3:37 | 16.59 km/h |
| 02:33:19 | 3:38 | 16.51 km/h |
| 02:34:01 | 3:39 | 16.44 km/h |
| 02:34:43 | 3:40 | 16.36 km/h |
{
"simon" : {
"renners" : [ "Arnaud Demare", "Sonny Colbrelli", "Andre Greipel", "Alejandro Valverde", "Christopher Froome", "Thomas de Gendt", "Dylan Groenewegen", "Ilnur Zakarin", "Rafal Majka", "Adam Yates", "Fernando Gaviria", "Steven Kruijswijk", "Mikel Landa" ],
"kluns" : "Richie Porte"
},
"kasper" : {
"renners" : [ "Warren Barguil", "Julian Alaphilippe", "Rigoberto Uran", "Greg van Avermaet", "Marcel Kittel", "Domenico Pozzovivo", "Romain Bardet", "Dylan Groenewegen", "Ilnur Zakarin", "Adam Yates", "Primoz Roglic", "Geraint Thomas", "Mikel Landa" ],
"kluns" : "Vincenzo Nibali"
},
"thijs" : {
@Kah0ona
Kah0ona / test.clj
Created September 7, 2017 19:39
Transducer that merges consecutive elements if they are similar
(declare merge-peak-with-first)
(defn concatenate-similar-peaks-xf []
(fn [xf]
(let [prev (volatile! ::none)]
(fn
([] (xf))
([result] (xf result))
([result input]
(let [prior @prev]
### Keybase proof
I hereby claim:
* I am kah0ona on github.
* I am kah0ona (https://keybase.io/kah0ona) on keybase.
* I have a public key ASDyA31JwMk91-RUyJsf3sxxihzZTfSlm2GxLkwIenJAygo
To claim this, I am signing this object: