Skip to content

Instantly share code, notes, and snippets.

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]
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))
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))
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))
@simrit1
simrit1 / adt.py
Created October 16, 2021 20:07 — forked from aarondewindt/adt.py
Experimental Algebraic Data Types implementation in Python 3.10
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
@simrit1
simrit1 / sets.py
Created November 16, 2021 07:20 — forked from infiniteregrets/sets.py
"""
MacOS:
brew install chromedriver && pip3 install beautifulsoup4 selenium
Todo:
- Put driver and set calculation on a different process
- Haskell!
~ Mehul
"""
@simrit1
simrit1 / auto_delete
Created November 17, 2021 06:08 — forked from saralgyaan/auto_delete
This script auto deletes messages from your gmail inbox.
#!/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)
"""
@simrit1
simrit1 / accumConditionalPattren_2.py
Created December 17, 2021 03:19 — forked from mayankdawar/accumConditionalPattren_2.py
Challenge For each word in words, add ‘d’ to the end of the word if the word ends in “e” to make it past tense. Otherwise, add ‘ed’ to make it past tense. Save these past tense words to a list called past_tense.
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)
@simrit1
simrit1 / PuLP_TSP.py
Created January 24, 2022 05:38 — forked from MaxvanHaastrecht/PuLP_TSP.py
Creating a TSP ILP in PuLP
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))
@simrit1
simrit1 / colouring_book.py
Created January 24, 2022 05:39 — forked from MaxvanHaastrecht/colouring_book.py
Creating a personalised colouring book from your own photos
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')