Skip to content

Instantly share code, notes, and snippets.

View hosackm's full-sized avatar

Matt H hosackm

View GitHub Profile
@hosackm
hosackm / colorlog.py
Created July 28, 2020 01:39
Colored logger module using Colorama
import logging
from colorama import init, Fore, Back
init(autoreset=True)
class ColorFormatter(logging.Formatter):
# Change this dictionary to suit your coloring needs!
COLORS = {
"WARNING": Fore.RED,
@hosackm
hosackm / Ringbuffer
Last active August 8, 2019 01:56
Dumb ringbuffer
CC=clang
CXX=clang++
SOURCES=ringbuffer.c
INCLUDES=-I.
test:test.cpp $(SOURCES)
$(CXX) -std=c++11 -o runtests $(INCLUDES) `pkg-config --cflags --libs gtest` $^
./runtests
@hosackm
hosackm / Makefile
Last active November 28, 2018 07:18
Introduction to googletest for C
CC=clang
CCX=clang++
SOURCES=adder.c
TESTSOURCES=test_add_two_numbers.cxx run_all_tests.cxx
INCLUDES=-I.
EXE=adder
$(EXE): $(SOURCES) main.c
$(CC) $(INCLUDES) $^ -o $@
@hosackm
hosackm / .json
Last active October 11, 2018 17:47
vscode_config
{
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
// "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"editor.fontFamily": "'Fira Code', Hack",
"editor.fontWeight": "100",
"editor.fontSize": 13,
"editor.fontLigatures": true,
"editor.rulers": [
120
@hosackm
hosackm / .js
Created May 14, 2018 20:25
vscode_config
{
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
// "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
"editor.fontFamily": "'Fira Code', Hack",
"editor.fontWeight": "100",
"editor.fontSize": 13,
"editor.fontLigatures": true,
"editor.rulers": [
120
@hosackm
hosackm / simple_flac_encoder.c
Created February 28, 2018 04:47
Encode signed 16 bit 16 kHz PCM to FLAC file
#include "FLAC/stream_encoder.h"
#define CHUNKSIZE 512
FLAC__StreamEncoderWriteStatus callback
(const FLAC__StreamEncoder *encoder
,const FLAC__byte buffer[]
,size_t bytes
,unsigned samples
,unsigned current_frame
@hosackm
hosackm / fftplot.py
Created June 21, 2016 04:27
FFT plot of 440 Hz sine tone in numpy
import numpy as np
import scipy.io.wavfile as wf
import matplotlib.pylab as plt
def main():
# use power of 2 for FFT length
FFTN = 2**14
try: # try to read from wav file
package main
import (
"github.com/hypebeast/go-osc/osc"
"github.com/rakyll/portmidi"
)
const (
NOTEOFF = 0x80
NOTEON = 0x90
@hosackm
hosackm / Makefile
Created October 21, 2015 17:28
Makefile for building objects for each source file. It takes too long too get it working when you start from scratch
CC=clang
LIB=
INCLUDES=-Iinclude/
FLAGS=-Wall -Werror -pedantic
SOURCES=$(wildcard src/*.c)
#OBJECTS=$(SOURCES:.c=.o) # This way works too
OBJECTS=$(patsubst %.c, %.o, $(SOURCES))
EXE=executable_name.out
all: $(EXE) clean
@hosackm
hosackm / fir_stuff.py
Last active June 21, 2016 04:28
FIR Filter using SciPy signal
import numpy as np
import scipy.signal as sig
from scipy.io.wavfile import write as write
from matplotlib import pyplot as plt
SR = 48000
SECS = 10.0
NSAMPS = int(SECS * SR)
NTAPS = 61
INT_MAX = 2**15-1