Skip to content

Instantly share code, notes, and snippets.

def get(self, section, key, **kwargs):
section = str(section).lower()
key = str(key).lower()
deprecated_name = self.deprecated_options.get(section, {}).get(key, None)
# first check environment variables
option = self._get_env_var_option(section, key)
if option is not None:
return option
@tszumowski
tszumowski / bash_profile
Created March 18, 2019 10:31
dadjoke bash profile
dadjoke () {
echo $(curl -s https://icanhazdadjoke.com/)
}
pr () {
# No args: defaults to default reviewers, opens file for edit with template and dad joke
# 1 arg: Argument is string of the reviewers to place
dj=$(dadjoke)
if [ "$#" == "0" ]; then
@tszumowski
tszumowski / datastore_export_operator-snippet.py
Last active March 19, 2019 10:22
Airflow DatastoreExportOperator Snippet
class DatastoreExportOperator(BaseOperator):
""" (...) """
@apply_defaults
def __init__(self,
bucket,
namespace=None,
datastore_conn_id='google_cloud_default',
(...)
overwrite_existing=False,
*args,
@tszumowski
tszumowski / airflow_init_warning.py
Created March 19, 2019 12:50
airflow warning of removing args/kwargs
if args or kwargs:
# TODO remove *args and **kwargs in Airflow 2.0
warnings.warn(
'Invalid arguments were passed to {c} (task_id: {t}). '
'Support for passing such arguments will be dropped in '
'Airflow 2.0. Invalid arguments were:'
'\n*args: {a}\n**kwargs: {k}'.format(
c=self.__class__.__name__, a=args, k=kwargs, t=task_id),
category=PendingDeprecationWarning,
stacklevel=3
@tszumowski
tszumowski / fetch_pd_data.py
Last active January 4, 2024 20:06
Fetch Polarity Digital Data
"""
This script fetches cryptocurrency data from the Polarity Digital API. It retrieves historical and
additional data for a list of cryptocurrencies and saves them as JSON files.
The script uses the requests library to make API calls and argparse for
command line argument parsing.
Data is fetched for each coin and metric, then saved in files named with the
format YYYYMMDD-{coin}-{metric}.json.
SETUP: