This file contains hidden or 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 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] |
This file contains hidden or 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 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))] |
This file contains hidden or 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 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 |
This file contains hidden or 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 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))))) |
This file contains hidden or 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 '[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 /" [] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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)) |
NewerOlder