Skip to content

Instantly share code, notes, and snippets.

@dmorgan-github
dmorgan-github / Pdv.sc
Last active March 2, 2023 04:00
SuperCollider mini dsl for durations and values
/*
NOTE: There is a Quark for this - https://github.com/dmorgan-github/Pdv
Copy to Extensions folder and re-compile
Ryhthmically sequences numeric values which can then be used with any event key, e.g. degree or midinote.
operators:
" " - empty space separates beats/values
~ - rest
call plug#begin()
Plug 'davidgranstrom/scnvim'
Plug 'preservim/nerdtree'
Plug 'jnurmine/Zenburn'
Plug 'itchyny/lightline.vim'
Plug 'L3MON4D3/LuaSnip'
" Plug 'neovim/nvim-lspconfig'
Plug 'hrsh7th/cmp-nvim-lsp'
(
~drec.fx(200, {|sig_in|
var updateFreq = 15;
var replyid = \bufposreplyid.kr(-1);
var buf = \buf.kr(0);
var in = sig_in.asArray.sum;//In.ar(\in.kr(0), 2).asArray.sum;
var frames = BufFrames.kr(buf);
var rate = \rate.kr(1);
var start = \startPos.kr(0) * frames;
var end = \endPos.kr(1) * frames;
(
Plazy({
Pbind(
\dur, Pseed(123, Prand([1, 0.5, 0.25], inf))
)
.finDur(8) // 8 beat measure
})
.repeat // repeat each measure
1) Exploring sounds
SynthDescLib.global.at(\mysynth).makeWindow;
@dmorgan-github
dmorgan-github / supercollider-pseudo-object
Last active July 10, 2022 19:50
SuperCollider pseudo-object cheatsheet
(
/*
Collection
|
|-- Set
|
|-- Dictionary
|
|-- IdentityDictionary
|

Loosely coupling in node.js

In JavaScript everything is an interface and nothing is an interface.

Or, conversely, everything is loosely coupled and nothing is loosely coupled. This doesn't mean distinguishing between contract and implementation goes out the window. Nor does it mean an application is instantly loosely coupled just by virtue of being a node app.

When a module loads its dependencies via the global require method it binds itself to a particular implementation from a particular location. Where you want to achieve loose coupling between components loading a dependency via require is probably not the way to go. Nevertheless, it is true enough modules can be swapped out simply by replacing the contents of the file. Obviously this would work but isn't particularly compelling.

@dmorgan-github
dmorgan-github / Application.java
Created July 16, 2014 21:06
Group by in Java 8 using streams and lambdas
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Application {
public static void main(String[] args) {
@dmorgan-github
dmorgan-github / f1.py
Created July 15, 2014 19:17
Training and testing RandomForest classifier in python
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import f1_score
target = 'e'
features = ['a', 'b', 'c', 'd']
cols = len(features)
rows = 1000