Skip to content

Instantly share code, notes, and snippets.

View iandenegri's full-sized avatar
🎯
Focusing

Ian Denegri iandenegri

🎯
Focusing
View GitHub Profile
@iandenegri
iandenegri / multiprocess_boi.py
Created December 16, 2021 03:41
Example of trying to use multiprocessing
import time
from PIL import Image, ImageFilter
def do_thing(duration:int=1):
print(f"Sleeping for {duration} second")
time.sleep(duration)
print("Done sleeping")
return "success"
def process_image(img_name):
import time
import threading
import concurrent.futures
start = time.perf_counter()
def do_thing(duration:int):
print(f"Sleeping for {duration} second")
time.sleep(duration)
print("Done sleeping")
@iandenegri
iandenegri / app.py
Created December 12, 2021 23:53
Python MongoDB practice using pymongo
import datetime
from pymongo import MongoClient
from bson.objectid import ObjectId
clust = MongoClient("mongodb://localhost:27017/")
print(clust)
db = clust["intro"]
print(db)
coll = db["introdb"]
@iandenegri
iandenegri / many_subflairs_jutsu.py
Last active September 19, 2021 18:31
Python PRAW Reddit Wrapper search many subreddits for many flairs
import praw
import datetime
class RedditPuller():
def __init__(self, *args, **kwargs):
pass
def reddit_oauth(self):
"""
Method required by bearer token authentication.
@iandenegri
iandenegri / local_var_mem_check.py
Created May 11, 2021 18:31
Local Variable Memory Usage Checker - Python
# Code snippets stolen from different SO threads and put together to accomplish variable checking in functions
import sys
from types import FunctionType
from gc import get_referents
def sizeof_fmt(num, suffix='B'):
''' by Fred Cirera, https://stackoverflow.com/a/1094933/1870254, modified'''
for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']:
if abs(num) < 1024.0:
@iandenegri
iandenegri / twitter_api_practice.py
Last active January 18, 2020 22:58
Twitter API Practice Party Rock Time :-)
import twitter
import twitter_config # Local file used to store private data like keys, etc.
api = twitter.Api(consumer_key=twitter_config.consumer_key,
consumer_secret=twitter_config.consumer_secret,
access_token_key=twitter_config.access_token_key,
access_token_secret=twitter_config.access_token_secret)
if api.GetStatus(1217704947225108481).current_user_retweet:
@iandenegri
iandenegri / rito_pls.py
Last active May 11, 2021 18:32
LEAGUE GRIEF CHECKER FOR RP
import requests
API_KEY = ""
def create_champion_mapping():
champ_map = dict()
champion_json = requests.get("http://ddragon.leagueoflegends.com/cdn/9.22.1/data/en_US/champion.json")
for champion in champion_json.json()['data']:
key = champion_json.json()['data'][champion]['key']
champ_map[key] = champion_json.json()['data'][champion]['id']
@iandenegri
iandenegri / shop.js
Created July 6, 2019 18:00
Program that uses Faker to generate 10 fake shop items and their prices.
const Faker = require("faker");
function fakeProducts(int){
for (let i = 0; i < int; i++){
console.log(Faker.commerce.productName() + " - $" + Faker.commerce.price());
};
};
fakeProducts(10);
@iandenegri
iandenegri / js_practice.js
Created July 6, 2019 17:22
Practicing basic Javascript functions to get more comfortable with Javascript
function echo(word, x){
for (i = 0; i < x; i++){
console.log(word);
};
};
echo("Echo!!", 10);
echo("Tater tots", 3);
@iandenegri
iandenegri / score-keep.html
Created June 23, 2019 23:41
Web application using HTML and vanilla JS to track scores between two players. Variable/id naming was done very poorly...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Score Keeper</title>
</head>
<body>
<h1 id="scoreboard">