This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function partition<T, K extends string | number>( | |
list: readonly T[], | |
getKey: (el: T) => K, | |
) { | |
const res: { [k in K]?: T[] } = {} | |
for (const el of list) { | |
const key = getKey(el) | |
const target: T[] = res[key] ?? (res[key] = []) | |
target.push(el) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* In a config object : | |
{ | |
"endpoints": { | |
"createUser": { | |
"path": "/users", | |
"method": "POST" | |
} | |
"listUsers": { | |
"path": "/users", | |
"method": "GET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type DeepDotKey<T> = { | |
[P in keyof T]: DeepDotKey<T[P]>; | |
} & (() => string); | |
/** | |
* Type safe string builder deep dot notation | |
* | |
* @example | |
* interface Foo { | |
* dictionary: { [key: string]: { value: number } | undefined }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"identity":{"name":"Jacques Rimbault","shortName":"jRimbault","description":"Programmeur, 29 ans, -Werror","location":"Paris"},"paragraphs":[{"name":"Experience","id":"experience","elements":[{"aside":{"kind":"date","date":"2018 .. 2019"},"title":"Développeur C# Angular","subTitle":"Société Générale - Corporate and Investment Banking","tags":[["C#","TypeScript","PowerShell"],[".NET","Angular"],["Windows Server"],["GitHub","TeamCity"]]},{"aside":{"kind":"date","date":"2016 .. 2018"},"title":"Développeur PHP","subTitle":"Ministère de l'Intérieur - SG-DSIC","subTitleDescription":"Secrétariat Général - Direction des Systèmes d'Information et Communication","resume":["Développement et maintenance d'une application de l'administration centrale."],"points":[{"description":"Migration de PHP 5.4 vers PHP 7.2","subPoints":[{"description":"Changement de l'API d'interface avec la base de donnée"},{"description":"Refonte sous une forme routeur/controleur"},{"description":"Management des dépendances"}]},{"description":"Fo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"basics": { | |
"name": "Jacques Rimbault", | |
"label": "Développeur 5 ans d'expérience", | |
"email": "jacques.rimbault@gmail.com", | |
"phone": "+336309644882", | |
"location": { | |
"city": "Paris" | |
}, | |
"profiles": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
OlderNewer