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):| 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 |
| """ | |
| 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 | |
| """ |
| 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 |
# 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):| { "_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" |
| { "_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 } } |
| """ | |
| Author: Jason Liu | |
| """ | |
| import random | |
| class BernoulliArm(object): | |
| """An arm that either returns 0 or 1 as it's reward""" |
| """ | |
| 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 |
| """ | |
| 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} ... |