Skip to content

Instantly share code, notes, and snippets.

View BenDoyle's full-sized avatar

Ben Doyle BenDoyle

  • Ottawa, Ontario, Canada
View GitHub Profile
@BenDoyle
BenDoyle / dimension_manager.sql
Created April 25, 2023 14:30
[SQLite3] query to manage dimensions incrementally
-- x has typ-0 semantics
-- y has type-1 semantics
-- z has type-2 semantics
WITH
-- FIXTURES
-- 8 nks each to represent a later change, each with a history
previous_output as (
SELECT
@BenDoyle
BenDoyle / dimension_manager.sql
Last active November 3, 2021 20:47
[presto] query to manage dimensions incrementally
-- x has typ-0 semantics
-- y has type-1 semantics
-- z has type-2 semantics
WITH
-- FIXTURES
-- 8 nks each to represent a later change, each with a history
previous_output as (
SELECT sk, nk, x, y, z, from_ts, to_ts, is_current, is_deleted FROM (
@BenDoyle
BenDoyle / conform.sql
Last active July 10, 2020 18:22
[SQLite3] td and tangering transactions conforming
CREATE TABLE conformed_transactions
(
source TEXT,
transaction_type TEXT,
transaction_text TEXT,
amount TEXT,
provider_category TEXT,
transaction_date TEXT
)
@BenDoyle
BenDoyle / owner.bash
Created May 22, 2019 16:43
incantation to get the email address of the first committer to a file
git log --pretty=format:%ae --diff-filter=A -- <filename>
@BenDoyle
BenDoyle / flatten.py
Last active March 7, 2019 15:43
[python] flatten function
from functools import reduce
import operator
def flatten(values):
if not values:
return values
return reduce(operator.concat, ([item] if not hasattr(item, '__iter__') else flatten(item) for item in values))
@BenDoyle
BenDoyle / building residuals from snapshots.sql
Created December 1, 2017 14:48
[presyo] query to estimate residuals from a fixed rate projection
-- building residuals join based
with
raw as (
SELECT 1 as t, 1 as v
UNION ALL
SELECT 2 as t, 1 as v
UNION ALL
SELECT 3 as t, 1 as v
UNION ALL
@BenDoyle
BenDoyle / sequence.sql
Created September 18, 2017 20:31
[presto] query to generate a simple sequence relation
SELECT m FROM UNNEST(sequence(0,23)) as t(m)
@BenDoyle
BenDoyle / init.txt
Created November 29, 2016 01:48
dcss init file
##### Crawl Init file ###############################################
# For descriptions of all options, as well as some more in-depth information
# on setting them, consult the file
# options_guide.txt
# in your /docs directory. If you can't find it, the file is also available
# online at:
# https://gitorious.org/crawl/crawl/source/HEAD:crawl-ref/docs/options_guide.txt
#
# Crawl uses the first file of the following list as its option file:
# * init.txt in the -rcdir directory (if specified)
Dungeon Crawl Stone Soup version 0.17.1-1 (tiles) character file.
482312 Uhijidghi the Black Sun (level 23, -29/169 HPs)
Began as a Vampire Enchanter on Mar 8, 2016.
Was a High Priest of Kikubaaqudgha.
Killed from afar by a frost giant (51 damage)
... with a bolt of cold
... on level 5 of the Vaults on Mar 28, 2016.
The game lasted 10:38:41 (109459 turns).
with
p as (
SELECT 1 as id, 1 as t, 'p' as k, 'x' as v
UNION ALL
SELECT 1 as id, 2 as t, 'p' as k, 'y' as v
UNION ALL
SELECT 1 as id, 5 as t, 'p' as k, 'z' as v
),
q as (
SELECT 1 as id, 3 as t, 'q' as k, 'a' as v