Skip to content

Instantly share code, notes, and snippets.

@FlameWolf
FlameWolf / ui-config.json
Last active June 7, 2023 13:40
AUTOMATIC1111 Web UI Configuration
{
"txt2img/Prompt/visible": true,
"txt2img/Prompt/value": "",
"txt2img/Negative prompt/visible": true,
"txt2img/Negative prompt/value": "poorly drawn, disfigured, deformed, cross-eyed, bad anatomy, bad proportions, mutated, extra limbs, extra legs, extra arms, missing limb, missing leg, missing arm, malformed limbs, asymmetrical, close-up, blurred, bad art, ugly, jewellery, hands, fingers",
"txt2img/Styles/visible": false,
"txt2img/Styles/value": [],
"txt2img/Sampling method/visible": true,
"txt2img/Sampling method/value": "DPM++ 2M",
"txt2img/Sampling steps/visible": true,
@FlameWolf
FlameWolf / getRandomIdString.js
Last active May 26, 2023 13:13
Generate random ID string
const getRandomIdString = (len = 32) => {
let retVal = "";
for (let i = 0; i < len; i++) {
const randVal = Math.random();
retVal += String.fromCharCode((randVal < 0.5 ? ((randVal * 26) + 65) : ((randVal * 10) + 48)) >> 0);
}
return retVal;
};
@FlameWolf
FlameWolf / PressAndRelease.js
Last active May 31, 2023 12:25
Global mouse hold event
(function () {
let isPressed = false;
let pressTimer = false;
const pressedEvent = new CustomEvent("press", {
bubbles: true,
cancelable: true,
composed: true
});
const releasedEvent = new CustomEvent("release", {
bubbles: true,
@FlameWolf
FlameWolf / onedrive-response.json
Created July 17, 2023 05:55
OneDrive API Response Format
{
"@content.downloadUrl": "https://public.dm.files.1drv.com/[200+ characters long random string]",
"createdBy": {
"application": {
"displayName": "OneDrive",
"id": "[file_id]"
},
"user": {
"displayName": "[user_display_name]",
"id": "[user_id]"
@FlameWolf
FlameWolf / Object.prototype.toString.js
Created August 18, 2023 07:30
Get `Object.prototype.toString()` to return JSON string without circular reference error
Object.defineProperty(Object.prototype, "toString", {
value: function () {
return JSON.stringify(
this,
(function () {
const ancestors = [];
return function (key, value) {
if (typeof value !== "object" || value === null) {
return value;
}
@FlameWolf
FlameWolf / getRandomIdString_v2.js
Last active October 17, 2023 05:52
Generate random ID string V2
const getRandomIdString = (steps = 4) => {
let seed = "";
for (let i = 0; i < steps; i++) {
seed += Math.random().toString().substring(2);
}
return BigInt(seed).toString(36).toUpperCase();
};
@FlameWolf
FlameWolf / bigIntToBase64.js
Last active October 26, 2023 05:27
Convert a BigInt to a base-64 number representation where the digits include (in the ascending order of value): 0-9, a-z, A-Z, &, and #
function bigIntToBase64(value) {
const base = 64n;
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&#";
const sign = value < 0n ? "-" : "";
let [result, quotient] = ["", sign ? 0n - this : this];
do {
result = `${digits[Number(quotient % base)]}${result}`;
} while (quotient /= base);
return `${sign}${result}`;
}
@FlameWolf
FlameWolf / BigInt.prototype.toBase64String.js
Last active October 26, 2023 05:28
Convert a BigInt to a base-64 number representation where the digits include (in the ascending order of value): 0-9, a-z, A-Z, &, and #
Object.defineProperty(BigInt.prototype, "toBase64String", {
value: function () {
const base = 64n;
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&#";
const sign = this < 0n ? "-" : "";
let [result, quotient] = ["", sign ? 0n - this : this];
do {
result = `${digits[Number(quotient % base)]}${result}`;
} while (quotient /= base);
return `${sign}${result}`;
@FlameWolf
FlameWolf / BigInt.prototype.toBase62String.js
Last active October 26, 2023 05:29
Convert a BigInt to a base-62 number representation where the digits include (in the ascending order of value): 0-9, a-z, and A-Z
Object.defineProperty(BigInt.prototype, "toBase62String", {
value: function () {
const base = 62n;
const digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const sign = this < 0n ? "-" : "";
let [result, quotient] = ["", sign ? 0n - this : this];
do {
result = `${digits[Number(quotient % base)]}${result}`;
} while (quotient /= base);
return `${sign}${result}`;