This file contains hidden or 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 math | |
import numpy as np | |
from timebudget import timebudget | |
iterations_count = round(1e7) | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) | |
[math.exp(i) * math.sinh(i) for i in [1] * iterations_count] |
This file contains hidden or 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 math | |
import numpy as np | |
from timebudget import timebudget | |
from multiprocessing import Pool | |
iterations_count = round(1e7) | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) |
This file contains hidden or 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 math | |
import numpy as np | |
from timebudget import timebudget | |
import ipyparallel as ipp | |
iterations_count = round(1e7) | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) |
This file contains hidden or 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 math | |
import numpy as np | |
from timebudget import timebudget | |
import ray | |
iterations_count = round(1e7) | |
@ray.remote | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) |
This file contains hidden or 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 dataclasses import dataclass | |
class ADTMeta(type): | |
def __new__(mcs, name, bases, namespace: dict): | |
adtc_class = super().__new__(mcs, name, bases, namespace) | |
if "__is_adt_variant__" in namespace: | |
if namespace["__is_adt_variant__"]: | |
return adtc_class |
This file contains hidden or 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
""" | |
MacOS: | |
brew install chromedriver && pip3 install beautifulsoup4 selenium | |
Todo: | |
- Put driver and set calculation on a different process | |
- Haskell! | |
~ Mehul | |
""" |
This file contains hidden or 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
#!/usr/bin/python3.6 | |
"""AutoDelete | |
This script auto deletes messages from your gmail inbox. | |
The perfect usecase is deleting the OTP messages received from banks after certain time period. | |
or deleting the messages received from certain services which doesn't have unsubscribe option. | |
Many parts of this script are copied from EZGmail by Al Sweigart (https://github.com/asweigart/ezgmail) | |
""" |
This file contains hidden or 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
words = ["adopt", "bake", "beam", "confide", "grill", "plant", "time", "wave", "wish"] | |
past_tense = [] | |
for i in words: | |
if(i[len(i)-1] == 'e'): | |
i += 'd' | |
else: | |
i += 'ed' | |
past_tense.append(i) |
This file contains hidden or 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 pulp as pl | |
# Define PuLP model | |
model = pl.LpProblem('TSP', pl.LpMinimize) | |
# Define binary variables | |
x = pl.LpVariable.dicts('x', ((i, j) for i in range(n_perm) for j in range(n_perm)), cat = 'Binary') | |
# Set the objective function | |
model += pl.lpSum(cost_dict[permutations[i], permutations[j]] * x[i, j] for i in range(n_perm) for j in range(n_perm)) |
This file contains hidden or 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 numpy as np | |
import matplotlib.pyplot as plt | |
from skimage import io | |
import skimage.color as color | |
import skimage.segmentation as seg | |
# Read the image you want to process | |
image = io.imread('image.png') |