Skip to content

Instantly share code, notes, and snippets.

View s3i7h's full-sized avatar
👻

Yuichiro Smith s3i7h

👻
View GitHub Profile
@s3i7h
s3i7h / omitNull.ts
Last active May 12, 2024 09:15
omitType, omitNull typescript example
type OmitNull<T> = T extends never ? never :
T extends null ? never :
T extends Array<infer U> ? Array<OmitNull<U>> :
T extends { [key: string]: unknown } ? { [K in keyof T]: OmitNull<T[K]> } :
T
type A = {
a: number
b: string | null
c: {
@s3i7h
s3i7h / reservoir_sample.py
Created January 8, 2022 16:37
A sample implementation of the Reservoir Sampling algorithm (might be wrong)
from typing import Iterable, TypeVar, List
from collections import deque
from itertools import islice
import math
import random
T = TypeVar("T")
@s3i7h
s3i7h / keybase.md
Last active April 29, 2024 01:17
feat: migrate identity from yu-ichiro to s3i7h

Keybase proof

I hereby claim:

  • I am s3i7h on github.
  • I am s3i7h (https://keybase.io/s3i7h) on keybase.
  • I have a public key ASC-PXQSVN4yIETiLsOzPw8pDmYkWL9lX5QQdjWKC_A7Vwo

To claim this, I am signing this object:

@s3i7h
s3i7h / LICENSE
Created December 1, 2020 11:35
LICENSE for all my public gists
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@s3i7h
s3i7h / AnyUri.py
Last active April 2, 2024 17:14
a class that handles uri
import re
from re import Pattern
from typing import Dict, Any, cast
from pydantic.utils import update_not_none
from pydantic.validators import constr_length_validator
class RFC3986Regex:
ALPHA: Pattern = r"[a-zA-Z]"