Skip to content

Instantly share code, notes, and snippets.

Oleg Kleshchunov LowerDeez

Block or report user

Report or block LowerDeez

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import collections
class OrderedSet(collections.MutableSet):
def __init__(self, iterable=None):
self.end = end = []
end += [None, end, end] # sentinel node for doubly linked list = {} # key --> [key, prev, next]
if iterable is not None:
self |= iterable
LowerDeez /
Last active Oct 3, 2019 — forked from gjain0/
Create HMAC SHA256 signature/encryption/encode
import hmac
import hashlib
import binascii
# 1
sudo apt-get install python3-pip
sudo pip3 install pipenv

If you have any problems with pip or pip3, edit /usr/bin/pip or /usr/bin/pip3 and change the import statement by changing

from pip import main

View Ngixn. Allow access to files from site root
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_connect_timeout 350;
proxy_send_timeout 350;
proxy_read_timeout 350;
proxy_pass http://app_server;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls|xlsx|ppt|pptx|odf|odp|ods|odt|psd|ai|eo$
root /home/django/public_html;
LowerDeez /
Created Apr 24, 2019 — forked from iandmyhand/
Django ORM function to sum absolute values.
from django.db.models import Sum
class AbsoluteSum(Sum):
name = 'AbsoluteSum'
template = '%(function)s(%(absolute)s(%(expressions)s))'
def __init__(self, expression, **extra):
super(AbsoluteSum, self).__init__(
expression, absolute='ABS ', output_field=IntegerField(), **extra)
LowerDeez /
Created Apr 22, 2019
Python. API Client example
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
import os
import platform
import requests
import requests.exceptions
from requests.compat import json
import traceback
LowerDeez /
Created Oct 24, 2018
Django. Custom views for admin.
class OrderAdmin(admin.ModelAdmin):
fieldsets = (
(_('main'), {
'fields': (
'cart', 'date', 'status', 'user', 'name', 'surname', 'phone',
'email', 'delivery_time', 'delivery_type', 'storage_address',
'user_address', 'address_str', 'lift', 'deliverer'
LowerDeez /
Created Oct 19, 2018
Django. Example how to use a class as dacorator
from functools import wraps
from django.http.response import HttpResponse
from django.utils.decorators import available_attrs
from rest_framework_extensions.settings import extensions_api_settings
from django.utils import six
LowerDeez / script.html
Created Oct 8, 2018
Django. Conditions inside mail template
View script.html
{{ order }}: Order
{{ email }}: User email
{% if order.shipping_method.service|lower == "new_post" %}
Новая почта
{% else %}
Не Новая почта
{% endif %}
LowerDeez /
Created Oct 1, 2018
Django. Remove GET parameters with specific prefix from querystring
qs = request.META.get('QUERY_STRING', '')
querystring = qs.split('&')
filtered_querystring = filter(lambda p: not p.split('=')[0].startswith('utm_'), querystring)
qs = '&'.join(filtered_querystring)
You can’t perform that action at this time.