Skip to content

Instantly share code, notes, and snippets.

#!/var/www/html/gdq/newpraw/bin/python
import praw, json
with open("/home/steven/gdqauth.json") as f:
auth = json.load(f)
r = praw.Reddit(user_agent='GDQ thread autoupdater by /u/suudo', refresh_token=auth["token"], **auth["login"])
with open("/var/www/html/gdq/schedule.json") as f:
data = json.load(f)
if not hasattr(__builtins__, "raw_input"):
@blha303
blha303 / mpv-icy-notify.sh
Created January 10, 2018 02:37
Wrapper for MPV that picks up icy-title updates and tells notify-send about them
#!/bin/bash
mpv http://stream 2>&1 | while read p; do if [[ "$p" != "A: "* ]]; then echo $p; fi; if [[ "$p" == *"icy-title:"* ]]; then notify-send "$(echo $p | cut -d' ' -f2-)"; fi; done
# exec(requests.get("").text)
__colors_rgb = {(0, 0, 0): 'Black', (0, 0, 128): 'Navy Blue', (0, 0, 200): 'Dark Blue', (0, 0, 255): 'Blue', (0, 7, 65): 'Stratos', (0, 27, 28): 'Swamp', (0, 35, 135): 'Resolution Blue', (0, 41, 0): 'Deep Fir', (0, 46, 32): 'Burnham', (0, 47, 167): 'International Klein Blue', (0, 49, 83): 'Prussian Blue', (0, 51, 102): 'Midnight Blue', (0, 51, 153): 'Smalt', (0, 53, 50): 'Deep Teal', (0, 62, 64): 'Cyprus', (0, 70, 32): 'Kaitoke Green', (0, 71, 171): 'Cobalt', (0, 72, 22): 'Crusoe', (0, 73, 80): 'Sherpa Blue', (0, 86, 167): 'Endeavour', (0, 88, 26): 'Camarone', (0, 102, 204): 'Science Blue', (0, 102, 255): 'Blue Ribbon', (0, 117, 94): 'Tropical Rain Forest', (0, 118, 163): 'Allports', (0, 123, 167): 'Deep Cerulean', (0, 126, 199): 'Lochmara', (0, 127, 255): 'Azure Radiance', (0, 128, 128): 'Teal', (0, 149, 182): 'Bondi Blue', (0, 157, 196): 'Pacific Blue', (0, 166, 147): 'Persian Green', (0, 168, 107): 'Jade', (0, 204, 153): 'Caribbean Green', (0, 204, 204): "Robin's Egg Blue", (0
#!/usr/bin/env python3
import discord
import asyncio
import aiohttp
from urllib.parse import quote_plus, urlencode
import os.path
from os import getcwd, chdir
from urllib.parse import unquote
from mutagen import File
import youtube_dl
@blha303
blha303 / channelsave.py
Last active November 19, 2017 12:54
Discord script to save a channel log
#!/usr/bin/env python3
import discord
from peewee import *
from argparse import ArgumentParser
client = discord.Client()
db = SqliteDatabase("logs.db")
args = None
class BaseModel(Model):
@blha303
blha303 / output.txt
Last active September 15, 2017 07:53
A script for getting connection statistics from a Vivid Wireless-supplied Huawei B315s-607. Other models may have a similar feature.
$ python3 usage.py
Current Connect Time: 23:52:44
Current Upload: 930.35MB
Current Download: 30.65GB
Current Download Rate: 610.00KB/s
Current Upload Rate: 6.35MB/s
Total Upload: 934.36MB
Total Download: 30.67GB
Total Connect Time: 01:26:02
@blha303
blha303 / textadventure_sample.py
Created August 6, 2017 11:35
I'd like to make a text adventure library some day
"""Welcome to py-textadventure!
This is a library intended to make writing text adventures really simple.
Below is a sample text adventure that mirrors the first few areas of Zork with a couple small changes.
I hope you enjoy using this library!"""
from textadventure import Room, Object, Item
import random
@blha303
blha303 / lightcycle.py
Created July 30, 2017 04:40
A script to solve the Light Cycle module in Keep Talking
from string import ascii_uppercase, digits
matrix = [
['5/B', 'B/R', 'M/G', 'Y/5', '4/1', 'R/W', '6/4', '1/6', '2/3', '3/M', 'G/Y', 'W/2'], #A
['2/R', '6/M', '4/3', '5/B', 'R/5', 'Y/2', '1/G', 'M/Y', 'W/6', '3/4', 'B/W', 'G/1'], #B
['M/Y', '2/4', 'Y/R', '3/5', 'W/2', 'G/B', '1/W', 'R/3', '5/G', '4/6', 'B/M', '6/1'], #C
['5/6', '6/3', '1/4', 'M/2', 'R/Y', '2/M', 'W/R', 'B/G', 'Y/W', '3/B', 'G/1', '4/5'], #D
['B/R', 'W/2', '2/3', '1/4', 'M/B', '5/6', 'Y/W', 'R/M', 'G/Y', '6/G', '3/5', '4/1'], #E
['R/Y', '2/G', '1/M', 'Y/5', '5/R', 'W/B', '6/3', 'B/1', 'M/4', 'G/6', '3/2', '4/W'], #F
['Y/1', '5/4', '2/W', 'R/Y', '1/R', 'B/3', '6/G', 'G/6', 'M/B', 'W/5', '4/2', '3/M'], #G
#!/usr/bin/env python3
import zlib
import os
import sys
import argparse
def crc32_file(filename):
with open(filename, "rb") as f:
return hex(zlib.crc32(f.read())).upper()[2:].zfill(8)
@blha303
blha303 / yt-pl-remove.js
Created June 14, 2017 16:14
Bookmarklet to remove all videos from a Youtube playlist with a single click. Note: Doesn't work in one go! You'll have to refresh the page and keep clicking until all the videos are gone, or remove the remainder by hand.
javascript:for (val of document.getElementsByClassName("pl-video-edit-remove")) { val.click() }