Skip to content

Instantly share code, notes, and snippets.

Daniel Kats boompig

View GitHub Profile
View agg_vim_plugins.py
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):
View gist:f05871140b928ae02b8f835d745158ac
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
View intervals_simul.py
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)
View intervals_queue.py
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):
View intervals.py
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."""
View make_palindrome.js
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] + ")");
@boompig
boompig / ece-main.py
Last active Aug 29, 2015
Auto-email Parser and Replyer
View ece-main.py
import cStringIO
import json
import re
import sendmail
import subprocess
import string
import sys
from time import sleep
UNDEF_GROUP = "undefined"
View roman_subseq.cpp
#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 {
View sign-games.cpp
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>
#include <set>
#include <stdlib.h>
#include <math.h>
using namespace std;
View tester-votes.cpp
#include <iostream>
#include <vector>
using namespace std;
struct region {
int pop, init, delta;
region() {}
region(int N, int I, int D) {
pop = N;
init = I;
You can’t perform that action at this time.