This file contains hidden or 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 AbsractDelModel(Model): | |
is_deleted = BoleanField(default = False) | |
class Meta: | |
abstract = True | |
class ArchesModel(Model): | |
name = CharField() |
This file contains hidden or 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
port_tree = PortageTree() | |
for package in port_tree.iter_packages(): | |
for ebuild in package.iter_ebuilds(): | |
ebuild.get_info() # get info about ebuild |
This file contains hidden or 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 LazyInput(object): | |
def __init__(self, str): | |
self._str = str | |
self._as_str = None | |
def __str__(self): | |
if self._as_str is None: | |
self._as_str = raw_input(self._str) | |
return self._as_str |
This file contains hidden or 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 flask import Flask, request | |
from werkzeug.exceptions import RequestEntityTooLarge | |
app = Flask(__name__) | |
app.config['MAX_CONTENT_LENGTH'] = 4 * 1024 # 4 Kb limit | |
app.config['DEBUG'] = True | |
@app.route("/", methods=["GET", "POST"]) | |
def hello(): | |
try: |
This file contains hidden or 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 flask import Flask, render_template_string | |
MAIN_TEMPLATE = """ \ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>{{ message }}</title> | |
</head> |
This file contains hidden or 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 flask import Flask, render_template_string | |
MAIN_TEMPLATE = """ \ | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>{{ message }}</title> | |
</head> |
This file contains hidden or 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 six | |
from six.moves import zip | |
import struct | |
uint = lambda x: x & 0xffffffff | |
uhex = lambda x: hex(x & 0xffffffff) | |
str_to_int = lambda x: struct.unpack("<i", x)[0] | |
int_to_str = lambda x: struct.pack("<i", sign_int(x)) | |
sign_int = lambda x: x if x < 0x7FFFFFFF else x - 0x100000000 |
This file contains hidden or 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
Realworldish Benchmark: | |
jinja 0.0009 seconds | |
mako 0.0008 seconds | |
django 0.0067 seconds | |
genshi 0.0144 seconds | |
(venv)slava@slava-air ~/src/jinja2/examples/rwbench $ python rwbench.py | |
Realworldish Benchmark: | |
jinja 0.0013 seconds | |
mako 0.0012 seconds | |
django 0.0066 seconds |
This file contains hidden or 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 os | |
import logging | |
from pyramid.config import Configurator | |
from pyramid.events import NewRequest | |
from pyramid.events import subscriber | |
from pyramid.events import ApplicationCreated | |
from pyramid.httpexceptions import HTTPFound | |
from pyramid.session import UnencryptedCookieSessionFactoryConfig | |
from pyramid.authentication import AuthTktAuthenticationPolicy |
This file contains hidden or 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 import create_engine, Column, Integer, MetaData, Table, String | |
from sqlalchemy.sql import select, Select, ColumnCollection | |
engine = create_engine('sqlite:///:memory:', echo=True) | |
metadata = MetaData() | |
class RearrangeSelect(Select): |
OlderNewer