Skip to content

Instantly share code, notes, and snippets.

Avatar

Marten Sytema Kah0ona

View GitHub Profile
@Kah0ona
Kah0ona / uppy.cljs
Created Dec 9, 2021
Uppy example in clojurescript
View uppy.cljs
(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 Mar 9, 2021
catching asserts inside a future body fails silently, but why?
View fails.clj
(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")
View euler.clj
(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 Mar 29, 2020
Clojure script to count number of chats per person from WhatsApp export
View script.clj
(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 Nov 21, 2019
paces halve marathon
View half_marathon.txt
| :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 |
View marathonpaces.txt
| 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 |
View gist:24cee488b12ce5cea46356d4c68a1f45
| :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 |
View gist:2fef44f9becfc25c3e203c1286deb74c
{
"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 Sep 7, 2017
Transducer that merges consecutive elements if they are similar
View test.clj
(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]
View gist:5b5930315d2a690cf459d59b74c82be2
### 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: