Skip to content

Instantly share code, notes, and snippets.

@anatolebeuzon
anatolebeuzon / README.md
Last active May 13, 2022 14:33
Auto-vendor Go dependencies in the background after a git checkout

Why?

Having to run go mod vendor every time I git checkout <branch> is annoying. If I forget, gopls is unusable, tests cannot be run, and VSCode complains (go: inconsistent vendoring).

What?

Add a post-checkout hook that will run go mod vendor in the background every time a branch is checked out.

How to add the hook?

@anatolebeuzon
anatolebeuzon / README.md
Last active February 13, 2022 11:43
HyperLogLog large range correction bias

This is an experimental tool to evaluate the quality of the estimations produced by the HyperLogLog algorithm described in the Flajolet et al. paper, with and without the large range correction (§4 of the paper).

This correction is only enabled for cardinalities beyond 143M, so any input below that will return the same result twice.

Usage

go mod tidy
go run main.go -count 3000000000
@anatolebeuzon
anatolebeuzon / main.go
Created January 4, 2021 20:06
CLI: set difference of two folders
// Suppose you have two folders, A and B, containing various files.
// You want to get the files in A that are not in B. This is what this CLI provides.
// A is called the 'in' set and B is called the 'discard' set.
// Items in A that are also in B will be _removed_ from A.
// File equality is based on MD5 hashes, not filenames.
package main
import (
"crypto/md5"
"flag"
@anatolebeuzon
anatolebeuzon / garmin_fit_to_trainingpeaks.py
Created March 1, 2020 21:09
Batch upload your Garmin .fit files to trainingpeaks.com using this Python script. I had 5000 of them, and their customer support suggested I drag and drop each of them individually. So I did, kind of :-)
import logging
import os
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.common.exceptions import NoSuchElementException, TimeoutException
from joblib import Parallel, delayed
@anatolebeuzon
anatolebeuzon / README.md
Last active January 2, 2020 19:22
Generating and printing a crossword of any size

Recently needed to create a giant crossword (4 sheets of A0 paper, basically 4 m^2 of crosswords). Quick how-to.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+               +               +               +               +
+               +               +               +               +
+               +               +               +               +
+               +               +               +               +
+      A0       +      A0       +      A0       +      A0       +
+ + + + +
@anatolebeuzon
anatolebeuzon / config.json
Last active October 15, 2019 12:01
Do a POST request every n milliseconds. Supports concurrent in-flight requests. Usage: `go run main.go`
{
"requestFrequencyInMS": 100,
"url": "http://localhost/",
"cookies": {
"key1": "value1",
"key2": "value2"
}
}
@anatolebeuzon
anatolebeuzon / 20auto-upgrades
Last active March 24, 2024 08:21
Unattended-upgrades config for Raspberry Pi running Raspbian
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "3";
APT::Periodic::Verbose "1";
APT::Periodic::Unattended-Upgrade "1";