Skip to content

Instantly share code, notes, and snippets.

View iandanforth's full-sized avatar

Ian Danforth iandanforth

View GitHub Profile
@iandanforth
iandanforth / pymunk_cartpole.py
Created June 6, 2018 02:57
A port of the cart-pole OpenAI gym environment to Pymunk
"""
Classic cart-pole system.
Pymunk version by Ian Danforth
"""
import math
import gym
import pygame
import pymunk
@iandanforth
iandanforth / cartpole_utils.py
Last active May 25, 2018 16:45
Cartpole implemented using Pymunk 2D physics
import pygame
import pymunk
from pygame.locals import (QUIT, KEYDOWN, K_ESCAPE)
##############################################################################
# Pygame
def handlePygameEvents():
for event in pygame.event.get():
if event.type == QUIT:
sys.exit(0)
@iandanforth
iandanforth / continuous_cartpole.py
Last active March 19, 2024 14:53
Continuous Cartpole for OpenAI Gym
"""
Classic cart-pole system implemented by Rich Sutton et al.
Copied from http://incompleteideas.net/sutton/book/code/pole.c
permalink: https://perma.cc/C9ZM-652R
Continuous version by Ian Danforth
"""
import math
import gym
@iandanforth
iandanforth / build.diff
Created May 2, 2018 23:38
build.js diff
diff --git a/app/tools/build.js b/app/tools/build.js
index 936182e..7a3af61 100644
--- a/app/tools/build.js
+++ b/app/tools/build.js
@@ -6,11 +6,15 @@
const path = require('path');
const shell = require('shelljs');
const crypto = require('crypto');
-const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
+const {
Component Abreviation Full Name Implementation Relevant # Unit
I Input image frames 64x64 pixels
V Vision VAE 4,348,547 parameters
z latent representation vector 32 values
M Memory RNN + MDN 422,368 parameters
h recurrent activation vector ??? values
C Controller single layer linear model 867 parameters
A Actions continuous values discretized as required varies by task N/A
@iandanforth
iandanforth / sun.js
Created January 22, 2018 01:48
Example Two.js code modified to work with Jupyter notebook example
// Example Two.js Code, slightly modified version of code from
// https://two.js.org/examples/depths.html
// for use with https://gist.github.com/iandanforth/1c6d0153d03e0caa771d5c92f2f7ec7e
(function() {
// Make an instance of two and place it on the page.
var elem = document.getElementById('draw-shapes');
var params = { width: 400, height: 400 };
var two = new Two(params).appendTo(elem);
@iandanforth
iandanforth / localjstojupyter.md
Last active February 15, 2024 17:23
How to serve local JavaScript to a hosted Jupyter notebook

Local JavaScript -> Hosted Jupyter notebook

Description

If you have:

  • A hosted Jupyter notebook (e.g. on Google Colaboratory)
  • A local JavaScript development environment you prefer to use

You can:

We couldn’t find that file to show.
@iandanforth
iandanforth / beep.js
Last active January 29, 2020 03:09
Add beep(); method to jupyter notebooks
%%javascript
// Source - https://stackoverflow.com/a/23395136
Jupyter.beep = () => {
var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4do
@iandanforth
iandanforth / jupyter-scroll.txt
Created December 3, 2017 22:59
Enable smooth scrolling with arrow keys in Jupyter Notebooks
%%javascript
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('up');
Jupyter.keyboard_manager.command_shortcuts.remove_shortcut('down');