Skip to content

Instantly share code, notes, and snippets.

View sillvva's full-sized avatar

Matt DeKok sillvva

View GitHub Profile
@sillvva
sillvva / builders.ts
Created September 21, 2023 15:04
Websocket Wrapper with Svelte 5 Runes
export default function createSocket<T>(
url: string | URL,
options?: {
name?: string;
protocols?: string | string[];
onOpen?: (event: Event) => void;
onError?: (error: Event) => void;
onMessage?: (data: T, requests: T[], event: Event) => void;
}
) {
@sillvva
sillvva / useTimer.tsx
Last active August 24, 2022 03:14
Zod-validated, query-based useTimer Hook
import qs from "qs";
import { z, ZodSchema } from "zod";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import { useEffect, useRef, useState } from "react";
dayjs.extend(duration);
const parseObjectPrimitives = (obj: Record<string, any>): any => {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => {
@sillvva
sillvva / qsZod.ts
Created August 24, 2022 01:34
Query String Parser with Zod
import qs from "qs";
import { ZodSchema } from "zod";
const parseObjectPrimitives = (obj: Record<string, any>): any => {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => {
if (typeof v === "object") return [k, parseObjectPrimitives(v)];
if (!isNaN(parseFloat(v))) return [k, parseFloat(v)];
if (v === "true") return [k, true];
if (v === "false") return [k, false];
@sillvva
sillvva / gist:db596d058f0f5901af5b1626f823570b
Created July 29, 2022 16:14
`vercel build` error message
error during build:
Error: EPERM: operation not permitted, symlink '.pnpm\zod@3.17.3\node_modules\zod' -> '.vercel\output\functions\render.func\node_modules\zod'
at Object.symlinkSync (node:fs:1651:3)
at create_function_bundle (file:///C:/Users/mattd/SynologyDrive/Web%20Development/matt.dekok.app%20(Sveltekit)/node_modules/.pnpm/@sveltejs+adapter-vercel@1.0.0-next.65/node_modules/@sveltejs/adapter-vercel/index.js:375:7)
at async generate_serverless_function (file:///C:/Users/mattd/SynologyDrive/Web%20Development/matt.dekok.app%20(Sveltekit)/node_modules/.pnpm/@sveltejs+adapter-vercel@1.0.0-next.65/node_modules/@sveltejs/adapter-vercel/index.js:153:5)
at async Object.adapt (file:///C:/Users/mattd/SynologyDrive/Web%20Development/matt.dekok.app%20(Sveltekit)/node_modules/.pnpm/@sveltejs+adapter-vercel@1.0.0-next.65/node_modules/@sveltejs/adapter-vercel/index.js:234:5)
at async adapt (file:///C:/Users/mattd/SynologyDrive/Web%20Development/matt.dekok.app%20(Sveltekit)/node_modules/.pnpm/@svelte
alias: 'Notification: Packages Delivered'
description: ''
trigger:
- platform: state
entity_id: sensor.mail_fedex_delivered
from: '0'
id: Fedex
- platform: state
entity_id: sensor.mail_ups_delivered
from: '0'
name: AL_Logsheet
description: ''
host: EXCEL
api_set: {}
script:
content: >-
/** @CustomFunction */
function AddingMagicItems(PreviousItems: string, NewItems: string): string {
try {
@sillvva
sillvva / Industrial Grid.xml
Created January 2, 2020 20:37
Cities Skylines: Industrial Grid
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="utf-8"?>
<Selection>
<center>
<x>747.102966</x>
<y>219.23024</y>
<z>2351.66821</z>
</center>
<state d2p1:type="BuildingState" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance">
<position>
<x>792.333069</x>
@sillvva
sillvva / Date Filtering.EXCEL.yaml
Last active June 26, 2019 02:03
Filters data based on date range
name: Date Filtering
description: Filters data based on date range
host: EXCEL
api_set: {}
script:
content: |
tryCatch(registerOnChangedHandler);
async function registerOnChangedHandler() {
await Excel.run(async (context) => {
@sillvva
sillvva / DDBTweaks.js
Last active June 19, 2019 05:03
D&D Beyond Tweaks
// ==UserScript==">
// @name D&D Beyond Tweaks
// @namespace http://dndbeyond.com/
// @version 2.1
// @description Adds quality of life changes
// @author Sillvva
// @match https://www.dndbeyond.com/*
// @grant none
// ==/UserScript==
@sillvva
sillvva / showto.md
Last active December 28, 2018 23:45
FVTT mod: showto

You could also probably accomplish that with a simple styles module like this:

<div>Everyone sees this part of the message</div>
<div showto="gm Sillvva">Only the GM and Sillvva see this part.</div>
Hooks.on('ready', () => {
    let style = document.createElement('style');