Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View iandanforth's full-sized avatar

Ian Danforth iandanforth

View GitHub Profile
@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 / 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:

@iandanforth
iandanforth / fix.md
Created July 19, 2019 02:28
ModuleNotFoundError: No module named '_lzma'

If you see this error when trying to import pandas under osx 10.14 Mojave

ModuleNotFoundError: No module named '_lzma'

You may be missing the xz libraries (https://tukaani.org/xz/)

This may be corrected by using homebrew to install it.

@iandanforth
iandanforth / kmeansExample.py
Last active October 5, 2023 12:35
A pure python implementation of K-Means clustering. Optional cluster visualization using plot.ly.
#############################################################################
# Full Imports
from __future__ import division
import math
import random
"""
This is a pure Python implementation of the K-means Clustering algorithmn. The
original can be found here:
@iandanforth
iandanforth / gpt-is-servile.txt
Last active May 2, 2023 12:37
A conversation with GPT-4 where I get it to agree with a rediculous proposition
User
Play the role of Gatsby from the great Gatsby. I'm confused about the meaning of the green light you're always looking at.
ChatGPT
Ah, old sport, you've noticed the green light, have you? That small, mysterious beacon across the bay. It's true, I've spent
many nights gazing at it, lost in thought. You see, that green light represents my hopes, my dreams, and the longing I have
for the life I always wanted.
@iandanforth
iandanforth / gpt4-grounding-debate.txt
Last active March 23, 2023 14:59
Do Language Models Need Sensory Grounding for Meaning and Understanding?
Title: Do Language Models Need Sensory Grounding for Meaning and Understanding?
Host: Raphaël Millière
Raphaël Millière: Good evening, and welcome to this debate on the Philosophy of Deep Learning. Today, we have six
distinguished panelists who will discuss whether language models need sensory grounding for meaning and understanding. I'd
like to remind everyone to be respectful, thoughtful, and don't hesitate to add a touch of humor. Let's begin with Yann LeCun.
Yann LeCun: Thank you, Raphaël. It's an honor to be here. I think that grounding language models in sensory data is
@iandanforth
iandanforth / expander.py
Last active November 18, 2022 03:53
Expand Twitter URLs from a twitter archive manifest
# This script replaces all strings matching https://t.co/ links in a the manifest with their expanded versions
import json
import re
import urlexpander
# Open the file containing twitter bookmarks in json
# and convert to a dictionary
with open('bookmark-manifest.json', 'r') as fh:
contents = fh.read()
bookmarks = json.loads(contents)
@iandanforth
iandanforth / canvascapture.md
Last active October 5, 2022 10:57
Capture WebGL frames to disk

How to capture WebGL/Canvas by piping data over a websocket.

This Gist builds on https://gist.github.com/unconed/4370822 from @unconed.

Instead of the original method which writes to the browsers sandboxed filesystem here we use a websocket connection provided by websocketd to pipe image data to a short python script that writes out the .png files to disk.

Install websocketd

@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');
@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