Skip to content

Instantly share code, notes, and snippets.

# 4chan thread grabber
import urllib
import urllib2
import json
API_URL = "https://api.4chan.org/%s/res/%s.json"
IMAGE_URL = "https://images.4chan.org/%s/src/%s"
def getThreadInfo(board, id):
@blha303
blha303 / irctwitch.py
Last active May 12, 2022 22:21
Python IRC bot for automatically retrieving Twitch stream status
# Twitch IRC status autoupdate
# Create an empty file called config.yml in the same directory, containing:
# host: irc.quakenet.org
# port: 6667
# channels: ["#channel", "#anotherchannel"]
# nspass: "nickserv/Q password"
# password: "server password for BNC or private server"
# twitch: "channelname"
import requests
@blha303
blha303 / OCRrainwaveNP.php
Last active December 3, 2022 20:31
Python and PHP scripts for getting Now Playing from ocr.rainwave.cc. MIT license
<?php
# Because sometimes it's easier to load up a web browser.
# http://blha303.com.au/rainwave
# https://github.com/blha303/Rainwave-NowPlaying
header("Access-Control-Allow-Origin: *");
$pagecontent = file_get_contents("http://ocr.rainwave.cc/");
preg_match_all("/PRELOADED_APIKEY = '(.*?)'/", $pagecontent, $matches);
$url = "http://ocr.rainwave.cc/sync/2/init";
$data = array('refresh' => 'full',
@blha303
blha303 / iclfm.js
Last active February 11, 2018 17:34
IRCCloud last.fm now-playing bookmarklet - Change the 'e' variable to your own last.fm username.
javascript: (function () { var jB = document.createElement('script'); jB.setAttribute('type', 'text/javascript'); jB.setAttribute('src', 'https://gist.github.com/blha303/7602104/raw/6ad79edbd0bec1b6bce17472409843c61d899842/irccloudlastfm.js'); document.body.appendChild(jB); document.body.appendChild(jB); }());
@blha303
blha303 / getsizefromurls.py
Last active December 29, 2015 12:29
Get total size of files indicated by a list of URLs
from urllib2 import urlopen
import sys
from os import sep
filename = ".".join(sys.argv[0].split(sep)[-1].split(".")[:-1])
def sizeof_fmt(num):
for x in ['bytes','KB','MB','GB','TB','PB','EB','ZB']:
if num < 1024.0 and num > -1024.0:
@blha303
blha303 / irccloud-trout.js
Created December 5, 2013 06:21
IRCCloud trout-slapping bookmarklet | Usage: Select the username or text you want to slap. If you can fix prompt(), please let me know.
javascript: (function () { var text = ""; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection && document.selection.type != "Control") { text = document.selection.createRange().text; } else { text = prompt("Enter username", "everyone"); } if (!text) { text = "everyone"; } cb().say("/me slaps " + text.replace(/[<>@+~&]/g, '').trim() + " around a bit with a large trout"); }());
@blha303
blha303 / irccloud-readall.js
Created December 5, 2013 06:29
Set all buffers as read (from Techman)
javascript:SESSION.buffers.each(function (b) { b.setLastSeen(b.messages.last()) })
@blha303
blha303 / bukjdrefresh.py
Last active December 30, 2015 09:59
bukjdm Refresh data for new Bukkit snapshot
import requests
from bs4 import BeautifulSoup as Soup
print "Getting data from jd.bukkit.org..."
data = requests.get("http://jd.bukkit.org/dev/apidocs/index-all.html")
soup = Soup(data.text)
print "Retrieved data. Bukkit version: " + soup.find('title').text[7:-1]
methods = {}
classes = {}
for dt in soup.findAll('dt'):
# If more than one link in definition (i.e. a class or method definition)...
@blha303
blha303 / irccloud-lotsafish.js
Last active December 30, 2015 11:29
Like /trout, but with hundreds of other possibilities for fish
(function () {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
} else if (document.selection && document.selection.type != "Control") {
text = document.selection.createRange().text;
} else {
text = cb().getName();
}
Array.prototype.randomElement = function () {
@blha303
blha303 / irccloud-globalawaytoggle.js
Created December 10, 2013 22:35
IRCCloud toggle global away with message. Put away message in current channel input box, click bookmarklet. Click bookmarklet again (in a connection marked as away) to use global /back.
javascript:if (cbc().isAway()) { SESSION.connections.each(function (c) { c.setBack() }) } else { var inputbox = $('#bufferInputView' + cb().bid()); var msg = inputbox.val(); inputbox.val(""); SESSION.connections.each(function (c) { c.setAway(msg) }) }