Skip to content

Instantly share code, notes, and snippets.

@lhrb
lhrb / gitstats.md
Last active December 14, 2022 20:17
Mine git stats

aggregate added, deleted loc and commits

git log --since="2022-01-01" --numstat --pretty="%s" | awk 'NF == 3 {add+=$1; del+=$2; c+=1} END {printf("add: %d del: %d, commits: %d",  add, del, c)}'

unique files changes

git log --since="2022-01-01" --numstat --pretty="%s" | awk 'NF == 3 {print $3}' | sort | uniq | wc -l
@lhrb
lhrb / ycombinator.clj
Last active December 6, 2021 19:03
Haskell Curry's Y Combinator
;; https://en.wikipedia.org/wiki/Fixed-point_combinator#Fixed-point_combinators_in_lambda_calculus
(defn ycombinator [f]
((fn [x]
(x x))
(fn [x]
(f (fn [y]
((x x) y))))))
(defn factorial [f]
@lhrb
lhrb / aoe.clj
Last active December 2, 2021 13:05
aoe2021
(ns lhrb.aoe
(:require [clojure.string :as str]))
(defn riddle1 [input]
(count (filter true? (map < input (rest input)))))
(defn dismantle [acc r]
(if (< (count r) 3)
acc
(recur (conj acc (take 3 r)) (rest r))))
#!/bin/sh
# https://auscunningham.medium.com/enforcing-git-commit-message-style-b86a45380b0f
# https://devhints.io/git-log-format
msg=`cat $1`
prefix=`echo $msg | grep -w "^(ADD\|UPDATE)"`
if [ -z "$prefix" ]
then