Skip to content

Instantly share code, notes, and snippets.

View jRimbault's full-sized avatar
💭
🦀🐍TS C#

Jacques Rimbault jRimbault

💭
🦀🐍TS C#
View GitHub Profile
@jRimbault
jRimbault / xkcd-sway-lock py
Created April 9, 2024 13:01
Lock swaywm with an xkcd comic
#!/usr/bin/env python3
"""Download random xkcd comic"""
import json
import random
import subprocess
import textwrap
from pathlib import Path
from urllib.request import urlopen, urlretrieve
{
"basics": {
"name": "Jacques Rimbault",
"label": "Développeur 5 ans d'expérience",
"email": "jacques.rimbault@gmail.com",
"phone": "+336309644882",
"location": {
"city": "Paris"
},
"profiles": [
/* In a config object :
{
"endpoints": {
"createUser": {
"path": "/users",
"method": "POST"
}
"listUsers": {
"path": "/users",
"method": "GET"
public static class TypeExt
{
public static string HumanReadableName(this Type self)
{
return InnerHumanReadable(self).ToString();
}
private static System.Text.StringBuilder InnerHumanReadable(Type self)
{
if (!self.IsGenericType)
@jRimbault
jRimbault / Mutex.cs
Last active May 9, 2021 10:58
a RAII mutex lock using the `IDisposable` interface
using System;
using System.Threading;
namespace Sync
{
// If C# had different (slightly better imo) visibility semantics
// that interface wouldn't exists and the nested type wouldn't need to be nested.
// The "best" we can do is use the repo version, put it in its own project and use
// the `internal` visibility, which is dumb shit.
public interface IMutexGuard<T> : IDisposable
@jRimbault
jRimbault / example.md
Last active March 29, 2021 16:20
SequentialFromParallelIterator
#!/usr/bin/env python3
"""Algorithm
1. read rows sorted by date :
- avg O(n log n)
- best O(n)
- worst O(n log n)
2. partition by name : O(n)
put all rows in buckets keyed by user id/name,
#!/usr/bin/env python3
import argparse
import csv
import os
import sys
from pathlib import Path
def main(args):
interface ResultMethods<T, E> {
ok(): T | null,
err(): E | null,
unwrap(): T | never,
unwrapErr(): E | never,
expect(message: string): T | never,
expectErr(message: string): E | never,
map<U>(f: (value: T) => U): Result<U, E>,
mapErr<U>(f: (error: E) => U): Result<T, U>,
andThen<U>(f: (value: T) => Result<U, E>): Result<U, E>,