Skip to content

Instantly share code, notes, and snippets.

View madidier's full-sized avatar

Maxime DIDIER madidier

  • Strasbourg, France
View GitHub Profile
@madidier
madidier / gray_code_toy.js
Created August 18, 2023 22:56
jsfiddle n-ary gray codes toy
const unindent = (strings, ...values) => {
// Quick and not so dirty unindented template strings.
// Handles tabs very roughly if they are present.
// The very first line is always left as is if not entirely whitespace,
// and removed otherwise.
const matchLine = line => {
const {groups} =
/^(?<line>(?<indent>[\t ]*)(?<nonws>[^\n]*)\n?)(?<tail>.*)$/s.exec(line);
return {
@madidier
madidier / README.md
Created December 22, 2023 22:52
Alternative SSH key switching approach to switch accounts on GitHub

Background

My need was to be able to easily switch the SSH key used to authenticate to GitHub because I have a work account and a personnal account. I know of this method, but it would be very unpractical on my codebases.

The reason is that I use Nix flakes both on personnal and on professional projects - and those flakes tend to reference other, private flakes. Flakes have lockfiles that pinpoint dependecies via their git+ssh: urls, and the aforementioned method would require messing with these URLs. In other words, I need git+ssh://git@github.com/org/repo to stay as it is and not become something like git+ssh://git@github.com-work/org/repo so that my Nix flakes and other dependency-pinning tools can work with private repos.

I did some reading on man ssh_config and came up with an enhanced method that fixes it for me. I'm providing the code I inserted in my Home Manager config along with instructions on how to achieve this if you are not using Home M

// ==UserScript==
// @name XCancel
// @namespace http://madidier.fr/
// @version 2025-01-25
// @description Redirige automatiquement sur xcancel.com
// @author madidier.fr
// @match https://x.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=xcancel.com
// @grant none
// ==/UserScript==