Skip to content

Instantly share code, notes, and snippets.

import unittest
from pybean import SQLiteWriter, Store
import resource
def memory_usage():
return resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
class TestPybean(unittest.TestCase):
import sqlite3
from pkg_resources import parse_version
__version__ = "0.2.1"
class SQLiteWriter(object):
"""
In frozen mode (the default), the writer will not alter db schema.
@johndoe46
johndoe46 / wavfile.py
Created March 26, 2019 21:22 — forked from josephernest/wavfile.py
wavfile.py (enhanced)
# wavfile.py (Enhanced)
# Date: 20190213_2328 Joseph Ernest
#
# URL: https://gist.github.com/josephernest/3f22c5ed5dabf1815f16efa8fa53d476
# Source: scipy/io/wavfile.py
#
# Added:
# * read: also returns bitrate, cue markers + cue marker labels (sorted), loops, pitch
# See https://web.archive.org/web/20141226210234/http://www.sonicspot.com/guide/wavefiles.html#labl
# * read: 24 bit & 32 bit IEEE files support (inspired from wavio_weckesser.py from Warren Weckesser)
@johndoe46
johndoe46 / wav-riff-reader.py
Created March 26, 2019 21:05 — forked from JonathanThorpe/wav-riff-reader.py
Python WAV File RIFF Header Reader
import struct
import io
class WAVFile:
def __init__(self, filename):
self.filename = filename
def read(self):
with io.open(self.filename, 'rb') as fh:
@johndoe46
johndoe46 / MIDI controller.ino
Created September 27, 2017 13:13 — forked from mzierer/MIDI controller.ino
Some code for a custom MIDI controller I built
//This code is to be used with a MIDI controller I recently built.
//Pictures and info about the project: http://imgur.com/a/ngEN2
//It's a Teensy LC arduino style microcontroller working inside an old guitar distortion effect foot pedal.
//The controller features four main potentiometers to send midi CC values in two different banks that can be changed by an spdt switch
//There's also one button to send a midi note and another potentiometer on the right side to send midi CC signals
//The code and project are heavily inspired by this awesome video tutorial series: https://youtu.be/JONIZdLZAVM (in German)
//The LED pulse effect I found somewhere on the internet
@johndoe46
johndoe46 / 0readme.md
Created July 5, 2017 14:05 — forked from mdamien/0readme.md
404 link detector with scrapy

List all the broken links on your website

Requirements:

python3 and scrapy (pip install scrapy)

Usage

  • scrapy runspider -o items.csv -a site="https://yoursite.org" 1spider.py
  • python3 2format_results.py
@johndoe46
johndoe46 / example.com.conf
Created May 5, 2017 12:41 — forked from a-vasyliev/example.com.conf
Nginx: proxy cache without utm_* parameters (remove query parameter, remove utm tags nginx)
server {
listen 443;
server_name example.com;
error_log /var/log/nginx/example_com_error.log warn;
ssl on;
ssl_certificate /etc/nginx/ssl/your.crt; #certificate chains
ssl_certificate_key /etc/nginx/ssl/your.key; #private key
@johndoe46
johndoe46 / hierarchical_data.sql
Last active May 18, 2018 20:49
Closure Table method for hierarchical data with PostGreSQL
DROP TABLE IF EXISTS page CASCADE;
CREATE TABLE IF NOT EXISTS page
(
id serial NOT NULL PRIMARY KEY,
title character(64) NOT NULL,
parent_id integer REFERENCES page
);
DROP TABLE IF EXISTS page_hierarchy;
CREATE TABLE IF NOT EXISTS page_hierarchy(
#!/usr/bin/env python
# needs unzip, flac and sox at your shell
from xml.dom import minidom
from subprocess import call
import sys
import wave
import os
/*
Adapted from denkitribe's code, which can be found here:
http://code.google.com/p/denkitribe/source/browse/trunk/Arduino/MonotronCVGateTest/MonotronCVGateTest.pde
pin setup: - DAC 1 ---> Arduino +5V
- DAC 2 ---> Arduino 10
- DAC 3 ---> Arduino 13
- DAC 4 ---> Arduino 11
- DAC 5 ---> Gnd
- DAC 6 ---> Not Connected