Skip to content

Instantly share code, notes, and snippets.

View TonyChangho's full-sized avatar

TonyChangho

View GitHub Profile
@TonyChangho
TonyChangho / valid-domain.js
Last active April 19, 2020 18:19
JavaScript regex code for validating fully-qualified domain names per RFCs 1034 and 1123
/*
Per https://www.ietf.org/rfc/rfc1034.txt, Section 3.5. and https://tools.ietf.org/html/rfc1123, Section 2.1:
- Domains (whether TLD or subdomains) consist of labels, separated by dots when there's more than one (e.g., gist.github.com)
- Labels must start and end with a letter or a digit, and can have zero or more letters, digits, or hyphens between (e.g., the
following are all valid: a.com, aa.com, a1.com, 1.com, 11.com, 1a.com, a-a.com, a-1.com, 1-a.com, 1-1.com, a--a.com)
- Labels can only be a max of 63 characters
- Domains can only be a maximum of 255 characters
So, we'll look for a TLD label, and then in front of that, one or more subdomain labels trailed with a dot, with no more than 63
@TonyChangho
TonyChangho / ffmpeg.sh
Last active June 26, 2020 05:24
ffmpeg cheat sheet
# Encode a video in H.264 with a constant rate factor of 0 (visually non-lossy), run it through a filter for deinterlacing (Weston
# Three-Field), and do not re-encode the audio
ffmpeg -i input.mkv -c:v libx264 -crf 0 -filter:v w3fdif -c:a copy output_edit-x264-crf0-w3fdif.mkv
# H.264 video at an average bitrate of 25MB/s, and just copy the audio
# - `-an` disables audio on first pass
# - `-y` automatically overwrites an existing output file, but don't worry since it's /dev/null on the first pass
ffmpeg -y -i input.mkv -c:v libx264 -b:v 25000k -pass 1 -an -f mp4 /dev/null && \
ffmpeg -i input.mkv -c:v libx264 -b:v 25000k -pass 2 -c:a copy output_edit-x264-abr25000.mkv