This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '["react" :as react]) | |
(require '["react-dom" :as rdom]) | |
(def empty-board [[\- \- \-] | |
[\- \- \-] | |
[\- \- \-]]) | |
(def init-state {:board empty-board :player \X}) | |
(defn get-board-cell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns view.index | |
(:require | |
[hoplon.core :as h] | |
[javelin.core :as j])) | |
(defn my-list [& items] | |
(h/div :class "my-list" | |
(apply h/ul (map #(h/li (h/div :class "my-list-item" %)) items)))) | |
(defonce clicks (j/cell 0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; based on code from https://www.baeldung.com/java-uuid | |
;; translated to Clojure by ChatGPT, minus the hex numbers which I evaluated in jshell | |
(defn get-64-least-significant-bits-for-version1 [] | |
(let [random (java.util.Random.) | |
random-63-bit-long (bit-and (.nextLong random) 4611686018427387903) | |
variant-3-bit-flag -9223372036854775808] | |
(bit-or random-63-bit-long variant-3-bit-flag))) | |
(defn get-64-most-significant-bits-for-version1 [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro <- | |
[& טופסים] | |
(let [[x & טופסים] (reverse טופסים)] | |
(loop [x x, טופסים טופסים] | |
(if טופסים | |
(let [טופס (first טופסים) | |
מתארגן (if (seq? טופס) | |
(with-meta `(~(first טופס) ~x ~@(next טופס)) (meta טופס)) | |
(list טופס x))] | |
(recur מתארגן (next טופסים))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { loadString } from 'npm:nbb@1.2.168' | |
await loadString(`(prn (+ 1 2 3))`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; {:deps {org.babashka/cli {:mvn/version "0.5.40"} | |
;; babashka/fs {:mvn/version "0.1.11"}}} | |
(ns test-args | |
{:clj-kondo/config '{:lint-as {test-args/deftest clojure.core/defn}}} | |
(:require | |
[babashka.cli :as cli] | |
[clojure.test :as t :refer [is]])) | |
(def ^:dynamic *test-args* (cli/parse-opts *command-line-args*)) |
NewerOlder