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
#!/usr/bin/env python | |
# The MIT License (MIT) | |
# Copyright (c) 2016 Michael-Keith Bernard | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
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 | |
# Much of this code is either directly copied from or heavily inspired by the | |
# following example lisp interpreter. The essential structure of this parser is | |
# mostly an exact replica, and for that I thank the original author for his | |
# inspirational work. | |
# Author: Peter Norvig | |
# Source: http://norvig.com/lispy2.html (http://norvig.com/lispy.py) |
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 expand_dotted_keys(hash, recursive = true) | |
deep_merge = lambda do |h1, h2| | |
merger = proc do |k, v1, v2| | |
v1.is_a?(Hash) && v2.is_a?(Hash) ? v1.merge(v2, &merger) : v2 | |
end | |
h1.merge(h2, &merger) | |
end | |
recursive_insert = lambda do |h, path, val| | |
h ||= {} |
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 | |
# The MIT License (MIT) | |
# Copyright (c) 2016 Michael-Keith Bernard | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
{ | |
"aggs": { | |
"counts_by_servicetype": { | |
"aggs": { | |
"by_servicetype": { | |
"terms": { | |
"field": "servicetype", | |
"size": 0 | |
} | |
} |
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 | |
# The MIT License (MIT) | |
# | |
# Copyright (c) 2015 David Woodruff, Michael-Keith Bernard | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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") |
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
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. |