Skip to content

Instantly share code, notes, and snippets.

@alexsavio
alexsavio / README.md
Last active April 22, 2026 08:26
SIGReg: Sliced Isotropic Gaussian Regularizer from LeWorldModel (Maes et al. 2026) — runnable PyTorch demo

SIGReg demo

Runnable PyTorch implementation of the Sliced Isotropic Gaussian Regularizer (SIGReg) from the LeWorldModel paper (Maes, Le Lidec, Scieur, LeCun, Balestriero, arXiv:2603.19312, March 2026).

SIGReg is a single-term regularizer that replaces the usual six-knob stack (EMA teachers, stop-gradient, frozen pretrained features, VICReg variance/covariance terms, momentum encoders, LR warmup schedules) used to prevent representation collapse in JEPA-style self-supervised world models.

Companion post: LeWorldModel: One Regularizer Instead of Six for Pixel JEPA.

How it works

@alexsavio
alexsavio / simulate_dependency_cooldown.py
Last active April 13, 2026 16:11
Dependency cooldown cost model — simulation and analytical check. Companion to https://alexsavio.github.io/dependency-cooldown-considered-harmful.html
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.11"
# dependencies = ["numpy>=2.0"]
# ///
"""Monte Carlo + analytical validation of the dependency cooldown cost model.
Backs the claims in the blog post
`content/dependency-cooldown-considered-harmful.md`.
@alexsavio
alexsavio / claude-sandbox
Created April 12, 2026 12:13
claude-sandbox — run Claude Code in an isolated Docker container with no permission prompts (uses your existing subscription via setup-token)
#!/usr/bin/env bash
# claude-sandbox — run Claude Code in an isolated container (uses your subscription)
#
# Usage:
# claude-sandbox "implement feature X" # pipe mode (non-interactive)
# claude-sandbox # interactive mode
#
# First run: prompts you to create a long-lived token via `claude setup-token`.
# Token is cached in ~/.claude-sandbox-token for subsequent runs.
set -euo pipefail
@alexsavio
alexsavio / cargo_lambda_action.yml
Created October 15, 2024 12:40
Raw Github Actions template to run cargo lambda packaging
---
name: "Template: Test, compile and zip Rust Lambdas"
on:
workflow_call:
inputs:
function-name:
required: true
type: string
description: |
@alexsavio
alexsavio / handlebars_helpers.md
Created October 21, 2023 07:50
A blog post on how to write Handlebars.rs helpers

Author: Alexandre Manhães Savio [email protected]

Date: 10.10.2023

Handlebars is a modern and extensible templating solution originally created in the JavaScript world. It’s used by many popular frameworks like Ember.js and Chaplin. It’s also ported to some other platforms such as Java.

Handlebars is a template rendering engine but lacks extensive filters and transformers for context data during rendering. Like many such libraries, Handlebars allows you to create custom operations, called 'helpers'.

Here I will write an instruction set on how to write custom helpers for handlebars-rust.

@alexsavio
alexsavio / handlebars_helpers.rs
Created October 10, 2023 09:01
handlebars helpers
use handlebars::{Handlebars, RenderError, HelperDef, RenderContext, Helper, Context, handlebars_helper};
use serde_json::Value as Json;
// #[allow(non_camel_case_types)]
// pub struct is_defined;
// impl HelperDef for is_defined {
// fn call_inner<'reg: 'rc, 'rc>(
// &self,
// h: &Helper<'reg, 'rc>,
@alexsavio
alexsavio / nested_access.py
Created August 30, 2022 12:53
Python simple nested structure access
# -*- coding: utf-8 -*-
from functools import singledispatch
def getvalue(value, path, default=None):
"""Get a named attribute or item from an object; getvalue(x, 'y.z')
is equivalent to x.y.z
When a default argument is given, it is returned when the attribute doesn't
exist; without it, None returned
List indexing supported x.0.y.1.z etc.
@alexsavio
alexsavio / git-crypt-rm-gpg-user.sh
Last active April 20, 2022 16:01 — forked from etam/git-crypt-rm-gpg-user.sh
Git-crypt remove user.
#!/usr/bin/env bash -x
#
# Script to remove GPG user (recipient) with git-crypt
#
# It will re-initialize git-crypt for the repository and re-add all keys except
# the one requested for removal.
#
# Note: You still need to change all your secrets to fully protect yourself.
# Removing a user will prevent them from reading future changes but they will
# still have a copy of the data up to the point of their removal.
@alexsavio
alexsavio / ssm_transfer.py
Created October 26, 2021 08:52
SSM Secrets Repository
"""
pip install boto3 'boto3-stubs[ssm]'
"""
from typing import TYPE_CHECKING
import boto3
if TYPE_CHECKING:
from mypy_boto3_ssm.client import SSMClient
@alexsavio
alexsavio / recapitalize.py
Last active June 10, 2021 10:43
Recapitalize names
"""
Recapitalize a string of words that has passed a pre-processing, word-cuttind and case lowering process.
"""
import re
import difflib
from typing import Iterator, List, Tuple
def recapitalize_name(original: str, result: str) -> str:
"""Return the `result` with the words capitalized as they appear in `original`."""