Skip to content

Instantly share code, notes, and snippets.

View phpdude's full-sized avatar
🏠
Working from home

Alexandr Shurigin phpdude

🏠
Working from home
View GitHub Profile
from django.contrib.admin import ModelAdmin, register, SimpleListFilter
from django.db.models.functions import Length, StrIndex, Substr, NullIf, Coalesce
from django.db.models import Value as V
from .models import Item
class AlphanumericSignatureFilter(SimpleListFilter):
title = 'Signature (alphanumeric)'
parameter_name = 'signature_alphanumeric'
from django.contrib.admin import ModelAdmin, register
from django.db.models import IntegerField
from django.db.models.functions import Cast
from django.db.models.expressions import Func, Value
from .models import Foo
class RegexpMatches(Func):
function = 'REGEXP_MATCHES'
@phpdude
phpdude / clean.py
Created December 10, 2019 16:20
Efficent way to remove docstrings in python source code
import ast
import astor # read more at https://astor.readthedocs.io/en/latest/
parsed = ast.parse(open('source.py').read())
for node in ast.walk(parsed):
# let's work only on functions & classes definitions
if not isinstance(node, (ast.FunctionDef, ast.ClassDef, ast.AsyncFunctionDef)):
continue
@phpdude
phpdude / yeah!
Created December 14, 2019 17:27
Top ranked in a week =)
Can do it :)