Skip to content

Instantly share code, notes, and snippets.

@mooware
mooware / ra_api.py
Last active March 7, 2024 04:30
RetroAchievements API client in python for getting random games from their database
import urllib.request
import os, json, random, time, re
# adult games are part of the hub "Theme - Mature",
# but I can't get the data over the API, so I manually scraped it from the website.
# use this expression in the browser dev console on the mature hub:
# Array.from(document.querySelectorAll("table td.py-2 a")).map(x => x.href.split("/")[4] + ", # " + x.parentElement.outerText.split("\n")[0]).join("\n")
# scrape date: 2024-03-06
_mature_games = set([
420, # Mario is a Drug Addict
# takes a csv export of the google sheet as input and tries to download pastebins
#
# usage:
# download_pastebins.py <prefix> <name column> <url column> <csv file>
#
# example:
# download_pastebins.py mt18 1 5 "MT18 Draw List - Played Games.csv"
import sys, os, re, urllib.request, csv
@mooware
mooware / donordrive-display.html
Last active November 4, 2021 19:20
Donordrive Display
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<style>
/* local css here */
@mooware
mooware / srl.html
Last active January 14, 2023 01:13
HTML page to list SRL races and link to multitwitch and similar services
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>SRL Races</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
@mooware
mooware / srlmulti.py
Last active January 17, 2021 01:08
Simple bottle.py application to open a multitwitch (or similar site) for an SRL race
from bottle import *
from urllib.request import urlopen
import json
import re
DEFAULT_HOSTS = ['multitwitch.tv', 'multistre.am', 'kadgar.net/live']
SRL_API = "https://api.speedrunslive.com/races/"
SANITY_RE = re.compile('[0-9a-z]+')
RACE_STATE_COMPLETE = 4 # from the SRL API
@mooware
mooware / jollymania.py
Created November 15, 2020 04:25
Download games2jolly games for Flashpoint
import os.path
import sqlite3
import urllib.request
def main():
db = sqlite3.connect(os.path.join('Data', 'flashpoint.sqlite'))
cur = db.execute("SELECT launchCommand FROM game WHERE launchCommand LIKE '%games2jolly%'")
urls = [s for (s,) in cur.fetchall()]
for index, url in enumerate(urls):
print('{}/{} {}'.format(index + 1, len(urls), url))
@mooware
mooware / codepage_unzip.py
Last active August 22, 2023 17:08
A little script to extract old japanese zip files with the correct text encoding for filenames. Most applications assume a US text codepage for old zip formats, which is not always correct.
# A little script to extract old japanese zip files
# with the correct text encoding for filenames.
# Most applications assume a US text codepage for
# old zip formats, which is not always correct.
import os
import shutil
import sys
import zipfile
from datetime import datetime
@mooware
mooware / outlook-disable-encryption.py
Created October 23, 2019 00:51
Python script to monitor the Windows registry and ensure that Outlook email encryption by default stays off
import ctypes, ctypes.wintypes
advapi32 = ctypes.windll.advapi32
# LSTATUS RegOpenKeyExA(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
RegOpenKeyExA = advapi32.RegOpenKeyExA
RegOpenKeyExA.argtypes = (ctypes.wintypes.HKEY, ctypes.wintypes.LPCSTR, ctypes.wintypes.DWORD, ctypes.wintypes.DWORD, ctypes.wintypes.PHKEY)
# LSTATUS RegCloseKey(HKEY hKey)
RegCloseKey = advapi32.RegCloseKey
@mooware
mooware / constexpr-char-lookup-table.cpp
Created September 28, 2019 01:49
Constexpr generation of character lookup tables
// generate character-based static lookup tables
// that can be used for character classification,
// e.g. like in cctype functions (isdigit, isalpha ...)
struct CharLookupTable
{
bool data[256];
template <unsigned int N>
constexpr CharLookupTable(const char (&str)[N])
@mooware
mooware / pihut_xmas_tree.py
Last active December 1, 2018 21:27
Script for the Pi Hut 3D Xmas Tree
from gpiozero import LEDBoard
from time import sleep
import random
tree = LEDBoard(*range(2, 28), pwm=True)
# first led is the top one in the star
tree[0].value = 0.6
leds = range(1, len(tree))