Skip to content

Instantly share code, notes, and snippets.

View mpizenberg's full-sized avatar

Matthieu Pizenberg mpizenberg

View GitHub Profile
@mpizenberg
mpizenberg / reserves-treasury-plot.py
Created November 4, 2024 10:40
Cardano analytics
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "matplotlib",
# "numpy",
# ]
# ///
# Start the script with "uv run reserves-treasury-plot.py"
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "requests",
# ]
# ///
import requests
import json
@mpizenberg
mpizenberg / discussion-claude-sonnet-35.md
Created October 4, 2024 09:09
Causal profiler for Elm

Me

If I wanted to implement a new benchmarking tool for the Elm language, that would be similar to Emery Berger’s causal profiler called Coz, how could I do it?

Claude

To implement a benchmarking tool for Elm similar to Emery Berger's Coz causal profiler, you'd need to tackle several key aspects. Here's an outline of how you might approach this:

  1. Understand Coz and causal profiling:
  • Coz is a causal profiler that helps developers identify optimization opportunities in their code.
@mpizenberg
mpizenberg / code-block-example.typ
Created April 3, 2023 07:28
Example for code blocks in Typst
#set par(justify: true)
*Goal*: being able to add line numbers, which are correct even in case of long lines that need wrapping.
*Strategy*: duplicate the code block, once for getting the line numbers correct, and the other for syntax highlighting. The idea is to split lines and prefix each line with its line number such that line wrapping should be respected.
#show raw.where(block: true): it => { set par(justify: false); grid(
columns: (100%, 100%),
column-gutter: -100%,
block(width: 100%, inset: 1em, for i, line in it.text.split("\n") {
@mpizenberg
mpizenberg / cached.m
Last active January 20, 2017 15:46
Transform a matlab function into a cached function (result stored in a file).
function varargout = cached(cache_filepath, f, varargin )
if exist(cache_filepath, 'file') == 2
load(cache_filepath, 'varargout');
else
[varargout{1:nargout}] = f( varargin{:} );
save(cache_filepath, 'varargout');
end
end
type Msg = Debounce VirtualTime | ...
-- create a deferred (by timeout) command taking currentVirtualTime as an argument
checkIfNothingHappenedIn : Time -> VirtualTime -> Cmd Msg
checkIfNothingHappenedIn timeout currentVirtualTime =
deferredCmd timeout (Debounce currentVirtualTime)
deferredCmd : Time -> Msg -> Cmd Msg
isItLongEnoughCmd : Cmd Msg
isItLongEnoughCmd = Task.perform IsItLongEnough Time.now
type alias Model = { ... , state : Debounce.State }
@mpizenberg
mpizenberg / medium_lodash_debounce.js
Last active December 7, 2016 09:14
Medium Debounce
// Avoid costly calculations while the window size is in flux.
jQuery(window).on(‘resize’, _.debounce(calculateLayout, 150));