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
import this | |
from random import choice | |
from django.conf import settings | |
from django.conf.urls import url | |
from django.core.management import execute_from_command_line | |
from django.http import HttpResponse | |
text = ''.join(this.d.get(c, c) for c in this.s) |
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.db.models import F | |
from django.core.files.uploadedfile import SimpleUploadedFile | |
from django.test import TestCase | |
from Core.models import Picture | |
class RaceConditionDemo(TestCase): | |
def setUp(self): | |
fakepic = SimpleUploadedFile('sample_pic.jpg', b'__content__') |
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
import sys | |
import os.path | |
import glob | |
# Get input and output folders as parameters | |
# if __name__ == '__main__': | |
# if len(sys.argv) < 3: | |
# pass | |
# else: |
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
import sys | |
import os.path | |
import glob | |
# Get input and output folders as parameters | |
try: | |
dir_in = sys.argv[1] | |
dir_out = sys.argv[2] | |
except IndexError: | |
print('======================================================\n' + |
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
#!/bin/sh | |
git_revision=$(git rev-parse HEAD) | |
echo "git_revision='$git_revision'" > version.py |
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
# example.conf | |
# the upstream component nginx needs to connect to | |
upstream example { | |
server unix:///tmp/example.sock; # for a file socket | |
} | |
# configuration of the server | |
server { | |
listen 80; |
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 import conf, http, urls | |
conf.settings.configure( | |
DEBUG = True, | |
ROOT_URLCONF = __name__ | |
) | |
def index(request): |
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
import requests | |
from collections import namedtuple | |
from xml.etree import ElementTree | |
""" Client for http://gismeteo.ru """ | |
# Sample forecast section: | |
# | |
# <FORECAST day="29" month="03" year="2016" hour="03" tod="0" predict="0" weekday="3"> | |
# <PHENOMENA cloudiness="0" precipitation="10" rpower="0" spower="0"/> |
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
import operator as op | |
# Simple calculator that can add, subtract, multiply and divide | |
OPS = (("Add", "+", op.iadd), | |
("Subtract", "-", op.isub), | |
("Multiply", "*", op.imul), | |
("Divide", "/", op.truediv)) | |
valid_choices = list(map(str, range(1, len(OPS)+1))) |
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
import re | |
import sys | |
from collections import Counter | |
from pymorphy2 import MorphAnalyzer | |
morph = MorphAnalyzer() | |
def words(text): | |
return re.findall('[а-яА-Яa-zA-Z-]+', text.lower()) |