Skip to content

Instantly share code, notes, and snippets.

View watzon's full-sized avatar
👀
Looking for work

Chris Watson watzon

👀
Looking for work
View GitHub Profile
@watzon
watzon / with_std.cr
Last active September 25, 2023 06:05
Crystal function to capture stdin and stdout and redirect them within the block, returning an array containing 2 strings
def with_std(&block)
original_stdout = File.open("/dev/null")
original_stdout.reopen(STDOUT)
original_stderr = File.open("/dev/null")
original_stderr.reopen(STDERR)
stdout_reader, stdout_writer = IO.pipe
stderr_reader, stderr_writer = IO.pipe
import { useState } from "preact/hooks";
export interface MessageInputProps {
onSubmit: (message: { content: string; image: string | null }) => void;
}
const MessageInput = ({ onSubmit }: MessageInputProps) => {
const [message, setMessage] = useState<string>("");
const [image, setImage] = useState<string | null>(null);
@watzon
watzon / promptconvert.py
Created February 22, 2023 04:22
Stable Diffusion WebUI to InvokeAI prompt conversion script
import re
import argparse
re_attention = re.compile(r"""
\\\(|
\\\)|
\\\[|
\\]|
\\\\|
\\|

Keybase proof

I hereby claim:

  • I am watzon on github.
  • I am watzon (https://keybase.io/watzon) on keybase.
  • I have a public key whose fingerprint is 51B2 65DD 8352 2995 046F C8D6 3670 7B02 0200 D3D9

To claim this, I am signing this object:

@watzon
watzon / tagcopier.js
Created October 21, 2022 01:09
Danbooru Tag Copier
// ==UserScript==
// @name Danbooru Tag Copier
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Automatically copy all general tags from danbooru page to your clipboard
// @author watzon
// @match https://danbooru.donmai.us/posts/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=donmai.us
// @grant none
// ==/UserScript==
KNOWN_ID_MAP = { 2768409 => 1383264000000, 7679610 => 1388448000000, 11538514 => 1391212000000, 15835244 => 1392940000000, 23646077 => 1393459000000, 38015510 => 1393632000000, 44634663 => 1399334000000, 46145305 => 1400198000000, 54845238 => 1411257000000, 63263518 => 1414454000000, 101260938 => 1425600000000, 101323197 => 1426204000000, 111220210 => 1429574000000, 103258382 => 1432771000000, 103151531 => 1433376000000, 116812045 => 1437696000000, 122600695 => 1437782000000, 109393468 => 1439078000000, 112594714 => 1439683000000, 124872445 => 1439856000000, 130029930 => 1441324000000, 125828524 => 1444003000000, 133909606 => 1444176000000, 157242073 => 1446768000000, 143445125 => 1448928000000, 148670295 => 1452211000000, 152079341 => 1453420000000, 171295414 => 1457481000000, 181783990 => 1460246000000, 222021233 => 1465344000000, 225034354 => 1466208000000, 278941742 => 1473465000000, 285253072 => 1476835000000, 294851037 => 1479600000000, 297621225 => 1481846000000, 328594461 => 1482969000000, 337808429 =
@watzon
watzon / portainer-agent-caddy.yml
Created December 21, 2021 16:45
Portainer + Caddy = <3
version: '3.3'
services:
agent:
image: portainer/agent:latest
environment:
AGENT_CLUSTER_ADDR: tasks.agent
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/volumes:/var/lib/docker/volumes
import { Api, TelegramClient } from 'telegram'
import { EditMessageParams, SendMessageParams } from 'telegram/client/messages';
import { Entity, EntityLike } from 'telegram/define'
import { EventBuilder, EventCommon } from "telegram/events/common";
import { toSignedLittleBuffer } from 'telegram/Helpers';
import { getInputPeer, _getEntityPair } from 'telegram/Utils';
import { escapeRegExp } from '../utils';
export interface NewCallbackQueryInterface {
chats: EntityLike[];
// rev 452
/********************************************************************************
* *
* Author : Angus Johnson *
* Version : 6.1.3 *
* Date : 19 January 2014 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2014 *
* *
* License: *
@watzon
watzon / emoji-map.json
Last active January 30, 2024 15:17
Map of emoji names to the emoji's byte sequence
{
"point_left": "\ud83d\udc48",
"mailbox_with_mail": "\ud83d\udcec",
"timer": "\u23f2",
"grinning": "\ud83d\ude00",
"yum": "\ud83d\ude0b",
"strawberry": "\ud83c\udf53",
"ice_skate": "\u26f8",
"middle_finger_tone2": "\ud83d\udd95\ud83c\udffc",
"star_and_crescent": "\u262a",