Skip to content

Instantly share code, notes, and snippets.

View ahmed1hsn's full-sized avatar
🎯
Focusing

Ahmed Hassan ahmed1hsn

🎯
Focusing
View GitHub Profile
@daveliepmann
daveliepmann / assert-or-not.md
Last active March 2, 2025 12:24
A guide to orthodox use of assertions in Clojure.

When to use assert?

In JVM Clojure, Exceptions are for operating errors ("something went wrong") and Assertions are for programmer and correctness errors ("this program is wrong").

An assert might be the right tool if throwing an Exception isn't enough. Use them when the assertion failing means

  • there's a bug in this program (not a caller)
  • what happens next is undefined
@henryw374
henryw374 / flexi_clock.clj
Created October 17, 2024 16:11
clojure java.time clock
(ns flexi-clock
(:import (java.time Clock Duration Instant ZonedDateTime)))
(defn clock
"potential library function (e.g. in tick or tempo).
This just implements the platform Clock - which works because non-test code only uses that API.
Any manipulation of time (which happens in testing code) is done via changing
what get-instant and get-zone return"
[get-instant get-zone]
@WebReflection
WebReflection / sqlite-as.md
Last active January 25, 2025 15:12
Bun sqlite `.as(Class)` alternative

This is a simple demo of how latest Bun could've implemented .as(Class) instead of using the quite jurassic Object.create which is slow, bloated due descriptors logic, if used at all, and incapable to play nicely with features introduced after Object.create was even specified.

// what `as(Class)` should return
const { assign } = Object;
const asClass = new WeakMap;
const setAsClass = Class => {
  class As extends Class {
    constructor(fields) {
      assign(super(), fields);
@rafd
rafd / flowstorm.md
Last active March 30, 2025 12:27
Ideal FlowStorm Setup

FlowStorm Quickstart

FlowStorm is a time-travelling debugger for clojure.

IMO, Clojure has the best development experience with its REPL-driven workflow. FlowStorm makes it even better.

Most notably:

  • "time-traveling" retrospective debugger (walk forward and backward, search for values)
  • zero-config tap> destination
  • retroactively add print statements to previous evaluations
@shvets-sergey
shvets-sergey / jst.clj
Created August 14, 2023 00:54
Implements a hiccup-like compiler into js templates
(ns jst
(:require [camel-snake-kebab.core :as csk]
[clojure.string :as string]
[hyperfiddle.rcf :refer [tests]]))
(hyperfiddle.rcf/enable!)
;; Implements a hiccup compiler into js-template.
;;
;; Usage: (jst cljs-symbol? template-fn? hiccup), where:
;; cljs-symbol - what symbol implements js-template in cljs (default: shadow.cljs.modern/js-template)
@dustingetz
dustingetz / electric-references.md
Last active June 5, 2025 13:07
Reference list — Electric Clojure

References — Electric Clojure

Electric Clojure implements a form of arrowized continuous time dataflow programming with extensions for network-transparent function composition.

@dustingetz
dustingetz / missionary-concept-map.md
Last active June 5, 2025 13:28
Missionary concept map

Missionary concept map

Missionary primitives fit into three categories:

Effect descriptions = pure functional programming which is about trees not graphs

  • continuous flow, m/?< (switch)
  • m/watch, m/latest, m/cp
  • m/observe
  • m/reductions, m/relieve
@pmonks
pmonks / java-members.clj
Last active August 20, 2025 15:39
Pretty prints results from clojure.reflect/reflect on an object or class in an idiomatic Clojure fashion
;
; Copyright © 2023 Peter Monks
;
; This Source Code Form is subject to the terms of the Mozilla Public
; License, v. 2.0. If a copy of the MPL was not distributed with this
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
;
; SPDX-License-Identifier: MPL-2.0
;
@WebReflection
WebReflection / esx.md
Last active October 6, 2024 12:35
Proposal: an ESX for JS implementation
@joshlemer
joshlemer / gen.clj
Last active September 7, 2025 20:28
(ns gen
(:require
[cloroutine.core :refer [cr]]
[criterium.core :as crit]))
(deftype ^:private GenIter [;; The Cloroutine generator function
^:unsynchronized-mutable ^clojure.lang.IFn g
;; Trilean boolean logic:
;; 0 = certainly no more elements, `x` is nil
;; 1 = certainly there are more elemennts, and the next object is stored in `x`