Skip to content

Instantly share code, notes, and snippets.

@OldPanda
OldPanda / requirements.txt
Created February 25, 2024 05:36
A Python script to fetch Twitter user's profile via their API. Sometimes it works, sometimes it doesn't
certifi==2024.2.2
charset-normalizer==3.3.2
idna==3.6
requests==2.31.0
urllib3==2.2.1
@OldPanda
OldPanda / icon_cropper.py
Created December 8, 2023 05:09
Script to crop icon image with size 1024x1024 to 16x16, 32x32, 48x48, and 128x128, and cut the icon to be a rounded square.
from PIL import Image, ImageDraw, ImageOps
corner_radius = 100
def crop_to_circle(image_path, output_path, size):
original_image = Image.open(image_path)
square_image = ImageOps.fit(original_image, (1024, 1024), method=0, bleed=0.0, centering=(0.5, 0.5))
rounded_image = Image.new("RGBA", square_image.size, (255, 255, 255, 0))
draw = ImageDraw.Draw(rounded_image)
let rec is_odd_pos(num: int): bool =
if num = 0 then false
else is_even_pos(num - 1)
and is_even_pos(num: int): bool =
if num = 0 then true
else is_odd_pos(num - 1);;
let rec is_odd_neg(num: int): bool =
if num = 0 then false
else is_even_neg(num + 1)
git branch master
git checkout master
git branch -D main
git push origin master
git push origin :main
class MyDict(object):
def __init__(self, size=99999):
self.hash_list = [list() for _ in range(size)]
self.size = size
self.length = 0
def __setitem__(self, key, value):
hashed_key = hash(key) % self.size
for item in self.hash_list[hashed_key]:
if item[0] == key:
import json
import logging
import psycopg2
from lxml import html
from requests import session
DB_CONN = {
"host": "<your-db-host>",
name date suffix_col
test 2014-12-31 1234