This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pathlib | |
REPLACE_CHARS = ':*?"' | |
def walk(path: pathlib.Path): | |
for item in path.iterdir(): | |
if item.is_dir(): | |
yield from walk(item) | |
elif item.is_file(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pathlib | |
from urllib.parse import urlparse, urlunparse, unquote, quote | |
import xml.dom.minidom | |
REPLACE_CHARS = '<>:' | |
path = pathlib.Path("~/.local/share/rhythmbox/rhythmdb.xml").expanduser() | |
out_path = path.parent / "new_rhythmdb.xml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
import xml.dom.minidom | |
path = pathlib.Path("~/.local/share/rhythmbox/rhythmdb.xml").expanduser() | |
out_path = path.parent / "new_rhythmdb.xml" | |
print("Updating date addeds in", path, "and outputting to", out_path) | |
d = xml.dom.minidom.parse(str(path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gzip | |
import os | |
import pathlib | |
import warcio.archiveiterator | |
from bs4 import BeautifulSoup | |
import pandas | |
def warc_stream(stream): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func RotatedImage(i *ebiten.Image, rotation float64) *ebiten.Image { | |
if i == nil { | |
return i | |
} | |
w, h := i.Size() | |
maxDim := int(math.Hypot(float64(w), float64(h))) | |
newimage := ebiten.NewImage(maxDim, maxDim) | |
op := ebiten.DrawImageOptions{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func RotateAround(pt, origin image.Point, angle float64) (int, int) { | |
x1, y1 := float64(pt.X-origin.X), float64(pt.Y-origin.Y) | |
magnitude := math.Hypot(x1, y1) | |
rotationAngle := math.Atan2(y1, x1) + angle | |
return origin.X + (int(math.Cos(rotationAngle) * magnitude)), origin.Y + (int(math.Sin(rotationAngle) * magnitude)) | |
} | |
func RotatedImage(i *ebiten.Image, rotation float64) *ebiten.Image { | |
if i == nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alpeppert | |
ampepperage | |
ampeppere | |
ampepperes | |
ampeppersand | |
ampeppersands | |
apepperiodic | |
apepperiodicity | |
apepperture | |
appeppertain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class TemperamentalClass(type): | |
@classmethod | |
def __instancecheck__(cls, other): | |
return random.choice([True, False]) | |
class MyClass(metaclass=TemperamentalClass): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
def order_query_string(url): | |
parsed_url = list(urllib.parse.urlparse(url)) | |
# Put the query string params in determinisitic order. | |
# According to docs.python this is in [3], but docs.python is a liar. | |
parsed_url[4] = urllib.parse.urlencode(sorted(urllib.parse.parse_qsl(parsed_url[4]))) | |
return urllib.parse.urlunparse(parsed_url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e = lambda x: "".join(u":lazer_{}:\u200b".format(c) if (c.isalpha() or c.isdigit()) else " {} ".format(c) for c in x.upper()) |
NewerOlder