Skip to content

Instantly share code, notes, and snippets.

View ghoullier's full-sized avatar
🧙‍♂️
TypeScript everything

Grégory Houllier ghoullier

🧙‍♂️
TypeScript everything
View GitHub Profile
@gdarchen
gdarchen / set-saved-replies.js
Last active March 21, 2025 16:11
Conventional Gitmoji review comments
(async function generateReplies(document) {
/**
* Those saved replies are a mix of the "conventional comments" and the
* "code review emoji guide".
* Refer to the following resources:
* - https://conventionalcomments.org
* - https://github.com/axolo-co/code-review-emoji-guide
*/
const LABEL = {
@colinhacks
colinhacks / bench.sh
Last active January 5, 2024 09:37
Benchmark testing libraries against Zod's test suite
# requires hyperfine and Bun v0.7 or later
# https://github.com/sharkdp/hyperfine
git clone [email protected]:colinhacks/zod.git
cd zod
bun install
hyperfine --warmup 3 --runs 10 \
"bun test src" \
"npx vitest --config configs/vitest.config.ts" \
"npx jest -c configs/babel-jest.config.json" \
@Firnael
Firnael / Dockerfile
Last active August 8, 2024 07:51
Distroless NodeJS + Typescript
## NodeJS Typescript multi-stage docker image ##
# build project with typescript
FROM node:16.15.1-stretch as ts-compiler
WORKDIR /app
COPY package*.json ./
COPY tsconfig*.json ./
RUN npm install
COPY . ./
RUN npm run build
@jacob-ebey
jacob-ebey / deferred-overview.md
Last active February 28, 2025 05:42
Deferred Overview

Remix Deferred

Remix Deferred is currently implemented on top of React's Suspense model but is not limited to React. This will be a quick dive into how "promise over the wire" is accomplished.

SSR + Hydration

It isn't rocket science, but a quick recap of how frameworks such as react do SSR:

  1. Load data
  2. Render the app
import assert from 'node:assert/strict';
// Extended RegExp mode (flag /x) [1] via a template tag
//
// Quote: “While the x-mode flag can be used in a RegularExpressionLiteral,
// it does not permit the use of LineTerminator in RegularExpressonLiteral.
// For multi-line regular expressions you would need to use the RegExp
// constructor.”
//
// The plan is to include this functionality in re-template-tag [2]. Then
@dagda1
dagda1 / UnionTo.ts
Last active February 9, 2022 06:16
// both examples below start
type UnionToXXX<T> = (T extends any ? (t: T) => T : never) extends infer U ? // rest
// Converts { x: string } | { y: number } to { x: string, y: number }
type UnionToIntersection<T, U = T> = (U extends any ? (arg: U) => any : never) extends ((arg: infer I) => void) ? I : never;
// Converts string | number | boolean to [string, number, boolean]
type UnionToTuple<T> = (
(
(
@alii
alii / ensure-keys.ts
Created August 25, 2021 14:12
Infer object values while strictly specifying keys in TypeScript
/**
* TypeScript currently lacks a way of typing a record of keys only but not values.
* we need this because we want an object of typed keys but we want to leave the values inferred.
* thankfully, we can do this with generics. This function allows the second generic's values to be inferred
* so that our object is fully type safe for hugely complex types, but we can guarantee that all the keys we need exist.
* It's not perfect, but it gets the job done for the time being
*/
export function ensureKeys<T>() {
/**
* Function that returns the value that gets put in, values are type-safely inferred
@jaredpalmer
jaredpalmer / MarkdownPage.tsx
Created February 17, 2021 13:52
Get headers from MDX in Next.js
import {MDXProvider} from '@mdx-js/react';
import {MDXComponents} from 'components/MDX/MDXComponents';
import {Toc} from 'components/Toc/Toc';
import * as React from 'react';
export interface MarkdownProps<Frontmatter> {
meta: Frontmatter;
children?: React.ReactNode;
}
@fvln
fvln / Jouons avec le phishing Paypal.md
Last active January 7, 2021 11:02
Quelques observations sur les attaques par phishing ciblant Paypal

Jouons avec le phishing Paypal

Courant septembre, j'ai testé un développement qui cherche des patterns parmi (les certificats TLS venant d'être délivrés publiquement)[http://certstream.calidog.io/]. La limite de cette recherche, c'est qu'elle s'applique sur des noms de domaines et pas des URL complètes ! Il suffit de filtrer ces certificats avec le mot-clé « paypal » pour obtenir des dizaines de noms de domaines malveillants par jour, avec parfois... juste un .zip à la racine. Comme j'en ai attrapé quelques-uns (ici 16shop), c'est l'occasion de les décortiquer ;)

Comment ça marche ?

Essayons de comprendre comment les attaquants travaillent !

@KATT
KATT / favourite-ts-tricks.md
Last active April 8, 2025 01:25
🧙‍♂️ Favourite non-obvious TS tricks

Record<string, x | undefined>

Represent maps

// rather than 
const map: {[ key: string ]: string} = {
  foo: 'bar',
}