Skip to content

Instantly share code, notes, and snippets.

View jackross's full-sized avatar

Jack A Ross jackross

  • gmatter
  • Charlotte, NC
View GitHub Profile
@jackross
jackross / compare_mail_plan.sql
Created February 25, 2015 02:51
Compare Actual Mail Plan to Forecasted Mail Plan
DECLARE @forecast_snapshot_id uniqueidentifier = '54266D12-8B13-4C23-9BDF-A740580ECFB2';
WITH _sources AS
(
SELECT
CASE
WHEN source LIKE 'MB[QL]%'
THEN LEFT(source, 7)
ELSE LEFT(source, 9)
END AS label
@jackross
jackross / reset.sql
Last active August 29, 2015 14:16
Reset Forecasts, Scenario Versions and Mail Plans
USE usga_apps;
GO
TRUNCATE TABLE seer.forecasts;
GO
INSERT INTO seer.forecasts
SELECT *
FROM USGAPROD2.usga_apps.seer.forecasts f
WHERE EXISTS
@jackross
jackross / extract_unique_names.sh
Last active August 29, 2015 14:23
Data Exploration Ideas
sort -uf \
<(cut -d'|' -f2 growers_20150608.txt) \
<(cut -d'|' -f3 growers_20150608.txt) \
>! names.txt
@jackross
jackross / config.yaml
Last active May 11, 2016 13:54
Sample Calculator input document JSON
name: Example Strategy
strategy: base_acre
geography: &geography
include:
states:
AR: all_counties
LA: all_counties
MS: all_counties
@jackross
jackross / changes_by_version.sql
Last active May 25, 2016 05:00
Cumulative Grower appearance in file
WITH _data AS
(
SELECT
*
,EXTRACT(YEAR FROM invoice_date + INTERVAL '3 MONTHS') AS season
FROM public.dcp_sales_log
)
,_new AS
(
SELECT
@jackross
jackross / jsonb_object_to_property_bag.pgsql
Last active April 22, 2021 11:39
Useful JSONB PG functions for transforming JSONB objects to property bags, and vice-versa
--# :down
DROP FUNCTION IF EXISTS jsonb_object_to_property_bag(jsonb, text, text)
;
--#
--# :up
CREATE FUNCTION jsonb_object_to_property_bag(jsonb, text = 'key', text = 'value')