Skip to content

Instantly share code, notes, and snippets.

View eritbh's full-sized avatar

Erin eritbh

View GitHub Profile
@eritbh
eritbh / README.md
Last active August 25, 2019 14:55
Fizzbuzz

Fizzbuzz

The classic programming exercise.

The Rules

For every integer in some range:

  • Print "fizz" if the number is divisible by 3
  • Print "buzz" if the number is divisible by 5
/*!
* /r/anime custom page width + background userstyle/RES snippet
* by /u/geo1088
* public domain
*
* If you use this style, please don't send modmails when it breaks
* Instead, message /u/geo1088 directy:
* <https://www.reddit.com/compose?to=geo1088>
*/
@eritbh
eritbh / csv to reddit comments.py
Last active January 5, 2019 08:17
Move moderator applications from a CSV generated from a Google Forms response sheet to individual comments on a submission.
import csv
import praw
import re
r = praw.Reddit(client_id="",client_secret="",username="",password="",user_agent="")
submission = r.submission(id="")
with open("file.csv", "r", encoding="utf-8") as file:
apps_reader = csv.reader(file)
for i, row in enumerate(apps_reader):
@eritbh
eritbh / iconbot.js
Created March 11, 2018 23:13
thing for lana/bob because why not
const Eris = require('eris')
const request = require('superagent')
const config = {
token: 'HI PUT THINGS HERE', // the token used to run the bot
frequency: 60, // frequency of server icon switch in minutes
guildId: '149327211470520321', // the guild you want to change the icon of
images: [ // an array of image URLs
'https://b.thumbs.redditmedia.com/AQ_47wQPWDOEuP0LohFeFYpoa3fdLcqWrgIxDYvU_PI.png'
]
}
const eris = require('eris')
const bot = new eris('token')
bot.on('guildMemberAdd', (member, guild) => {
bot.getDMChannel(member.id).then(channel => {
console.log(channel.id)
}).catch(e => {
console.log('Get channel fail\n' + e)
})
})
@eritbh
eritbh / asdf.js
Last active January 29, 2018 01:00
bot.registerCommand("help", (msg, args) => {
var result = "";
if(args.length > 0) {
var cur = bot.commands[bot.commandAliases[args[0]] || args[0]];
if(!cur) {
return "Command not found";
}
var label = cur.label;
for(var i = 1; i < args.length; ++i) {
cur = cur.subcommands[cur.subcommandAliases[args[i]] || args[i]];
@eritbh
eritbh / dmHelp.js
Last active January 29, 2018 00:55
// replaces https://github.com/abalabahaha/eris/blob/master/lib/command/CommandClient.js#L78-L123
this.registerCommand("help", (msg, args) => {
var result = "";
if(args.length > 0) {
var cur = this.commands[this.commandAliases[args[0]] || args[0]];
if(!cur) {
return "Command not found";
}
var label = cur.label;
for(var i = 1; i < args.length; ++i) {
@charset "utf-8";
/* CSS Document */
@import url(http://fonts.googleapis.com/css?family=Oswald:700);
body {
background-attachment: fixed, scroll;
background-color: #FFF;
background-image: url("https://i.imgur.com/rrZbXQb.jpg"), url("http://i.imgur.com/CY8doiE.png");
@eritbh
eritbh / fml.js
Last active January 8, 2018 22:59
;(function batchDeleteMyMessages (channel, limit, before = undefined, loops = 1) {
if (limit <= 0 || loops > 10) return console.log(limit, loops) // If there are no more messages or we've been here too long, leave
// Get 100 messages from the channel
channel.getMessages(100, before).then(messages => {
// Get a list of all the messages from the bot
let toDelete = messages.filter(m => m.author.id === (channel.guild.shard.client || channel._client).user.id)
// Also save the ID of the first message so we can give to the next iteration
const firstMessageId = messages[0].id
@eritbh
eritbh / maybe.py
Last active October 9, 2017 04:35
import praw, time, requests, json
r = praw.Reddit(
client_id="",
client_secret="",
username="",
password="",
user_agent="script:some_random_identifier:v1.0 (by /u/you)")
sub = r.subreddit("your_sub") # no /r/ here