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 July 16, 2024 01:25
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
@kabili207
kabili207 / Rclone systemd service.md
Last active July 13, 2024 20:28
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.
@SHaTRO
SHaTRO / git-forked-to
Last active July 14, 2021 07:23
BASH script to change "original" upstream clone to newly forked repo
#!/bin/bash
## If you cloned a repository, then forked it and want to change your clone to point to your fork...
## Usage:
## git-forked-to <NEW ORIGIN URL> [<BRANCH>]
##
## <NEW ORIGIN URL> should be your new forked repo URL
## <BRANCH> defaults to "master"
##
## For example: git-forked-to git@github.com:SHaTRO/conveyance.git