This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ================ | |
# PRODUCTION IMAGE | |
# ================ | |
FROM YOUR-BASE-IMAGE | |
ARG GIT_HASH | |
ENV GIT_HASH ${GIT_HASH:-dev} | |
WORKDIR /src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######### Cloud Run | |
import os | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route('/') | |
def hello_world(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle, json, msgpack | |
data = {"device_id": "499675491", "s_10": 10} | |
# using the pickle module | |
pickle.dumps(data) | |
# using the json module | |
json.dumps(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events = {} | |
data = [1, 2] | |
if "id" in events: | |
events["id"].extend(data) | |
else: | |
events["id"] = [*data] | |
############## 🔥 setdefault ############## | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime as dt | |
ISO_8601_UTC = "%Y-%m-%dT%H:%M:%S.%fZ" | |
previous_date = dt.datetime.strptime("2018-09-06T13:34:30.168Z", ISO_8601_UTC) | |
dt.datetime.utcnow() - previous_date <= dt.timedelta(minutes=10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
airflow: | |
image: barrachri/pyconde2018_airflow:latest | |
restart: always | |
depends_on: | |
- postgres | |
environment: | |
- POSTGRES_USER=airflow | |
- POSTGRES_PASSWORD=airflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from psycopg2 import IntegrityError | |
from sqlalchemy import ( | |
Boolean, | |
Column, | |
DateTime, | |
Integer, | |
String, | |
Table, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Needs Python 3.7""" | |
import asyncio | |
import time | |
def blocking(): | |
print("\tStarting sleeping") | |
time.sleep(5) | |
print("\tSleeping completed") | |
return "Hello World" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Small comparison between append VS insert and pop() VS pop(0)""" | |
SIZE_OF_THE_LIST = 1000 | |
ELEMENTS_TO_BE_REMOVED = 500 | |
def test_append(): | |
my_list = [] | |
for i in range(SIZE_OF_THE_LIST): | |
my_list.append(i) | |
return my_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[flake8] | |
ignore = E265,E501,D203 | |
max-line-length = 100 | |
max-complexity = 10 | |
inline-quotes = double | |
exclude = | |
.tox, | |
.git, | |
__pycache__, | |
docs/source/conf.py, |
NewerOlder