Skip to content

Instantly share code, notes, and snippets.

@blha303
blha303 / get_jackbox_room_code.py
Created November 25, 2016 23:35
Jackbox room code sniffer
# a function to listen for the current jackbox room id being received
# requirements: pyshark python module, tshark library or wireshark
# sometimes the code gets cut off between packets. need to restart the current game if no code is found; this happens 10% of the time
def get_jackbox_room_code(packet_count=None):
""" blocks until room code is found or packet_count is reached
>>> get_jackbox_room_code()
'CTLE' """
def get_outgoing_ip():
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
@blha303
blha303 / updatename.py
Last active November 13, 2016 05:30
Randomises an emoji at the end of a twitter user name
#!/usr/bin/env python
import tweepy
import json
import random
from emoji import unicode_codes
emoji = [e.encode('utf-8') for e in unicode_codes.EMOJI_UNICODE.values() if len(e.encode('utf-8')) == 4]
with open(".twitter_config.json") as f:
config = json.load(f)
import urllib,json
d=json.loads(urllib.urlopen("https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json").read())["president"]
print("""As of {timestamp}:
Clinton:
Votes: {electoral_votes_counted[clintonh]}/270
Counted: {vote_share_counted[clintonh]:.3%}
Win prob: {win_prob[clintonh]:.3%}
Trump:
Votes: {electoral_votes_counted[trumpd]}/270
Counted: {vote_share_counted[trumpd]:.3%}
@blha303
blha303 / mp3_fn_to_tags.py
Created September 13, 2016 07:09
Because MP3Tag is a bit overkill for this task
#!/usr/bin/env python3
from mutagen.easyid3 import EasyID3 # pypi mutagen
from parse import parse # pypi parse
from argparse import ArgumentParser
from glob import glob
from sys import exit
def write_tags(filename, newinfo):
audio = EasyID3(filename)
audio.update(newinfo)
@blha303
blha303 / gmusicupload.py
Last active March 8, 2019 07:25
A script to upload music to Google Play Music
#!/usr/bin/env python3
from gmusicapi import Musicmanager # pip install gmusicapi
from glob import glob
from argparse import ArgumentParser
from sys import stderr
from urllib.parse import quote_plus
m = Musicmanager()
if not m.login():
m.perform_oauth()
from util import hook,http,web
from json import loads
from urllib2 import HTTPError
oldplugin = """@hook.regex(r'instagram.com/p/(.+?)/')
def ig_regex(match, bot=None):
"Returns info for instagram urls "
token = bot.config.get("api_keys", {}).get("instagram", None)
try:
data = http.get_json("https://api.instagram.com/v1/media/shortcode/{}?access_token={}".format(match.group(1), token))["data"]
@blha303
blha303 / docs.md
Last active April 20, 2021 12:10
Life Is Strange stats server investigation
@blha303
blha303 / recursive_checksum.py
Last active December 3, 2022 21:03
A tool to generate checksums for all files in current directory and notify when mismatches with an existing file are found
#!/usr/bin/env python
import os
import json
from hashlib import md5
rootdir = os.getcwd()
CHECKSUMS = "checksums.json"
@blha303
blha303 / getvideourl.py
Last active March 21, 2016 14:38
A script that loads the given (list of) urls, waits for there to be a video tag on the page, then starts downloading the video using the page url as a filename (e.g http://example.com/my-show/episode-1 will produce my-show.episode-1.mp4)
#!/usr/bin/env python3
# pip install selenium, you probably want firefox as well or it won't work so good
import contextlib
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
from subprocess import Popen
from sys import argv, stderr, stdin
@blha303
blha303 / scloud_get.js
Created March 6, 2016 20:58
A soundcloud track getter thingy
// Soundcloud stream thingy. For playlist, opens a prompt with the urls for the tracks
// in the playlist spearated by spaces. For songs, opens a prompt with the stream url.
// Create an applicaiton at soundcloud.com and chuck your client id in there.
var cid = "";
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var data = JSON.parse(xmlhttp.responseText);
if (data.kind == "track") {