Skip to content

Instantly share code, notes, and snippets.

@mihow
mihow / parallel_download.sh
Last active February 4, 2023 00:08
Bash Parallel File Download
#!/bin/bash
# USAGE
# bash ./parallel_download.sh url_list.txt
set -o nounset
set -o errexit
FILELIST=$1
@mihow
mihow / send_get_as_post.py
Created March 14, 2023 01:16
Send a GET request as a POST to overcome 414 Request-URI Too Large
# Submit a "GET" request via POST so we can send
# more data than fits in a URL
resp = requests.post(
url,
headers = {'X-HTTP-Method-Override': 'GET'},
data=params)
@mihow
mihow / image_from_url.py
Created September 11, 2023 23:10
Load image into PIL object from URL with streaming request, one line
import requests
from PIL import Image
image = Image.open(requests.get(url, stream=True).raw)
@mihow
mihow / example_matching_rows.sql
Created January 25, 2024 01:24
5 example matching rows for each category in a joined table (PostgreSQL)
SELECT c.category_name, i.image_id FROM categories c
CROSS JOIN LATERAL (
SELECT image_id
FROM image_hashes v
WHERE v.category_id = c.category_id
LIMIT 5
) i;