Skip to content

Instantly share code, notes, and snippets.

@blha303
blha303 / torrentdirsum.py
Last active August 29, 2015 13:55
Sum up the total size of the contents of a folder of torrents
import libtorrent as lt
from os import listdir
import json
def sizeof_fmt(num):
for x in ['bytes','KB','MB','GB']:
if num < 1024.0 and num > -1024.0:
return "%3.1f%s" % (num, x)
num /= 1024.0
return "%3.1f%s" % (num, 'TB')
@blha303
blha303 / showprocess.py
Last active August 29, 2015 13:56
Script to rename daily show episodes to "<show name> sXXeXX"
import os
import requests
import XML2Dict # The PyPI installer doesn't work; get this from http://blha303.com.au/XML2Dict.zip
from sys import argv
apikey = argv[1] # Get your API key from http://www.thetvdb.com/wiki/index.php?title=Programmers_API
ids = {"The.Daily.Show": "71256", "The.Colbert.Report": "79274", "Craig.Ferguson": "73387"}
eplookupurl = "http://thetvdb.com/api/GetEpisodeByAirDate.php?apikey=%s&seriesid=%s&airdate=%s"
srslookupurl = "http://thetvdb.com/data/series/%s/en.xml"
# I hate working with XML, so let's make them dicts.
@blha303
blha303 / bropages.py
Created February 27, 2014 13:16
Get all bropages entries and output to folder
import requests
from os import mkdir, sep, listdir
from BeautifulSoup import BeautifulSoup as Soup
# Load page
soup = Soup(requests.get("http://bropages.org/browse").text)
# Get rows excluding header
rows = soup.findAll('tr')[1:]
cmds = []
# iterate over rows, get commands, save list without duplicates
for a in rows:
@blha303
blha303 / mp3list.php
Last active August 29, 2015 13:57
Produce list of MP3 files in current and sub directories, playable by clicking
<?php
if (isset($_GET['print'])) {
highlight_file(__FILE__);
die();
}
function load_addon($filename) {
if (file_exists($filename)) {
include $filename;
}
}
@blha303
blha303 / bestgameever.py
Last active August 29, 2015 13:57
Best game ever.
# Usage: python bestgameever.py <password>
# Hint: It's alphanumeric, less than 5 characters.
from sys import argv
import hashlib
code = "98f588baf6859ca943164042560b6479dc277a8c481f186b6ef1b03cb5670dcdbeb226cd2e3808fd12f0b84eff6803290e667735b49fc4134206997e2add5ddf"
if len(argv) > 1:
if hashlib.sha512(hashlib.md5(argv[1]).hexdigest()).hexdigest() == code:
print "Yep."
else:
print "Nope."
@blha303
blha303 / skype_list_rooms.py
Last active August 29, 2015 13:57
List active chats with their IDs. Used with https://gist.github.com/blha303/9913570
import Skype4Py
skype = Skype4Py.Skype(Transport='x11')
print "\n\n".join(["%s: %s" % (a.Name, ", ".join([b.Handle for b in a.Members])) for a in skype.Chats])
from twisted.words.protocols import irc
from twisted.internet import protocol, task, reactor
from twisted.application import internet, service
import subprocess
nick = "Nexus"
user = "Nexus"
passw = "bouncer password"
jenkins_nick = "HawkJenkins"
jenkins_job = "Nexus"
@blha303
blha303 / stv_panels.js
Created May 23, 2014 05:04
Speedrun.tv Twitch panels script
// Copying this into the browser console (when you have a chat tab selected) will open the Twitch panels in a new window.
$.getJSON("http://www.corsproxy.com/api.twitch.tv/api/channels/"+$('.selected')[0].textContent+"/panels",
function(result){
var out = [];
$.each(result,
function(i, field){
var outp = "";
if (field["data"]["link"]) {
outp += "<a href=\"" + field["data"]["link"] + "\">";
}
@blha303
blha303 / mediaserverindex.html
Created June 17, 2014 01:38
A drop-in media server index for apache that uses directory indexing and adds a HTML5 video player. loads directory changes with ajax
<html>
<head>
<script src="jquery.js"></script>
</head>
<body>
<span id="VideoList"></span>
<script>
var videosPath = "/Videos/";
var curdir = "";
function updateList(data) {
@blha303
blha303 / tpparse.py
Last active August 29, 2015 14:03
Transperth offline bus stop data and example implementation
# Data can be retrieved (gzipped) from
# https://mega.co.nz/#!os4gjQBR!fspHcvoHZHDzN6IGtJgIXUh4N_ciIEL40tHoivqcKXg
# Currently this data only contains info for weekdays, as of 2014-06-20. I can't make the data
# collection process public, sadly, so please email me if you'd like saturday or sunday/holiday data.
#
# This is an example implementation of a program to read this data, in Python
# It replicates Transperth's service to look up the next five bus times to a stop, as seen here
# http://136213.mobi/Bus/StopResults.aspx?SN=14353
# Please direct questions to steven+transperthdata@blha303.com.au
#