Skip to content

Instantly share code, notes, and snippets.

View edo248's full-sized avatar
😎
!

Eduard Babayan edo248

😎
!
  • Optiver
  • Netherlands
View GitHub Profile
NANO_TIMESTAMP=$(date +%s%N)
curl -XPOST "http://localhost:8086/write?db=metrics" --data-binary "mymeas,mytag=1 myfield=90 $NANO_TIMESTAMP";
@edo248
edo248 / customdate.py
Last active September 26, 2019 20:07
custom python datetime object with default format
# Custom datetime class that can be initialized by date string and has default format
# useful for automatic serialization/deserializaion (to JSON, or other formats) such that
# when deserialized constructore can be called directly CustomDate(<string>) and serialization is just str()
import datetime
class CustomDate(datetime.datetime):
__date_format = '%Y/%m/%d'
@edo248
edo248 / json2model.py
Created September 21, 2019 16:51
Parsing json to python models and serializing to json using pydantic
"""
Parsing complex json structure with pydantic.
Using example json file from from nobelprize.org
### laureate.json from http://api.nobelprize.org/v1/laureate.json
Original data looked like this:
------------
@edo248
edo248 / flask-api-with-swagger-docs.py
Created May 18, 2019 15:21
Flask API with swagger docs
import flask
from marshmallow import Schema, fields as schema_field_type
from flask_apispec import use_kwargs, marshal_with, FlaskApiSpec, MethodResource
from flask_apispec.annotations import doc
from flask_restful import Resource as RestfulResource, Api
from flask_marshmallow import Marshmallow
from flask_sqlalchemy import SQLAlchemy