Skip to content

Instantly share code, notes, and snippets.

View mikesol's full-sized avatar
🎯
Focusing

Mike Solomon mikesol

🎯
Focusing
View GitHub Profile
@mikesol
mikesol / kludge.scd
Last active December 18, 2016 16:39
le ballon rouge - 1er brouillon
MIDIClient.init;
MIDIClient.sources;
MIDIIn.connect; // init for one port midi interface
MIDIIn.removeFuncFrom(\control, ~controlKludge);
~current = 0;
~controlKludge = { arg src, chan, num, val;
if (val == 127, {
[chan,num,val].postln;
@mikesol
mikesol / better.js
Created December 18, 2016 16:41
La programmation réactive gère des évènements musicaux
currentSeq = tops[top] ? tops[top].scene || new EvSeq(new EventEmitter()) : currentSeq;
if (verb === states.STAGED || verb === states.SHIT) {
console.log("playing " + top);
if (verb === states.SHIT) {
// reset currentSeq
currentSeq.stop();
}
// TODO: figure out a way to unsubscribe observables...this will probably in a memory leak
Observable.fromEvent(tops[top].event || new EventEmitter(), 'sc')
.subscribe(function(msg) {
@mikesol
mikesol / saga-teller.js
Last active November 9, 2017 02:22
Telling a saga
import _ from 'lodash';
const ____kludge = (function*() {}).constructor;
const isGeneratorFunction = ugh => ugh instanceof ____kludge;
const recurse = rules => fn => isGeneratorFunction(fn) ? sagaTeller(fn, rules) : fn;
const genWrapper = (value, rules) => ({
...value,
fn: recurse(rules)(value.fn),
args: value.args.map(recurse(rules)),
});
_BACKEND_SPEC = dict(
set_learning_phase=__set_learning_phase,
is_keras_tensor=__is_keras_tensor,
variable=__variable,
placeholder=__placeholder,
eye=__eye,
eval=__eval,
random_uniform_variable=__random_uniform_variable,
random_normal_variable=__random_normal_variable,
random_uniform=__random_uniform_variable,
@mikesol
mikesol / tabhack.js
Created April 18, 2018 06:51
A hack for fenced code tabs in mkdocs material
document.addEventListener('DOMContentLoaded', function () {
var hashcache = {};
var langcache = {};
var ariacache = {};
Array.prototype.forEach.call(document.querySelectorAll('ul.nav.nav-tabs'), function(tablist) {
Array.prototype.forEach.call(tablist.querySelectorAll('li.nav-item'), function(tabitem) {
Array.prototype.forEach.call(tabitem.querySelectorAll('a'), function (anchor) {
var lang = anchor.getAttribute("data-lang");
var aria = anchor.getAttribute("aria-controls");
var obj = {
@mikesol
mikesol / test_negative_list_sum.py
Last active August 7, 2019 10:18
Prove that the sum of a list of negative numbers is negative
from z3 import *
def test_negative_list_sum():
ll = Datatype('ll')
ll.declare('empty')
ll.declare('cons', ('car', IntSort()), ('cdr', ll))
ll = ll.create()
list_sum = Function('list_sum', ll, IntSort(), BoolSort())
a,e = Consts('a e', ll)
b,c,d = Ints('b c d')
@mikesol
mikesol / test_list_elt_gt_1.py
Last active August 7, 2019 10:23
Prove that a list whose sum is greater than its length must have at least one element greater than one
from z3 import *
def test_list_elt_gt_1():
ll = Datatype('ll')
ll.declare('empty')
ll.declare('cons', ('car', IntSort()), ('cdr', ll))
ll = ll.create()
list_sum = Function('list_sum', ll, IntSort(), BoolSort())
list_len = Function('list_len', ll, IntSort(), BoolSort())
a,e = Consts('a e', ll)
@mikesol
mikesol / prose.kt
Last active August 19, 2019 19:36
Kotlin code snippet
class _First {
infix fun sign(into: _Into) = into
}
class _Into {
infix fun your(console: _Console) {
// insert sign in logic, ie via Robolectric
return console
}
}
class _Console { val Then = this
@mikesol
mikesol / stripe-v1-customers.json
Created February 9, 2020 21:19
Mock data from stripe /v1/customers
{
"object": "list",
"data": [
{
"id": "cus_GhmXKD3awekHyV",
"object": "customer",
"account_balance": -755,
"address": {
"city": "Elk Grove",
"country": "US",
@mikesol
mikesol / stripe-hoverfly-simulation.json
Last active February 10, 2020 08:20
A stripe hoverfly simulation
{
"error": {
"message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/docs/api#authentication for details, or we can help at https://support.stripe.com/.", "type": "invalid_request_error"
}
}