Skip to content

Instantly share code, notes, and snippets.

Note: apply-old includes the optimized to-array of CLJS-2100
"Datastructure: Set"
(apply-old f args), 1000000 runs, 716 msecs
(apply f args), 1000000 runs, 225 msecs
(apply-old f args), 1000000 runs, 641 msecs
(apply f args), 1000000 runs, 184 msecs
"Single arity fn, like JS fn"
(apply-old f 1 2 3 4 args), 1000000 runs, 903 msecs
(apply f 1 2 3 4 args), 1000000 runs, 358 msecs
@mfikes
mfikes / io-resource.md
Created June 4, 2017 23:13
ClassLoader.getResource

If you profile incremental compilation where you repeately touch your source files and have it re-compile, you will see that java.lang.ClassLoader.getResource() appears at the top of the profile, and the primary call site is io/resource calls in cljs.util/ns->source.

If you look at the call patterns, lots of calls are made with ns of goog.*, and this always returns nil. On the other hand, there are calls for namespaces that won't change.

Re-writing this to short-circuit goog.* to return nil, and to cache "core" namespaces, eliminates ClassLoader.getResource() from the top of the profile. It also seems to speed up my incremental compile loop by perhaps 5–10%.

@Rich-Harris
Rich-Harris / prepack-svelte.md
Last active May 19, 2022 11:02
Is Prepack like Svelte?

Note: I'm not involved in Prepack in any way — please correct me if I say anything incorrect below!

A few people have asked me if Prepack and Svelte are similar projects with similar goals. The answer is 'no, they're not', but let's take a moment to explore why.

What is Prepack?

Prepack describes itself as a 'partial evaluator for JavaScript'. What that means is that it will run your code in a specialised interpreter that, rather than having some effect on the world (like printing a message to the console), will track the effects that would have happened and express them more directly.

So for example if you give it this code...

@reborg
reborg / rich-already-answered-that.md
Last active January 23, 2025 22:49
A curated collection of answers that Rich gave throughout the history of Clojure

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats.

How to use:

  • The link in the table of content jumps at the copy of the answer on this page.
  • The link on the answer itself points back at the original post.

Table of Content

@jingzhehu
jingzhehu / CMakeLists.txt
Created February 26, 2017 15:36
Clion meets bitcoin.
cmake_minimum_required(VERSION 3.3)
project(bitcoin)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
add_custom_target(build-bitcoin ALL
COMMAND ./autogen.sh
COMMAND ./configure
COMMAND $(MAKE) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@t4sk
t4sk / segwit-regtest.md
Created December 29, 2016 21:51
How to activate segwit on regtest

How to activate segwit on regtest

Start bitcoind

> bitcoind -regtest -daemon

Generate block chain

> bitcoin-cli -regtest generate 432
@swannodette
swannodette / inference.md
Last active August 7, 2023 16:13
Externs Inference

Externs Inference

Integrating third party JavaScript libraries not written with Google Closure Compiler in mind continues to both be a source of error for users when going to production, and significant vigilance and effort for the the broader community (CLJSJS libraries must provide up-to-date and accurate externs).

In truth writing externs is far simpler than most users imagine. You only need externs for the parts of the library you actually intend to use from ClojureScript. However this isn't so easy to determine from Closure's own documentation. Still in the process of writing your code it's easy to miss a case. In production you will see the much dreaded error that some mangled name does not exist. Fortunately it's possible to enable some compiler flags :pretty-print true :pseudo-names true to generate an advanced build with human readable names. However debugging missing externs means compiling your production build for each missed case. So much time wasted for such simple mistakes damages our sen

@olivergeorge
olivergeorge / spec_utils.cljs
Created August 18, 2016 06:58
Work around cljs.spec.test/instrument features to report useful errors when used with cljs-devtools.
(ns spec-utils
(:require [goog.object :as gobj]
[cljs.spec :as s]
[cljs.spec.test :as stest]
[cljs.stacktrace :as st]))
(defn explain-console
"prints an explanation to *out*."
[ed]
(if ed
@bhauman
bhauman / compiler-options-schema.clj
Last active August 8, 2017 21:19
A Schema for ClojureScript Options
(ns cljs.compiler-options-schema
(:require
[clojure.spec :as s]
[clojure.string :as string]
;; for initial dev
[clojure.test :refer [deftest is testing]]))
(defn non-blank-string? [x] (and (string? x) (not (string/blank? x))))
(defonce ^:private registry-ref (atom {}))
(ns om.next.spec
(:require [cljs.spec :as s]
[clojure.test.check :as tc]
[clojure.test.check.properties :as tcp]))
(s/def ::statics
(s/cat
:static '#{static}
:protocol-name '#{om.next/Ident om.next/IQuery om.next/IQueryParams}
:impls (s/* seq?)))