Skip to content

Instantly share code, notes, and snippets.

View deliro's full-sized avatar
🦀
Rust in action

deliro

🦀
Rust in action
  • Tochka Bank
  • Russia
View GitHub Profile
def calculate_volume(relief):
left_max = 0
right_max = 0
left = 0
right = len(relief) - 1
volume = 0
while left < right:
if relief[left] > left_max:
left_max = relief[left]
from django.template.defaultfilters import slugify as django_slugify
alphabet = {'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd', 'е': 'e', 'ё': 'yo', 'ж': 'zh', 'з': 'z', 'и': 'i',
'й': 'j', 'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't',
'у': 'u', 'ф': 'f', 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ы': 'i', 'э': 'e', 'ю': 'yu',
'я': 'ya'}
def slugify(s):
"""
class Matrix(object):
data = None
def __init__(self, data):
self.data = data
self.columns = len(self.data)
self.rows = len(self.data[0])
def get(self, t):
return self.data[t[0]][t[1]]
# coding: utf-8
# requirements:
# requests
# beautifulsoup4
# flask
# html5lib
import re
import webbrowser
@deliro
deliro / gunicorn.service
Created July 19, 2016 16:36
Create systemd service
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:/home/sammy/myproject/myproject.sock myproject.wsgi:application
@deliro
deliro / bloom.py
Created January 18, 2017 11:24
Bloom filter on pure python
from math import log
from array import array
from struct import unpack
from hashlib import sha512
class Bits:
__slots__ = ('data',)
def __init__(self, cap):
#!/usr/bin/env python3
import argparse
import csv
import os
import re
import subprocess
import sys
from collections import OrderedDict, namedtuple
from datetime import datetime, timedelta
@deliro
deliro / find_ip.py
Created July 6, 2018 13:15
Find a subnet that contains ip
from heapq import heappush
from functools import total_ordering, reduce
def ip(s):
return reduce(lambda r, c: c + (r << 8), map(int, s.split(".")), 0)
@total_ordering
class Subnet:
def __init__(self, start, end):
self.start = start
@deliro
deliro / Dockerfile
Last active April 17, 2020 12:33
python alpine lxml image example
FROM python:3.7-alpine
EXPOSE 8000
WORKDIR /app
COPY . .
RUN apk add --update --no-cache --virtual .build-deps \
g++ \
python-dev \
libxml2 \
libxml2-dev && \
@deliro
deliro / Dockerfile
Created October 10, 2018 12:51
node-to-python multi-stage Vue project build
FROM node:9-alpine AS admin-build
WORKDIR /app
COPY manager .
RUN npm install && npm run build
FROM python:3.7-alpine3.7
EXPOSE 5000
WORKDIR /app