Skip to content

Instantly share code, notes, and snippets.

View yunruse's full-sized avatar
don't forget to drink some water!

Mia yun Ruse yunruse

don't forget to drink some water!
View GitHub Profile
@yunruse
yunruse / yt.py
Last active January 31, 2024 03:13
very basic YouTube-to-RSS extractor
#!/usr/bin/env python3
# pip install scrapetube
# for basic operation, use `python -m http.server --cgi`
# and access /cgi-bin/yt.py?c={CHANNEL_ID}
# Note that due to scrapetube limits, dates are fetched as eg "3 days ago"
# so the further in the past a video is, the less precise the date will be.
@yunruse
yunruse / co2e_wasted_boiling.py
Created July 2, 2023 18:06
Ballpark guess at CO2 emissions from wasted boiling of water
"""
Tool to calculate the average additional CO2e emissions
from the instruction "boil half a kettle",
rather than some slightly more precise figure ("boil 200ml").
Naturally, not everyone will follow this -- we're all busy people --
so we will have to assume not all of these wasted emissions
can be reduced.
This is targetted at a recipe-delivery service company;
@yunruse
yunruse / hi.py
Last active June 30, 2023 11:34
Image that tells you your user agent
#!/usr/bin/env python3
"Image that dynamically tells you your user agent"
# save this as ./cgi-bin/index.png
# run python -m http.server --cgi
# go to http://localhost:8000/cgi-bin/hi.png
import os, sys
from PIL import Image, ImageDraw
def serve_png(io, file=sys.stdout):
@yunruse
yunruse / concat.ipynb
Created March 20, 2023 21:24
Concatenative 2x2 matrices
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yunruse
yunruse / tumblr.css
Created March 6, 2023 16:11
tumblr nonsense remover stylesheet
/* "NEW" merch */
header>div>div:has(button[aria-label="Shop TumblrMart"]),
/* Tumbly live I shoot you like the gun */
div[data-timeline]>div>div:has(div[data-testid=liveMarquee]),
div:has(>a>button[aria-label='Live']),
#q{display: none}
@yunruse
yunruse / bubblewrap
Last active February 4, 2023 10:49
Discord bubble wrap
#! /usr/bin/env python3
# I hope the example input is fairly obvious
# but this is a quick tool to randomly pick emoji from a palette
# and apply it onto a grid.
# Input Discord-markdown in the format of example.txt to stdin.
# Add `spoilers` to argv if you wish to make a cute find-the-emoji puzzle!
@yunruse
yunruse / pypi_stats.py
Last active January 29, 2023 12:05
Python 3.x minor version usage stats, by proxy of PyPI downloads
'''
Python 3.x minor version usage stats, by proxy of PyPI downloads.
Placed into public domain by Mia yun Ruse.
(I wouldn't recommend using it though. It's a tad hacky.)
'''
from datetime import date as Date, timedelta
from requests import get
from json import loads
@yunruse
yunruse / phoneticpassword.py
Created December 2, 2022 17:14
Phonetic password schema, a la iCloud
'''
Small tool that generates a phonetic password with a schema
identical to that used in iCloud's password generators.
Pronouncable-ish with 20 characters and ~70 bits of entropy.
Useful for password managers or sysadmins.
'''
# Example password from schema: fivhAp-riznux-0mizhi
# Let V be the set of all lowercase vowels "aiueoy".
# Let C be the set of all lowercase consonants in the Latin (English) alphabet.
@yunruse
yunruse / pangram.ipynb
Created May 17, 2022 03:55
Toki Pona Pangram Maker
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yunruse
yunruse / redirect.py
Created February 5, 2022 16:07
Output to stdout only if currently being redirected with > or >>
from os import fstat
from stat import S_ISREG
def is_redirected() -> bool:
'''Detect if program is being redirected (i.e. using the > or >> operator).'''
return S_ISREG(fstat(1).st_mode)
if __name__ == '__main__':
if is_redirected():
print('Hi file!')