Skip to content

Instantly share code, notes, and snippets.

View sylvaindethier's full-sized avatar

Sylvain Dethier sylvaindethier

View GitHub Profile
@sylvaindethier
sylvaindethier / is_array.sh
Last active September 6, 2017 23:50 — forked from coderofsalvation/is_array.bash
check if variable is array, returns 0 on success, 1 otherwise
## Check if variable is array
# @param mixed
# @return integer 0 on success, 1 otherwise
#
# @example
# value=("i'm an array" "and that's my 2nd value")
# if is_array value; then
# echo 'value is an Array'
# else
# echo 'value is NOT an Array'
@sylvaindethier
sylvaindethier / solidjs-RouteDefinitionParams.d.ts
Last active April 19, 2024 19:58
SolidJS type safe for `useParam` from a `RouteDefinition`
import type { RouteDefinition } from "@solidjs/router";
/**
* Refine a Type
* @example
* ```ts
* type Refined = Refine<{ foo: string, bar: unknown[] }, { foo: `${number}` }>
* // ^? { foo: `${number}`, bar: unknown[] }
* ```
*/
@sylvaindethier
sylvaindethier / Refine.d.ts
Created April 19, 2024 16:15
Refine TypeScript utility
/**
* Refine a Type
* @example
* ```ts
* type Refined = Refine<{ foo: string, bar: unknown[] }, { foo: `${number}` }>
* // ^? { foo: `${number}`, bar: unknown[] }
* ```
*/
export type Refine<T, P extends Partial<T>> = {
[k in keyof T]: T[k] & P[k];
@sylvaindethier
sylvaindethier / fastify-https-anchor.ts
Created May 7, 2024 06:48
Fastify HTTPS server with @anchordotdev/cli
//@ts-expect-error no declaration files
import {createSNICallback} from "anchor-pki/auto-cert/sni-callback";
//@ts-expect-error no declaration files
import { TermsOfServiceAcceptor } from "anchor-pki/auto-cert/terms-of-service-acceptor";
import https from "node:https";
import type { FastifyServerFactory } from "fastify";
const serverFactory: FastifyServerFactory = (handler) => {
const SNICallback = createSNICallback({