Skip to content

Instantly share code, notes, and snippets.

@jayvynl
jayvynl / docx_thumbnail.py
Last active September 12, 2024 07:57
pywin32 capture thumbnail of first page of docx document
import os.path
import time
from PIL import ImageGrab
from win32com.client import constants
import win32com.client as win32
def create_docx_thumbnail(docx_file, output_image):
# Launch the Word application
@jayvynl
jayvynl / broadcast.py
Last active July 12, 2023 09:05
python udp broadcast
import atexit
import fcntl
import socket
import struct
import time
import traceback
INTERVAL = 5
sockets = {}
@jayvynl
jayvynl / redis_cache.py
Last active August 16, 2024 12:07
python redis cache decorator
import json
import logging
from functools import wraps, _make_key
from inspect import getfullargspec
import redis
logger = logging.getLogger(__name__)
rs = redis.StrictRedis()