Skip to content

Instantly share code, notes, and snippets.

karpathy /
Created May 30, 2016
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward
View index.html
<!DOCTYPE html>
<script src=""></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
ffmpeg -i -vcodec libx264 -vf 'scale=640:trunc(ow/a/2)*2' -acodec aac -vb 1024k -minrate 1024k -maxrate 1024k -bufsize 1024k -ar 44100 -strict experimental -r 30 out.mp4
philipbelesky /
Created Nov 23, 2015
Traverses a Grasshopper XML definition(.ghx) and extracts VB/C#/Python components to separate individual .vb/.cs/.py files
from xml.etree.ElementTree import ElementTree
import os
def ProcessGHXFile(definition_path, base_filename):
# Loads the file and sets up the XML parser
the_file = open(definition_path)
the_directory = os.path.dirname(definition_path)
the_tree = ElementTree()
IsolateTheScript(the_tree, the_directory, base_filename)
View gist:a078a580974c2d917e5d
<?xml version="1.0"?>
imjasonh / markdown.css
Last active Oct 18, 2021
Render Markdown as unrendered Markdown (see
View markdown.css
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
PatrickJS / factory-shared.es5.js
Last active Apr 19, 2018
Different examples of OOP "class" with "inheritance" done using JavaScript including languages that transpile into js. Take notice to the amount of boilerplate that's needed in ES5 compared to ES6. These examples all have the same interface with pros/cons for each pattern. If they seem similar that's whole point especially the difference between…
View factory-shared.es5.js
var EventEmitter = require('events').EventEmitter;
var _ = require('lodash');
// Factory shared
var makePerson = function() {
var person = {};;
person.wallet = 0;
_.extend(person, personMethods)
return person;
View gist:67c719b8597a837d59fd
import java.util.Map;
import java.util.Comparator;
import java.util.Collections;
int index = 0;
PImage pokemon, current;
PGraphics pie;
HashMap<Integer,Integer> colorMap;
ArrayList<Integer> colorByCount;
zloedi / roguelike_FOV.c
Last active Aug 6, 2021
Efficient roguelike grid FOV / shadowcasting / line of sight in a single C function inspired by
View roguelike_FOV.c
// Copyright (c) 2021 Stoiko Todorov
// This work is licensed under the terms of the MIT license.
// For a copy, see
// What this function does:
// Rasterizes a single Field Of View octant on a grid, similar to the way
// field of view / line of sight / shadowcasting is implemented in some
// roguelikes.
// Uses rays to define visible volumes instead of tracing lines from origin
// to pixels.