Skip to content

Instantly share code, notes, and snippets.

@shurain
shurain / nvaltjournal
Created August 8, 2012 18:50
nvALT: Fix for "Append to nvALT journal" Alfred extension. Handling non-English characters as well.
on alfred_script(q)
set theYear to year of (current date) as string
set theMonth to (month of (current date) as number)
if theMonth < 10 then
set theMonth to "0" & theMonth
else
set theMonth to "" & theMonth
end if
@shurain
shurain / boston.json
Created October 2, 2012 18:20 — forked from pprett/boston.json
Decision Tree Viewer (D3 and Sklearn)
{"error": 42716.2954, "samples": 506, "value": [22.532806324110698], "label": "RM <= 6.94", "type": "split", "children": [{"error": 17317.3210, "samples": 430, "value": [19.93372093023257], "label": "LSTAT <= 14.40", "type": "split", "children": [{"error": 6632.2175, "samples": 255, "value": [23.349803921568636], "label": "DIS <= 1.38", "type": "split", "children": [{"error": 390.7280, "samples": 5, "value": [45.58], "label": "CRIM <= 10.59", "type": "split", "children": [{"error": 0.0000, "samples": 4, "value": [50.0], "label": "Leaf - 4", "type": "leaf"}, {"error": 0.0000, "samples": 1, "value": [27.9], "label": "Leaf - 5", "type": "leaf"}]}, {"error": 3721.1632, "samples": 250, "value": [22.90520000000001], "label": "RM <= 6.54", "type": "split", "children": [{"error": 1636.0675, "samples": 195, "value": [21.629743589743576], "label": "LSTAT <= 7.57", "type": "split", "children": [{"error": 129.6307, "samples": 43, "value": [23.969767441860473], "label": "TAX <= 222.50", "type": "split", "children": [{"err
@shurain
shurain / autoencoder.py
Created October 6, 2012 16:31 — forked from anonymous/autoencoder.py
Python: Sparse Autoencoder
import numpy as np
#from matplotlib import pyplot as plt
from scipy.optimize import fmin_l_bfgs_b as bfgs,check_grad,fmin_bfgs,fmin_tnc
from scipy.io import loadmat
import cPickle
class params:
'''
@shurain
shurain / waitforit.sh
Created April 24, 2013 06:39
Watch for a particular pid and execute the command when the given process terminates. Useful when used together with notification system. $ ./waitforit.sh [PID] [CMD]
#!/bin/bash
delay=5
pid=$1
cmd=$2
status="0"
while [ "$status" == "0" ]
do
sleep $delay
javascript:(function(){var p=document.createElement("p");p.innerHTML="<strong>Loading&hellip;</strong>";p.id="loadingp";p.style.padding="20px";p.style.background="#fff";p.style.left="20px";p.style.top=0;p.style.position="fixed";p.style.zIndex="9999999";p.style.opacity=".85";document.body.appendChild(p);document.body.appendChild(document.createElement("script")).src="https://gist.github.com/ttscoff/6109434/raw/Bullseye.js?x="+(Math.random());})();
@shurain
shurain / naverclippable.bookmarklet
Last active December 20, 2015 10:49
Naver Clippable
javascript:(function(){var%20p=document.getElementsByTagName('frame')[0];if(document.domain.indexOf('naver.com')==-1){window.location.href=p.src}else{p=p.contentDocument;x=p.createElement('SCRIPT');x.type='text/javascript';x.src='https://gist.github.com/shurain/6146690/raw/735b099c2e6b174b035fde2a861b87fbd819bb1a/naverreadability.js';p.getElementsByTagName('head')[0].appendChild(x);y=p.createElement('LINK');y.rel='stylesheet';y.href='http://brettterpstra.com/share/readability.css?x='+(Math.random());y.type='text/css';y.media='screen';p.getElementsByTagName('head')[0].appendChild(y);}})();
@shurain
shurain / naverreadability.js
Created August 3, 2013 14:39
Readability for Naver blog. Ripped off from brettterpstra.com/share/readability.js
var readabilityVersion = "2";
var readStyle='style-ebook';
var readSize='size-medium';
var readMargin='margin-wide';
(function(){
// removing all existing scripts so they don't cause conflicts...
var docscripts = document.getElementsByTagName('script');
for (k=0;k < docscripts.length; k++) {
if (docscripts[k].src != null && ! docscripts[k].src.match(/readability|[Cc]lippability/)) {
docscripts[k].parentNode.removeChild(docscripts[k]);
#readOverlay {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
}
#readInner {
text-align: left;
line-height: 1.4em;
@shurain
shurain / matrix_sketch.py
Created November 6, 2013 05:09 — forked from mblondel/matrix_sketch.py
Frequent directions algorithm for matrix sketching.
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
from scipy.linalg import svd
def frequent_directions(A, ell, verbose=False):
"""
Return the sketch of matrix A.