This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional, Tuple, Set, List, Dict | |
import copy | |
import time | |
from argparse import ArgumentParser | |
import random | |
import json | |
import numpy as np | |
import os | |
import uuid | |
from types import SimpleNamespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
def skip(fp): | |
for i, line in enumerate(fp): | |
if line.endswith("clearing screen\n"): | |
return i | |
raise ValueError("Error: skipped whole file") | |
def print_profile(time_by_file, occurrences_by_file): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2016/08/19 13:24:25 [INFO] Terraform version: 0.7.0 e822a79165dbc06bbf8271ee349fe256867d53dc | |
2016/08/19 13:24:25 [DEBUG] Detected home directory from env var: /Users/daniel_kats | |
2016/08/19 13:24:25 [DEBUG] Detected home directory from env var: /Users/daniel_kats | |
2016/08/19 13:24:25 [DEBUG] Attempting to open CLI config file: /Users/daniel_kats/.terraformrc | |
2016/08/19 13:24:25 [DEBUG] File doesn't exist, but doesn't need to. Ignoring. | |
2016/08/19 13:24:25 [DEBUG] Detected home directory from env var: /Users/daniel_kats | |
2016/08/19 13:24:25 [DEBUG] Checking variable noop: var.region | |
2016/08/19 13:24:25 [DEBUG] No diff, not a noop | |
2016/08/19 13:24:25 [DEBUG] Checking resource noop: aws_s3_bucket.bucket | |
2016/08/19 13:24:25 [DEBUG] No diff, not a noop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Item(object): | |
def __init__(self, time, val): | |
self.time = time | |
self.val = val | |
def get_over_limit_simul(interval_list, limit): | |
queue = Queue(lambda o: o.time) | |
for interval in interval_list: | |
o_in = Item(interval.start, interval.val) | |
o_out = Item(interval.end, -1 * interval.val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import heapq | |
from collections import deque | |
def insert_into_queue(item, queue): | |
if not item.is_empty(): | |
queue.push(item) | |
class Queue(object): | |
def __init__(self, fn): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Interval(object): | |
def __init__(self, start, end, val): | |
self.start = start | |
self.end = end | |
self.val = val | |
def get_intersection(self, other): | |
"""Modify self and other to make non-overlapping intersections. | |
If there is another guy, return him. Otherwise return None. | |
Intervals can be changed to zero-length, which means they disappear.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var makePalindrome = function(text) { | |
// take a letter from the beginning and add it to the end | |
var front = true; | |
var start = 0; | |
var end = text.length - 1; | |
while (start < end) { | |
console.log("compared " + text[start] + " and " + text[end]); | |
if (text[start] != text[end]) { | |
if (front) { | |
console.log("inserting " + text[start] + " before index " + (end + 1) + "(after char " + text[end] + ")"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cStringIO | |
import json | |
import re | |
import sendmail | |
import subprocess | |
import string | |
import sys | |
from time import sleep | |
UNDEF_GROUP = "undefined" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <assert.h> | |
using namespace std; | |
int romeEval(const int a, const int b) { | |
if (a < b) { | |
return b - a; | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <algorithm> | |
#include <queue> | |
#include <functional> | |
#include <set> | |
#include <stdlib.h> | |
#include <math.h> | |
using namespace std; |
NewerOlder