This file contains hidden or 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 numpy as np | |
import pandas as pd | |
from random import choice, randint | |
names = ['David', 'James', 'John', 'Michael', 'Richard', 'Robert', 'William'] | |
surnames = ['Davis', 'Jones', 'Lee', 'Miller', 'Moore', 'Smith', 'Taylor'] | |
colors = ['Black', 'Blue', 'Green', 'Purple', 'Red', 'White', 'Yellow'] | |
pets = ['', 'Dog', 'Cat', 'Bird', 'Fish', 'Bunny', 'Hamster', 'Guinea Pig'] | |
def random_person(): |
This file contains hidden or 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
from pathlib import Path | |
# Input parameters | |
folders = ['/my/video/folder1', '/my/video/folder2'] | |
video_file_types = 'avi flv m4v mkv mov mp4 mpg wmv'.split(' ') | |
# Folders as pathlib objects | |
folders = [Path(folder) for folder in folders if Path(folder).is_dir()] | |
# List and sort all files from all folders |
This file contains hidden or 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 math | |
def human_readable_size(size_bytes, base=1024, decimal_places=2): | |
suffixes = 'B KB MB GB TB PB EB ZB YB'.split(' ') | |
if size_bytes == 0: | |
return '0B' | |
magnitude_index = int(math.floor(math.log(size_bytes, base))) | |
magnitude_bytes = math.pow(base, magnitude_index) | |
size = size_bytes / magnitude_bytes | |
suffix = suffixes[magnitude_index] |
This file contains hidden or 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
#!/home/bms/miniconda3/bin/python3 | |
# This script toggles status (enabled/disabled) of my notebook touchpad. My | |
# notebook is a Thinkpad 440p and its touchpad is a Synaptics TM2722-001. The | |
# system is Linux Mint. I map it to a keyboard shortcut (alt+F11 in my case). | |
# | |
# I tried just using: xinput disable 14 | |
# ... but the device id keeps changing after boot. | |
# | |
# I tried just using: xinput disable "Synaptics TM2722-001" |
This file contains hidden or 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
from pathlib import Path | |
import cv2 | |
import numpy as np | |
def make_mosaic(cap, n_rows=4, n_cols=5): | |
n_frames = n_rows * n_cols | |
cap_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT)) | |
floor = int(cap_frames*0.05) | |
ceil = int(cap_frames*0.95) | |
frames_indexes = np.linspace(floor, ceil, n_frames).astype(int) |
This file contains hidden or 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
# Imports to download the wav file. Not necessary for local files. | |
from requests import get | |
from io import BytesIO | |
# Import to read the wav file. | |
from scipy.io import wavfile | |
# Import to plot the waveform. | |
import matplotlib.pyplot as plt |
NewerOlder