Skip to content

Instantly share code, notes, and snippets.

View avilior's full-sized avatar

Avi Lior avilior

View GitHub Profile
@avilior
avilior / main.py
Created April 30, 2021 23:45
FastApi
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import FastAPI
import logging
LOG = logging.getLogger(__name__)
app = FastAPI()
@avilior
avilior / main.py
Last active December 31, 2020 19:46
FastAPI main file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from fastapi import FastAPI, Depends, HTTPException, Request
from fastapi.middleware.cors import CORSMiddleware # https://fastapi.tiangolo.com/tutorial/cors/
from fastapi.staticfiles import StaticFiles # needs aiofiles to be installed
import logging
LOG = logging.getLogger(__name__)
@avilior
avilior / main_asyncio.py
Created December 9, 2019 10:53
Basic asyncio base template with python 3.8
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
import logging
import uvloop
from kafka_producer import KafkaProducer
from kafka_consumer import KafkaConsumer
LOG=logging.getLogger(__name__)
@avilior
avilior / docker-compose.yml
Created December 9, 2019 10:44
Get Kafka/Zookeeper Bitnami working with Docker For MAC
version: '3.7'
networks:
kafka-net:
driver: bridge
services:
zookeeper:
image: 'bitnami/zookeeper:latest'
@avilior
avilior / vose_vose_alias.py
Last active August 13, 2017 12:40
vose alias
import random
import functools
"""
Reference: http://www.keithschwarz.com/darts-dice-coins/
Initialization:
1 Create arrays Alias and Prob, each of size n.
2 Create two worklists, Small and Large.
@avilior
avilior / python2main.py
Created August 9, 2017 14:30
argparse, logging
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
import argparse
import logging
import sys
logger = logging.getLogger(__name__)