Skip to content

Instantly share code, notes, and snippets.

@bboe
bboe / redditor_save.py
Created June 16, 2013 19:02
Saves all the available comments and submissions for a given user.
#!/usr/bin/env python
import cPickle
import praw
import sys
PERIODS = ['all', 'year', 'month', 'week', 'day', 'hour']
PERIOD_VIEWS = ['controversial', 'top']
VIEWS = [{'sort': x, 't': y} for x in PERIOD_VIEWS for y in PERIODS]
VIEWS.insert(0, {'sort': 'new'})
@bboe
bboe / NOTES.txt
Last active February 17, 2021 00:24
BBoe's Updates to "How To Make A reddit Bot — Part One"
Intro:
I'm Bryce (/u/bboe) Author of PRAW
/u/busterroni's Submission:
https://www.reddit.com/r/learnpython/comments/5ury27/heres_a_tutorial_i_made_on_creating_a_reddit_bot/
/u/busterroni's Part 1:
https://www.youtube.com/watch?v=krTUf7BpTc0
@bboe
bboe / comment_loop_test.py
Last active June 7, 2021 06:26
Python Reddit API Comment Loop Test
#!/usr/bin/env python3
import logging
import sys
import time
import praw
def configure_logging():
logger = logging.getLogger("praw")
@bboe
bboe / domains.txt
Created June 16, 2021 23:03
Test time to DNS query and connect to various domains
google.com
facebook.com
youtube.com
twitter.com
instagram.com
linkedin.com
microsoft.com
apple.com
wikipedia.org
googletagmanager.com
@bboe
bboe / validation.rb
Last active July 23, 2021 18:45
ActiveModel Validation With Whitespace
#!/usr/bin/env ruby
require 'active_model'
require 'minitest/autorun'
class Simple
include ActiveModel::Model
validates :name, allow_blank: true, allow_nil: true, length: { is: 2 }
attr_accessor :name
@bboe
bboe / set_retention.py
Last active April 14, 2022 09:54
Set retention on slack conversations with deleted users to 1 day.
#!/usr/bin/env python
"""Set retention on slack conversations to 400 days.
Usage: ./set_retention.py [--perform] --token SLACK_TOKEN
The `--perform` flag is necessary to actually perform the action.
Due to the fact that `conversations.setToken` is not part of the public API
the slack legacy token concept will not work. To obtain the API token,
open up slack in the browser and observe networking traffic while performing
@bboe
bboe / ranges.txt
Last active July 20, 2023 00:34
Ranges
Private:10.0.0.0-10.255.255.255
Private:100.64.0.0-100.127.255.255
Local:127.0.0.0-127.255.255.255
Private:172.16.0.0-172.31.255.255
Private:198.18.0.0-198.19.255.255
Private:192.168.0.0-192.168.255.255
@bboe
bboe / parse_email_list.js
Last active January 22, 2024 15:02
Javascript email list parser with display name
function display_name(text) {
/* Remove all quotes
Remove whitespace, brackets, and commas from the ends. */
return text.replace(/(^[\s,>]+)|"|([\s,<]+$)/g, '');
}
function emails(addr_list) {
/* Regex source:
https://html.spec.whatwg.org/multipage/forms.html#valid-e-mail-address
*/