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 4, 2025 12:22
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 13, 2025 02:32
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)))
@fepegar
fepegar / unet-constraints.ipynb
Last active April 11, 2024 06:30
Understanding U-Net shape constraints
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.