Skip to content

Instantly share code, notes, and snippets.

View abunuwas's full-sized avatar
🎯
Focusing

José Haro Peralta abunuwas

🎯
Focusing
View GitHub Profile
from dataclasses import dataclass
from datetime import datetime
from typing import Dict
@dataclass
class Sale:
data: Dict
def __post_init__(self):
from dataclasses import dataclass
from datetime import datetime
from typig import List
@dataclass
class Sale:
date: datetime
price: float
from dataclasses import dataclass
from typing import Dict, List
@dataclass
class Property:
address: Dict
sales: List[Dict]
property_type: str
residential_type: str
rooms: int
property = {
'address': {
'street': 'Python Way',
'number': '1',
'post_code': 'PY19 4DJ',
'city': 'London',
'country': 'United Kingdom'
},
'sales': [
{
-module(test).
-export([test/0]).
test() ->
eredis_pool:create_pool(pool1, 10, "stgejabberdswann.bndouw.ng.0001.euw1.cache.amazonaws.com", 6379, 0).
test2() ->
S = [{size, 10}, {max_overflow, 10}]
P = [{name, global, pool1}}, {worker_module, eredis}]
@abunuwas
abunuwas / test_queue_limit.py
Created April 13, 2017 13:55
See what happens when a Python queue reaches its limit
from queue import Queue
from threading import Thread
import time
class Worker:
def __init__(self):
self.q = Queue()
self.q.maxsize = 4
from queue import Queue
from threading import Thread
import time
class Worker:
def __init__(self):
self.q = Queue()
self.q.maxsize = 4
#!/usr/bin/env python3
# MTI License
"""This is an example of how to use the try-except-else-finally
clauses in Python. Generally, you want to include within the try:
clause only the specific line that can raise the error which you
explicitly catch with except. Any other operation that should be
performed after that step and can raise a different error should
be included in the else: clause. Operations that should be performed
independently or whether the exception is raised, or not, should
@abunuwas
abunuwas / Dockerfile
Last active March 6, 2017 16:08
Dockerfile template for Python apps
#######################
# Dockerfile template #
#######################
# Set the base image to Ubuntu
FROM python:3.5-alpine
# File Author / Maintainer
MAINTAINER Jose Haro
"""
This code snippet shows how to dynamically generate
permissions for API calls to AWS with the boto3
SDK when using instance profile roles in an ec2
instance.
"""
import boto3
import botocore.session