Skip to content

Instantly share code, notes, and snippets.

@jay3686
jay3686 / data.json
Created November 9, 2016 18:36
scraped exit poll data from cnn
{
"totalPages": 1,
"race": "U.S. President",
"title2": "",
"polls": [
{
"numrespondents": 24537,
"qid": 279,
"question": "Gender",
"pollname": "SEX",
@jay3686
jay3686 / min_stack.py
Last active August 17, 2016 17:56
basic min stack implementation
class MinStack:
def __init__(self):
self.data = []
self.mins = []
# @param x, an integer
def push(self, x):
self.data.append(x)
if self.mins == [] or self.mins[-1] >= x:
@jay3686
jay3686 / tree.py
Last active August 5, 2016 15:46
kth element in tree in order traversal
###
# 5
# 3 7
# 2 4 6 8
# 1
###
# n c k
# 1 0 1
# 2 1 2 1
# 3 2 3 2 1
@jay3686
jay3686 / morse_led.js
Created April 13, 2016 01:16
Converts text to dots and dashes
var morse = require('morse-node').create("ITU");
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
var led = new five.Led(11);
@jay3686
jay3686 / countingproblem.py
Created March 30, 2016 16:00
[TODO] describe what this is.
#/usr/bin/env python
# memo = {}
def f(part, target, sub_sum=0.0, previous=0.0, chosen_path=''):
# if memo.get((part, target)):
# print memo[(part, target)]
# return
if part == '':
if target == (sub_sum + previous):
"""Coding challenge cample with tests."""
import unittest
# the naive recursive solution is solution is branching 2 ^ n
# we can make it O(n) with memoizing the sub problems.
memo = {}
1. Won. Plant map. I played Raynor, terrible and should have lost by all accounts.
Missed Q a lot, didnt group up with team, they were ahead 3 levels most of the game.
Healer was tiliting a bit but I made an effort not to engage.
We won it in the end by wiping their team while we had terror. Pushed mid to core in a single push.
2. Loss. Spider Queen. I played Zagara, The Valla that was recking me last game was on my team.
We had double specialist with abathur, made a point not to be negative but did say that it was a bad idea. Trusting in team.
Abathur was terrible. He got called out, picked it up a bit. I made a point to give game feedback in a positive manner
34 minutes in full wipe the other team, but in final push our core died to minions. With our entire team up and pushing their base. womp womp.
1. Loss. Infernal shrines. I first picked Zagara. Their only tank sonya.
Our johana goes afk 1 minute in gets force dc'd. We continue with johana bot losing but not giving up.
Johana reconnects 25 minutes in. Only to afk in the middle of map the whole time to get picked off. Other team wipes rest of team and wlaks to base.
2. Won, Sky Temple. last picked morales. Nicely convinced first pick not to go chogal. Almost lost it because of huge early lead. People got ballsy and didnt group.
Core got down to 75%, it got better after we stopped having people go off and solo stuff (we didnt lose a single 5v5 team fight.
3. Loss. Cursed hollow. First pick diablo. Bad teamfight engage. enemy had double tank
4. Win. Spider queen. 3rd pick zag. We had a good xp lead but I died a lot. I had most deaths on team.
1. Sky temple. I was Morales. Lost game because only warrior decided to go solo jungle all game and only responded to chat in curses or insults (same during draft)
2. cursed hollow. I was Zag. Won game - our team was waaay better than theirs. their lili took dragon?? Got cocky and died some, but still had 2x their kills. Only won 50 points.
3. Dragon Shire. I was Morales. Major loss with 4 level lead for other team. Hero raynor liked to charge in solo and focus tanks. 0 death Lili with 107k heals because of it. Asked Raynor multiple times to focus Lili, but he told me to shut up because he's top damage. 80k hero damage against mostly diablo and artanis.
4. Spider Queen. I was Muradin. Hero gaz solo all game. talked trash to rest of team because he was top damage, lost every team fight.
5. Dragonshire. I was DPS Tass. Won game. Close match until I got the dragon (other 3 times we got dragon our team would full wipe with dragon push). Got all dragons tho.
import time
def rate_limited(num_calls, interval):
minInterval = float(interval) / float(num_calls)
def decorate(func):
lastTimeCalled = [0.0]
def rate_limited_function(*args, **kargs):