Skip to content

Instantly share code, notes, and snippets.

View rfielding's full-sized avatar

Robert Fielding rfielding

View GitHub Profile
#!/bin/env python3
# Andrej Karpathy - Reinforcement learning demo, fixed to work in Python3.7
#
# http://karpathy.github.io/2016/05/31/rl/
#
# - Python3 fixes
# - I used conda
# - You have to install the atary_py separately, AND also import all the Atari ROMs separately
#
# Algebraic Calculus
# All rules with partials - on binary operators where BOTH args are not necessarily constant
d[f + C] : (d[C]==0) = d[f]
d[a + b] = d[a] + d[b]
d[a * b] = a * d[b] + d[a] * b
# a and b must commute for this definition
d[a^b] = b * a^(b-1) * d[a] + log_e[a] * a^b * d[b]
# a and b must commute for this definition
# Notice that log is a binary operator, where the base can vary, for completeness!
d[log_a[b] = (-1/a) ln[b]/(ln[a]^2) * d[a] + (1/b) * (1/ln[a]) * d[b]

Keybase proof

I hereby claim:

  • I am rfielding on github.
  • I am robfielding (https://keybase.io/robfielding) on keybase.
  • I have a public key ASCdxoKdgZzx54mus0dnAwN2L4OSqJBTMw5QXndke-6VYgo

To claim this, I am signing this object:

/*
Schematic:
Just stack an Arduino Uno (r3) with a Olimex MIDI shield.
Plug in MIDI in to a keyboard, and MIDI out to a synth.
Ensure that MIDI channel out is same as channel receiving in synth (this does not channel rewrite).
This proxy works by:
- was last note down lower than -6 semitones from last?
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Error;
//#[allow(dead_code)]
#[derive(Copy,Clone)]
enum Opb {
PAIR,
ADD,
SUB,
@rfielding
rfielding / An excerpt of how it's used
Created January 5, 2012 22:17
Fixing a huge omission in MIDI, note-ties
if(fingerTurningOff != NOBODY)
{
struct Fretless_fingerState* turningOffPtr = &ctxp->fingers[fingerTurningOff];
if(turningOffPtr->isOn == FALSE)
{
ctxp->fail("turningOffPtr->isOn should be on\n");
}
if(turningOffPtr->isSupressed == FALSE)
{
ctxp->fail("turningOffPtr->isSupressed should be supressed\n");
@rfielding
rfielding / Fretless.h
Created December 19, 2011 18:45
Hiding the vulgarities of MIDI behind a frequency oriented interface.
//
// Fretless.h
// AlephOne
//
// Created by Robert Fielding on 10/14/11.
//
// This should remain a *pure* C library with no references to external libraries
/*
* There is no internal global state, so this entire library is re-entrant.
//WHAT A LIE. Measure it by recording the diff between acoustic and instrument output
float latency = 0.005;
OSStatus status =
AudioSessionSetProperty(
kAudioSessionProperty_PreferredHardwareIOBufferDuration,sizeof(latency),
&latency
);