Skip to content

Instantly share code, notes, and snippets.

hellerve / capitalize-string.carp
Last active January 19, 2020 15:13
Our solutions to the puzzles from the Clojure Berlin Meetup in January, in Carp
; as an introduction, we tried to do string capitalization by hand,
; using as many different interesting idioms as possible
(defn capitalize-char [c]
(if (Char.lower-case? c)
(=> c
(- 32)
sebmarkbage /
Created September 4, 2019 20:33
Why is React doing this?

I heard some points of criticism to how React deals with reactivity and it's focus on "purity". It's interesting because there are really two approaches evolving. There's a mutable + change tracking approach and there's an immutability + referential equality testing approach. It's difficult to mix and match them when you build new features on top. So that's why React has been pushing a bit harder on immutability lately to be able to build on top of it. Both have various tradeoffs but others are doing good research in other areas, so we've decided to focus on this direction and see where it leads us.

I did want to address a few points that I didn't see get enough consideration around the tradeoffs. So here's a small brain dump.

"Compiled output results in smaller apps" - E.g. Svelte apps start smaller but the compiler output is 3-4x larger per component than the equivalent VDOM approach. This is mostly due to the code that is usually shared in the VDOM "VM" needs to be inlined into each component. The tr

bhb / gist:c121191c61453bec850a61cc428a109e
Created July 6, 2018 21:19
User-friendly REPL example
clj -Sdeps '{:deps {friendly {:git/url "" :sha "c6b0b7cb0a30e2edbf7050c0119ef038cf0f0ac2"}}}' -m friendly
user=> (let [:x 5] x)
Call to clojure.core/let did not conform to spec:
-- Spec failed --------------------
([:x 5] x)
should satisfy
mk / dependency.clj
Created July 5, 2018 18:39
Figwheel selective build
(:require [ :as ctn.track]
[ :as ctn.dir]
[ :as ctn.file]
[ :as ctn.dep]
[ :as ctn.parse]
[ :as ctn.find]
[ :as io]
[ :as reader])
bhb /
Last active May 15, 2023 01:28
Clojure friendly mode, inspired by
OliverJAsh / foo.ts
Last active July 29, 2023 18:16
Records and dictionaries in TypeScript
In JavaScript, objects can be used to serve various purposes.
To maximise our usage of the type system, we should assign different types to our objects depending
on the desired purpose.
In this blog post I will clarify two common purposes for objects known as records and dictionaries
(aka maps), and how they can both be used with regards to the type system.
(def kw-cache #js{})
(defn cached-kw [fqn]
(if-some [kw (unchecked-get kw-cache fqn)]
(let [kw (keyword fqn)]
(unchecked-set kw-cache fqn kw)
(defn js->clj-fast
lmakarov / lambda-basic-auth.js
Created August 30, 2017 19:15
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
thheller / es6-class.cljs
Created August 24, 2017 13:51
class extends React.Component in CLJS
(defn my-component [props context updater]
(cljs.core/this-as this
(js/ this props context updater)
;; anything else you want to set-up. use goog.object/set on this
(.. my-component -prototype)
YurySolovyov / class-names.cljs
Created July 2, 2017 12:17
class-names for ClojureScript
(defn class-names [& args]
(clojure.string/join " "
(mapv name
(reduce (fn [arr arg]
(or (string? arg)
(symbol? arg)
(keyword? arg)) (conj arr arg)
(vector? arg) (vec (concat arr arg))
(map? arg) (vec (concat arr