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
#!/usr/bin/env python3 | |
""" | |
Download the Detroit precinct reporting data from here: | |
https://election-county-reports-prod112020.s3.amazonaws.com/4539283c-3f09-4fdf-ad93-0bfd82d32be1/c64f9ade-9049-43ef-ab73-3feebc7ef5f0/Results%20per%20Precinct%20Data%20report.pdf | |
save it to /tmp/data.txt and this will anlayze the dem/repub reported vote counts and show their benford distribution | |
""" | |
data = open('/tmp/data.txt').readlines() |
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
#!/usr/bin/env python | |
""" | |
This is a dumb script and isn't too well written. The entire point is to take a string | |
like "business john" and print all combinations of upper/lower case letters for all | |
alpha characters in the string, e.g. | |
bUsiNEsS joHn | |
BuSInEsS JoHn | |
... |
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
{ | |
"Public Domain": { | |
"license_name": "Public Domain", | |
"license_full_name": "Public Domain Mark", | |
"license_text_url": "https://creativecommons.org/choose/mark/", | |
"license_attributes": { | |
"public_domain": true, | |
"required_attribution_upon_sharing": false, | |
"requires_share_alike": false, | |
"commercially_available": true, |
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
vis_motion_vectors () | |
{ | |
if [ "$#" -lt 1 ]; then | |
echo "Need an input file"; | |
return 1; | |
else | |
ffmpeg -y -loglevel error -flags2 +export_mvs -i "$1" -vf codecview=mv=pf+bf+bb /tmp/motion_vectors.mp4; | |
case "$(uname -s)" in | |
Linux*) vlc /tmp/motion_vectors.mp4;; | |
Darwin*) open /tmp/motion_vectors.mp4 -a vlc;; |
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
show_keyframes() { | |
ffprobe -loglevel error -select_streams v -show_frames -show_entries frame=pict_type -of csv $1 | grep -n I | cut -d ':' -f 1 | |
} | |
# use like | |
# $ show_keyframes /tmp/video.mp4 | |
# 1 | |
# 31 | |
# 61 | |
# 91 |
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
showcolor () { | |
if [ "$#" -lt 3 ]; then | |
echo "need to give 3 (r,g,b) values" | |
return 1 | |
fi | |
python -c "from PIL import Image; Image.new('RGB', (300, 300), ($1, $2, $3)).show()" | |
} | |
# use like | |
# $ showcolor 125 125 200 |
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
get_format_info () | |
{ | |
ffprobe -v error -select_streams v:0 -show_entries stream -of default=noprint_wrappers=1 -print_format json "$1" | |
} | |
# use like get_format_info /tmp/video.mp4 | |
# $ get_format_info /tmp/video.mp4 | |
{ | |
"programs": [ |
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
gifenc () | |
{ | |
palette="/tmp/palette.png"; | |
filters="fps=$4,scale=$3:-1:flags=lanczos"; | |
ffmpeg -v warning -i $1 -vf "$filters,palettegen" -y $palette; | |
ffmpeg -v warning -i $1 -i $palette -lavfi "$filters [x]; [x][1:v] paletteuse" -y $2 | |
} | |
# use like this to encode /tmp/video.mp4 to /tmp/output.gif at 240p and 12fps | |
# $ gifenc /tmp/video.mp4 /tmp/output.gif 240 12 |
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
function vidconcat { | |
TEMP=$(mktemp /tmp/temporary-file.XXXXXXXX) | |
for file in "$@" | |
do | |
echo "file '$file'" >> $TEMP | |
done | |
ffmpeg -loglevel error -hide_banner -f concat -safe 0 -i $TEMP -c copy /tmp/concat.mp4 | |
echo "concat video file is at /tmp/concat.mp4" | |
rm -f $TEMP | |
} |
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
#!/usr/bin/env python | |
import sys | |
import os | |
import random | |
def mockify_word(word): | |
last_cap = False | |
letters = list(word) | |
for index in range(0, len(letters)): | |
upper_chance = 1 |