Skip to content

Instantly share code, notes, and snippets.

View swannodette's full-sized avatar

David Nolen swannodette

View GitHub Profile
@swannodette
swannodette / FourteenBitCC.sc
Created August 4, 2020 09:44 — forked from carltesta/FourteenBitCC.sc
14-bit MIDI Handler for SuperCollider
FourteenBitCC {
/*
//Use Case:
MIDIIn.connectAll;
~x = FourteenBitCC.new("x", 72, 104);
~x.func = {|val| ("x: "++val).postln};
//MPE Example with Sensel Morph
MIDIIn.connectAll

SuperCollider Byte Code Reference

Brian Heim 2018-06-19

Table of Contents

  • Introduction
@swannodette
swannodette / cljs_deps2.md
Last active April 11, 2020 00:58
Transitive Foreign Dependencies 2

Add a new :target option, :bundle. When this target is set :nodejs is true and :nodejs-rt is false. We want to take advantage of the fact that the :nodejs target emits Node.js require for libs found in node_modules. :nodejs-rt false clarifies that we are not actually going to target the Node.js runtime.

The :bundle target always generates an index.js file, it need only be created once.

The contents of index.js looks like the following:

@swannodette
swannodette / transitive_foreign.md
Last active June 1, 2020 14:22
Transitive Foreign Dependencies
NOTE: This proposal is dead. A simpler solution was arrived at via the new `:bundle` target.

ClojureScript Support for Foreign Libraries via NPM

Problem Description

The current Webpack solution works reasonable well for application oriented development, but does not address the wider issue of developing ClojureScript libraries that depend on the wider JavaScript ecosystem where the artifacts do not reside in Java-centric distrubtion like Maven (i.e. NPM). Currently a ClojureScript library cannot express these kinds of foreign library dependencies at all. Thus users must constantly redefine basic dependencies from NPM such as React, boilerplate Webpack configuration, boilerplate import/export files, and thus cannot create and share reusable ClojureScript components that depend on this vast ecosystem.

@swannodette
swannodette / linnstrument.sc
Created April 2, 2019 18:26 — forked from kisielk/linnstrument.sc
Linnstrument + Supercollider
(
var notes, synths, on, off, mod, bend, touch;
~num_channels = 8;
~bend_range = 24;
MIDIIn.connectAll;
notes = Array.newClear(~num_channels);
synths = Array.newClear(~num_channels);
// Twister devices are expected to be named in this form:
// classvar <endpointDevice="Midi Fighter Twister %", <endpointName="Midi Fighter Twister";
// Where "Midi Fighter Twister 1" is TwisterDevice(\default) and "Midi Fighter Twister 2" is TwisterDevice(\secondary)
// A twister device. These are singletons - there is only ever one registered per device. It works ala Ndef, Pdef, etc, see Singleton help file.
~device = TwisterDevice(\default);
// If your MIDI Fighter is named something other than the above, you can register it via:
this.registerDevice(\myDevice, "endpoint device", "endpoint name");
// And then access it via TwisterDevice(\myDevice)
DummyMIDI {
var dummy = 0;
*new {
^super.newCopyArgs();
}
noteOn {}
noteOff {}
control {}
@swannodette
swannodette / core.cljs
Last active July 13, 2018 14:58
Figwheel :paths bug
;; src/cljs/hello_world/core.cljs
(ns hello-world.core)
(println "Hello, world!")
("goog.debug.Error"
"goog.dom.NodeType"
"goog.string"
"goog.asserts"
"goog.reflect"
"goog.object"
"goog.math.Integer"
"goog.string.StringBuffer"
"goog.array"
"goog.math.Long"

Code Splitting

NOTE: This gist uses the master branch of ClojureScript. Clone ClojureScript and from the checkout run ./script/bootstrap and ./script/uberjar. This will produce target/cljs.jar which you can use to follow this guide.

As client applications become larger it becomes desirable to load only the code actually required to run a particular logical screen. Previously ClojureScript :modules compiler option permitted such code splitting, but this feature only worked under :advanced compilation and users would still have to manage loading these splits. :modules also required manual