Skip to content

Instantly share code, notes, and snippets.

View borkdude's full-sized avatar

Michiel Borkent borkdude

View GitHub Profile
(ns test1
(:require
[applied-science.js-interop :as j]
[promesa.core :as p]
[cljs-bean.core :refer [bean ->clj ->js]]
[re-frame.core :as rf]
[re-frame.db :as rf.db]
[re-frame.alpha :as rf.a]
[reagent.core :as r]
[reagent.dom.server :as rds]
@borkdude
borkdude / ohm.cljs
Created October 27, 2025 07:56
Ohm's calculator
(ns reagami.core
{:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [update!]}}}})
(def svg-ns "http://www.w3.org/2000/svg")
(defn- parse-tag
"From hiccup, thanks @weavejester"
[^String tag]
(let [id-index (let [index (.indexOf tag "#")] (when (pos? index) index))
class-index (let [index (.indexOf tag ".")] (when (pos? index) index))]
@borkdude
borkdude / reagami.cljs
Created October 26, 2025 12:45
Reagami ported to CLJS
(ns reagami.core
{:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [update!]}}}})
;; array-seq didn't exist in scittle
(defn array-seq [x]
(into [] x))
(def svg-ns "http://www.w3.org/2000/svg")
(defn- parse-tag
@borkdude
borkdude / my_hoplon_demo.cljs
Last active October 3, 2025 21:15
my_hoplon_demo.cljs
(ns test1
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(h/defelem timer [attrs children]
(let [start (or (:start attrs) 0)
seconds (j/cell start)]
(.setInterval js/window #(swap! seconds inc) 1000)
(h/div attrs (j/cell= (str "Seconds Elapsed: " seconds)))))
@borkdude
borkdude / simple.clj
Created September 6, 2025 08:39
clj-simple-router with babashka
(require '[babashka.deps :as deps])
(deps/add-deps '{:deps {io.github.tonsky/clj-simple-router {:mvn/version "0.1.2"}}})
(require '[org.httpkit.server :as server]
'[clj-simple-router.core :as router])
(def routes
(router/routes
"GET /" []
@borkdude
borkdude / tictactoe.cljs
Created December 14, 2023 18:57
squint_react_tictactoe.cljs
(require '["react" :as react])
(require '["react-dom" :as rdom])
(def empty-board [[\- \- \-]
[\- \- \-]
[\- \- \-]])
(def init-state {:board empty-board :player \X})
(defn get-board-cell
@borkdude
borkdude / aoc23_01.cljs
Last active December 7, 2023 19:53
AOC 2023 day 3 in squint + TC39 Tuples
;; Helper functions:
;; (fetch-input year day) - get AOC input
;; (append str) - append str to DOM
;; (spy x) - log x to console and return x
;; original solution:
;; https://github.com/russmatney/advent-of-code/blob/master/src/_2023/_03/core.clj
(require '["https://unpkg.com/@bloomberg/record-tuple-polyfill" :as tc39])
@borkdude
borkdude / aoc_ui.cljs
Last active December 5, 2023 16:15
AOC ui boilerplate
(require '[clojure.string :as str])
#_(assoc-in! (js/document.querySelector "#compiledCode") [:style :display] :none)
(when-not (js/document.querySelector "#aoc_token")
(let [create-element (fn create-element [tag attributes]
(let [element (js/document.createElement tag)]
(doseq [[key value] attributes]
(aset element key value))
element))
@borkdude
borkdude / pinball.cljs
Last active November 17, 2023 23:54
Squint pinball
;; Adapted from: https://thegeez.net/2023/03/01/pinball_scittle.html
#_(do #_:clj-kondo/ignore (warn-on-lazy-reusage!))
(defn element [tag id child-of prepend?]
(or (js/document.getElementById id)
(let [elt (js/document.createElement tag)
parent (if child-of (js/document.querySelector child-of)
js/document.body)]
(set! (.-id elt) id)
@borkdude
borkdude / wordle.cljs
Created November 16, 2023 12:18
Squint wordle
(ns wordle)
(def board-state (atom []))
(def counter (atom 0))
(def attempt (atom 0))
(def word-of-the-day (atom "hello"))
(defn write-letter [cell letter]
(set! (.-textContent cell) letter))