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 re | |
step_list = ['1. Pour\n2. Lather\n2. Rinse\n3. Repeat', # Note two step 2's. | |
'1. Start filling with water\n1. Open Lid\n1. Load\n2. Add detergent\n3. Add fabric softener\n4. Add clothes\n5. Close lid', # Note 3 step 1's | |
'1. Put toothpaste on brush\n2. Rub toothbrush on all teeth for two minutes, spit as necessary\n3. Rinse mouth\n4. Floss\n5. Swish mouthwash in mouth for 30 seconds\n6. Gargle, spit'] | |
new_step_list = [] | |
for row in step_list: | |
if re.match(r'^\d+\. ', row): |
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
#!/bin/bash | |
for f in `find -maxdepth 1 . -type f -name '*.zip'`; do | |
datetime=`date -j -f "%y-%b-%d %H:%M" "$(zipinfo $f | head -n 3 | tail -n 1 | awk '{print $7 " " $8}')" +"%Y%m%d%H%M"`; | |
echo "$f $datetime" | |
# To rename, appending the date instead: mv $i `echo "$i" | sed -e "s/\(.*\)\(\..*\)/\1_${datetime}\2/"`; | |
done |
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
test_info = { | |
'old_macs': { | |
'processors': [ | |
{'68000': [ | |
{'name': 'Mac 128k', 'color': False}, | |
{'name': 'Mac 512k', 'color': False}, | |
{'name': 'Mac Plus', 'color': False}, | |
{'name': 'Mac SE', 'color': False}, | |
]}, | |
{'68020': [ |
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
# To pass in the correct input, you need to use Automator on macOS. | |
# First, add in the "Find Calendar Events" Action and set it to find events where "Date starting" "is today". | |
# Then, pass that to the "Event Summary" Action. | |
# Finally, add a "Run Shell Script" Action and paste the following into it. | |
import sys | |
import re | |
cal_array = [] |
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 jinja2 import Template | |
from datetime import datetime, timedelta | |
today = datetime.now() | |
date_today = datetime(today.year, today.month, today.day) | |
day_of_the_week = date_today.weekday() | |
date_start_delta = timedelta(-(date_today.weekday())) | |
date_start = date_today + date_start_delta # Result should be Monday of this week. | |
date_end_delta = timedelta(4) | |
date_end = date_start + date_end_delta # Result should be Friday of this week. |
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 sys | |
import re | |
from collections import defaultdict | |
# Script takes in a GitHub-Flavored-Markdown table assuming the following format: | |
# | |
# Start | Stop | Task | |
# ----- | ---- | ---- | |
# 9:20 | 9:40 | Email/Admin | |
# 9:40 | 11:30 | Automation |
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
# Find a sequence of files and remove them in parallel with xargs. Helpful for FUSE-based object stores attached to VMs. | |
find . -type f -name "file*.png" | xargs rm -n 1 -P 8 |
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
for i in `seq -f '%06g' 1 10`; do echo "/path/to/file.${i}.png"; done | xargs > ./filelist.txt | |
# ^Generate a space-delimited list of filenames and output it to `filelist.txt`. | |
# Contents of `filelist.txt`: | |
# /path/to/file.000001.png /path/to/file.000002.png /path/to/file.000003.png /path/to/file.000004.png /path/to/file.000005.png /path/to/file.000006.png /path/to/file.000007.png /path/to/file.000008.png /path/to/file.000009.png /path/to/file.000010.png | |
gsutil cp -m `cat ./filelist.txt` gs://png-bucket/path/to/receptacle/ | |
# ^Read the list of files as an argument to gsutil and use multithreaded copy to copy to the bucket. |
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
# This is my frame range calculator. There are many like it, but this one is mine. | |
# Python 2 and 3 compatible. The division method becomes less optimal as the number increases, but | |
# it works for the use case of relatively small numbers of divisions (up to a few dozen). | |
import math | |
import argparse | |
argparser = argparse.ArgumentParser() |
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
test = 'hello' | |
print(test[:-1] == 'hell') | |
# returns "True" | |
print(test[:-1] is 'hell') | |
# returns "False", these do not point to the same object in memory. |