Skip to content

Instantly share code, notes, and snippets.

I may be slow to respond.

Spencer Phillip Young spyoungtech

I may be slow to respond.
View GitHub Profile
remove code from unasync-generated code wherever there is a `unasync: remove` comment is placed
MIT License
Copyright (c) 2022 Spencer Phillip Young
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
spyoungtech /
Last active Jun 26, 2022
Adaptive sound - Keyboard Inputs from audio pitch

How to use

(Windows only)

  1. Download the files from this gist
  2. Install Python (using default options is OK)
  3. In command prompt, type py -m pip install --prefer-binary -r C:\path\to\requirements.txt (replacing the actual path to the requirements.txt file you downloaded from this gist)
  4. In the command prompt, type py C:\path\to\ -- in 5 seconds recording will start
  5. Open the window you want to send input to
spyoungtech /
Last active Sep 21, 2022
Parse docker repo info
from parse_repo import parse
with open('') as f:
text =
images = parse(text)
for image in images:
print('Image Digest:', image.digest)
for layer in image.layers:
print('\t', "Digest:", layer.digest)
print('\t', "Size:", layer.size)
spyoungtech / upgradewsl.ps1
Last active Jun 1, 2020
Upgrade all WSL distros to version 2
View upgradewsl.ps1
$oldversion = "1"
$newversion = "2"
$output = wsl -l -v
$distros = $output -replace "`0",'' | ConvertFrom-String -PropertyNames Active,Name,State,Version | where {$_.Version -ne "VERSION"}
$outdated = $distros | where {$_.Version -like $oldversion}
$outdated | ForEach-Object {wsl --set-version $_.Name $newversion}
spyoungtech /
Last active May 26, 2020
generate json
# Make sure to pip install json-five
from functools import singledispatch, update_wrapper
from json5.model import *
from json5.dumper import ModelDumper
import json5
import random
import string
VALUE_MODELS = [Integer, JSONObject, JSONArray, DoubleQuotedString, SingleQuotedString, Float, NullLiteral,
BooleanLiteral, Infinity, NaN, UnaryOp]
spyoungtech /
Last active Sep 30, 2021
Download twitch emotes from channel
import os
from requests import Session
from bs4 import BeautifulSoup
requests = Session()
class EmoteNotFoundError(RuntimeError):
import builtins
from textwrap import dedent
from unittest import mock
from contextlib import contextmanager
from itertools import cycle
_print = builtins.print
TEMPLATE_HEART = dedent('''
#### ####
# # # #
spyoungtech /
Created Jun 22, 2018
A lambda function intended to be triggered by S3 object creations made by Appveyor S3 deployments
import boto3
client = boto3.client('codedeploy')
def lambda_handler(event, context):
s3_event = event['Records'][0].get('s3')
bucket_name = s3_event['bucket']['name']
key = s3_event['object']['key']
etag = s3_event['object']['eTag']
spyoungtech /
Last active Mar 29, 2018
Decorate a function to automatically convert specified arguments from strings to datetimes
Decorator to convert string arguments into datetimes automatically.
The decorated function will also still accept datetime objects per normal.
Useful for commandline tools, for example.
import dateutil.parser
import datetime
@parse_dates('start', 'some_date')
def days_until(some_date, start=None):
if start_time is None:
spyoungtech /
Last active Nov 5, 2019
A webscraping example
import re
import json
import requests
from pprint import pprint
from bs4 import BeautifulSoup
def type_section(tag):
"""Find the tags that has the move type and pokemon name"""
pattern = r"[A-z]{3,} Type: [A-z]{3,}"
# if all these things are true, it should be the right tag