Skip to content

Instantly share code, notes, and snippets.

View dawranliou's full-sized avatar

Daw-Ran Liou dawranliou

View GitHub Profile
(defn newton
[f fprime tol max-iteration x]
(if (<= max-iteration 0)
nil
(let [y (f x)
yprime (fprime x)
x-new (- x (/ y yprime))]
(if (<= (Math/abs(- x-new x)) (* tol (Math/abs x-new)))
x-new
(newton f fprime tol (dec max-iteration) x-new)))))
@dawranliou
dawranliou / random-key.py
Created August 28, 2019 22:27
Generate 16-bytes server secret key
import secrets
import string
alphabet = string.ascii_letters + string.digits
print(''.join(secrets.choice(alphabet) for i in range(16)))
@dawranliou
dawranliou / emoji.edn
Created September 18, 2019 19:26
Emoji for Clojure
{:hash "#️⃣"
:keycap_star "*️⃣"
:zero "0️⃣"
:one "1️⃣"
:two "2️⃣"
:three "3️⃣"
:four "4️⃣"
:five "5️⃣"
:six "6️⃣"
:seven "7️⃣"