Skip to content

Instantly share code, notes, and snippets.

@shurain
shurain / gist:9739449
Last active August 29, 2015 13:57 — forked from enygma/gist:1413370
Simple RSS feed creation for @PHPQuickFix
<?php
$jsonCacheFile = './quickfix.json';
$gimmieFeed = 'https://gimmebar.com/api/v0/public/assets/phpquickfix';
$wgetCmd = 'wget -O'.$jsonCacheFile.' '.$gimmieFeed;
// look for the cache file
if(!is_file($jsonCacheFile) || (is_file($jsonCacheFile) && filemtime($jsonCacheFile)<strtotime('-1 minute')) ){
// fetch the latest content from gimmiebar
exec($wgetCmd);
@shurain
shurain / gist:10222709
Last active August 29, 2015 13:58 — forked from mitsuhiko/gist:10130454
Quick and dirty demonstration of CVE-2014-0160 by
#!/usr/bin/env python
# Quick and dirty demonstration of CVE-2014-0160 by
# Jared Stafford (jspenguin@jspenguin.org)
# Modified so that it finds cookies
import sys
import struct
import socket
import time
import select
@shurain
shurain / 538.json
Created August 12, 2014 06:15 — forked from CamDavidsonPilon/538.json
Use the two files below to mimic graphs on 538. www.dataorigami.net/blogs/fivethirtyeight-mpl
{
"lines.linewidth": 2.0,
"examples.download": true,
"patch.linewidth": 0.5,
"legend.fancybox": true,
"axes.color_cycle": [
"#30a2da",
"#fc4f30",
"#e5ae38",
"#6d904f",
@shurain
shurain / README.md
Last active August 29, 2015 14:06 — forked from takluyver/README.md
Flatten notebooks for git diff

Copy nbflatten.py to somewhere on $PATH. Then, in the root of a git repository, run these commands:

echo "*.ipynb diff=ipynb" >> .gitattributes 
git config diff.ipynb.textconv nbflatten.py

When you change a notebook and run git diff, you'll see the diff of flattened, simplified notebooks, rather than the full JSON. This does lose some information (metadata, non-text output), but it makes it easier to see simple changes in the notebook.

This doesn't help with merging conflicting changes in notebooks. For that, see nbdiff.org.

@shurain
shurain / mutual_info.py
Last active August 29, 2015 14:06 — forked from GaelVaroquaux/mutual_info.py
Non-parametric computation of entropy and mutual-information
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
These computations rely on nearest-neighbor statistics
'''
import numpy as np
@shurain
shurain / dnn.py
Last active August 29, 2015 14:12 — forked from syhw/dnn.py
A deep neural network with or w/o dropout in one file.
"""
A deep neural network with or w/o dropout in one file.
License: Do What The Fuck You Want to Public License http://www.wtfpl.net/
"""
import numpy, theano, sys, math
from theano import tensor as T
from theano import shared
from theano.tensor.shared_randomstreams import RandomStreams
@shurain
shurain / conv_deconv_vae.py
Last active August 29, 2015 14:15 — forked from kastnerkyle/conv_deconv_vae.py
conv_deconv_vae.py
# Alec Radford, Indico, Kyle Kastner
# License: MIT
"""
Convolutional VAE in a single file.
Bringing in code from IndicoDataSolutions and Alec Radford (NewMu)
Additionally converted to use default conv2d interface instead of explicit cuDNN
"""
import theano
import theano.tensor as T
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
tell application "Google Chrome"
# 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
@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):