Skip to content

Instantly share code, notes, and snippets.

🏄
Happy

Christian Barra barrachri

🏄
Happy
Block or report user

Report or block barrachri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@barrachri
barrachri / main.py
Last active Nov 8, 2019
Schema-less serializazion in Python
View main.py
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)
View snippet01.py
events = {}
data = [1, 2]
if "id" in events:
events["id"].extend(data)
else:
events["id"] = [*data]
############## 🔥 setdefault ##############
View main.py
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)
View docker-compose.yml
version: '3'
services:
airflow:
image: barrachri/pyconde2018_airflow:latest
restart: always
depends_on:
- postgres
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
View model.py
import uuid
from psycopg2 import IntegrityError
from sqlalchemy import (
Boolean,
Column,
DateTime,
Integer,
String,
Table,
View blocking_function.py
"""Needs Python 3.7"""
import asyncio
import time
def blocking():
print("\tStarting sleeping")
time.sleep(5)
print("\tSleeping completed")
return "Hello World"
View test_list.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
View setup.cfg
[flake8]
ignore = E265,E501,D203
max-line-length = 100
max-complexity = 10
inline-quotes = double
exclude =
.tox,
.git,
__pycache__,
docs/source/conf.py,
View streams.py
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
View keybase.md

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:

You can’t perform that action at this time.