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 flask | |
app = flask.Flask(__name__) | |
@app.route('/') | |
def index(): | |
return 'ahoj <img src="/graf">' | |
@app.route('/graf') | |
def graf(): |
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 | |
# -*- coding: UTF-8 -*- | |
import json | |
import oauth2 # https://raw.github.com/brosner/python-oauth2/master/oauth2/__init__.py | |
from pprint import pprint | |
import urllib2 | |
stream_url = "https://stream.twitter.com/1/statuses/filter.json" |
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
export default class PageLayout extends React.Component { | |
render() { | |
const { | |
children, siteTitleH1, mobileView, userAgent, | |
currentLanguage, enVersionUrl, csVersionUrl, | |
} = this.props; | |
let appBar = null; |
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 python3 | |
''' | |
Inspired by pytest fixtures :) | |
''' | |
import argparse | |
from inspect import signature | |
import logging | |
from reprlib import repr as smart_repr |
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 python3 | |
import boto3 | |
from datetime import datetime | |
import logging | |
import socket | |
from time import time, sleep | |
logger = logging.getLogger(__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
importy.png: importy.dot | |
dot -Tpng importy.dot > importy.png |
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
x = 11 | |
def f(): | |
x = 22 | |
print('uvnitr f:', x) | |
print(x) | |
f() | |
print(x) | |
# Výstup programu: | |
# |
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
# my_app/container.py | |
from .clients import ShopifyClient | |
from .model import Model, connect_db | |
from .util import System | |
factories = { | |
'system': lambda cx: System(), # obsahuje wrapper okolo datetime a tak, pro snadnější mockování v testech | |
'model': lambda cx: Model(db=connect_db(cx['conf'].db), system=cx['system']), | |
'shopify_client': lambda cx: ShopifyClient(cx['conf'].shopify), |
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 yaml | |
def yaml_dump(obj): | |
return yaml.dump(obj, width=120, default_flow_style=False, Dumper=_CustomDumper) | |
class _CustomDumper (yaml.SafeDumper): | |
pass | |
def _str_representer(dumper, data): | |
style = '|' if '\n' in data else None |
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 alpine | |
RUN apk add py3-flask py3-gunicorn | |
COPY hello.py . | |
EXPOSE 8000 | |
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "hello:app"] |