Skip to content

Instantly share code, notes, and snippets.

View hkjels's full-sized avatar

Henrik Kjerringvåg hkjels

View GitHub Profile
@rigdern
rigdern / Design in Practice outline.md
Last active February 17, 2024 12:02
Outline of the talk "Design in Practice by Rich Hickey (2023)": https://youtu.be/fTtnx1AAJ-c

Below is the high-level structure of Design in Practice by Rich Hickey (2023). The talk gives a concrete description of some tools and processes he and his team use for designing things.

Rich says that he believes very strongly that if you take this kind of rigorous approach to doing design, then the thing you make will be smaller and more general due to having designed it.

How do you measure progress in the design process? In programming, progress can be measured by the accretion of functionality. In design, progress can be measured by the accretion of understanding.

Techniques

  1. Glossary
    • Example
    • Carefully choosing words that have the meaning you intend helps everybody come to a shared understanding. Precision in naming yields precision in thinking.
@borkdude
borkdude / class_to_package.clj
Last active April 10, 2022 16:47
Retrieve the package string from a .class file
(require '[clojure.java.io :as io]
'[clojure.string :as str])
(defn class->package
"Implementation by Marco Marini."
[class-file]
(with-open [dis (java.io.DataInputStream. (io/input-stream class-file))]
;; skip first 8 bytes
(.skipBytes dis 8)
(let [constant-pool-count (.readUnsignedShort dis)
@retrogradeorbit
retrogradeorbit / Makefile
Last active July 20, 2023 01:10
Hot loading C wasm into the browser while preserving the state of the heap
CLANG_DIR = $(HOME)/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04
CLANG = $(CLANG_DIR)/bin/clang
LLC = $(CLANG_DIR)/bin/llc
LD = $(CLANG_DIR)/bin/wasm-ld
C_SRC := $(wildcard src/c/*.c)
OBJ_SRC := $(patsubst %.c, %.o, $(C_SRC))
%.o: %.c # delete competing implicit rule
@hkjels
hkjels / slack.md
Created November 20, 2020 15:01
Slack - Clojurians theme

Copy and paste these values to your Slack settings Sidebar Theme section: #5A80D9,#076570,#62B234,#FFFFFF,#93B3FD,#FFFFFF,#62B234,#F15340,#475FA1,#FFFFFF

@bhb
bhb / examples.clj
Created March 20, 2018 00:06
Expound examples
;; There is still a ton of work to do wrt to formatting, testing, and improving examples,
;; but here's a proof-of-concept of Expound printing examples.
;; 'defn' examples are adapted from "Improving Clojure's Error Messages with Grammars"
;; https://youtu.be/kt4haSH2xcs?t=10m20s
;; Changing types
(defn "foo" [] 1)
;; -- Example ------------------------
;; (<f> foo [] 1)
@yannvanhalewyn
yannvanhalewyn / build.boot
Last active December 13, 2017 17:37
Boot node cljs repl
(set-env!
:target-path "target"
:source-paths #{"src"}
:dependencies '[[org.clojure/clojure "1.9.0-RC1"]
[org.clojure/clojurescript "1.9.946"]
[figwheel-sidecar "0.5.14"]])
(require '[figwheel-sidecar.repl-api :as ra])
(deftask cljs-repl []
@boogie666
boogie666 / html.cljs
Created May 8, 2017 15:58
Parsing Hiccup with clojure spec
(ns test.html
(:require [clojure.spec :as s]
[clojure.string :as string])
(:require-macros [cljs.spec :as s]))
(def non-closing-elements
#{:area :base :br :col :command
:embed :hr :img :input :link
:meta :keygen :param :source
:track :wbr})

clojure.spec

Available in Clojure 1.9 (now in alpha)

(defproject robochef "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.9.0-alpha5"]])

In the namespace clojure.spec

Writing Generic Components

The React community has gone through several patterns for how to compose React components, but it generally has settled on a few techniques. Which one you use depends on the type of component you are building.

Using props.children

The simplest way to make a component more generic is to allow

@pandeiro
pandeiro / README.md
Last active June 2, 2020 08:02
Example of a simple webapp written as a single file

Instructions

  1. Get Boot
  2. Copy the above file to $HOME/app.boot
  3. $ chmod a+x $HOME/app.boot
  4. $ cd &amp;&amp; ./app.boot