Skip to content

Instantly share code, notes, and snippets.

View jxnl's full-sized avatar

Jason Liu jxnl

View GitHub Profile
for i in range(1,101):print"Fizz"*(not i%3)+"Buzz"*(not i%5) or i
@jxnl
jxnl / yelp_location_crawler.py
Last active August 29, 2015 14:16
A yelp Search Request only returns min(n, 20) responses for a certain geo-query. This script will recursively Quadrisect the box until there is 20 in each box. It will also print the json output of the response
from __future__ import print_function
from Queue import Queue
import json
def subdivide(posn1, posn2):
"""
Accepts two Tuple2 and returns a generator that produces the four new boxes.
Args:
@jxnl
jxnl / LinearAlgebra.scala
Last active August 29, 2015 14:16
made the mistake of not defining row length in the template....
package learning
object LinearAlgebra {
class Row(r: Double*) extends Seq[Double] {
val row: List[Double] = r.toList
val length = row.length
def * (that: Row): Double = {
require(that.length == length, "Sizes don't align")
\usepackage{listings}
\usepackage[numbered,framed]{matlab-prettifier}
\usepackage{color}
\usepackage{geometry}
\geometry{verbose,tmargin=1.0in,bmargin=1.0in,lmargin=0.5in,rmargin=0.5in}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
@jxnl
jxnl / set.py
Last active March 8, 2016 19:44
generates 16 cards from the deck of SET and returns all possible winning hands.
from itertools import product
from itertools import permutations
from random import sample
cards = filter(
lambda _: all(
[
# look at all unique values of each property and see if there is 1 or 3
len(set([a[i][1] for a in _])) in {1,3} for i in range(4)
]
from __future__ import division
from tqdm import *
import chainer
from chainer import functions as F
from chainer import links as L
import numpy as np
@jxnl
jxnl / ROC.r
Last active April 13, 2016 20:05
common snippet for ROC TESTS
library(pROC)
df = read.csv("...")
## 75% of the sample size
set.seed(123)
smp_size <- floor(0.75 * nrow(df))
train_ind <- sample(seq_len(nrow(df)), size = smp_size)
from chainer.links import caffe
func = caffe.CaffeFunction("../bvlc_alexnet.caffemodel")
# construct a correctly sized chainer variable
x = chainer.Variable(...)
# outputs is a list of layers to extract and it will return
# each layer seperatly
fc7, = func(inputs={"data":x}, outputs=["fc7"])
function [Q,R]=BandQR(A, p)
[n,n]=size(A);
R=A; %Start with R=A
Q=eye(n); %Set Q as the identity matrix
for k=1:n-1
x = zeros(p+1,1);
j=min(n, k+p-1);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.