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 / update_lwjgl.sh
Last active February 4, 2024 20:20
Updates the lwjgl that minecraft uses.
#!/usr/bin/env bash
echo "Determining OS..."
if [[ "$(uname -s)" == "Linux" ]]; then
mcdir="$HOME/.minecraft/"
downloader="wget --no-check-certificate -q -O"
os="linux"
natives="libjinput-linux libjinput-linux64 liblwjgl liblwjgl64 libopenal libopenal64"
elif [[ "$(uname -s)" == "Darwin" ]]; then
@aperson
aperson / gaming_stats.py
Created April 12, 2012 00:50
Does simple comparison of who moderates what other gaming subreddits.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import urllib.request
import time
import re
import sys
class Grabber:
@aperson
aperson / dictionary_search.py
Created April 17, 2012 21:07
Ways to pull out a value from a dict case insensitively
def ids (t, d):
for i in d.keys():
if re.match(r'^{}$'.format(t), i, re.I):
return d[i]
@aperson
aperson / overviewer_filters.py
Created May 9, 2012 11:57
A set of marker filters for the Minecraft Overviewer
def screenshotFilter(poi):
'''This looks for signs that have their first line in the 'Image:<id>' format, where <id> is an
id from an Imgur.com image.'''
if poi['id'] == 'Sign':
if poi['Text1'].startswith('Image:'):
poi['icon'] = "painting_icon.png"
image_html = "<style>.infoWindow img[src='{icon}'] {{display: none}}</style><a href='http://imgur.com/{id}'><img src='http://imgur.com/{id}s.jpg' /></a>".format(icon=poi['icon'], id=poi['Text1'][6:])
return "\n".join([image_html, poi['Text2'], poi['Text3'], poi['Text4']])
def playerFilter(poi):
@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