Skip to content

Instantly share code, notes, and snippets.

@totalgee
totalgee / remove_if_vs_find_if.cpp
Last active August 7, 2020 17:23
remove_if bug (vs find_if)
// Run this code here: https://coliru.stacked-crooked.com/a/1a9ad442077cd0f6
#include <vector>
#include <algorithm>
#include <iostream>
#include <memory>
int main()
{
std::vector<std::unique_ptr<int>> vec;
(
// Look for strings like deg"1 2 ~ 4" for a \degree pattern with durations
var pattern = "(\\w{3})\"([^\"\n]*)\"";
preProcessor = { |code|
var curOffset = 0;
var pat = code.findRegexp(pattern).clump(3);
// pat.debug("pat");
pat.do{ arg p;
var fullMatch = p[0];
var patternType = p[1].last;
@totalgee
totalgee / PtimeChain.sc
Last active April 29, 2020 02:37
SuperCollider Event pattern similar to Pchain, except it merges "value events" from the right-hand patterns with the values and time structure of the first pattern.
PtimeChain : Pattern {
var <>patterns;
*new { arg ... patterns;
^super.newCopyArgs(patterns);
}
<< { arg aPattern;
var list;
list = patterns.copy.add(aPattern);
@totalgee
totalgee / ScriptPerformanceComparisons.txt
Last active February 24, 2022 12:09
Performance comparison of ChaiScript w/ several other scripting languages
Summary for simple looped calculation (details and code below):
- on OS X 10.10.3, Mac Pro: 3,7 GHz Quad-Core Intel Xeon E5
Language Tested Version Best Time Relative Perf Notes
======== ============== ========= ============= =====
Node.js v0.10.33 0.0028 1
Lua v5.3.0 0.0098 3.5
SuperCollider v3.6.6 0.0138 4.9
Ruby v2.0.0p481 0.0143 5.1
Python v2.7.6 0.0413 14.8