Skip to content

Instantly share code, notes, and snippets.

View SpotlightKid's full-sized avatar

Christopher Arndt SpotlightKid

View GitHub Profile
from contextlib import contextmanager
from time import time
from sys import stdout
@contextmanager
def duration(outfile=stdout):
start = time()
yield
end = time()
outfile.write(str(end - start) + '\n')
from contextlib import contextmanager
from operator import itemgetter
from sys import argv, stdout
from time import time
@contextmanager
def duration(outfile=stdout):
start = time()
yield
end = time()
@SpotlightKid
SpotlightKid / synth.cpp
Created January 17, 2016 21:21 — forked from genericpenguin/synth.cpp
Arduino Synth
/* Arduino Synth from
https://janostman.wordpress.com/2016/01/15/how-to-build-your-very-own-string-synth/
*/
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
@SpotlightKid
SpotlightKid / cmdline.py
Last active February 9, 2016 15:55
Logging in Python command line scripts
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import argparse
import logging
import sys
log = logging.getLogger(__name__)
def main(args=None):
@SpotlightKid
SpotlightKid / O2.ino
Created February 20, 2016 20:53 — forked from anonymous/O2.ino
// O2 Minipops rhythm box (c) DSP Synthesizers 2016
// Free for non commercial use
// http://janostman.wordpress.com
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
// dsp-L8 Latin Perc Chip (c) DSP Synthesizers 2015
// Free for non commercial use
// http://janostman.wordpress.com
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
@SpotlightKid
SpotlightKid / dspD8.ino
Created February 20, 2016 21:02 — forked from anonymous/dspD8.ino
The dsp-D8 drum synthesizer
// dsp-D8 Drum Chip (c) DSP Synthesizers 2015
// Free for non commercial use
// http://janostman.wordpress.com
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
@SpotlightKid
SpotlightKid / jdutil.py
Last active March 11, 2016 16:48 — forked from jiffyclub/jdutil.py
Functions for converting dates to/from JD and MJD
"""
Functions for converting dates to/from JD and MJD. Assumes dates are historical
dates, including the transition from the Julian calendar to the Gregorian
calendar in 1582. No support for proleptic Gregorian/Julian calendars.
:Author: Matt Davis
:Website: http://github.com/jiffyclub
"""
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ntppeerstats.py
#
# Copyright 2016 Christopher Arndt <chris- at- chrisarndt -dot- de>
#
"""Get NTP daemon peer statistics and graph time offsets.
Documentation of the file format:
@SpotlightKid
SpotlightKid / registrable.py
Last active April 13, 2016 15:47
Demonstrates how to use meta-classes to build a registry of sub-classes.
# -*- coding: utf-8 -*-
#
# registrable.py
#
"""Demonstrates how to use meta-classes to build a registry of sub-classes."""
__all__ = [
'Registrable',
'RegistrableMeta',
'BlueColor',