SELECT
components.*,
COALESCE(SUM(previous_month.resource_counts), 0.0) AS previous_month_resource_counts,
COALESCE(SUM(previous_month.unblended_cost), 0.0) AS previous_month_unblended_cost,
COALESCE(SUM(previous_month.blended_cost), 0.0) AS previous_month_blended_cost,
COALESCE(SUM(month_to_date.resource_counts), 0.0) AS month_to_date_resource_counts,
COALESCE(SUM(month_to_date.unblended_cost), 0.0) AS month_to_date_unblended_cost,
COALESCE(SUM(month_to_date.blended_cost), 0.0) AS month_to_date_blended_cost
FROM "components"
This file contains hidden or 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 re | |
import operator | |
import curator | |
import elasticsearch | |
class IndexFilter(object): | |
def __init__(self, | |
time_format="%Y.%m.%d", |
This file contains hidden or 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 argparse | |
def main(): | |
parser = argparse.ArgumentParser("Do a thing with stuff!") | |
parser.add_argument("number", type=int) | |
args = parser.parse_args() | |
print "nan" * args.number + " batman!" |
This file contains hidden or 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 OTIPAddr < IPAddr | |
attr_reader :mask_addr | |
def prefix_len | |
@mask_addr.to_s(2).count "1" | |
end | |
end |
This file contains hidden or 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
>>> def example(): | |
... return 1, 2, 3 | |
... | |
>>> example() | |
(1, 2, 3) | |
>>> a, b, c = example() | |
>>> a | |
1 | |
>>> b | |
2 |
This file contains hidden or 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
#!/usr/bin/env python | |
import os | |
import json | |
import sqlite3 | |
import argparse | |
from collections import namedtuple, OrderedDict | |
from operator import attrgetter | |
from StringIO import StringIO |
This file contains hidden or 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
#!/usr/bin/env python | |
import copy | |
import random | |
import functools | |
def memoize(fn): | |
memo = {} | |
@functools.wraps(fn) | |
def _wrapper(*args): |
This file contains hidden or 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 shlex | |
import tempfile | |
import subprocess | |
LOREM = """ | |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ornare enim | |
gravida congue mollis. Nullam imperdiet hendrerit lorem, vitae tempor nisl | |
facilisis ut. Integer at blandit ipsum, non blandit metus. Pellentesque enim | |
magna, malesuada sed mi eget, mattis viverra odio. Praesent ut imperdiet libero. | |
Phasellus varius laoreet quam, eget rutrum enim. Fusce sit amet volutpat arcu. |
This file contains hidden or 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
def main(): | |
# Application code goes here! | |
pass | |
PACKAGES = ("praw", ) | |
### IGNORE BELOW THIS LINE ### | |
def run(cmd, shell=False, silent=False): |
This file contains hidden or 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 StringIO import StringIO | |
from operator import attrgetter | |
import textwrap | |
class Node(object): | |
def __init__(self, val=None, *children): | |
self.val = val | |
self.children = list(children) | |
test1 = Node("foo") |