Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
@SpotlightKid
SpotlightKid / lv2_list_plugin_presets.py
Last active November 8, 2019 01:33
List all preset URIs of an LV2 plugin with the given URI
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""List all preset URIs of an LV2 plugin with the given URI."""
import sys
import lilv
PRESET_NS = 'http://lv2plug.in/ns/ext/presets'
RDFS_NS = 'http://www.w3.org/2000/01/rdf-schema'
@SpotlightKid
SpotlightKid / jack-property-listener.py
Last active November 8, 2019 01:33
Listen to and print JACK client/port meta-data changes.
#!/usr/bin/env python3
"""Listen to and print JACK client/port meta-data changes."""
import jack
PROPERTY_CHANGE_MAP = {
jack.PROPERTY_CREATED: 'created',
jack.PROPERTY_CHANGED: 'changed',
jack.PROPERTY_DELETED: 'deleted'
@SpotlightKid
SpotlightKid / timebase.py
Last active November 8, 2019 01:32
Query and manipulate JACK transport state and provide timebase information using jackclient-python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# timebase.py
#
"""A simple JACK timebase master."""
import argparse
import sys
import time
@SpotlightKid
SpotlightKid / alsa-query.c
Created April 29, 2019 15:49
Print hardware capabilities of ALSA device
/*
* alsa-query.c - print hardware capabilities of ALSA device
*
* compile with: gcc -o alsa-query alsa-query.c -lasound
*/
#include <stdio.h>
#include <alsa/asoundlib.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof *(a))
@SpotlightKid
SpotlightKid / graph.py
Created March 19, 2019 18:43
Modelling source file dependencies with a graph in Python
# -*- coding: utf-8 -*-
"""A very basic general graph library."""
from __future__ import print_function
__all__ = ('Edge', 'Graph', 'Node')
import uuid
@SpotlightKid
SpotlightKid / gh-get.py
Created October 19, 2018 15:09
Download a single file from a GitHub repository
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# gh-get.py
#
"""Download a single file from a GitHub repository."""
import shutil
from os.path import expanduser
@SpotlightKid
SpotlightKid / urlparse.py
Last active September 24, 2018 18:38
Reduced urllib.parse_qsl implementation for MicroPython
# -*- coding: utf-8 -*-
def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
encoding='utf-8', errors='replace'):
"""Parse a query given as a string argument.
Arguments:
qs: percent-encoded query string to be parsed. May be a unicode
string or a UTF-8 encoded byte-string.
@SpotlightKid
SpotlightKid / sendmail-smtp.py
Last active October 4, 2019 09:29
Simple command line mailer
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Simple command line mailer.
Send text-only email via SMTP with message text read from stdin to all email addresses given as
arguments.
"""
import sys
@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 / file2h.py
Last active August 5, 2018 14:48
Convert a file to a C char array representation. Outputs a C header on standard output.
#!/usr/bin/env python
"""Convert a file to a C char array representation.
Outputs a C header on standard output.
"""
from sys import argv, exit, stdout
from os.path import basename, isfile