Skip to content

Instantly share code, notes, and snippets.

View tuttle's full-sized avatar

Vlada Macek tuttle

View GitHub Profile
import datetime
dates = ['20220902', '20220909', '20220916', '20220923', '20220930',
'20221007', '20221014', '20221021', '20221118', '20221216',
'20230120', '20230317', '20230421', '20230616', '20230915',
'20240119', '20240315', '20240621']
# [ datetime.date(2022, 9, 2), datetime.date(2022, 9, 9), datetime.date(2022, 9, 16), ... ]
dates = [datetime.datetime.strptime(d, '%Y%m%d').date() for d in dates]
--- t 2022-07-06 14:23:36.859694051 +0200
+++ v 2022-07-06 14:23:36.363691598 +0200
@@ -1,94 +1,53 @@
-def sync_table(conn_info, stream, state, desired_columns, md_map):
+def sync_view(conn_info, stream, state, desired_columns, md_map):
time_extracted = utils.now()
# before writing the table version to state, check if we had one to begin with
first_run = singer.get_bookmark(state, stream['tap_stream_id'], 'version') is None
-
@tuttle
tuttle / pre-commit
Last active October 12, 2022 13:48
Git pre-commit hook to test the developer didn't forget to create database migrations and that all migrations are staged for commit.
#!/bin/sh
#
# Git pre-commit hook to test the developer didn't forget to create database migrations
# and that all migration files are staged for commit.
#
# Note: chmod +x .git/hooks/pre-commit
#
echo "pre-commit: Checking for forgotten/untracked/unstaged migrations..."
#!/bin/bash
# stop on first error
#set -e
# match patterns in a case-insensitive fashion when performing matching while executing case or [[
shopt -s nocasematch
RESIZE=""
TRIM=""
@tuttle
tuttle / cached_function.py
Last active August 29, 2015 13:56
Cached function decorator (Python, not mandatory Django)
import hashlib
from functools import wraps
from django.core import cache # Importing this way so debug_toolbar can patch it later.
from django.core.cache.backends.base import DEFAULT_TIMEOUT
ALLOWED_CACHED_FUNCTION_ARG_TYPES = set((type(None), int, float, long, bool, str, unicode))
def cached_function(func=None, num_args_to_key=None, timeout=DEFAULT_TIMEOUT):