This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! -f .env ] | |
then | |
export $(cat .env | xargs) | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from PIL import Image | |
image = Image.open(requests.get(url, stream=True).raw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import base64 | |
import struct | |
import boto3 | |
import paramiko | |
from paramiko.util import deflate_long | |
PEM_FILEPATH = '~/.ssh/test-key.pem' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ignores commented out lines and handles spaces | |
# https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-pair-values | |
export $(grep -v '^#' .env | xargs -d '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# DESCRIPTION: | |
# | |
# Set the bash prompt according to: | |
# * the active virtualenv | |
# * the branch/status of the current git repository | |
# * the return value of the previous command | |
# * the fact you just came from Windows and are used to having newlines in | |
# your prompts. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# USAGE | |
# bash ./parallel_download.sh url_list.txt | |
set -o nounset | |
set -o errexit | |
FILELIST=$1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT *, pg_size_pretty(total_bytes) AS total | |
, pg_size_pretty(index_bytes) AS index | |
, pg_size_pretty(toast_bytes) AS toast | |
, pg_size_pretty(table_bytes) AS table | |
FROM ( | |
SELECT *, total_bytes-index_bytes-coalesce(toast_bytes,0) AS table_bytes FROM ( | |
SELECT c.oid,nspname AS table_schema, relname AS table_name | |
, c.reltuples AS row_estimate | |
, pg_total_relation_size(c.oid) AS total_bytes | |
, pg_indexes_size(c.oid) AS index_bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This works when running code as script, module and with doctests. | |
Also sets the log level for imported packages like requests. | |
python -m mymodule.myfile | |
python mymodule/myfile.py | |
python -m unittest mymodule/myfile.py | |
""" | |
import logging |
NewerOlder