Skip to content

Instantly share code, notes, and snippets.

@secemp9
secemp9 / threading_wait4.py
Last active February 6, 2024 13:18
Threading wait POC 4
import threading
import time
import signal
class ControlledExecution:
def __init__(self):
self.lock = threading.Lock()
self.condition = threading.Condition(self.lock)
self.shutdown = False
@secemp9
secemp9 / threading_wait3.py
Created February 6, 2024 12:28
Threading wait POC 3
import threading
import time
class ControlledExecution:
def __init__(self):
self.lock = threading.Lock()
self.condition = threading.Condition(self.lock)
self.shutdown = False
def worker(self):
@secemp9
secemp9 / threading_wait2.py
Created February 6, 2024 12:06
Threading wait POC 2
import threading
import time
import signal
class ControlledExecution:
def __init__(self):
self.lock = threading.Lock()
self.condition = threading.Condition(self.lock)
self.shutdown = False
@secemp9
secemp9 / threading_wait.py
Created February 6, 2024 12:06
Threading wait POC
import threading
import time
class ControlledExecution:
def __init__(self):
self.lock = threading.Lock()
self.condition = threading.Condition(self.lock)
self.shutdown = False
def worker(self):
@secemp9
secemp9 / scrape_test.py
Created January 26, 2024 19:05
scraping...
import time
from io import BytesIO
import cv2
import numpy as np
import pytesseract
import requests
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
@secemp9
secemp9 / loom_video_links.py
Last active January 26, 2024 06:01
Get video links from Loom's folder link (no commandline support)
@secemp9
secemp9 / loom_video_links.py
Last active January 26, 2024 05:33
Loom get video links from folder (version that work with commandline)
@secemp9
secemp9 / hungarian_numpy.py
Created January 22, 2024 16:56
hungarian algorithm for the assignment problem (using numpy)
import numpy as np
def hungarian_algorithm(cost_matrix):
N = len(cost_matrix)
max_cost = np.max(cost_matrix)
cost_matrix = max_cost - cost_matrix # Convert to a profit matrix
# Step 1: Subtract the row minimum from each row
for i in range(N):
cost_matrix[i] -= np.min(cost_matrix[i])
@secemp9
secemp9 / tkinter_random_word.py
Created January 20, 2024 18:15
tkinter random word replace
import tkinter as tk
from tkinter import scrolledtext
import requests
import random
import re
def fetch_text(url):
try:
response = requests.get(url)
response.raise_for_status()
@secemp9
secemp9 / sudoku_solver.py
Created January 19, 2024 09:57
Solving sudoku
import time
class Sudoku:
def __init__(self, board):
if not self.is_valid_input(board):
raise ValueError("Board must be a 9x9 grid of integers from 0 to 9.")
self.board = board
self.steps = 0
def is_valid_input(self, board):