Skip to content

Instantly share code, notes, and snippets.

View patrys's full-sized avatar

Patryk Zawadzki patrys

View GitHub Profile
@patrys
patrys / example.py
Last active October 9, 2015 12:15
Test file for flake8
from example import (
f401_unused)
@f821_undefined_name
def c901_too_complex(x):
if x > 1:
if x > 2:
if x > 3:
if x > 4:
if x > 5:
@patrys
patrys / .fonts.conf
Created March 8, 2016 12:27
Fedora, fonts and Chrome
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="font">
<edit name="autohint" mode="assign"><bool>true</bool></edit>
<edit name="antialias" mode="assign"><bool>true</bool></edit>
<edit name="hinting" mode="assign"><bool>true</bool></edit>
<edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
<edit name="rgba" mode="assign"><const>rgb</const></edit>
</match>
</fontconfig>
#!/usr/bin/env python
from tornado import httpserver, ioloop, wsgi
from saleor.wsgi import application
container = wsgi.WSGIContainer(application)
server = httpserver.HTTPServer(container)
server.listen(8000)
ioloop.IOLoop.current().start()
#!/usr/bin/env python
from tornado import httpserver, ioloop, wsgi
from saleor.wsgi import application
container = wsgi.WSGIContainer(application)
server = httpserver.HTTPServer(container)
server.bind(8000)
server.start(0)
ioloop.IOLoop.current().start()
#!/usr/bin/env python
from cherrypy import wsgiserver
from saleor.wsgi import application
server = wsgiserver.CherryPyWSGIServer(
('0.0.0.0', 8000), application, numthreads=10)
try:
server.start()
except KeyboardInterrupt:
#!/usr/bin/env python
from meinheld import server
from saleor.wsgi import application
server.listen(('0.0.0.0', 8000))
server.run(application)
@patrys
patrys / cbv-wat1.py
Last active December 20, 2016 18:57
from django.template.response import TemplateResponse
from django.views.generic import View
class MyClassBasedView(View):
def __init__(self, foo='bar'):
self._foo = foo
def get(self, request):
context = {'foo': self._foo}
from django.views.generic import View
from django.template.response import TemplateResponse
def get(request):
return TemplateResponse(request, 'index.html')
my_class_based_view = View.as_view(get=get)
# TypeError: You tried to pass in the get method name as a keyword argument to View(). Don't do that.
from django.views.generic import View
from django.template.response import TemplateResponse
def get(request):
return TemplateResponse(request, 'index.html')
my_class_based_view = View.as_view(http_method_not_allowed=get)
from django.views.generic import View
from django.template.response import TemplateResponse
def get(request):
return TemplateResponse(request, 'index.html')
my_class_based_view = View.as_view(dispatch=get)