Skip to content

Instantly share code, notes, and snippets.


Daniil Manakovskiy WinnerOK

  • Innopolis University
View GitHub Profile
WinnerOK /
Last active Sep 25, 2020
Vector clock implementation
from multiprocessing import Process, Pipe
from os import getpid
from datetime import datetime
from time import sleep
def local_time(counter):
return '| (VECTOR_TIME={}, LOCAL_TIME={})'.format(counter,
def calc_recv_timestamp(recv_time_stamp, counter):
for id in range(len(counter)):
WinnerOK /
Created Sep 16, 2020
Simple square-multiply exponentiation
base, exp, mod = list(map(int, input("Enter base power mod: ").split()))
r = 1
for i in bin(exp)[2:]:
bit = int(i)
r = (r * r) % mod
if bit == 1:
r = (r * base) % mod
print(f"Answer: {r}\nr == (base ** exp) % mod: {r == (base ** exp) % mod}")
WinnerOK /
Last active Sep 15, 2020
File uploading by sockets in Python
import argparse
import sys
import socket
import os
# Validate that file exists.
# It was possible to use type=argparse.FileType("wb")
# But it outputs raw exception on error
def is_valid_file(parser, arg):
WinnerOK /
Created Jun 25, 2020
[django] export object with dependants
from itertools import chain
from django.core import serializers
from django.contrib.admin.utils import NestedObjects
from tasks.models import SectionTypeDescriptor
collector = NestedObjects(using="default") # database name
WinnerOK / segment_intersection.go
Created Dec 7, 2019
Find out wheter segments AB CD intersect
View segment_intersection.go
type point struct {
x int
y int
func pointSum(p1, p2 point) point {
return point{
x: p1.x + p2.x,
y: p1.y + p2.y,
You can’t perform that action at this time.