Skip to content

Instantly share code, notes, and snippets.

@shurain
shurain / fix-venv.sh
Created February 17, 2017 08:24 — forked from pv8/fix-venv.sh
Fix virtualenv symlinks after upgrading python with Homebrew and running brew cleanup
#!/usr/bin/env bash
#
# Fix virtualenv symlinks after upgrading python with Homebrew and then running
# `cleanup`.
#
# After upgrading Python using Homebrew and then running `brew cleanup` one can
# get this message while trying to run python:
# dyld: Library not loaded: @executable_path/../.Python
# Referenced from: /Users/pablo/.venv/my-app/bin/python
# Reason: image not found
@shurain
shurain / min-char-rnn.py
Created June 4, 2016 16:08 — forked from karpathy/min-char-rnn.py
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)
@shurain
shurain / README.md
Created March 19, 2016 14:40 — forked from EderSantana/CATCH_Keras_RL.md
Keras plays catch - a single file Reinforcement Learning example

Code for Keras plays catch blog post

Train

python qlearn.py

Generate figures

python test.py
@shurain
shurain / arxiv2kindle.ipynb
Created January 16, 2016 15:19 — forked from bshillingford/arxiv2kindle.ipynb
arxiv2kindle: recompiles an arxiv paper for kindle-sized screens, and sends it to your wifi-enabled kindle
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shurain
shurain / nginx.conf
Created January 11, 2016 03:48 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@shurain
shurain / problem2-1.java
Created December 9, 2015 06:22
2004-1 java class
package project2;
import java.io.*;
public class problem2 {
public static void main(String[] args) throws Exception {
int rnum[] = new int[11];
int inum[] = new int[11];
String ist[] = new String[11];
double rd[] = new double[11];
String slts;
""" Poisson-loss Factorization Machines with Numba"""
# Author: Vlad Niculae <vlad@vene.ro>
# License: Simplified BSD
from __future__ import print_function
import numpy as np
from numba import jit
from scipy import sparse as sp
from sklearn.utils import check_random_state, check_array, check_X_y
@shurain
shurain / antoniak.py
Last active September 15, 2015 16:37 — forked from tdhopper/antoniak.py
Sample from Antoniak Distribution with Python. `rand_antoniak` draws a sample from the distribution of tables created by a Chinese restaurant process with parameter `alpha` after `n` patrons are seated. Some notes on this distribution are here: http://www.cs.cmu.edu/~tss/antoniak.pdf.
import numpy as np
from numpy.random import choice
def stirling(N, m):
if N < 0 or m < 0:
raise Exception("Bad input to stirling.")
if m == 0 and N > 0:
return 0
elif (N, m) == (0, 0):
return 1
@shurain
shurain / gist:d26d44d7ef0ea1908b10
Last active August 29, 2015 14:25 — forked from karpathy/gist:587454dc0146a6ae21fc
An efficient, batched LSTM.
"""
This is a batched LSTM forward and backward pass
"""
import numpy as np
import code
class LSTM:
@staticmethod
def init(input_size, hidden_size, fancy_forget_bias_init = 3):
# Authors: Kyle Kastner
# License: BSD 3-clause
import theano.tensor as T
import numpy as np
import theano
class rmsprop(object):
"""
RMSProp with nesterov momentum and gradient rescaling