Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am barrachri on github.
  • I am barrachri (https://keybase.io/barrachri) on keybase.
  • I have a public key whose fingerprint is 0A57 D1FC 5539 5523 1453 43A2 9C67 4465 A2E8 4985

To claim this, I am signing this object:

import asyncio
from aiohttp import web
import subprocess
async def uptime_handler(request):
# http://HOST:PORT/?interval=90
# Without the Content-Type, most (all?) browsers will not render
# partially downloaded content. Note, the response type is
[flake8]
ignore = E265,E501,D203
max-line-length = 100
max-complexity = 10
inline-quotes = double
exclude =
.tox,
.git,
__pycache__,
docs/source/conf.py,
"""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
"""Needs Python 3.7"""
import asyncio
import time
def blocking():
print("\tStarting sleeping")
time.sleep(5)
print("\tSleeping completed")
return "Hello World"
import uuid
from psycopg2 import IntegrityError
from sqlalchemy import (
Boolean,
Column,
DateTime,
Integer,
String,
Table,
version: '3'
services:
airflow:
image: barrachri/pyconde2018_airflow:latest
restart: always
depends_on:
- postgres
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
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)
events = {}
data = [1, 2]
if "id" in events:
events["id"].extend(data)
else:
events["id"] = [*data]
############## 🔥 setdefault ##############
@barrachri
barrachri / main.py
Last active November 8, 2019 20:14
Schema-less serializazion in Python
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)