Skip to content

Instantly share code, notes, and snippets.

@ggorlen
ggorlen / ebook_organizer.py
Created September 13, 2020 23:29
keeps my ebooks nicely organized
"""
keeps my ebooks nicely organized
"""
import os
import re
categories = {
"computer architecture": ["architecture", "computer architecture"],
"ai": ["machine learning", "big data", "convolutional", "neural", "artificial", "intelligence"],
@ggorlen
ggorlen / app.py
Created September 20, 2020 04:07
Flask and unittest starter
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello there!"
@app.route("/<name>")
def hello_name(name):
return f"Hello, {name}!"
@ggorlen
ggorlen / dir_to_mp3.pl
Last active January 5, 2022 23:17
Convert files in a directory to mp3
# Convert files in a directory to mp3
use strict;
use warnings;
use feature "say";
use Data::Dumper;
use File::Basename;
use File::Path;
use File::Spec::Functions;
@ggorlen
ggorlen / show_all_mp3_bitrates.pl
Last active December 7, 2020 00:11
show bitrates of mp3s in a directory
# show bitrates of mp3s in a directory
use strict;
use warnings;
use feature 'say';
use File::Find;
use File::Spec::Functions;
use MP3::Info;
my @res;
@ggorlen
ggorlen / make_bulk_qrs.py
Last active June 27, 2021 23:32
Generates bulk bin QR codes from an Excel file
################
# One-time setup
#
# 1. Install the latest version of Python 3 from the world wide web
# 2. open a terminal and run: pip install pandas qrcode openpyxl
# if you get an error, try: pip3 install pandas qrcode openpyxl
# or: python3 -m pip install pandas qrcode openpyxl
# or: python -m pip install pandas qrcode openpyxl
#
# If all of these fail, and the commands `python3` `python` and `py` fail,
@ggorlen
ggorlen / canvas_submission_file_comment.py
Last active October 27, 2020 02:31
Add a file to a submission in the Canvas LMS API
import requests
token = "YOUR CANVAS API TOKEN"
filename = "test.txt"
file_url = "https://gatech.instructure.com/api/v1/courses/137794/assignments/537670/submissions/26370"
url = file_url + "/comments/files"
headers = {"Authorization": f"Bearer {token}"}
data = {
"name": filename,
@ggorlen
ggorlen / mp3scraper.pl
Last active November 15, 2020 06:58
Print/play/download all mp3s on a webpage
#!/usr/bin/perl
# Play all mp3s on a webpage:
# $ ./mp3scraper.pl http://www.microsound.org/projects/project.php?name=Klanghausen | xargs -o mpg123
#
# Download all mp3s on a webpage:
# $ wget -r -l1 -H -nd -A mp3 -e robots=off http://www.microsound.org/projects/project.php?name=Klanghausen
use strict;
use warnings;
@ggorlen
ggorlen / web-audio-cli.md
Last active February 28, 2025 02:30
Streaming web audio on the command line

Web audio on the command line

Install mpv and ytdlp

MPV can play most URLs

mpv -no-vid https://www.youtube.com/watch?v=jJxRjWtwmEE # single YT video
mpv -no-vid https://www.discogs.com/master/50617-Wire-Chairs-Missing # webpage with videos
mpv -no-vid https://robertturman.bandcamp.com/album/chapter-eleven-1976-1987 # bandcamp album
@ggorlen
ggorlen / vagrant-cheatsheet.md
Created November 18, 2020 05:22
Vagrant cheatsheet

Vagrant cheatsheet

vagrant box add ubuntu/trusty64
vagrant init ubuntu/trusty64
vagrant up

# possible error: default: The guest additions on this VM do not match the installed version
vagrant halt
vagrant plugin install vagrant-vbguest
@ggorlen
ggorlen / inplace_convert_dir_to_mp3.pl
Last active December 7, 2020 00:10
Convert directory to mp3 recursively
# Convert files to mp3 recursively using ffmpeg, destroying originals
# FIXME fails on unicode chars
# FIXME should work on flac/wav rather than only high-bitrate mp3s
use strict;
use warnings;
use File::Copy;
use File::Find;
my $verbose = 0;