Skip to content

Instantly share code, notes, and snippets.

View tcardlab's full-sized avatar
🥐
Strudel Time

Halu tcardlab

🥐
Strudel Time
View GitHub Profile
@cayter
cayter / repository.ts
Last active September 9, 2024 15:49
Drizzle ORM Type-Safe Repository With PgTable
import { startSpan } from "@sentry/remix";
import type { StartSpanOptions } from "@sentry/types";
import {
type AnyColumn,
type AnyTable,
type BuildQueryResult,
type DBQueryConfig,
type DrizzleTypeError,
type Equal,
type ExtractTablesWithRelations,
@ikupenov
ikupenov / db-client.ts
Created February 29, 2024 18:40
Intercepting Drizzle db calls
import { and, type DBQueryConfig, eq, type SQLWrapper } from "drizzle-orm";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres, { type Sql } from "postgres";
import { type AnyArgs } from "@/common";
import {
type DbClient,
type DbTable,
type DeleteArgs,
@eyecatchup
eyecatchup / calc-sapisidhash.js
Last active August 27, 2024 07:15
Calculate SAPISIDHASH
// Generates the SAPISIDHASH token Google uses in the Authorization header of some API requests
async function getSApiSidHash(SAPISID, origin) {
function sha1(str) {
return window.crypto.subtle.digest("SHA-1", new TextEncoder("utf-8").encode(str)).then(buf => {
return Array.prototype.map.call(new Uint8Array(buf), x=>(('00'+x.toString(16)).slice(-2))).join('');
});
}
const TIMESTAMP_MS = Date.now();
const digest = await sha1(`${TIMESTAMP_MS} ${SAPISID} ${origin}`);
@OlfillasOdikno
OlfillasOdikno / Linux_GPU_PV.md
Last active September 17, 2024 02:45
Hyperv Linux Guest GPU PV

Hyperv Linux Guest GPU PV

  • Create VM
$isopath = <iso location>
$vhdpath = <vhdx location>
$vmpath = <vm path>
$vmname = "Arch-dxgkrnl"
New-VM -Name $vmname -MemoryStartupBytes 8GB -BootDevice VHD -NewVHDPath $vhdpath -Path $vmpath -NewVHDSizeBytes 20GB -Generation 2 -Switch "Default Switch"
@ryansolid
ryansolid / framework size comparison.md
Last active October 22, 2022 13:27
Size Comparison Vue vs Svelte vs Solid

Based on Evan You's methodology: https://github.com/yyx990803/vue-svelte-size-analysis

Table

Vue Vue (SSR) Svelte Svelte (SSR) Solid Solid (SSR)
Source 3.93kb - 3.31kb - 4.98kb -
Compiled w/o imports (min) 2.73kb - 5.01kb (183.52%) 6.59kb (241.39%) 3.68kb (134.805) 3.96kb (145.05%)
Compiled w/o imports (min+gz) 1.25kb - 2.13kb (170.40%) 2.68kb (214.40%) 1.46kb (116.80%) 1.57kb (125.60%)
Compiled w/o imports (min+brotli) 1.10kb - 1.88kb (170.91%) 2.33kb (211.82%) 1.26kb (114.55%) 1.32kb (120.00%)

Electron is tricky to get set up on Windows Subsystem for Linux, but it can work!

Four things needed overall:

  1. you need WSL2, not WSL1
  2. you need node, of course, and that part isn't so bad
  3. you need to apt install several dependencies
  4. you need an X Server so it can display the electron GUI over in Windows-land

Setup instructions, in order:

@dakshin-k
dakshin-k / drag.ahk
Created May 27, 2020 09:52
AutoHotKey Script for Three finger Click and Drag gesture on Windows
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
drag_enabled := 0
+^#F22::
@Wenangsani
Wenangsani / fastify_netlify.js
Created January 9, 2020 07:21
Fastify for Netlify
"use strict";
const fastify = require("fastify");
const app = fastify();
const serverless = require("serverless-http");
app.get("/test", (request, reply) => {
reply.send({ hello: "world" });
});
app.get("/test/one", (request, reply) => {
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.