Skip to content

Instantly share code, notes, and snippets.

Deraen / shadow.clj
Created May 4, 2022 12:13
Shadow CLJS and Dart Sass
View shadow.clj
(:require [shadow.cljs.devtools.api :as shadow]
[clojure.edn :as edn]))
;; Run this with:
;; npx shadow-cljs clj-run
(set! *warn-on-reflection* true)
(defn watch
Deraen / reagent-latency.cljs
Created November 10, 2022 18:45
Testing React vs Reagent update latency
View reagent-latency.cljs
(def start (atom nil))
(def log (atom []))
(defn latency-test []
(let [a (r/atom 0)]
(fn []
(let [[b update-b] (react/useState 0)]
(fn []
View TV lights.yml
alias: TV valot
description: ""
- platform: state
- unknown
seconds: 5
Deraen / edn.cljx
Last active February 3, 2022 16:15
Transit / edn date/datetime serialisers
View edn.cljx
(ns metosin.common.edn
(:require [clj-time.format :as f])
(:require [cljs-time.format :as f]
#+clj (:import [org.joda.time DateTime LocalDate]))
;; #DateTime tagging
Deraen / test.js
Last active April 25, 2021 13:02
View test.js
var vm = require("vm");
var fs = require("fs");
function nodeGlobalRequire(file) {
var _module = global.module,
_exports = global.exports,
exportedRequire = false;
// to circumvent Node.js environment detection in bundled libraries
global.module = undefined;
Deraen / editor.cljs
Last active March 27, 2021 15:34
ClojureScript goog.editor
View editor.cljs
(ns frontend.view.editor
(:require [reagent.core :as reagent]
[goog.dom :as dom])
(:import [goog.editor Field ContentEditableField Command]
[goog.ui.editor DefaultToolbar ToolbarController ToolbarFactory]
[goog.editor.plugins BasicTextFormatter RemoveFormatting ListTabHandler
SpacesTabHandler EnterHandler HeaderFormatter TableEditor]))
(defn editor-view []
(let [field-name (gensym)
Deraen / build-package.json
Last active July 17, 2020 13:04
Grunt build script for CI (Jenkins)
View build-package.json
# Create build-directory in project and place this package.json in that dir
"name": "build",
"version": "0.0.0",
"private": true,
"description": "Grunt-cli & Bower",
"dependencies": {
"grunt-cli": "0.1.11",
"bower": "1.2.8"
Deraen / components.clj
Last active December 15, 2019 08:03
Compojure-api with Component
View components.clj
(ns foobar.components
(:require [com.stuartsierra.component :as component]
[compojure.api.sweet :refer :all]))
(defmethod compojure.api.meta/restructure-param :components
[_ components acc]
(update-in acc [:letks] into [components `(::components ~'+compojure-api-request+)]))
(defn wrap-components [handler components]
(fn [req]
Deraen /
Last active October 4, 2019 13:43
Ideas for linter checks

Merge with map literal

(merge a {:a 1 :b 2}) -> (assoc a :a 1 :b2)

(-> foo (merge {:foo :bar}) -> (-> foo (assoc :foo :bar))


  • Performance
  • Easier to read?
Deraen /
Last active October 1, 2019 08:40
Compojure-api and Buddy
  • (:identity req) is auth backend independent way to access user data
  • login and logout implementation depends on auth backend
  • :current-user doesn't imply that authentication is required, route should also have :auth-rules if authentication is required