Skip to content

Instantly share code, notes, and snippets.

View yucer-elbt's full-sized avatar

Yurdik Cervantes yucer-elbt

View GitHub Profile
@yucer-elbt
yucer-elbt / archive.py
Created August 21, 2022 09:26
Python Mixin for SQLAlchemy autopartition by week (postgres)
import logging
from sqlalchemy.sql import text
_logger = logging.getLogger(__name__)
class ArchivableMixin:
"""Model which can be duplicated via one special materialized view"""
WITH CTE AS (
SELECT
concat(
substr('20220416T070044.243Z', 1, 4), '-',
substr('20220416T070044.243Z', 5, 2), '-',
substr('20220416T070044.243Z', 7, 2), 'T',
substr('20220416T070044.243Z', 10, 2), ':',
substr('20220416T070044.243Z', 12, 2), ':',
substr('20220416T070044.243Z', 14)
) as ts
@yucer-elbt
yucer-elbt / RDS-Aurora-CloudFormation-Example.yaml
Created September 8, 2022 14:54 — forked from yyolk/RDS-Aurora-CloudFormation-Example.yaml
A basic CloudFormation template for an RDS Aurora cluster.
---
AWSTemplateFormatVersion: 2010-09-09
Description: A basic CloudFormation template for an RDS Aurora cluster.
Parameters:
DatabaseInstanceType:
Default: db.r3.large
AllowedValues:
- db.r3.large
- db.r3.xlarge
- db.r3.2xlarge
@yucer-elbt
yucer-elbt / athena_csv_header_pivot.sql
Created September 15, 2022 14:48
non-standard csv header expansion
WITH
HEADER_ROWS AS (
SELECT
col0 key
, col1 value
, "$path" file
FROM
"database"."orders"
WHERE (NOT (col0 LIKE 'PID_%'))
)
@yucer-elbt
yucer-elbt / athena_query_iso8601_opt_seconds.sql
Created September 20, 2022 08:16
iso8601 in athena queries: optional seconds and microseconds in UTC
select format_datetime(current_timestamp, 'YYYY-MM-dd''T''HH:mm''Z''')