Skip to content

Instantly share code, notes, and snippets.

View jxnl's full-sized avatar

Jason Liu jxnl

View GitHub Profile
@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:
for i in range(1,101):print"Fizz"*(not i%3)+"Buzz"*(not i%5) or i
@jxnl
jxnl / new_assignment.py
Created January 6, 2015 21:30
Generates a template for cs116 assginments
"""
This script generates a template rkt file for cs116 assignments
Generates the assignment header. sample contract and sample function.
Usage:
python new_assignment.py A Q NameOfAssignment
Author: Jason Liu
Date: May 20th, 2014
"""
@jxnl
jxnl / pi.py
Last active August 29, 2015 14:10
lol pi.py
import random
import math
count_total = 10000
count_inside = 0
for _ in xrange(count_total):
inside_the_unit_circle = (math.hypot(random.random(), random.random()) < 1)
count_inside += 1 if (inside_the_unit_circle) else 0
Want to speak with me? I'm jason at jxnl.co

# First things first, Fizzbuzz
for i in range(1, 101): print "Fizz" * (not i % 3) + "Buzz" * (not i % 5) or i

# Or if you want... Simpson's Rule
def simpson(a, b, f, N):
@jxnl
jxnl / likes.json
Last active August 29, 2015 14:10
json.dumps.hh.mongo
{ "_id" : { "$oid" : "546469e762104c2ef8743db1" }, "post_id" : "752305101527031", "from_name" : "Dan Zhang", "group_id" : "752213728202835", "from_id" : "10104353956153783" }
{ "_id" : { "$oid" : "546469e862104c2ef8743db2" }, "post_id" : "752330641524477", "from_name" : "Dave Fontenot", "group_id" : "752213728202835", "from_id" : "10152524105304355" }
{ "_id" : { "$oid" : "546469e862104c2ef8743db3" }, "post_id" : "752330641524477", "from_name" : "Iheanyi Ekechukwu", "group_id" : "752213728202835", "from_id" : "10152375559281984" }
{ "_id" : { "$oid" : "546469e962104c2ef8743db4" }, "post_id" : "752216121535929", "from_name" : "Dave Fontenot", "group_id" : "752213728202835", "from_id" : "10152524105304355" }
{ "_id" : { "$oid" : "546469e962104c2ef8743db5" }, "post_id" : "752216121535929", "from_name" : "Millun Atluri", "group_id" : "752213728202835", "from_id" : "953619831318616" }
{ "_id" : { "$oid" : "546469e962104c2ef8743db6" }, "post_id" : "752216121535929", "from_name" : "Shane Creighton-Young", "group_id"
@jxnl
jxnl / git-repo-lang-dump.json
Created November 18, 2014 03:39
top 900 github repos with respect to stars.
{ "_id" : "AFNetworking/AFNetworking", "lang" : { "Objective-C" : 583348, "Ruby" : 3753, "C" : 22245 } }
{ "_id" : "Alamofire/Alamofire", "lang" : { "Objective-C" : 1297, "Swift" : 126338 } }
{ "_id" : "AndroidBootstrap/android-bootstrap", "lang" : { "Groovy" : 147, "Python" : 989, "Java" : 183026 } }
{ "_id" : "Automattic/_s", "lang" : { "PHP" : 36147, "JavaScript" : 2665, "CSS" : 34736 } }
{ "_id" : "Automattic/socket.io", "lang" : { "JavaScript" : 79091, "CSS" : 1885 } }
{ "_id" : "Automattic/socket.io-client", "lang" : { "Shell" : 111, "JavaScript" : 197777 } }
{ "_id" : "BBC-News/Imager.js", "lang" : { "JavaScript" : 48035, "CSS" : 760 } }
{ "_id" : "BBC-News/wraith", "lang" : { "Shell" : 584, "JavaScript" : 8403, "Ruby" : 25172 } }
{ "_id" : "Bearded-Hen/Android-Bootstrap", "lang" : { "Groovy" : 2959, "Java" : 77221 } }
{ "_id" : "BoltsFramework/Bolts-iOS", "lang" : { "Objective-C" : 175553, "Shell" : 16732, "Ruby" : 5455 } }
@jxnl
jxnl / bandit.py
Created October 17, 2014 00:37
Multivariate testing
"""
Author: Jason Liu
"""
import random
class BernoulliArm(object):
"""An arm that either returns 0 or 1 as it's reward"""
@jxnl
jxnl / markov.py
Created September 23, 2014 00:05
Generates Parody Text.
"""
This module contains a markov chain class that can be used to generate
a psuedo random list of elements from a selected corpus. It does so
by collecting all existing bigrams e.i. (element_i, element_i+1) of the
selected corpus and defining a markov chain with transition probabilities
proportional to the relative frequency of the bigrams.
Author: Jason Liu
Date: May 24th, 2014
@jxnl
jxnl / twit.py
Last active August 29, 2015 14:06
Wow 77 lines to do that? What is this... Java?
"""
Make a tweet when you commit. Honestly could have been way shorter.
Like without a class, or so many dependencies. But.. If you want to add something.
I'm sure that you'll figure it out.
Usage
-----
>>> py twit.py -h
usage: twit.py [-h] {commit} ...