Skip to content

Instantly share code, notes, and snippets.

@Aluriak
Aluriak / autoload_package_submodules.py
Last active July 20, 2021 09:52
Autoloading of a package submodules in python
def autoload_package_submodules(package:object, log_info:callable=print, log_error:callable=print):
"""Import all submodules of given package to have them loaded"""
import os, glob, importlib
path = os.path.split(package.__file__)[0]
pkg_name = package.__name__
for fname in glob.glob(os.path.join(path, '*.py')):
modname = os.path.splitext(os.path.split(fname)[1])[0]
if modname.startswith('_'): continue # ignore private modules
try:
@armornick
armornick / playwav.c
Created August 24, 2012 07:31
Play a sound with SDL2 (no SDL_Mixer)
#include <SDL2/SDL.h>
#define MUS_PATH "Roland-GR-1-Trumpet-C5.wav"
// prototype for our audio callback
// see the implementation for more information
void my_audio_callback(void *userdata, Uint8 *stream, int len);
// variable declarations
static Uint8 *audio_pos; // global pointer to the audio buffer to be played