Skip to content

Instantly share code, notes, and snippets.

View shofetim's full-sized avatar

Jordan Schatz shofetim

View GitHub Profile
SELECT
t1.a -- I need all of these
SUM(t2.b) --but only sum these of t2.c = TRUE
WHERE
t2.c = TRUE
SELECT
meta.name AS "Name",
string_agg(DISTINCT product.code, ', ') AS "Product Codes",
COALESCE(SUM(line.quantity_ordered *
line.unit_price_at_checkout_time),
0) AS "Total Quantity Ordered (in dollars)"
FROM warehouse_pieces_piecemeta AS meta
LEFT JOIN warehouse_pieces_piece AS piece
ON piece.piece_meta_id = meta.id
LEFT JOIN products_product AS product
-- This doesn't work as product.id is not grouped.
SELECT
meta.name AS "Name",
string_agg(DISTINCT product.code, ', ') AS "Product Codes",
(
SELECT COALESCE(SUM(line.quantity_ordered *
line.unit_price_at_checkout_time),
0)
FROM orders_orderline AS line
LEFT JOIN orders_order AS orders ON orders.id = line.order_id
-- Works!
SELECT
name AS "Name",
codes AS "Product Codes",
COALESCE(total, 0.00) AS "Total Sales (in Dollars)"
FROM
(SELECT
meta.id AS meta_id,
meta.name AS "name",
string_agg(DISTINCT product.code, ', ') AS "codes"
admin:
group:
- present
beehive:
group:
- present
user.present:
- shell: /bin/bash
- home: /srv/beehive
salt-minion --versions-report
Salt: 0.15.1
Python: 2.7.3 (default, Jan 2 2013, 13:56:14)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.6
PyYAML: 3.10
PyZMQ: 2.2.0
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotSelectableException
from selenium.webdriver.common.by import By
def qaclickit(driver, bytype, loc, options='') :
#
# required parms
#
# driver - web page to click on ( driver instance from webdriver )
# bytype - ID, XPATH, CSS, Etc...
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import ElementNotSelectableException
from selenium.webdriver.common.by import By
def qaclickit(driver, bytype, loc, options='') :
#
# required parms
#
# driver - web page to click on ( driver instance from webdriver )
# bytype - ID, XPATH, CSS, Etc...
from selenium.common.exceptions import NoSuchElementException, ElementNotSelectableException
from selenium.webdriver.common.by import By
def clickit(driver, bytype, loc):
#
# required parms
#
# driver - web page to click on ( driver instance from webdriver )
# bytype - ID, XPATH, CSS, Etc...
# loc - location of where to find the item(s) to click on
#!/usr/bin/python
import salt.client
import os
client = salt.client.LocalClient()
ret = client.cmd("*", "network.ip_addrs")
ips = set(reduce(lambda x, y: x+y, ret.values()))
cmd = "ssh-keyscan "
for ip in ips:
cmd += ip + " "