Skip to content

Instantly share code, notes, and snippets.

View notwa's full-sized avatar
🚲
bikeshedding

Connor notwa

🚲
bikeshedding
View GitHub Profile
@notwa
notwa / convert.py
Last active August 29, 2015 14:00
personalized one-way music sync
import subprocess as sp
import os
def ogg(fin, fout):
p1 = sp.Popen(["ffmpeg", "-loglevel", "error", "-i", fin, "-f", "flac", "-"], stdout=sp.PIPE)
p2 = sp.Popen(["oggenc", "-Q", "-q", "5", "-", "-o", fout], stdin=p1.stdout, stdout=sp.PIPE)
p1.stdout.close()
p2.communicate()
ret = p1.poll() or p2.poll()
return ret
@notwa
notwa / halfband.c
Last active April 16, 2024 14:27
polyphase halfband filter generator
// C port of http://ldesoras.free.fr/prod.html#src_hiir
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <errno.h>
const double PI = 3.1415926535897932384626433832795;
void
compute_transition_param(double *kp, double *qp, double transition)
@notwa
notwa / _G.yml
Last active December 11, 2016 13:24
lua table dumping as pseudo-yaml
__root: &__root_t0x4004f960
_G: *__root_t0x4004f960
_VERSION: Lua 5.1
arg: &arg_t0x40055cc8
"-1": luajit
0: run.lua
assert: fbuiltin#2
bit: &bit_t0x40054d58
arshift: fbuiltin#70
band: fbuiltin#73
@notwa
notwa / data.py
Last active February 14, 2016 17:44
guitar tension ideal string finder
# (product name, unit weight)
# D'Addario stock via http://www.daddario.com/upload/tension_chart_13934.pdf
# Circle K String stock http://circlekstrings.com/CKSIMAGES/UnitWeightChart130105.pdf
# string names don't necessarily match up with their actual product names
daddario_plain_steel = (
('DAPL007' , .00001085),
('DAPL008' , .00001418),
@notwa
notwa / enc.bat
Last active August 29, 2015 14:07
personal video/audio encode script
@ECHO OFF
set input=%1
set output="%~p1%~n1.fdk.mp4"
REM any of these can be commented out
set trim=start=0:duration=41
set scale=640:480
set aspect=4:3
set volume=24dB
@notwa
notwa / commands
Last active August 29, 2015 14:19
#!/usr/bin/env bash
shopt -s expand_aliases
input="phdump2.txt"
# matches ascii, fullwidth punctuation,
# and various japanese character blocks
regex='[\t\x{20}-\x{7E}\x{4E00}-\x{9FAF}\x{3000}-\x{30FF}\x{FF00}-\x{FFEF}]+'
# adds UTF-8 BOM
@notwa
notwa / corepatchlua.lua
Created May 26, 2015 01:56
explicit globals
local mt = getmetatable(_G)
if mt == nil then
mt = {}
setmetatable(_G, mt)
end
mt.__declared = {}
function mt.__newindex(t, n, v)
if not mt.__declared[n] then
local info = debug.getinfo(2, "S")
if info and info.what ~= "main" and info.what ~= "C" then
@notwa
notwa / Makefile
Last active July 5, 2017 02:37
r4300i disassembler by spinout182
#CFLAGS = -ggdb -Wall
CFLAGS = -Ofast -Wall
install: all
cp zadis /usr/bin/zadis
all:
$(CC) $(CFLAGS) -o zadis adis.c
clean:
from retry import retry
import requests, requests.exceptions
class StatusCodeError(Exception):
def __init__(self, code, url):
self.code = code
self.url = url
def __str__(self):
return 'request for {} returned status code {}'.format(self.url, self.code)
import numpy as np
import matplotlib.pyplot as plt
import scipy.signal as sig
# optionally, use an alternate style for plotting.
# this reconfigures colors, fonts, padding, etc.
# i personally prefer the look of ggplot, but the contrast is generally worse.
plt.style.use('ggplot')
# create log-spaced points from 20 to 20480 Hz.