Skip to content

Instantly share code, notes, and snippets.

@TheEssem
TheEssem / rtpin.js
Created October 10, 2019 16:18 — forked from twilight-sparkle-irl/rtpin.js
pin retweets on twitter
$(document).ajaxComplete((e, x, o) => {
if (o.url == "https://api.twitter.com/1.1/statuses/retweet.json") {
tweet_id = JSON.parse(x.responseText)['id_str'];
auth_token = JSON.parse(document.querySelector('#init-data').value)['formAuthenticityToken'];
fetch("https://twitter.com/i/tweet/pin", {
body: `authenticity_token=${auth_token}&id=${tweet_id}`,
method: "POST",
headers: {
Accept: "application/json, text/javascript, */*; q=0.01",
"Cache-Control": "no-cache",

Keybase proof

I hereby claim:

  • I am TheEssem on github.
  • I am essem (https://keybase.io/essem) on keybase.
  • I have a public key whose fingerprint is 5F58 CDCB 7689 1299 DCB7 1D58 A3F9 F021 2909 2FCA

To claim this, I am signing this object:

@TheEssem
TheEssem / migratedb.js
Created September 9, 2023 19:13
An ancient migration script from back when esmBot was switching to MongoDB, uploading here so it isn't lost forever
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/esmBot");
module.exports = async (client) => {
const settings = client.settings;
const tags = client.tags;
const guildSchema = new mongoose.Schema({
id: String,
tags: Map,
@TheEssem
TheEssem / migratei18n.js
Created April 17, 2025 23:29
A script I wrote to extract the command metadata strings (and some responses) for i18n usage in esmBot.
import { promises } from "node:fs";
import { resolve, dirname } from "node:path";
import { fileURLToPath } from "node:url";
import ImageCommand from "./classes/imageCommand.js";
async function* getFiles(dir) {
const dirents = await promises.readdir(dir, { withFileTypes: true });
for (const dirent of dirents) {
const name = dir + (dir.charAt(dir.length - 1) !== "/" ? "/" : "") + dirent.name;