Skip to content

Instantly share code, notes, and snippets.

View PythonCoderAS's full-sized avatar

PythonCoderAS PythonCoderAS

  • New York City
  • 10:53 (UTC -04:00)
View GitHub Profile
for file in huge/*.{mov,mp4}(N)
do
duration=`ffprobe -v error -show_entries format=duration -of csv=p=0 $file`
duration=$((duration-3))
ffmpeg -ss 00:00:00 -to $duration -i $file -c copy Final/"$(basename "$file")"
rm "$file"
done
for file in huge/*.mp4
do
ffprobe -loglevel error -show_entries stream_tags:format_tags -of json "$file" | jq -r '.format.tags.creation_time' | sed -E 's/\-0(4|5):00//g' | sed -E 's/[T:\.\-]/ /g' | read year month day hour minute second _
[[ "$year" = "null" ]] && { echo "Could not parse year from $file, got null, aborting"; break }; mv -vi $file "$(dirname "$file")"/"Dailies $year-$((month))-$((day)) $((hour))-$((minute))-$((second)).mp4"
done
@PythonCoderAS
PythonCoderAS / auto-publish-youtube.js
Last active March 18, 2025 01:37
Auto publish all drafts on YouTube Studio (assuming you have defaults set so all you need to do is click the next/done buttons)
const sleep = ms => new Promise(r => setTimeout(r, ms));
async function publishDraft() {
document.querySelector('.edit-draft-button .yt-spec-touch-feedback-shape__fill').click();
do { await sleep(500); } while (!document.querySelector('#next-button .yt-spec-touch-feedback-shape__fill'))
for (let i = 0; i < 3; i++) {
document.querySelector('#next-button .yt-spec-touch-feedback-shape__fill').click();
await sleep(1000);
}
document.querySelector('#done-button .yt-spec-touch-feedback-shape__fill').click()
@PythonCoderAS
PythonCoderAS / trim.sh
Created September 19, 2024 17:26
Trim two seconds from the end of every movie file
for file in huge/*.mov
do
duration=`ffprobe -v error -show_entries format=duration -of csv=p=0 $file`
duration=$((duration-2))
ffmpeg -ss 00:00:00 -to $duration -i $file -c copy Final/"$(basename "$file")"
rm "$file"
done
@PythonCoderAS
PythonCoderAS / name.sh
Created September 19, 2024 17:25
Mass rename files exported from Photos.app with created date
for file in huge/*.mov
do
ffprobe -loglevel error -show_entries stream_tags:format_tags -of json $file | jq -r '.format.tags["com.apple.quicktime.creationdate"]' | sed 's/-04:00//g' | sed -E 's/[T:\-]/ /g' | read year month day hour minute second
mv -v $file huge/"Dailies $year-$((month))-$((day)) $((hour))-$((minute))-$((second)).mov"
done
@PythonCoderAS
PythonCoderAS / README.md
Created August 12, 2023 01:16
How to mass resolve a domain list to find valid domains

Input

  • domains: A list of domains without protocol or any slashes. Example: ["google.com", "amazon.com"]
for time in 2019{05..12} {2020..2023}{01..12}; do curl -vL --silent "https://web.archive.org/web/${time}00000000/https://www.imdb.com/pressroom/stats/" > data-$time.txt 2>&1; done
@PythonCoderAS
PythonCoderAS / spawn vs child_process.md
Last active August 5, 2022 23:18 — forked from devarajchidambaram/spawn vs child_process
Difference between spawn and exec functions of child_process

Difference between spawn and exec functions of child_process

The Node.js Child Processes module (child_process) has two functions spawn and exec, using which we can start a child process to execute other programs on the system. Those new to child_process may wonder why there are two functions to do the same thing, and which one they should use. I'll explain the differences between spawn and exec to help you decide when to use what.

The most significant difference between child_process.spawn and child_process.exec is in what they return - spawn returns a stream and exec returns a buffer.

child_process.spawn returns an object with stdout and stderr streams. You can tap on the stdout stream to read data that the child process sends back to Node. stdout being a stream has the "data", "end", and other events that streams have. spawn is best used to when you want the child process to return a large amount of data to Node - image processing, reading binary data etc.

child_process.spawn is "asynchronously async

pipenv run pip install --verbose --upgrade --force xonsh
Using pip 22.0.4 from /Users/User/.local/share/virtualenvs/xonsh-0.12.5-m1tMou8K/lib/python3.9/site-packages/pip (python 3.9)
Collecting xonsh
Using cached xonsh-0.12.5-py39-none-any.whl (891 kB)
Installing collected packages: xonsh
Attempting uninstall: xonsh
Found existing installation: xonsh 0.12.5
Uninstalling xonsh-0.12.5:
Removing file or directory /Users/User/.local/share/virtualenvs/xonsh-0.12.5-m1tMou8K/bin/xonsh
Removing file or directory /Users/User/.local/share/virtualenvs/xonsh-0.12.5-m1tMou8K/bin/xonsh-cat
#!/usr/bin/env python3
# Note: Do not embed any non-ASCII characters in this file until pip has been
# fixed. See https://github.com/xonsh/xonsh/issues/487.
import os
import subprocess
import sys
from setuptools import setup
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop