Skip to content

Instantly share code, notes, and snippets.

View RossBencina's full-sized avatar
💭
I'm working on the thing that uses QueueWorld

Ross Bencina RossBencina

💭
I'm working on the thing that uses QueueWorld
View GitHub Profile
@RossBencina
RossBencina / git_quickref.md
Last active August 22, 2023 07:59
Quick Reference for Common Git Operations
@RossBencina
RossBencina / illegal_explicit_specialization.cpp
Created February 20, 2017 10:59
You can't use explicit function specialization at class scope
class Foo{
template<typename X>
void foo()
{
}
template<>
void foo<int>() // error: explicit specialization of 'foo' in class scope
{
@RossBencina
RossBencina / tag_dispatch_flags
Last active December 5, 2016 15:51
Using tag-dispatch to implement or-combinable flags. Code for my SO question: http://stackoverflow.com/questions/40977757
#include <iostream>
// **Current Solution: Part 1 - send() function**
// This is the easy part.
// First, a type-level enum helper
template<typename EnumClass, EnumClass X>
struct EnumValue {
// These are reduced test cases derived from a work-in-progress (non-production) code base.
// Can you spot the bugs that PVS-Studio found?
#include <atomic>
#include "catch.hpp"
///////////////////////////////////////////////////////////////////////////////
// Bug #1
# Symbolic integration of [(1 - x^a)^b * e^iwx] dx from -1 to 1
# see discussion on music-dsp mailing list
# "Re: [music-dsp] a family of simple polynomial windows and waveforms"
from math import factorial
from copy import deepcopy
import string
# binomial coefficient nCk
def binomial(n, k):
@RossBencina
RossBencina / SH1.py
Last active November 5, 2015 14:52
Compute spectrum of sample-and-hold noise
# see https://lists.columbia.edu/pipermail/music-dsp/2015-November/000424.html
# psd derivation due to Ethan Duni
import numpy as np
from numpy.fft import fft, fftfreq
import matplotlib.pyplot as plt
N = 16384*2*2*2*2*2 # FFT size
y = (np.random.random(N) * 2) - 1 # ~U(-1,1)
r = np.random.random(N) # ~U(0,1)
@RossBencina
RossBencina / inherit-types-from-template-base-class.cpp
Created August 31, 2015 15:14
Experiment: Inheriting Types From Template Base Class
/// Inheriting Types From Template Base Class
/// =========================================
///
/// I put together this comparison of various methods of looking up types in
/// a base class template after noticing that my code would compile correctly
/// in MSVC but break in clang and gcc.
///
/// Having reviewed the various cases, my conclusion is that MSVC is very
/// permissive in looking up names in base class templates. It doesn't
/// implement the correct C++ dependent name lookup rules.
// Template-based async method continuation idea by Ross Bencina <rossb@audiomulch.com> May 2014.
// see: https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/ryhWI6cX3Ko
#include <iostream>
#include <list>
typedef void (*async_callback_fn_t)(void*);
struct PendingSimulatedTaskCallback{
async_callback_fn_t simulatedAsyncCallbackFn_;
@RossBencina
RossBencina / MyCoroutine.cpp
Last active August 29, 2015 14:01
C++ Coroutine Using Template
// Template-based Coroutine continuation idea by Ross Bencina <rossb@audiomulch.com> May 2014.
// see: https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/ryhWI6cX3Ko
#include <iostream>
class MyCoroutine {
typedef MyCoroutine this_t;
typedef bool (this_t::*coroutine_fn_t) ();
coroutine_fn_t next_;