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
import functools | |
class Foo: | |
@functools.lru_cache | |
def get(self, z): | |
return z | |
def set_cache_size(self, s): | |
Foo.get = functools.lru_cache(maxsize=s)(Foo.get.__wrapped__) |
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
import sys | |
import shiboken2 | |
from PySide2.QtCore import QObject, QThread, Signal, Qt | |
from PySide2.QtWidgets import QApplication, QPushButton | |
class Grandchild(QObject): | |
def __init__(self, parent=None): | |
super(Grandchild, self).__init__(parent) |
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
#!/bin/sh | |
#Run from root of a CD volume on OSX | |
album=$(basename "$PWD") | |
mkdir -p ~/Desktop/Music/FLAC/"${album}" | |
mkdir -p ~/Desktop/Music/M4A/"${album}" | |
for track in *.aiff; do | |
newname=$(basename "$track" .aiff) |
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
TARGET_WIDTH="1920" | |
TARGET_HEIGHT="1080" | |
TARGET_DAR="16/9" | |
ffmpeg -i "input.mov" -vf \ | |
"scale=iw*sar:ih, | |
scale= | |
'w=if(lt(dar, $TARGET_DAR), trunc(oh*a/2)*2, min($TARGET_WIDTH,ceil(iw/2)*2)): | |
h=if(gte(dar, $TARGET_DAR), trunc(ow/a/2)*2, min($TARGET_HEIGHT,ceil(ih/2)*2))', | |
setsar=1" \ |
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
#!/bin/sh | |
curl -# -o test.html "$1" | |
mkdir downloaded-vids | |
for line in $(cat test.html); do | |
url=$(echo $line | grep -e .*http.*webm.* -e .*http.*mp4.* | sed 's/src=\(.*\)/\1/' | tr -d \') | |
if [[ ! -z $url ]]; then | |
curl -# -o downloaded-vids/$(basename $url) $url | |
fi |
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 video duration in frames | |
duration=$(ffmpeg -i [filename] 2>&1 | sed -n "s/.* Duration: \([^,]*\), start: .*/\1/p") | |
fps=$(ffmpeg -i [filename] 2>&1 | sed -n "s/.*, \(.*\) tbr.*/\1/p") | |
hours=$(echo $duration | cut -d":" -f1) | |
minutes=$(echo $duration | cut -d":" -f2) | |
seconds=$(echo $duration | cut -d":" -f3) | |
FRAMES=$(echo "($hours*3600+$minutes*60+$seconds)*$fps" | bc | cut -d"." -f1) | |
# Start ffmpeg, use awk to flush the buffer and remove carriage returns | |
ffmpeg -i [filename] [options] [outputfile] 2>&1 | awk '1;{fflush()}' RS='\r\n'>[errorlog] & |