Skip to content

Instantly share code, notes, and snippets.

View Christopher-Hayes's full-sized avatar
🇺🇦
stand-with-ukraine.pp.ua

Chris​‌​‮ ‬Hayes‌​​​ Christopher-Hayes

🇺🇦
stand-with-ukraine.pp.ua
View GitHub Profile
@adamstddrd
adamstddrd / theme-picker.js
Created September 18, 2023 22:54
A theme picker custom element with a "random" option
/* ----------------------------------------------------------------------------
switch between color themes
---------------------------------------------------------------------------- */
export default class ThemePicker extends HTMLElement {
static randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
static getLuminanace(values) {
const rgb = values.map((v) => {
@ciiqr
ciiqr / zod-optional-null.ts
Last active April 24, 2025 20:02
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@jpvalery
jpvalery / _api_folder_incoming.js
Last active October 7, 2023 08:59
How to do fire-and-forget requests in NextJS using middleware (Slack FaaS serverless ack() alternative)
// path /api/folder/incoming.js
export default async function handler(req, res) {
let message = `hi from /api/folder/incoming`;
console.log(message);
console.log(req.body)
res.status(200).send(message);
return;
}
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
# Written by jachiam
import argparse
import os.path as osp
import torch
@ckcr4lyf
ckcr4lyf / node_ipc_malware.md
Last active May 26, 2022 00:12
Explanation of the malware in node-ipc
@jyydev
jyydev / README.md
Last active April 16, 2025 21:21
VSCode -> autocomplete -> disable & turn off autocomplete on dot . period

Disable (turn off) autocomplete on dot . period for VSCode

Most people do not want to have autocompletion when they press the dot key, which should be disabled by default in VSCode.

Below shows 2 ways to turn this off.

Method 1:

  1. Go to VSCode setting and search for:
editor.acceptSuggestionOnCommitCharacter
@kabili207
kabili207 / Rclone systemd service.md
Last active April 21, 2025 09:50
Rclone systemd user service

rclone systemd service

Preparation

This service will use the same remote name you specified when using rclone config create. If you haven't done that yet, do so now.

Next, create the mountpoint for your remote. The service uses the location ~/mnt/<remote> by default.

mkdir ~/mnt/dropbox
@claus
claus / _app.js
Created May 14, 2020 05:35
Restore scroll position after navigating via browser back/forward buttons in Next.js
import useScrollRestoration from "utils/hooks/useScrollRestoration";
const App = ({ Component, pageProps, router }) => {
useScrollRestoration(router);
return <Component {...pageProps} />;
};
export default App;
@TriMill
TriMill / gen-unicode-list.py
Created February 28, 2020 00:04
List of all (non-control) Unicode characters with codepoint and Unicode descriptor (as given by python module "unicodedata").
#!/usr/bin/python
import unicodedata
import math
MIN_CHAR=0x20
MAX_CHAR=0x100000
PROGRESS=0x8000
print("|%s|" % ("*"*math.ceil((MAX_CHAR-MIN_CHAR) / PROGRESS)))
@markknol
markknol / shadertoy.md
Last active April 25, 2025 07:48
Shader cheatsheet (from shadertoy)

This help only covers the parts of GLSL ES that are relevant for Shadertoy. For the complete specification please have a look at GLSL ES specification

Language:

Version: WebGL 2.0
Arithmetic: ( ) + - ! * / %
Logical/Relatonal: ~ < > <= >= == != && ||
Bit Operators: & ^ | << >>
Comments: // /* */
Types: void bool int uint float vec2 vec3 vec4 bvec2 bvec3 bvec4 ivec2 ivec3 ivec4 uvec2 uvec3 uvec4 mat2 mat3 mat4 mat?x? sampler2D, sampler3D samplerCube
Format: float a = 1.0; int b = 1; uint i = 1U; int i = 0x1;