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 / 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

@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 / unindent.js
Created August 16, 2023 22:42
JavaScript unindent tagged template literal
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 / bbn.user.js
Created July 24, 2023 20:29
BlueBird Necromancer
// ==UserScript==
// @name BlueBird Necromancer
// @namespace https://twitter.com/madidier_
// @version 0.1
// @description Bring back the blue bird from the dead!
// @author @madidier_
// @match https://twitter.com/*
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJkSURBVHgB7VZBbtpQEH3zIW0WVYuXVaH4Bs0NSk4AOUFhEarskhMknIDsqkKlcIT0BNAT1D1B3ZJK3dmVuirwp/MhVmzAxiagKBJv9+ePZ97M/JkxsMMODwzChlD84FWQp3MxeCDHAhiumB+MJrr1+8Ryw3p/9+H4DctfIPCq49Xlw8Kv99YlMuB19885gy/i7llziwGfFFWJyR02XzSCuwiBUse7BlFVaz5LS8KQVkRXaXRJsqImfDjKSZBNyzEyFWFKVJ4KFbWLElUao6KbSk8i9TXgTPaorxTskPwOxa7/9baGt4zg8oQbNyfWYJlRU0/KUx9ZwNwYNq1ecFRzl18QpW0bB0Ks//KjV1uwlbuLJA3GxEdh5wb5yGEPl3qMd2xecYQHKnlFlVLX95kxYCFKGg5IlU2a0uLpCM68LEJA+sJ/Dm6Jy3aMjQIRakRUm+UuvfOp/X34iQSejeFo0Hdx4optG5uFH/R+GHNvANcm3VtwLs+Lvy2TRwhIOnrYHhysIuDKcCDwGbYAjglOzQt+HssElF6dvoNNOZeuCSbfSgIGMjILMo4/ExZf7TqghNLmlwm1gpSC2tmaLAZMvWGz0Iu7XpqBm2NrQNN5cD+Y5
// ==UserScript==
// @name Pesky MSDN translations !
// @namespace http://madidier.github.com/
// @version 0.2
// @description Disable translations on MSDN and other MS documentation sites.
// @author Maxime A. Didier
// @match https://*.microsoft.com/fr-fr/*
// @grant none
// ==/UserScript==
@madidier
madidier / Typeclass.fs
Last active July 16, 2017 11:15
Oh, god ! I did it !
module Typeclass
type __<'f, 'a> = interface end
// __<fμ, 'a> -> f<'a>
let inline ω (x: __<'f, 'a>) = (^f: (static member ω : __<'f, 'a> -> 'b) x)
// f<'a> -> __<fμ, 'a>
let inline μ (x: 'a) = (x :> __<'f, 'b>)
@madidier
madidier / F.java
Last active July 5, 2017 19:45
Interpreters for Iota/IotaM
import java.io.*;
import java.util.function.*;
@FunctionalInterface
public interface F {
F $(F α);
default Object μ() {
return null;
}
{-# LANGUAGE BangPatterns #-}
module Iota
( Expr(..)
, run
) where
import Prelude hiding (succ)
import Control.Monad (void)
import Data.Char (chr, ord)
@madidier
madidier / Lambda.pro
Last active March 18, 2018 17:54
Lambda calculus simplifier and interpreter in SWI prolog
/*
* AST definition
*/
:- op(100, fx , (:)).
:- op(200, yfx, ($)).
:- op(300, xfy, (->)).
isName(N) :- N =.. [_].
@madidier
madidier / Either-hof.agda
Last active July 6, 2023 12:05
Sum type encoding and catamorphism of "Either" in various languages and approaches
-- I haven't been able to actually run the program (broken archlinux packages), but it typechecks
open import Data.String
open import Function
open import IO.Primitive
Either : Set → Set → Set₁
Either l r = {a : Set} → (l → a) → (r → a) → a
Left : { l r : Set } → l → Either l r