Skip to content

Instantly share code, notes, and snippets.

@stt
stt / change-screen-by-aspect-ratio.lua
Created May 27, 2023 20:33
mpv script for changing active screen based on video's aspect ratio
-- change-screen-by-aspect-ratio.lua
-- (c)2023, stt
--
-- mpv script for systems with 2+ monitors in portrait and landscape orientation,
-- when new video starts in fullscreen the active screen is changed based on
-- video's aspect ratio
--
-- NOTE: edit the script with screen numbers based on your screen configuration
function checkAspectRatio()
@stt
stt / dler.sh
Created August 15, 2022 21:34
Minimal yt-dlp download queue + manager
#!/bin/bash
# Minimal yt-dlp download queue + manager
# 2022, <samuli@tuomola.net>
#
# Requires youtube-dl:
# https://github.com/yt-dlp/yt-dlp
# and redis:
# docker run --name dler_redis -d redis:7
command -v youtube-dl >/dev/null 2>&1 || { echo >&2 "youtube-dl required. Abort."; exit 1; }
@stt
stt / yt-dl-transcript.sh
Last active August 12, 2021 23:10
Download youtube transcripts/captions/subtitles
#!/bin/bash
## Download youtube transcripts/captions/subtitles
## 2021, stt
##
## NOTE: this is a toy, nothing is guaranteed and it's likely to break when they
## change things. seriously, use the API https://developers.google.com/youtube/v3/
##
## one dumb way to get video links from the channel page is to run in console:
## Array.from(document.querySelectorAll('ytd-browse a.ytd-thumbnail')).map(e => e.href).join(' ')
## put it in urls.txt and do
@stt
stt / bagman.xml
Created October 18, 2018 23:24
Mame cheat file for Bagman
<mamecheat version="1">
<cheat desc="Run, thief, run">
<script state="on">
<action>maincpu.md@0C4A=3C5400CD</action>
<action>maincpu.md@0CA4=3D540ACD</action>
<action>maincpu.md@0E8F=3D5410CD</action>
<action>maincpu.md@0EA2=3C5416CD</action>
<action>maincpu.mq@5400=FFFFC901C665823A</action>
<action>maincpu.mq@5408=C901D665823AFFFF</action>
@stt
stt / ra_parse.py
Last active August 24, 2018 20:28
Simplistic RA achievement rule parser
"""
ra_parse.py
2018, <samuli@tuomola.net>
Usage:
curl -H 'Cookie: RA_User=xxx; RA_Cookie=xxx' "https://retroachievements.org/dorequest.php?r=patch&g=1448&" >ra_game.json
python ra_parse.py ra_game.json
"""
import json
import re
@stt
stt / ra_cheevo_lpl.py
Last active August 11, 2018 21:56
Quick script to generate retroachievements capable playlist for retroarch
# ra_cheevo_lpl.py
# 2018, <samuli@tuomola.net>
#
from urllib.request import Request, urlopen
from lxml import html
import os
def read_lpl(fp):
rl = open(fp).readlines()
return [rl[i:i+6] for i in range(0,len(rl),6)]
@stt
stt / paypal-scriptlet.js
Created December 28, 2017 22:21
Export eBay purchases / payment history to CSV/Excel/Google spreadsheet
/*
The new Paypal UI has lost some important functions that the old UI had, one being purchase history exporting.
This is alternative way to export the information:
1. open https://www.paypal.com/myaccount/activity
2. open your browser's js console (win: ctrl-shift-j, osx: cmd-opt-j)
3. copy-paste the following code into js console and execute it
*/
j=JSON.parse($('#js_activityView').getAttribute('data-transactions'));
@stt
stt / hi.py
Last active June 17, 2019 19:07
MAME hiscore parser
#!/usr/bin/env python3
"""Binary parser utility (e.g. for retrieving hiscore from MAME)
Copyright (C) 2017 <samuli.tuomola@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
#!/usr/bin/env python
"""
wsdl2raml
Tested only with .NET asmx produced WSDL
Script output is primarily meant to assist in manual API conversion
and as such RAML output is not guaranteed to be valid
"""
from lxml import etree as ET
from textwrap import wrap
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "07_SeeingSound"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{