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 random | |
import time | |
class Animal: | |
legs_count = None | |
eyes_count = None | |
def __init__(self, name): | |
self.name = name |
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
# decorator - create signal handler with async task as handler | |
def async_signal_handler(task, conditions=None, **options): | |
conditions = conditions or [] | |
def signal_handler(sender, *args, **kwargs): | |
if any(not c(sender, *args, **kwargs) for c in conditions): | |
return | |
kwargs['sender'] = sender | |
task.apply_async(args=args, kwargs=kwargs, **options) | |
return signal_handler | |
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 viewset_factory(*, name: str, method_mapping: Mapping, viewset_class=viewsets.GenericViewSet, **attrs): | |
"""Returns ViewSet class with views' methods got from `method_mapping` | |
Example: | |
Suppose, we have 2 views: | |
FooListView(generics.ListAPIView): | |
def list(request): | |
# impl. | |
pass |
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
(function(seconds) { | |
function httpGetAsync(theUrl) | |
{ | |
var xmlHttp = new XMLHttpRequest(); | |
xmlHttp.onreadystatechange = function() { | |
} | |
xmlHttp.open("GET", theUrl, true); // true for asynchronous | |
xmlHttp.send(null); | |
} |
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 | |
from collections import Counter | |
from collections import defaultdict | |
from itertools import chain | |
from operator import attrgetter, itemgetter | |
from actstream.models import Action | |
from django.conf import settings | |
from django.contrib.auth.mixins import PermissionRequiredMixin | |
from django.contrib.auth.models import User |
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 datetime | |
from flask import Blueprint, render_template, make_response, url_for, abort, \ | |
current_app as app | |
from werkzeug.local import LocalProxy | |
from werkzeug.routing import Rule | |
blueprint = Blueprint('sitemap', __name__, template_folder='templates') |
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 TeaserUpdate(TeaserMixin, UpdateView): | |
title = "Редактировать тизер" | |
template_name = 'advert/teaser_form.html' | |
def get(self, request, *args, **kwargs): | |
self.object = self.get_object() | |
form, image_form = self.get_forms() | |
return self.render_to_response(self.get_context_data(form=form, image_form=image_form)) | |
def post(self, request, *args, **kwargs): |
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
Attaching to oblichiusers_db_1, oblichiusers_redis_1, oblichiusers_rabbitmq_1, oblichiusers_web_1 | |
db_1 | 2015-02-17T00:42:19.667+0000 [initandlisten] connection accepted from 172.17.0.235:57332 #2 (1 connection now open) | |
web_1 | * Running on http://0.0.0.0:5000/ | |
web_1 | * Restarting with reloader | |
db_1 | 2015-02-17T00:42:20.612+0000 [initandlisten] connection accepted from 172.17.0.235:57338 #3 (2 connections now open) | |
db_1 | 2015-02-17T00:42:58.449+0000 [clientcursormon] mem (MB) res:50 virt:1053 | |
db_1 | 2015-02-17T00:42:58.449+0000 [clientcursormon] mapped (incl journal view):320 | |
db_1 | 2015-02-17T00:42:58.449+0000 [clientcursormon] connections:2 | |
web_1 | 172.17.42.1 - - [17/Feb/2015 00:44:53] "POST /api/v1.0/users/login HTTP/1.1" 500 - | |
web_1 | Traceback (most recent call last): |
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
/** | |
* Контактенирует засабмиченную конфигурацию | |
* преобразует в массив, фильтрует все пустые и нулевые значения, | |
* подсчитывает количество совпадений | |
* и возвращает наибольший результат (id выбранного продукта) | |
* | |
* @return int configurable_id | |
*/ | |
public function getConfigurableId() { | |
$configurations = Yii::app()->request->getParam('configurations'); |
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
14 => stdClass#16 | |
( | |
[OperTypeID] => 8 | |
[OperCtgID] => 2 | |
[OperName] => 'Обработка' | |
[DateOper] => '04.07.2012 10:42:00' | |
[IndexOper] => '630099' | |
) | |
15 => stdClass#17 | |
( |
NewerOlder