Skip to content

Instantly share code, notes, and snippets.

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 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
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 / 0002_customuser.py
Last active May 27, 2020 12:15
raw sql
managers=[
('objects', django.contrib.auth.models.UserManager()),
],
),
migrations.RunSQL("INSERT INTO core_customuser SELECT * FROM auth_user"), # <--- this line
]
@axil
axil / models.py
Last active May 28, 2020 06:19
better foreignkey update
class Book(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
@axil
axil / models.py
Last active May 30, 2020 19:20
foreignkey update
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
from django.db import models
class Book(models.Model):
author = models.ForeignKey(User, on_delete=models.CASCADE)
class Comment(models.Model):
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)