Skip to content

Instantly share code, notes, and snippets.

View slipset's full-sized avatar
🙃

Erik Assum slipset

🙃
View GitHub Profile
@slipset
slipset / Leibniz.clj
Created October 18, 2024 14:36
Some Leibniz code
;; https://github.com/niklas-heer/speed-comparison/tree/master
;; Decompilation provided by clj-java-decompiler
(defn calc-pi-leibniz
"Translation of Java solution to Clojure"
[^long rounds]
(let [end (+ 2 rounds)]
(loop [i 2 x 1.0 pi 1.0]
(if (= i end)
(* 4 pi)
(defn baz [z]
...
(foobar æ))
(defn bar [y]
...
(baz z))
(defn foo [x]
...
;; json-mode
(use-package json-mode
:ensure t)
(use-package web-mode
:ensure t
:mode (("\\.js\\'" . web-mode)
("\\.jsx\\'" . web-mode)
("\\.ts\\'" . web-mode)
("\\.tsx\\'" . web-mode)
(ns area3
(:require
[clojure.math :as math]
[criterium.core :as crit]))
(set! *warn-on-reflection* true)
(set! *unchecked-math* false)
(definterface IArea2
(^double area []))
(ns area2
(:require
[clojure.math :as math]
[criterium.core :as crit]))
(set! *warn-on-reflection* true)
(set! *unchecked-math* false)
(defprotocol IArea
(area [this]))
(require '[clj-java-decompiler.core :refer [decompile]])
(decompile
(ns src.core)
(def regex #"(\d+(?:\.\d+)?)|([().^*\/+-])")
(def presedence {'+ 1
'- 1
'* 2
'/ 2})
(defn tokenize [expr]
@slipset
slipset / reduce_og_sånt.js
Created March 10, 2020 19:26
litt om reduce
// så vi har et array med tall, og vi skal legge de sammen.
const numbers = [1, 2, 4, 10];
// den måten man kanskje lærer først, som vi gikk gjennom på tavla er noe sånt:
let summedNums = 0;
for (i = 0; i< numbers.length; i++) {
summedNums = summedNums + numbers[i];
}
(ns foo.core
(:require [ring.adapter.jetty :as jetty]))
(defn add-connection-middleware [handler uri]
(fn [req]
(let [connection (mg/connect-via-uri uri)]
(handler (assoc req :connection connection)))))
(defn handler [{:key [connection] :as request}]
{:status 200

Technical debt for fun and profit

Mention technical debt to any normal engineer and they'll look upon you as something the cat dragged in. But is technical debt all bad? The term was coined by Ward Cunningham as a way to talk about complexity and bad code in a way that non-technical people could understand. The compound effect of interest on real-life loans was used to explain how complex, badly written code becomes increasingly harder to develop and maintain.

In this talk I'll explore the debt metaphore in more detail and see if, as in real life, there are ways we can leverage debt in our work without ending up in the software equvivalent of the Luxury Trap.

(ns wc.core
(:require [clojure.core.reducers :as r]))
(defn char-counter [key init pred]
(fn [reducing-fn]
(fn
([acc]
(reducing-fn acc))
([acc c]
(reducing-fn (if (pred c)