Skip to content

Instantly share code, notes, and snippets.

@doubledare704
doubledare704 / env_property_example.py
Created August 23, 2021 08:33
decorator for properties, that will try to get ENV variable or return value from property method.
import os
from typing import Optional, Any
def get_env_var(var_name: str) -> Optional[str]:
return os.environ.get(var_name)
def env_prop(fn=None, name=None):
def env_prop_decorator(func):
@doubledare704
doubledare704 / digitalocean.txt
Created July 31, 2019 14:02
Digital ocean referal link with 50$ for 1 month! https://m.do.co/c/4b585b1b69c8
https://m.do.co/c/4b585b1b69c8
@doubledare704
doubledare704 / main.py
Created February 28, 2019 11:16
Find a pair of two created by doubledare704 - https://repl.it/@doubledare704/Find-a-pair-of-two
def magic_sum_of_two(number_list, magic_number):
print("We should find pair of numbers to sum a magic one")
print("For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17.")
print(f"Number list: {number_list}")
print(f"Magic number: {magic_number}")
for idx, val in enumerate(number_list):
temp_n = magic_number - val
if temp_n in number_list:
print(f"The answer is {temp_n} {val}")
@doubledare704
doubledare704 / screenshoter.py
Created January 5, 2018 14:11
python screenshots with opencv
import numpy as np
import pyautogui
import cv2
import datetime
import time
import os
p = os.path.dirname(os.path.abspath(__file__))
p = p + '/screens/'
ts = time.time()
@doubledare704
doubledare704 / gridchallenge.py
Created July 4, 2016 18:29
Grid challenge of hacker rank
import copy
def checking_grid():
N = int(input())
L, iL, answer = [], [], ''
for i in range(N):
L.append(list(input()))
for idx,item in enumerate(L):
item.sort()
import numpy as np
n = 10
a = np.random.randint(0, 10, (n, n, n))
print("All matrix: {0}".format(a))
columns = a.sum(axis=0)
rows = a.sum(axis=1)
z_s = a.sum(axis=2)
t = columns.max()
def compareInteger(a,b):
stringa = str(a)
stringb = str(b)
for i in xrange(min(len(stringa), len(stringb))):
if stringa[i] > stringb[i]:
return 1
elif stringa[i] < stringb[i]:
return -1
if len(stringa) > len(stringb):
return compareInteger(stringa[len(stringb):], stringb)