Skip to content

Instantly share code, notes, and snippets.

View Atorich's full-sized avatar

Eugene Kuznetsov Atorich

  • Russia, Novosibirsk
View GitHub Profile
@Atorich
Atorich / Sites
Created October 8, 2012 08:38
123456
//Model: Teasers
public function relations() {
//...
'visitsSum' => array(self::STAT, 'LinkVisits', 'tid',
'select' => 'SUM(count)',
),
'ordersSum' => array(self::STAT, 'TeaserZakaz', 'tid',
'select' => 'SUM(count)',
),
//...
//EUrlManager (ext. CUrlManager)
public function parseUrl(CHttpRequest $request) {
$route = parent::parseUrl($request);
CVarDumper::dump(array($route, $request->getUrl()), 10, 1);
return parent::parseUrl($request);
}
//output:
array
(
14 => stdClass#16
(
[OperTypeID] => 8
[OperCtgID] => 2
[OperName] => 'Обработка'
[DateOper] => '04.07.2012 10:42:00'
[IndexOper] => '630099'
)
15 => stdClass#17
(
/**
* Контактенирует засабмиченную конфигурацию
* преобразует в массив, фильтрует все пустые и нулевые значения,
* подсчитывает количество совпадений
* и возвращает наибольший результат (id выбранного продукта)
*
* @return int configurable_id
*/
public function getConfigurableId() {
$configurations = Yii::app()->request->getParam('configurations');
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):
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):
# 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')
# 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
(function(seconds) {
function httpGetAsync(theUrl)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
}
xmlHttp.open("GET", theUrl, true); // true for asynchronous
xmlHttp.send(null);
}
@Atorich
Atorich / views.py
Last active December 3, 2019 08:52
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