Skip to content

Instantly share code, notes, and snippets.

@Mihai-P
Mihai-P / handbreak.sh
Last active April 6, 2024 13:31
Renaming SRT files
#!/usr/bin/env bash
echo '**************************************'
echo '* INITIAL FINDINGS *'
echo '**************************************'
IFS='
' # split on newline only
set -o noglob # disable globbing
SOURCE="/process/"
sudo apt-get install ffmpeg
for f in ./*.mkv; do sudo ffmpeg -i "$f" -vcodec libx264 -acodec aac -strict -2 -movflags faststart "${f%.mkv}.mp4"; rm -rf "$f"; done
# get the files out of folders
for f in `find . -name '*mp4' -or -name '*mkv' -or -name '*avi' -or -name '*srt'`; do mv $f .; done
# not working find . -name '*mp4' -or -name '*mkv' -or -name '*avi' -or -name '*srt' -exec mv {} . \;
# delete all files that are not videos
for f in `find . -not -name '*mp4' -and -not -name '*mkv' -and -not -name '*avi' -and -not -name '*srt'`; do rm -rf $f; done
cd /media/
sudo mkdir movies
sudo chmod 777 movies
sudo mkdir tv
sudo chmod 777 tv
sudo mkdir kids
sudo mkdir kids/tv
sudo mkdir kids/movies
sudo chmod -R 777 kids
@Mihai-P
Mihai-P / memcached.keys
Created May 18, 2017 01:10
Linux commands
MEMCHOST=localhost; printf "stats items\n" | nc $MEMCHOST 11211 | grep ":number" | awk -F":" '{print $2}' | xargs -I % printf "stats cachedump % 10000\r\n" | nc $MEMCHOST 11211
@Mihai-P
Mihai-P / Controller.php
Last active April 10, 2016 00:49
Yii2 interesting links and articles
public function actionRestProvider()
{
$page = Yii::$app->request->get('page', 1);
$models = [];
for($i = $page * 10; $i < $page * 10 + 10; $i++) {
$models[] = ['name' => 'Name' . $i];
}
$dataProvider = new \common\components\RestDataProvider([
'allModels' => $models,
@Mihai-P
Mihai-P / 0_reuse_code.js
Last active August 29, 2015 14:22
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console