Skip to content

Instantly share code, notes, and snippets.

View crawles's full-sized avatar

Chris Rawles crawles

View GitHub Profile
@crawles
crawles / .bashrc
Last active June 23, 2018 16:40
bashrc
# vim mode
# also need to edit .inputrc
set -o vi
bind '"kj":vi-movement-mode'
alias rm=rmtrash
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
@karpathy
karpathy / pg-pong.py
Created May 30, 2016 22:50
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
@nirum
nirum / animations.py
Last active April 7, 2019 07:19
Save a numpy array (a stack of images) as a gif using moviepy
import os
from moviepy.editor import ImageSequenceClip
def gif(filename, array, fps=10, scale=1.0):
"""Creates a gif given a stack of images using moviepy
Notes
-----
works with current Github version of moviepy (not the pip version)
@evenv
evenv / Spark Dataframe Cheat Sheet.py
Last active June 24, 2022 23:45
Cheat sheet for Spark Dataframes (using Python)
# A simple cheat sheet of Spark Dataframe syntax
# Current for Spark 1.6.1
# import statements
from pyspark.sql import SQLContext
from pyspark.sql.types import *
from pyspark.sql.functions import *
#creating dataframes
df = sqlContext.createDataFrame([(1, 4), (2, 5), (3, 6)], ["A", "B"]) # from manual data
@EthanRosenthal
EthanRosenthal / ExplicitMF_ALS.py
Created March 13, 2016 20:38
Class for ALS training of an explicit matrix factorization model
from numpy.linalg import solve
class ExplicitMF():
def __init__(self,
ratings,
n_factors=40,
item_reg=0.0,
user_reg=0.0,
verbose=False):
"""
@bbertka
bbertka / gist:41a6730cff6462cb77f6
Created December 21, 2015 17:36
CF Lattice API CRUD Demo via Python
# Implements Create, Debug, and Delete Lattice Instance usable from within a Python app
#
import os, jsonr
import requests
# Note these are only a few variables, closer inspection of this Gist will show that there is alot of possibility here based on your app container.
# needed to make requests
auth_header = {'Authorization':'Basic YmJlcnRrYTprYXJtYTE5NzY='}
@karpathy
karpathy / min-char-rnn.py
Last active May 8, 2024 20:15
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active May 2, 2024 05:55
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application: