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 django import forms | |
from django.utils.html import escape, conditional_escape | |
from django.utils.encoding import force_unicode | |
def get_attr(obj, attr): | |
if hasattr(obj, attr): | |
res = getattr(obj, attr) |
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 itertools import product | |
import time | |
m = 10 | |
squares = set([x * x for x in range(2 * m)]) | |
delimeters = {1: set({})} # Словарь делителей чисел | |
for x, y in product(xrange(2, m + 1), repeat=2): |
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 django.test import LiveServerTestCase | |
from selenium import webdriver | |
from selenium.common.exceptions import WebDriverException | |
from django.contrib.auth import get_user_model | |
User = get_user_model() | |
class AdminTestCase(LiveServerTestCase): | |
def setUp(self): |
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
city_list = [{name: 'Moscow', id: 1},{name: 'Saint Petersburg', id: 2}] | |
$('.city').select2 | |
query: (options) -> | |
term = options.term.toLowerCase() | |
results = [] | |
output = {} | |
paginate_by = 50 | |
i = 0 | |
j = 0 |
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
upstream dr-tg.tyavin.name { | |
server localhost:8019 fail_timeout=0; | |
} | |
server { | |
listen 80; | |
client_max_body_size 4G; | |
server_name dr-tg.tyavin.name; | |
access_log /var/log/dr-tg.log; | |
error_log /home/vinograd19/dr-tg/log/nginx_error.log; |
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 ShopTest(TestCase): | |
def setUp(self): | |
self.network = Network.objects.create() | |
self.region1 = Region.objects.create() | |
self.region2 = Region.objects.create() | |
self.city1 = City.objects.create(region=self.region1) | |
self.city2 = City.objects.create(region=self.region2) | |
self.shop1 = Shop.objects.create( | |
code='0001', | |
cluster=Cluster.objects.create(), |
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 Mixin(object): | |
def get_queryset(self): | |
raise self.get_object().products.all() | |
class WrongListView(ListCreateAPIView, Mixin): | |
pass | |
class RightListView(Mixin, ListCreateAPIView): |
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
module.exports = class Base | |
edge: (which) -> | |
if which == 'start' | |
return 'left' | |
else if which == 'end' | |
return 'right' | |
throw new TypeError('What kind of an edge is ' + which) | |
edgeProp: (edge, prop) -> | |
o = @$el[prop]() | |
o[@edge(edge)] |
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
password | |
123456 | |
12345678 | |
1234 | |
qwerty | |
12345 | |
dragon | |
pussy | |
baseball | |
football |
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 time | |
import math | |
N = 1000 # any number greater than 1000 | |
class B(object): | |
""" | |
Hash always returns the same value. | |
Then any hash table based on instances of this class will always contain one chain. |
OlderNewer