Skip to content

Instantly share code, notes, and snippets.

@jnhmcknight
jnhmcknight / download_large_file.py
Created October 25, 2023 16:43 — forked from wasi0013/download_large_file.py
how to download large file using python, requests without exhausting device ram.
import requests
chunk_size = 4096
filename = "logo.png"
document_url = "https://wasi0013.files.wordpress.com/2018/11/my_website_logo_half_circle_green-e1546027650125.png"
with requests.get(document_url, stream=True) as r:
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size):
if chunk:
f.write(chunk)
@jnhmcknight
jnhmcknight / postgres_queries_and_commands.sql
Last active November 4, 2022 13:36 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show granted locks
SELECT blocked_locks.pid AS blocked_pid,
blocked_activity.usename AS blocked_user,
blocking_locks.pid AS blocking_pid,
blocking_activity.usename AS blocking_user,
blocked_activity.query AS blocked_statement,
blocking_activity.query AS current_statement_in_blocking_process
FROM pg_catalog.pg_locks AS blocked_locks
JOIN pg_catalog.pg_stat_activity AS blocked_activity ON blocked_activity.pid = blocked_locks.pid
JOIN pg_catalog.pg_locks AS blocking_locks