Skip to content

Instantly share code, notes, and snippets.

hellerve / capitalize-string.carp
Last active Jan 19, 2020
Our solutions to the puzzles from the Clojure Berlin Meetup in January, in Carp
View capitalize-string.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 Sep 4, 2019
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

View gist:c121191c61453bec850a61cc428a109e
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 Jul 5, 2018
Figwheel selective build
View dependency.clj
(: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 3, 2021
Clojure friendly mode, inspired by
OliverJAsh / foo.ts
Last active Oct 27, 2021
Records and dictionaries in TypeScript
View foo.ts
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.
View faster-js->clj.cljs
(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
View parse-json-with-transit.cljs
(ns transito.core
For easier transit handling...
Caching of keywords, no transit UUID's.
[cognitect.transit :as transit]
[com.cognitect.transit :as t]))
(deftype ^:no-doc MapBuilder []
lmakarov / lambda-basic-auth.js
Created Aug 30, 2017
Basic HTTP Authentication for CloudFront with Lambda@Edge
View lambda-basic-auth.js
'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 Aug 24, 2017
class extends React.Component in CLJS
View es6-class.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)