Skip to content

Instantly share code, notes, and snippets.

@dazld
dazld / mutableReducer.ts
Created January 9, 2025 14:28
broken mutable reducer like proxy-memoze DO NOT USE
import { useReducer, useCallback, useRef } from 'react';
function createMutableReducer(reducer, initialState) {
// Track if we're currently in a draft phase
let drafting = false;
// Store pending changes during the draft phase
const changes = new Map();
// Create a proxy handler that tracks mutations
const handler = {
get(target, prop) {
{
"id": "cpjg1BS9Go8fmW6rAs9V",
"number": "5366654761210216498",
"begin": "2022-10-17T18:05:21+00:00",
"created": "2022-10-17T18:40:14+00:00",
"end": "2022-10-17T20:59:49+00:00",
"modified": "2022-10-17T20:59:49+00:00",
"external_desc": "Multiregion: Dataproc jobs missing from the console",
"updates": [
{
I am attesting that this GitHub handle dazld is linked to the Tezos account tz1UnNGLUYPhETDV8mXWBMuk7YsPgctmT16g for tzprofiles
sig:edsigtxbVPcus9383fJsDLH2sb344wy46g8uirgse8A8xtQmmhcnW39hTyjoaiFBUT8vjRvJi68cBMmHW9PiVz4TJsXTr7BMuAP
@dazld
dazld / gist:c580943dbe638a6faa735b54edd19c29
Created January 13, 2022 09:16 — forked from daviesian/gist:4517859
Code to redirect output nrepl output to a particular client repl.
;; After connecting an nrepl client repl to an nrepl server, some
;; output will still appear on stdout from the server.
;; Try these snippets - they will both produce output on the nrepl server
;; Java libraries commonly do both these things.
(.println System/out "Hello stdout.")
(.start (Thread. #(println "Hello from a new thread.")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
:root {
--z-index: 1;
}
.up {
--z-index: calc(var(--z-index) + 1);
z-index: var(--z-index);
}
/*
*** Ramer Douglas Peucker
The Ramer-Douglas–Peucker algorithm is an algorithm for reducing the number of points in a curve that is approximated by a series of points.
It does so by "thinking" of a line between the first and last point in a set of points that form the curve.
It checks which point in between is farthest away from this line.
If the point (and as follows, all other in-between points) is closer than a given distance 'epsilon', it removes all these in-between points.
If on the other hand this 'outlier point' is farther away from our imaginary line than epsilon, the curve is split in two parts.
The function is recursively called on both resulting curves, and the two reduced forms of the curve are put back together.

https://clojure.org/guides/repl/enhancing_your_repl_workflow#writing-repl-friendly-programs

@cfleming: Tools | REPL | Sync files in REPL, as recently discussed

sync basically works out which files you’ve changed and loads them all in dependency order. Load file also does that, except only starting with the file that you’re loading (i.e. that file and all its dependencies will be loaded if modified). sync will do that for all files, even if the current file doesn’t depend on them.

(require your.main :reload-all)
clojure.tools.namespace.repl/refresh-all
/*@media (prefers-color-scheme: dark) {*/
html {
filter: invert();
}
img, svg {
@dazld
dazld / fix
Created October 15, 2020 21:09
fix unidentified developer VSTs on macOS
sudo xattr -rd com.apple.quarantine /Library/Audio/Plug-Ins/VST/Airwindows/*.vst
(ns backend.dummy
(:require [io.pedestal.interceptor.chain :as chain]
[io.pedestal.interceptor :as i]
[io.pedestal.interceptor.error :as err]
[ring.util.response :as rr]))
(def notify-enabled? (constantly true))
(def websocket-notifier (i/interceptor {:name :pusher
:leave (fn [ctx]