Skip to content

Instantly share code, notes, and snippets.

View ikitommi's full-sized avatar
💭

Tommi Reiman ikitommi

💭
View GitHub Profile
@ikitommi
ikitommi / 2024-01-02.md
Last active April 30, 2024 09:22
Clojurians Together 2024

Clojurists Together Project Update, 01-02/2024, Tommi Reiman

Worked on a big new release of Malli and wrote a blog post about it.

Reitit should be now feature-complete for OpenAPI, will cut out release soon.

Helped users to use and adopt the libs.

0.14.0 (2024-01-16)

@ikitommi
ikitommi / Proposal.md
Last active March 4, 2024 01:49
Specs & Schema for Clojure web apps

Specs & Schema for Clojure web apps

Common ground for different modelling libs (Spec, Schema, ...) for web usage.

Additional metadata on models

  • for Schema, there are multiple ways to add extra metadata (at least in ring-swagger, schema-tools and in compojure-api)
  • emerging tools for spec
  • could have a common model
    • less syntax to learn
@ikitommi
ikitommi / 01-02.2023.md
Last active December 31, 2023 11:46
Clojurists Together Project Updates 2023

Clojurists Together Project Update, 01-02/2023, Tommi Reiman

Spend a lot of time with Malli and Reitit for revisiting, priorising and designing the essential missing core features.

For Malli, my top priority is to resolve the derivation and declaration of effective types, which will simplify library internals, writing schema extensions and makes CLJS bundle size smaller. Might have to break the protocol-api for this.

For Reitit, drafting a proper plugin system, have studied how this is solved in other ecosystems (e.g. fastify, phoenix). Reitit is powerful, proper plugin system makes it much more approachable.

Have also reviews lot's of PRs, helped people online and pushed out some smaller features and release the following:

@ikitommi
ikitommi / iframe.html
Created November 20, 2023 13:08
js-events learning trip
<html>
<body>
<h1>framed!</h1>
</body>
</html>
@ikitommi
ikitommi / what.md
Last active December 1, 2022 18:32
Fetch + Clojure/Script

Given

  • local development, FE (3008) & BE (6047) running in separate ports
  • want to send and read cookies over fetch, BE sets, FE sends, http-only
  • in real environments, CORS is handled in api-gateway, so just need local CORS solution here

Solution

  1. fetch needs to have :credentials set to "include" (different ports, "same-origin" doesn't seem to work)
  2. because of 1, the local CORS can't have wildcards, you need list all possible headers, origins etc.
@ikitommi
ikitommi / gist:5378805
Created April 13, 2013 15:19
Filtering nested maps in Clojure
;; here only data used in filtering.
(def docs [{:schema {:info {:name "party"}}}
{:schema {:info {:name "bonus"}}}
{:schema {:info {:name "party"}}}])
;; anonymous function with get-in (72)
(filter (fn [doc] (= "party" (get-in doc [:schema :info :name]))) docs)
;; anonymous function & threading (66)
(filter (fn [doc] (-> doc :schema :info :name (= "party"))) docs)
@ikitommi
ikitommi / malli.md
Last active March 2, 2022 12:00
Clojurists Together Malli Project Update, part1

Clojurists Together Project Update, Malli, part 1/3 (09-10/2021)

Have spent a lot of time working with Malli internals: on hammock, paper protos, reading about stuff done elsewhere, perf tuning and testing, better designs, in the mushroom forest, refactoring and finally, an initial new internal design I'm quite happy with.

The Performance gains

@ikitommi
ikitommi / malli-load-perf.md
Created January 23, 2022 10:38
Malli initialization speed

Create a new project:

~ mkdir demo
➜  ~ cd demo
➜  demo echo '{:deps {metosin/malli {:mvn/version "0.8.0-20220123.082237-3"}} :aliases {:dev {:extra-paths ["classes"]}}}' > deps.edn

Loading takes ages:

@ikitommi
ikitommi / demo1.clj
Last active January 9, 2022 08:47
Immutable Malli Schemas for Anna
;;
;; 1) using immutable support registry via options
;;
(ns demo
(:require [malli.core :as m]
[malli.registry :as mr]
[malli.util :as mu]))
(def default-registry
@ikitommi
ikitommi / parse1.clj
Last active December 24, 2021 05:42
Parsing specs with multimethod dispatch
(ns spec-tools.parse1
(:require [clojure.spec :as s]))
(defmulti parse-list first)
(defn parse [spec]
(if (or (fn? spec) (symbol? spec))
spec
(let [form (s/form spec)]
((if (seq? form) parse-list identity) form))))