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
# If you create xml via ElementFlow and make some bad things (and exceptions raise) | |
# you will get invalid xml (only a criple part of the xml you wish to have). | |
# | |
# This is a wrapper for ElementFlow for 'atomic' xml: it either created or not. | |
import shutil | |
import tempfile | |
class ElementFlowAtomicOutputWrapper(object): | |
def __init__(self, out_file_path): |
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
source 'https://rubygems.org' | |
gem 'rails', '3.2.1' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' | |
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 permutations(l): | |
""" | |
>>> f = permutations | |
>>> f(['a', 'b']) | |
[('a', 'b'), ('b', 'a')] | |
>>> f(['a', 'b', 'c']) | |
[('a', 'b', 'c'), ('a', 'c', 'b'), ('b', 'a', 'c'), ('b', 'c', 'a'), ('c', 'a', 'b'), ('c', 'b', 'a')] | |
""" | |
if len(l) == 1: |
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
#-*- coding: UTF-8 -*- | |
import re | |
def recognize_phone(s): | |
""" | |
>>> f = recognize_phone | |
>>> f(u'8-912-234-56-78') | |
u'8-912-234-56-78' |
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
compass create -r ninesixty vizavi-layout --using 960 --syntax sass --sass-dir "sass" --css-dir "css" --javascripts-dir "js" --images-dir "images" |
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
{# use in combination with https://github.com/zyga/django-pagination #} | |
{# and http://twitter.github.com/bootstrap/ #} | |
{# project-dir/templates/pagination/pagination.html #} | |
{% if is_paginated %} | |
{% load i18n %} | |
<div class="pagination"> | |
<ul> | |
{% block previouslink %} | |
{% if page_obj.has_previous %} |
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 tinymce | |
from django_any import xunit | |
from django_any.models import any_model, any_field | |
@any_field.register(tinymce.models.HTMLField) | |
def any_tinymce_html_field(*_): | |
return xunit.any_string(min_length=1, max_length=400) |
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
EMAIL_HOST = 'smtp.yandex.ru' | |
EMAIL_HOST_USER = '[email protected]' | |
EMAIL_HOST_PASSWORD = 'password' | |
EMAIL_PORT = 587 | |
EMAIL_USE_TLS = True |
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.conf import settings | |
def send_sms(phone, text): | |
q = ("<?xml version='1.0' encoding='UTF-8'?><data><login>%(login)s</login>" + | |
"<password>%(password)s</password><text>%(text)s</text><to number='%(phone)s'></to></data>") % { | |
'phone': phone.encode('utf-8'), | |
'text': text.encode('utf-8'), | |
'login': settings.SMS_INTELL_LOGIN, | |
'password': settings.SMS_INTELL_PASSWORD, | |
} |
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
class AbstractParseTarget(object): # http://lxml.de/parsing.html#the-target-parser-interface | |
def __init__(self): | |
self.current_tag = None | |
def start(self, tag, attrib): | |
self.current_tag = tag | |
method = getattr(self, '%s_start' % tag, None) | |
if method: |
OlderNewer