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
# -*- coding: utf-8 -*- | |
""" | |
The Pygments reStructuredText directive | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
This fragment is a Docutils_ 0.5 directive that renders source code | |
(to HTML only, currently) via Pygments. | |
To use it, adjust the options below and copy the code into a module | |
that you import on initialization. The code then automatically |
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
''' | |
Simple usage as cherrypy daemon as example | |
''' | |
import soaplib | |
from soaplib.core.server import wsgi | |
from cherrypy.wsgiserver import CherryPyWSGIServer | |
HOST = "0.0.0.0" | |
PORT = 45124 |
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
def get_by_path(path): | |
''' | |
get python object from path | |
>>> get_by_path('os.path.join') | |
<function join at ...> | |
''' | |
spl = path.split('.') | |
mod = None | |
for n, s in enumerate(spl, start=1): | |
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
Как написать location в nginx, который срабатывает, если два условия должны выполняться. Логично было бы написать так: | |
if ($http_user_agent ~* "Opera" AND $http_referer ~* "yandex.ru") { | |
bla bla bla | |
} | |
nginx не предусматривает в условиях логические операторы | |
Решение есть в виде хака: | |
set $a ""; |
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
-*- coding: utf-8 -*- | |
''' | |
http://code.google.com/apis/picasaweb/docs/1.0/developers_guide_python.html | |
''' | |
import os | |
import os.path | |
import mimetypes | |
import sys | |
import logging | |
import logging.handlers |
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
# -*- coding: utf-8 -*- | |
''' | |
Usage: | |
python album_fetcher.py https://plus.google.com/photos/118353143366443526186/albums/5626152497309725217 | |
python album_fetcher.py https://plus.google.com/118353143366443526186 | |
python album_fetcher.py https://plus.google.com/118353143366443526186 [email protected] yourpassword | |
python album_fetcher.py https://plus.google.com/118353143366443526186 [email protected] yourpassword /out_dir/ | |
TODO: use opt parse | |
''' | |
import os |
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
#!./virtualenv_python.sh | |
#some text |
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 django.shortcuts import render_to_response | |
from django.template import RequestContext | |
from functools import wraps | |
def render_to(template_name, title='Main'): | |
""" | |
Decorator for Django views that sends returned dict to render_to_response function | |
with given template and RequestContext as context instance. | |
If view doesn't return dict then decorator simply returns output. |
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
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import imp | |
from django.template.loader import BaseLoader | |
from django.template.loaders.filesystem import Loader as FileSystemLoader | |
from django.template.base import TemplateDoesNotExist | |
from django.conf import settings |
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
# -*- coding: utf-8 -*- | |
import os | |
import Image | |
from django.core.files.storage import FileSystemStorage | |
from django.db import models | |
from django.db.models.fields.files import ImageFieldFile | |
from south.modelsinspector import add_introspection_rules | |
add_introspection_rules([], ["^blog\.fields\.AvatarImageField"]) |