Skip to content

Instantly share code, notes, and snippets.

View ThePyProgrammer's full-sized avatar
💻
Dying of Multiple Project Setting and Abandoning Disorder (MPSAD)

Prannaya Gupta ThePyProgrammer

💻
Dying of Multiple Project Setting and Abandoning Disorder (MPSAD)
View GitHub Profile
@ThePyProgrammer
ThePyProgrammer / devpost.py
Created February 27, 2024 12:59
Track down all Devpost Hackathon Projects via Participant List (when project gallery isn't released)
import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from bs4 import BeautifulSoup
from tqdm import tqdm
import pandas as pd
# Set up the Chrome WebDriver
driver = webdriver.Chrome()
@ThePyProgrammer
ThePyProgrammer / config-highlight.cfg
Created February 11, 2023 09:46
Themes built just for Python IDLE
[IDLE Classic]
normal-foreground= #000000
normal-background= #ffffff
keyword-foreground= #ff7700
keyword-background= #ffffff
builtin-foreground= #900090
builtin-background= #ffffff
comment-foreground= #dd0000
comment-background= #ffffff
string-foreground= #00aa00
@ThePyProgrammer
ThePyProgrammer / asm.sh
Created August 23, 2022 09:36
Run x86 ASM Assembly from WSL2
file=$1
patharr=(${file//./ })
finalexe=${patharr[0]}
nasmfile="${finalexe}.o"
nasm -f elf64 $file
ld -s -o $finalexe $nasmfile
@ThePyProgrammer
ThePyProgrammer / clone.sh
Created May 23, 2022 15:37
A simple shell script to simplify the cloning process.
if (( $# == 1 )); then
# if only one argument is given (that is that directory = name of repo)
git clone $1
repo=$1
repo2arr=(${repo//// }) # split string into list by `/`
gitname=${repo2arr[-1]} # get last value
git2arr=(${gitname//./ }) # split by `.`
name=${git2arr[0]} # get first place
echo "Created repo at $name"
cd $name # move into directory
@ThePyProgrammer
ThePyProgrammer / panda.py
Created September 14, 2021 09:01
A utitlity function list that can allow simpler code.
import requests
import pandas as pd
import re
from io import StringIO
def read_csv(loc, *args, **kwargs):
if re.search(r"[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)", loc):
return read_csv(requests.get(loc, allow_redirects=True).content, *args, **kwargs)
loc = loc.strip("\n")
if re.search(r"[\n:<>\"/\|?*]", loc):
@ThePyProgrammer
ThePyProgrammer / image.py
Last active September 14, 2021 08:58
An Image Class for simplistic processing of images.
import numpy as np
import matplotlib.pyplot as plt
import cv2
from skimage.color import rgb2gray, gray2rgb
from skimage import filters
from skimage.transform import rescale, resize, downscale_local_mean, swirl
from skimage.filters import threshold_otsu, threshold_local, try_all_threshold
import skimage.io as skio
from PIL import Image, ImageOps
@ThePyProgrammer
ThePyProgrammer / pearson.py
Last active August 22, 2021 17:28
Computing the Pearson Correlation Coefficient in NumPy, without any involvement of SciPy.
import numpy as np
# Functions I painstakingly researched and coded with 2 shots of coffee at 3 am
def gamma(n):
"""
A Simplified Gamma Function for "powers" of 1/2
Gamma Function for Integers are given by: Γ(n) = (n-1)!
Gamma Function for Values ending with 1/2: Γ(n) = 0.5 * 1.5 * ... * (n-1) * √(π)
@ThePyProgrammer
ThePyProgrammer / convolution.py
Last active December 22, 2021 03:15
2D Convolution of Image using a complex Numpy algorithm with constant speed-up.
import numpy as np
def convolve(image, kernel):
# We start off by defining some constants, which are required for this code
kernelH, kernelW = kernel.shape
imageH, imageW = kernel.shape
h, w = imageH + 1 - kernelH, imageW + 1 - kernelW
# filter1 creates an index system that calculates the sum of the x and y indices at each point
# Shape of filter1 is h x kernelW
@ThePyProgrammer
ThePyProgrammer / commit.sh
Created July 18, 2021 14:28
A simple shell script to run commits in a single line
# First let's check the status
git status
# We now add the file as in the arguments
for i in $(seq 2 $#);
do git add ${!i};
done
# Commit files based on first argument
git commit -m "$1"
@ThePyProgrammer
ThePyProgrammer / Point.cpp
Last active June 5, 2021 17:42
A Point class in CPP.
//
// Created by ThePyProgrammer on 5/6/2021.
//
#include <cmath>
#include "Point.h"
#include <limits>
Point::Point(double x, double y) {