Skip to content

Instantly share code, notes, and snippets.

View zoontek's full-sized avatar

Mathieu Acthernoene zoontek

View GitHub Profile
@zoontek
zoontek / keybase.md
Created March 15, 2017 13:14
keybase.md

Keybase proof

I hereby claim:

  • I am zoontek on github.
  • I am zoontek (https://keybase.io/zoontek) on keybase.
  • I have a public key ASAap_lL6Nf_OF1ZJQwaweIV1PFKNLtNkh3qlp6RlR9d0go

To claim this, I am signing this object:

type ReturnType<F> = F extends (...args: any[]) => infer R ? R : any;
type MemoizeResolver<F extends (...args: any[]) => any> = (
...args: Parameters<F>
) => string;
type MemoizedFuntion<F extends (...args: any[]) => any> = ((
...args: Parameters<F>
) => ReturnType<F>) & {
@zoontek
zoontek / match.ts
Created April 15, 2020 14:11
TS match functions
type Key = string | number | symbol;
type ExhaustiveMatch<K extends Key, T> = Record<K, T>;
type PartialMatch<K extends Key, T> = Partial<Record<K, T>> & { _: T };
export const match = <T, K extends Key = Key>(
key: K,
map: ExhaustiveMatch<K, T> | PartialMatch<K, T>,
): T => (map.hasOwnProperty(key) ? map[key] : (map as PartialMatch<K, T>)._) as T;
// Libs internal
type Segment<T> = {
test: (value: unknown) => boolean;
parse: (string: string) => T;
stringify: (value: T) => string;
};
const string: Segment<string> = {
test: (value) => typeof value === "string",
import frenchkiss, { TranslationParams } from "frenchkiss";
const en = {
"button.hello": "Hello",
};
type TranslationKey = keyof typeof en;
const fr: { [key in TranslationKey]: string } = {
import { useSyncExternalStore } from "react";
export type Atom<Value> = {
get: () => Value;
set: (value: Value | ((prevValue: Value) => Value)) => void;
subscribe: (callback: (value: Value) => void) => () => void;
reset: () => void;
};
export const atom = <Value>(initialValue: Value): Atom<Value> => {
@zoontek
zoontek / gpg.sh
Created April 7, 2023 08:17
GPG on macOS (compatible with Fork)
$ brew install gnupg
$ brew install pinentry-mac
$ echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
$ killall gpg-agent