Skip to content

Instantly share code, notes, and snippets.

View vegeta897's full-sized avatar
😵
working on my biggest project

Devin Spikowski vegeta897

😵
working on my biggest project
View GitHub Profile
@vegeta897
vegeta897 / copy-wsj-crossword-clues.js
Created July 5, 2021 04:07
WSJ crossword bookmarklet to copy list of clues for Discord
javascript:(function(){function getBoxes(e){return""===e.innerText.trim()?e.children.length:" `"+[].slice.call(e.children).map(e=>e.innerText||"_").join(" ")+"` "}function listClues(e){return`\n**__${e.toUpperCase()}__**\n`+[].slice.call(document.getElementsByClassName("puzzle-frame")[0].contentDocument.getElementById(e+"holder").children[0].children[1].children).map(e=>"**"+e.children[0].innerText.replace("\n","** ").split("_").join("\\_")+" ("+getBoxes(e.children[1])+")").join("\n")}navigator.clipboard.writeText(`<${window.location.href.replace("www.","")}>${listClues("across")}\n${listClues("down")}`);})();
@vegeta897
vegeta897 / discord-js-data-persistence.js
Created January 21, 2019 17:53
Saving and loading data from disk for persistence in a Discord.js bot
const fs = require('fs');
const Discord = require('discord.js');
const client = new Discord.Client();
let saveData;
try {
saveData = JSON.parse(fs.readFileSync('./save-data.json', 'utf8')); // Load save data
} catch(e) {
saveData = { caseCount: 0 }; // Init if no save data found
}
@vegeta897
vegeta897 / inbox.js
Created November 14, 2018 18:02
Heroku d-zone ignoring users with no roles
'use strict';
const Eris = require('eris');
var EventEmitter = require("events").EventEmitter;
var inherits = require('inherits');
var util = require('./../web/script/common/util');
module.exports = Inbox;
inherits(Inbox, EventEmitter);
var commandCooldowns = {};
@vegeta897
vegeta897 / canvas.js
Created January 23, 2018 12:17
Adds 0.5x zoom level
'use strict';
var util = require('./../common/util.js');
var EventEmitter = require('events').EventEmitter;
var inherits = require('inherits');
var BetterCanvas = require('./../common/bettercanvas.js');
module.exports = Canvas;
inherits(Canvas, EventEmitter);
var scales = [0.5,1,2,3,4];
var fs = require('fs');
var filename = './sendHistory.json';
var sendHistory;
try {
JSON.parse(fs.readFileSync(filename));
} catch(err) {
fs.writeFileSync(filename, JSON.stringify({data:[]})+'\n');
} finally {
sendHistory = JSON.parse(fs.readFileSync(filename)).data;
}
@vegeta897
vegeta897 / mc-status-bot.js
Last active September 6, 2023 17:55
(Outdated) Simple Minecraft server status bot command with Discord.js -- add me on Discord! vegeta897#7777
/*
##############################################################################
# #
# Sorry, this script is outdated and I can't justify maintaining it anymore. #
# #
# If you want to view the last version, it's archived here: #
# https://gist.github.com/vegeta897/e3d2fcd4b661bd9d021c397e7505be05 #
# #
# If you want to see a newer one that is similar, look here: #
# https://github.com/Baggette/minecraft-server-ping-example #