Skip to content

Instantly share code, notes, and snippets.

@aperson
aperson / pychart.py
Created November 9, 2011 01:59
Quick and dirty function to build a google pie chart url
def piechart(data, labels=None, colors=None, size='600x400'):
'''Accepts a list to graph. Optionally accepts labels and colors. Both optional arguments
must have the same len as the data.'''
baseurl = 'https://chart.googleapis.com/chart?cht=p'
chs = 'chs={}'.format(size)
chd = 'chd=t:{}'.format(','.join([str(i) for i in data]))
chds = 'chds=0,{}'.format(sum(data))
if labels:
chl = 'chl={}'.format('|'.join(
['{}: {}'.format(y, data[x]) for x,y in enumerate(labels)]))
@aperson
aperson / approve_all.py
Created November 16, 2011 15:07
will approve all submissions in a subreddit
#/usr/bin/env python3
import json, signal, sys, time
import urllib.request
from urllib.parse import urlencode
import http.cookiejar
def sigint_handler(signal, frame):
'''Handles ^c'''
@aperson
aperson / prune_bans.py
Created May 12, 2012 15:19
Python script to remove shadowbanned and stagnant user from a subreddit's ban list.
#!/usr/bin env python3
import json
import urllib.request
import time
import sys
import signal
from urllib.parse import urlencode
import http.cookiejar
@aperson
aperson / dew_ripper.py
Created May 14, 2012 09:36
Rips music from bandcamp that's on Dewtroid's source list.
#!/usr/bin env python3
import re
import json
import os
import sys
import time
import signal
import urllib.request
opener = urllib.request.build_opener()
@aperson
aperson / prune_bans.py
Created July 14, 2012 18:58
Script to purge bans in a subreddit
#!/usr/bin env python3
import json
import urllib.request
import time
import sys
import signal
from urllib.parse import urlencode
import http.cookiejar
@aperson
aperson / reddit_submit.py
Created July 14, 2012 23:44
Quick script to submit a url to subreddits
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# moderator-bot.py
#
# Copyright 2012 Zach McCullough <nosrepa@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
import json
import urllib.request
import time
from urllib.parse import urlencode
import http.cookiejar
def _isVideo(submission):
'''Returns video author name if this is a video'''
if 'media' in submission:
@aperson
aperson / sidebar_updater.py
Created September 12, 2012 23:53
Quick script made up of parts of moderator-bot that can update a subreddit's sidebar text with the status of Mojang's servers
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import re
import urllib.request
import time
from collections import defaultdict
def _isVideo(submission):
@aperson
aperson / remove-ham.py
Created September 24, 2012 01:47
Quick script to remove ham from the modqueue en-mass
#/usr/bin/env python3
import json
import urllib.request
import time
import re
import signal
import sys
from urllib.parse import urlencode
import http.cookiejar
@aperson
aperson / twitch.py
Created April 8, 2014 19:01
Script to stream to twitch.tv. I got this from @brownan, but I can't find it anywhere at the moment online
#!/usr/bin/env python3
# Adapted from http://www.creativetux.com/2012/11/streaming-to-twitchtv-with-linux.html
#
# Make sure to put your twitch.tv key in a file called "key" in the current directory.
#
# Before running, make sure PulseAudio is set up with the correct loopback modules
# and a null sink named "mix". You can use something ilke the following commands:
#
# pactl load-module module-null-sink sink_name=mix