Skip to content

Instantly share code, notes, and snippets.

View ddupont808's full-sized avatar
๐Ÿ™ƒ

ddupont ddupont808

๐Ÿ™ƒ
  • MIT
  • Hawaii
View GitHub Profile
@ddupont808
ddupont808 / bogo_permutate.ts
Last active September 20, 2021 21:29
a one liner bogo permutation function
/**
* Generates a random subset of permutations of the given array,
* recursively calls itself until the randomly generated subset is
* the set of all permutations of the given array
*
* @param array
* @returns all permutations of array
*/
const bogo_permutate = <T>(array:T[]):T[][] =>
new Set(Array.from({ length: Array.from({ length: array.length }, (v, k) => k + 1).reduce((a, b) => a * b, 1) }, () => [...array].sort(() => .5 - Math.random())).map(e => JSON.stringify(e))).size < Array.from({ length: array.length }, (v, k) => k + 1).reduce((a, b) => a * b, 1) ? bogo_permutate(array) : Array.from({ length: Array.from({ length: array.length }, (v, k) => k + 1).reduce((a, b) => a * b, 1) }, () => [...array].sort(() => .5 - Math.random()));
@ddupont808
ddupont808 / ascii stereogram.js
Created October 16, 2020 04:45
generates a stereogram with text
const text = `
_I_
_hort_
_all_
_of_u_
_without_
_cursed_i_
_would_not
_have_
_survived_
@ddupont808
ddupont808 / discord webhook.gs
Created September 15, 2020 23:30
Gscript to automatically send google forms responses to a discord channel
/**
* Automatically send google form responses to a discord channel/webhook
*
* Instructions:
*
* Edit the Google Sheet connected to your form
* Menu > Tools > Script Editor
* Copy and paste this into the file, remove anything there already
* Update the variables in the top section
* In the script editor hit run > myFunction to create the trigger
@ddupont808
ddupont808 / index.js
Last active January 14, 2021 20:52
DiscordJS Hangman Bot
const Discord = require("discord.js");
const client = new Discord.Client();
var usage = "`!hangman <channel id> <your phrase>`\n`Example: !hangman 368845035560763402 grandest nan is the man`";
var letters = ["๐Ÿ‡ฆ", "๐Ÿ‡ง", "๐Ÿ‡จ", "๐Ÿ‡ฉ", "๐Ÿ‡ช", "๐Ÿ‡ซ", "๐Ÿ‡ฌ", "๐Ÿ‡ญ", "๐Ÿ‡ฎ", "๐Ÿ‡ฏ", "๐Ÿ‡ฐ", "๐Ÿ‡ฑ", "๐Ÿ‡ฒ", "๐Ÿ‡ณ", "๐Ÿ‡ด", "๐Ÿ‡ต", "๐Ÿ‡ถ", "๐Ÿ‡ท", "๐Ÿ‡ธ", "๐Ÿ‡น", "๐Ÿ‡บ", "๐Ÿ‡ป", "๐Ÿ‡ผ", "๐Ÿ‡ฝ", "๐Ÿ‡พ", "๐Ÿ‡ฟ"];
var unicode = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"];
var games = [];
var stages = [`\`\`\`