Skip to content

Instantly share code, notes, and snippets.

import re
from random import choice
#e1 = re.compile('((x((y|z))*x)|(y|z))*$') # my
#e2 = re.compile('(y|z)*(x(y|z)*x(y|z)*)*$')
e1 = re.compile('(?:(?:x(?:[yz])*x)|[yz])*$') #my
e2 = re.compile('(?:y|z)*(?:x(?:y|z)*x(?:y|z)*)*$')
res = 0
import re
from random import choice
e1 = re.compile('(?:(?:x(?:[yz])*x)|[yz])*$') #my
e2 = re.compile('(?:y|z)*(?:x(?:y|z)*x(?:y|z)*)*$')
res = 0
def test(e, s):
global res
format:
n:
regexp1_try1 try2 try3 regexp2_try1 try2 try3
10 :
4.35, 4.30, 4.31, 4.80, 4.81, 4.71,
4.31, 4.35, 4.33, 5.00, 5.04, 4.99,
3.88, 3.84, 3.85, 4.03, 3.99, 4.02,
4.13, 4.14, 4.17, 4.54, 4.53, 4.54,
4.42, 4.47, 4.37, 5.00, 4.96, 5.04,
import jinja2
env = jinja2.Environment(extensions=['jinja2.ext.do'])
template = '''
{% set p = [4,5,6] %}
{% set res = [] %}
{% for i in p %}
{% do res.append(i) %}
{% endfor %}
@axil
axil / test.py
Last active December 5, 2018 15:22
test
test(markdown('[Google - поиск №1](http://google.com)'),
'<a href="http://google.com">Google - поиск №1</a>')
test(markdown('[MS Bing] компания [Microsoft Bing](http://bing.com)'),
'[MS Bing] компания <a href="http://bing.com">Microsoft Bing</a>')
test(markdown('[Python](http://python.org)(v3.7)'),
'<a href="http://python.org">Python</a>(v3.7)')
test(markdown('[Яндекс!](http://ya.ru) и [百度](http://baidu.com)'),
'<a href="http://ya.ru">Яндекс!</a> и <a href="http://baidu.com">百度</a>')
@axil
axil / settings.py
Created May 27, 2020 11:59
include core app
INSTALLED_APPS = [
'core',
'django.contrib.admin',
@axil
axil / models.py
Created May 27, 2020 12:06
book model
from django.db import models
from django.contrib.auth.models import User
class Book(models.Model):
author = models.ForeignKey(User)
@axil
axil / create_book.py
Last active May 31, 2020 08:12
create a book
In [1]: from django.contrib.auth.models import User
In [2]: from core.models import *
In [3]: u = User.objects.create(username='aaa')
In [4]: Book.objects.create(author=u)
Out[4]: <Book: Book object (1)>
In [5]: Comment.objects.create(author=u)
@axil
axil / models.py
Last active May 31, 2020 10:04
customuser
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
class Meta:
db_table = 'auth_user'
@axil
axil / settings.py
Last active June 10, 2020 18:49
auto_user_model
AUTH_USER_MODEL = 'users.CustomUser'