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
.*.swp |
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
web: python app.py |
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
(define sum (make-aggregate + 0)) | |
(sum (list 1 2 3)) ; 6 | |
(define product (make-aggregate * 1)) | |
(product (list 2 3 4)) ; 24 | |
(define sum2 (make-aggregate (lambda (a b) (+ a b)) 0)) | |
(sum2 (list 1 2 3)) ; 6 | |
(define product2 (make-aggregate (lambda (a b) (* a b)) 1)) | |
(product2 (list 2 3 4)) ; 24 |
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
.*.swp | |
resized-*.jpg | |
resized-*.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
export PROJECTS_HOME="$HOME/Projects" | |
function has_virtualenv__() { | |
if [[ "$VIRTUAL_ENV" == "" ]]; then | |
if [[ $(dirname "`pwd`") == $PROJECTS_HOME ]]; then | |
venvname=$(basename "`pwd`") | |
if [[ -d "$WORKON_HOME/$venvname" ]]; then | |
workon "$venvname" | |
fi | |
fi |
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 wand.display import display | |
from wand.image import Image | |
from wand.place import place | |
with Image(...) as a, Image(...) as b, \ | |
Image(...) as c, Image(...) as d, \ | |
Image(...) as e: | |
with place(''' | |
|a | |b | | |
|c| |
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
""":mod:`crosspop.web.debugtoolbar` --- :pypi:`Flask-DebugToolbar` customization | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Some of objects in this module are compied from :pypi:`Flask-SQLAlchemy` | |
extension. Most of customization is removing dependencies on | |
:pypi:`Flask-SQLAlchemy` and making it to use internal database modules | |
(:mod:`crosspop.orm` and :mod:`crosspop.web.db`) instead. | |
This module is full of monkey patches! :-( Although it works well anyway. |
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
""":mod:`crosspop.web.urlmap` --- URL--model objects mapping | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
The most of model objects (e.g. :class:`~crosspop.user.User`, | |
:class:`~crosspop.comic.Comic`) have their own permalink urls. | |
Although you can link them using :func:`flask.url_for()`:: | |
url_for('user.profile', login=user.login) |
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 django.core.files import images | |
def get_image_dimensions(file_or_path, close=False): | |
if hasattr(file_or_path, 'read'): | |
arg_name = 'file' | |
file = True | |
filepos = file_or_path.tell() if hasattr(file_or_path, 'tell') else 0 | |
else: | |
arg_name = 'filename' |
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
def get_session(): | |
if getattr(flask.g, 'session_got', False): | |
return flask.g.session | |
session = was.orm.Session(bind=engine) | |
flask.g.session = session | |
flask.g.session_got = True | |
return flask.g.session | |
session = werkzeug.local.LocalProxy(get_session) |