Skip to content

Instantly share code, notes, and snippets.

@jaens
jaens / zod-deep-strict-partial.ts
Last active October 29, 2024 22:34
Zod deep strict and `deepPartial` utility
/*
Copyright 2024, Jaen - https://github.com/jaens
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@jaens
jaens / storyBookRouter.tsx
Created February 18, 2024 00:01
Storybook fake Tanstack router
/* eslint-disable react-refresh/only-export-components */
import {
createMemoryHistory,
createRootRoute,
createRoute,
createRouter,
useRouterState,
type NotFoundRouteProps,
} from "@tanstack/react-router";
import { createContext, useContext, type ReactNode } from "react";
{
"log": {
"version": "1.2",
"creator": {
"name": "Firefox",
"version": "117.0"
},
"browser": {
"name": "Firefox",
"version": "117.0"
@jaens
jaens / parser.ts
Last active January 10, 2021 16:41
Quick example of an LL(1) incremental parser in TypeScript
type RuleName = string;
type TokenName = string;
type Ast = { type: string; args: Ast[] };
// Stack frame for executing grammar rules
type Frame = {
/** Current rule being executed */
rule: RuleName;
/** Position within instruction array */
#!/usr/sbin/dtrace -C -s
#pragma D option quiet
#pragma D option switchrate=10hz
inline int af_inet = 2; /* AF_INET defined in bsd/sys/socket.h */
inline int af_inet6 = 30; /* AF_INET6 defined in bsd/sys/socket.h */
#define HEADER "%-6s %-16s %-8s %-30s %-5s %8s %s\n"
#define HEADERD "%-6d %-16s %-8s %-30s %-5d %8d %s\n"
#!/usr/sbin/dtrace -w -C -s
#pragma D option quiet
inline int af_inet6 = 30; /* AF_INET6 defined in bsd/sys/socket.h */
inline string CHARLES = "Charles";
syscall::connect*:entry
{