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 /
Created Oct 24, 2019 — forked from MaxBareiss/
Fréchet Distance in Python
# 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 /
Last active Oct 30, 2018
Install Oracle 12c onto 64-bit Ubuntu 16.04 or Linux Mint 18 Sarah
# ---------------------------------------------------------------------------------
# This script written by Howard Rogers.
# It's purpose is to install Oracle 12c onto 64-bit Ubuntu 16.04.
# See for some details.
# Copyright (c) 2016 Howard Rogers,Dizwell Informatics
pikhovkin /
Created Sep 30, 2018
Dash simple example on Django
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
def metaclass_resolver(*classes, **options):
"""Metaclass resolver
SomeClass(metaclass_resolver(ClassMixin, BaseClass, SomeActionClass, some_field1=True, some_field2=42)):
:param classes:
:param options:
pikhovkin /
Created Jan 29, 2018
Get all pathes from Django project
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 /
Created Oct 10, 2017 — forked from pyrocat101/
Encode multipart/form-data in python
_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 /
Created Oct 29, 2016
Test for the Ramax
# -*- coding: utf-8 -*-
__all__ = (
pikhovkin /
Last active Mar 28, 2020
Patch for openpyxl 2.1.2 for basic reading images. and are in the patch_reader package
# coding: utf-8
from __future__ import absolute_import
import os.path
from io import BytesIO
from openpyxl.xml.constants import (PACKAGE_WORKSHEET_RELS,
pikhovkin /
Last active Aug 29, 2015
Parser "if then else" expression
# 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 /
Last active Aug 29, 2015
Django-middleware for auto login in DEBUG mode
# 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.