Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
JoeThunyathep / resizeImages.py
Last active April 10, 2024 20:46
Resize images in a folder using Pillow
from PIL import Image
import pathlib
maxsize = (512, 512)
for input_img_path in pathlib.Path("input").iterdir():
output_img_path = str(input_img_path).replace("input","output")
with Image.open(input_img_path) as im:
im.thumbnail(maxsize)
im.save(output_img_path, "JPEG", dpi=(300,300))
print(f"processing file {input_img_path} done...")
@pedrominicz
pedrominicz / telnet.py
Last active April 19, 2023 20:53
Extremely simple "distributed echo server" server in Python (Telnet clients should be able to connect to it).
#!/usr/bin/env python3
import socket
# Read "distributed echo server" as "(distributed echo) server". The "server"
# is not "distributed" but the echos are "distributed" to every connected
# client.
# Connect to the server with `telnet localhost 5000`.
from keras_tqdm import TQDMNotebookCallback
batch_size = 32
history = model.fit_generator(
generator=training,
steps_per_epoch=training.samples // batch_size,
epochs=10,
callbacks=[TQDMNotebookCallback(leave_inner=True, leave_outer=True)],
validation_data=validation,
#Copyright 2022 Fabian Bosler
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#Copyright 2022 Fabian Bosler
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
@FBosler
FBosler / static_scraping.py
Last active September 20, 2022 14:17
Download data from wikipedia
#Copyright 2022 Fabian Bosler
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom
# the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
@loleg
loleg / grab-commons-images-sh
Last active January 8, 2025 07:33
Download images and metadata from a Wikimedia Commons category or results page
#!/bin/bash
#
# Download images from a Wikimedia Commons category
#
# Highest preview resolution and metadata in XML format will be saved in subfolders.
# Usage: execute this script on a Linux command line, providing the full URL to the category page.
#
# Shell tools required for this script: wget sed grep
#
@raelgc
raelgc / Email Server (Windows Only).md
Last active October 8, 2025 22:41
Setup a Local Only Email Server (Windows Only)