This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://stackoverflow.com/a/30168962/6766934 | |
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 | |
collector.collect(SectionTypeDescriptor.objects.all()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, datetime.now()) | |
def calc_recv_timestamp(recv_time_stamp, counter): | |
for id in range(len(counter)): |