Skip to content

Instantly share code, notes, and snippets.

View WoLfulus's full-sized avatar
🖥️
C:\> wsl --user 🐺

WoLfulus WoLfulus

🖥️
C:\> wsl --user 🐺
View GitHub Profile
@WoLfulus
WoLfulus / bindings.ts
Last active June 5, 2024 10:36
Keeps the client instance the same when adding extensions.
import { DirectusClient } from "@directus/sdk";
export interface BindableClient {
with: <
Client extends DirectusClient<any>,
Extension extends object,
>(
createExtension: (client: Client) => Extension,
) => this & Extension;
@WoLfulus
WoLfulus / sync.md
Created October 20, 2023 11:09
Windows Time Sync
w32tm /config /manualpeerlist:"time.cloudflare.com" /syncfromflags:manual /update
w32tm /resync

Quick Usage

Component

button.module.scss

@include "@wolfulus/component" as *;
@include "@wolfulus/props" as props;
@WoLfulus
WoLfulus / naci.scss
Last active May 18, 2023 19:00
naci.js evolution (syntax)
// --------------------------------------------------------
// v1
$button: component(
name("Button"),
type("button"),
props(
prop(size, (default large)),
),
);
import { z } from "zod";
import { query } from "@/lib/api/middlewares/with-query";
import { responses } from "@/lib/api/responses";
import { get, route } from "@/lib/api/route";
import { locales } from "@/server/middlewares/with-locales";
import { db } from "@/server/middlewares/with-db";
export const { GET } = route(
@WoLfulus
WoLfulus / conditionals.ts
Created February 23, 2023 01:45
TypeScript build/compilation-time if/then/else blocks
// Utilities
declare const TAG: unique symbol;
type TAG = typeof TAG;
export type Tagged<TagSymbol extends symbol> = {
readonly [TAG]: TagSymbol;
};
export type WithTag<TagSymbol extends symbol, Target> = Tagged<TagSymbol> &
@WoLfulus
WoLfulus / switch.ts
Created February 22, 2023 21:54
"Switch Case" for TypeScript Types
// PoC, has problems with type matching in case array
type Case<V extends boolean = any, T = any> = [V, T];
type Switch<T extends readonly any[], Fallback = never> =
T extends [infer Head, ...infer Rest] ? [Head] extends [[true, infer V]] ? V :
Switch<Rest> : Fallback;
type Default<V> = [true, V];
@WoLfulus
WoLfulus / pages-index.tsx
Last active February 17, 2023 00:47
Strongly typed Next.js routes and SWR
// pages/index.tsx
import { preload } from "@routes/server";
import People from "../lib/loaders/people";
export default Index({ defaultCount }) {
const [count, setCount] = useState(defaultCount);
return (
<>
@WoLfulus
WoLfulus / Bridge.cs
Last active May 18, 2022 01:55
Bridge
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using UnityEngine;
using Vuplex.WebView;
namespace UI.Interop
{
@WoLfulus
WoLfulus / watch.js
Created June 13, 2021 06:45
Watch and restart executables
const fs = require('fs');
const path = require('path');
const yargs = require('yargs');
const short = require('short-uuid')();
const chokidar = require("chokidar");
const log = require('pino')({
prettyPrint: true,
});
const args = yargs.argv;