This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from fastapi import FastAPI | |
from uicheckapp.services import EchoService | |
logging.config.fileConfig('logging.conf', disable_existing_loggers=False) | |
logger = logging.getLogger(__name__) | |
app = FastAPI() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReportFormat(object): | |
PDF = 0 | |
TEXT = 1 | |
class Report(object): | |
def __init__(self, format_): | |
self.title = 'title' | |
self.format_ = format_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Single Responsibility Principle | |
“…You had one job” — Loki to Skurge in Thor: Ragnarok | |
A class should have only one job. | |
If a class has more than one responsibility, it becomes coupled. | |
A change to one responsibility results to modification of the other responsibility. | |
""" | |
class Animal: | |
def __init__(self, name: str): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTTPError implements ClientError interface. | |
type HTTPError struct { | |
Cause error `json:"-"` | |
Detail string `json:"detail"` | |
Status int `json:"-"` | |
} | |
func (e *HTTPError) Error() string { | |
if e.Cause == nil { | |
return e.Detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import pandas as pd | |
from io import StringIO | |
class S3DataFrame(pd.DataFrame): | |
""" | |
# Make a dataframe and upload it as csv | |
s3df = S3DataFrame({'h1':[1], 'h2':[2]}) | |
s3df.to_s3(Bucket='bucket-name', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.dialects import postgresql | |
def bulk_upsert(session: Session, | |
items: Sequence[Mapping[str, Any]]): | |
session.execute( | |
postgresql.insert(MyModel.__table__) | |
.values(items) | |
.on_conflict_do_update( | |
index_elements=[MyModel.id], | |
set_={MyModel.my_field.name: 'new_value'}, |
Short (72 chars or less) summary
More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).
Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import hashlib | |
page_contents = requests.get('http://www.google.com') | |
response = page_contents.text | |
print hashlib.sha256(response.encode('utf-8')).hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Safe Queue Celery App Settings | |
from __future__ import absolute_import, unicode_literals | |
from celery import Celery | |
app = Celery('some_project', | |
broker='amqp://', | |
backend='amqp://', | |
include=['some_project.tasks']) |
NewerOlder