Skip to content

Instantly share code, notes, and snippets.

Sergei Pikhovkin pikhovkin

Block or report user

Report or block pikhovkin

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
@pikhovkin
pikhovkin / frechet.py
Created Oct 24, 2019 — forked from MaxBareiss/frechet.py
Fréchet Distance in Python
View frechet.py
# Euclidean distance.
def euc_dist(pt1,pt2):
return math.sqrt((pt2[0]-pt1[0])*(pt2[0]-pt1[0])+(pt2[1]-pt1[1])*(pt2[1]-pt1[1]))
def _c(ca,i,j,P,Q):
if ca[i,j] > -1:
return ca[i,j]
elif i == 0 and j == 0:
ca[i,j] = euc_dist(P[0],Q[0])
elif i > 0 and j == 0:
@pikhovkin
pikhovkin / mandela.sh
Last active Oct 30, 2018
Install Oracle 12c onto 64-bit Ubuntu 16.04 or Linux Mint 18 Sarah
View mandela.sh
#!/bin/bash
# ---------------------------------------------------------------------------------
# This script written by Howard Rogers.
#
# It's purpose is to install Oracle 12c onto 64-bit Ubuntu 16.04.
#
# See http://www.dizwell.com/wordpress/technical-articles/oracle/install-oracle-12c-on-ubuntu-16-04/ for some details.
#
# Copyright (c) 2016 Howard Rogers,Dizwell Informatics
@pikhovkin
pikhovkin / dash_simple_example.py
Created Sep 30, 2018
Dash simple example on Django
View dash_simple_example.py
from datetime import datetime as dt
from django.conf import settings
from django.conf.urls import include, url
from dash import BaseDashView, Dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from pandas_datareader import data as web
View metaclass_resolver.py
def metaclass_resolver(*classes, **options):
"""Metaclass resolver
Example:
SomeClass(metaclass_resolver(ClassMixin, BaseClass, SomeActionClass, some_field1=True, some_field2=42)):
pass
:param classes:
:param options:
:return:
@pikhovkin
pikhovkin / django_urls.py
Created Jan 29, 2018
Get all pathes from Django project
View django_urls.py
from django.urls import RegexURLResolver, RegexURLPattern, get_resolver
from django.utils.regex_helper import normalize
r = get_resolver()
r._up = ''
urlpatterns = [r]
urls = []
while urlpatterns:
u = urlpatterns.pop(0)
@pikhovkin
pikhovkin / multipart.py
Created Oct 10, 2017 — forked from pyrocat101/multipart.py
Encode multipart/form-data in python
View multipart.py
_CONTENT_TYPES = { '.png': 'image/png', '.gif': 'image/gif', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.jpe': 'image/jpeg' }
def _encode_multipart(**kw):
'''
Build a multipart/form-data body with generated random boundary.
'''
boundary = '----------%s' % hex(int(time.time() * 1000))
data = []
for k, v in kw.iteritems():
data.append('--%s' % boundary)
@pikhovkin
pikhovkin / ma.py
Created Oct 29, 2016
Test for the Ramax
View ma.py
# -*- coding: utf-8 -*-
__all__ = (
'MyError',
'Parent',
'First',
'Second',
'A',
)
@pikhovkin
pikhovkin / drawings.py
Last active Mar 28, 2020
Patch for openpyxl 2.1.2 for basic reading images. drawings.py and excel.py are in the patch_reader package
View drawings.py
# coding: utf-8
from __future__ import absolute_import
import os.path
from io import BytesIO
from openpyxl.xml.constants import (PACKAGE_WORKSHEET_RELS,
REL_NS,
PACKAGE_RELS,
PACKAGE_IMAGES,
@pikhovkin
pikhovkin / ifthenelse.py
Last active Aug 29, 2015
Parser "if then else" expression
View ifthenelse.py
# coding: utf-8
from funcparserlib.lexer import make_tokenizer, Spec
from funcparserlib.parser import (maybe, many, eof, skip, oneplus, fwd,
name_parser_vars, memoize, SyntaxError)
from funcparserlib.util import pretty_tree
from funcparserlib.contrib.common import unarg, flatten, n, op, op_, sometoks
from funcparserlib.contrib.lexer import (make_comment, make_multiline_comment,
newline, space)
@pikhovkin
pikhovkin / middlewares.py
Last active Aug 29, 2015
Django-middleware for auto login in DEBUG mode
View middlewares.py
# coding: utf-8
from django.contrib import auth
from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.shortcuts import redirect
User = auth.get_user_model()
You can’t perform that action at this time.