Skip to content

Instantly share code, notes, and snippets.

View Saul-Mirone's full-sized avatar
🍼
Working on Milkdown and Blocksuite

Mirone Saul-Mirone

🍼
Working on Milkdown and Blocksuite
View GitHub Profile
// https://github.com/microsoft/TypeScript/issues/27024
export type Equals<X, Y> =
(<T>() => T extends X ? 1 : 2) extends
(<T>() => T extends Y ? 1 : 2) ? true : false;
@Saul-Mirone
Saul-Mirone / squash.sh
Created September 18, 2022 09:44
Squash all commits
git checkout yourBranch
git reset $(git merge-base main $(git branch --show-current))
git add -A
git commit -m "one commit on yourBranch"
export type Pipeline = (env: PipelineEnv, next: () => Promise<void>) => Promise<void>;
const runPipeline = (pipelines: Pipeline[]) => {
return (env: PipelineEnv, next?: Pipeline): Promise<void> => {
let index = -1;
const dispatch = (i: number): Promise<void> => {
if (i <= index) return Promise.reject(new Error('next() called multiple times'));
index = i;
let fn = pipelines[i];
if (i === pipelines.length) fn = next;
type Many<T> = T | ReadonlyArray<T>;
interface Flow {
flow<A extends any[], R1, R2, R3, R4, R5, R6, R7>(
f1: (...args: A) => R1,
f2: (a: R1) => R2,
f3: (a: R2) => R3,
f4: (a: R3) => R4,
f5: (a: R4) => R5,
f6: (a: R5) => R6,
type RemoveNever<T> = { [P in keyof T as T[P] extends Function ? P : never]: T[P] };
type A_Methods = RemoveNever<A>; // { render: () => void; }
export type TRequiredKeys<T, keys extends keyof T = keyof T> =
Pick<T, Exclude<keyof T, keys>> & {
[K in keys]-?: Required<Pick<T, K>>
}[keys];
@Saul-Mirone
Saul-Mirone / file-embed.hs
Created July 27, 2018 01:38
A mini file-embed using Template Haskell
{-# LANGUAGE TemplateHaskell #-}
module TH
( embedFile )
where
import Data.String (IsString (..))
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
@Saul-Mirone
Saul-Mirone / Cookie.js
Last active February 7, 2017 05:56
A Node.js cookie module, a middleware based on express or my core.js module
@Saul-Mirone
Saul-Mirone / mini-express.js
Last active November 15, 2019 12:36
Just An Express Style Framework
const http = require('http')
const url = require('url')
const path = require('path')
const fs = require('fs')
const mime = {
"html": "text/html",
"css": "text/css",
"js": "text/javascript",
"json": "application/json",
"gif": "image/gif",
@Saul-Mirone
Saul-Mirone / MVVM.js
Last active July 21, 2022 11:59
A simple mvvm
class Register {
constructor() {
this.routes = []
}
regist(obj, k, fn) {
const _i = this.routes.find(function(el) {
if((el.key === k || el.key.toString() === k.toString())
&& Object.is(el.obj, obj)) {
return el