Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
@SpotlightKid
SpotlightKid / countitems.py
Last active April 19, 2024 20:50
Count occurences of same lines read from standard input.
"""Count occurences of same lines read from standard input.
Outputs a table sorted by descending count.
"""
import sys
from collections import Counter
import natsort
@SpotlightKid
SpotlightKid / clone-gists.py
Last active April 11, 2024 15:31
Clone all gists of GitHub username given on the command line.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Clone all gists of GitHub user with given username.
Clones all gist repos into the current directory, using the gist id as the
directory name. If the directory already exists as a git repo, try to perform a
'git pull' in it.
"""
@SpotlightKid
SpotlightKid / jack-transport-query.py
Last active April 11, 2024 14:04
Check whether JACK transport is rolling and toggle state
import sys
# See https://github.com/SpotlightKid/jack-matchmaker/blob/master/jackmatchmaker/jacklib.py
import jacklib
result = jacklib.jack_status_t()
client = jacklib.client_open("transport-query", jacklib.JackNoStartServer, result)
if result:
sys.exit("Error connecting to JACK server.")
@SpotlightKid
SpotlightKid / example_program_change_map.py
Last active April 11, 2024 14:00
Change program number of MIDI Program Change events according to given mapping
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Example script which maps program change numbers."""
from miditk.smf import MidiFileReader, MidiFileWriter
class ProgramChangeMapper(MidiFileWriter):
"""Change program number of Program Change events according to given mapping."""
@SpotlightKid
SpotlightKid / joystick2midi.py
Last active April 11, 2024 13:10
Convert joystick axis position into MIDI Control Change value in-/decrements using pygame.joystick and python-rtmidi
#!/usr/bin/env python
"""Convert joystick axis position into MIDI Control Change value in-/decrements."""
import os
import sys
import pygame
from rtmidi.midiutil import open_midioutput
@SpotlightKid
SpotlightKid / Makefile
Last active April 11, 2024 12:49
Generic FAUST to LV2 plugin makefile
DESTDIR ?=
PREFIX ?= /usr
LV2_DIR ?= $(PREFIX)/lib/lv2
FAUSTFLAGS ?= -nvoices 4
NAME ?= mydsp
FAUST_DSP = $(NAME).dsp
LV2_BUNDLE = $(NAME).lv2
ROOT_DIR:=$(shell dirname "$(realpath $(firstword $(MAKEFILE_LIST)))")
@SpotlightKid
SpotlightKid / rofi-selectfile.sh
Last active April 3, 2024 22:38 — forked from thingsiplay/selectfile
Use rofi to select file or folder until file is selected, then print it.
#!/usr/bin/env bash
#
# rofi-selectfile
#
# Use rofi to select file or folder until file is selected, then print it.
#
# Arguments
# $1=directory to start, defaults to "." (specified in variable default_dir)
#
# Adapted from: https://gist.github.com/thingsiplay/6c4bd13a106a4a609d69c402e675c137
@SpotlightKid
SpotlightKid / app.py
Last active March 22, 2024 18:18
Basic FastAPI app template with Jinja2 templating and static files
"""Template for a minimal FastAPI app serving just one page from a Jinja2 template and a favicon.
Place the Jinja2 "index.html" template in "templates/jinja2" and a "favicon.ico" icon file in
"static/img" and additional static files (JavaScript, CSS, images) below "static". You can then
reference them in the template like this ("path" is relative to "static"):
{{ url_for('static', path='/dir/file.txt') }}
"""
@SpotlightKid
SpotlightKid / github_download.py
Created August 6, 2014 14:12
Github file viewer / general URL download script for Pythonista
"""Prompt user for URL and filename and download the remote resource to a file.
If the clipboard contains a HTTP(S) or FTP(S) URL, the URL input dialog is
pre-filled with it.
The suggested local filename is extracted from the URL, if possible.
If a github file viewer URL is given, it is transformed into the matching
raw file access URL, which makes it easier to download files on github you
are viewing in your browser. Just copy the URL to the clipboard, change to
@SpotlightKid
SpotlightKid / getdocstrings.py
Created September 1, 2014 09:22
Parse Python source code and get or print docstrings.
# -*- coding: utf-8 -*-
"""Parse Python source code and get or print docstrings."""
__all__ = ('get_docstrings', 'print_docstrings')
import ast
from itertools import groupby
from os.path import basename, splitext