MP4 to Webm
ffmpeg -i video.mp4 -c:v libvpx -crf 10 -b:v 1M -c:a libvorbis video.webm
MP4 to Webm
ffmpeg -i input.mp4 -c:v libtheora -q:v 7 -c:a libvorbis -q:a 4 output.ogv
MP4 to MP3
ffmpeg -i input.mp4 output.mp3
MKV to MP3
ffmpeg -i input.mkv -vn -c:a libmp3lame -y output.mp3
MOV to MP4 (Compressed)
ffmpeg -i my-video.mov -vcodec h264 -acodec mp2 my-video.mp4

Filter by response code:


#!/usr/bin/node
module.paths.push('/usr/lib/node_modules');
const fs = require('fs');
var data = {};
var params = process.argv[2];
function read(config={}){
  fs.readFile(params,'utf8',function(err,data){
    if(err) throw err;
    data = JSON.parse(data).log.entries;
    if(config.by.length>0){
      if(config.by[0]=='status'){
        data = data.filter(function(v){return v.response.status==config.by[1]}).map(function(v){return v.request.url});
      }
    };
    if(config.save){
      save()
    }else{
      console.log(data)
    }
  })
};
function save(){
  fs.writeFile(params.replace(/(\.har)$/,"-output$1"),JSON.stringify(data),function(err){if(err) throw err})
};
read({
  save:false,
  by:['status',404]
})

Separate string by character length

"This is String".replace(/(.{4})/,"$1\n")
Result:
This
 is 
Stri
ng

Audio

  • audacity apt-get install audacity

Video

Etc

Don't Log :

    
      SetEnvIf Remote_Addr "^((127\.0\.0\.1)|(\:\:1)|(192\.168\.1\.[1-2][0-5]?[0-6]))$" dontlog
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined env=!dontlog
    
  

After first install:

  • a2enmod rewrite
  • a2ensite default-ssl.conf
  • rm /var/www/html -rf && ln -s /path/to/html /var/www/html
  • Add <Directory ...> to /etc/apache2/sites-available/default-ssl.conf

command using dd:

umount /dev/sd<?><?>
dd bs=4M if=path/to/input.iso of=/dev/sd<?> conv=fdatasync  status=progress

Reference: https://askubuntu.com/questions/372607/how-to-create-a-bootable-ubuntu-usb-flash-drive-from-terminal
Search and replace (RegExp)

/* Tips:
 * Backup file or folder before using sed
 * Make sure RegEx script is working with trying it on single file (dummy file/copied one)
 */

// sed single file using regex to remove match string
sed -i -E 's/<script.*?netbro_cache_analytics.*?<\/script>//' ./documentation.html

// adding g at the end of 'pattern' to make it global or match more than 1 occurance, example:
sed -i -E 's/&lt.*?class=\"elements-to-be-removed\.*?\/div>//g' ./documentation.html

// using `find` to search more than 1 files:
find path/to/folder -type f -iname "*.php" -exec sed -i -E 's/<script.*?netbro_cache_analytics.*?<\/script>//' {} \;

// Escape quote ( ' )
sed -i -E 's/'"'"'base_url'"'"' => base_url\(\)/'"'"'base_url'"'"' => base_url\(\),\n\t'"'"'asset_url'"'"' => asset_url\(\)/' ./Controller.php
Sed Help
sed --help
Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

  -n, --quiet, --silent
                 suppress automatic printing of pattern space
      --debug
                 annotate program execution
  -e script, --expression=script
                 add the script to the commands to be executed
  -f script-file, --file=script-file
                 add the contents of script-file to the commands to be executed
  --follow-symlinks
                 follow symlinks when processing in place
  -i[SUFFIX], --in-place[=SUFFIX]
                 edit files in place (makes backup if SUFFIX supplied)
  -b, --binary
                 open files in binary mode (CR+LFs are not processed specially)
  -l N, --line-length=N
                 specify the desired line-wrap length for the 'l' command
  --posix
                 disable all GNU extensions.
  -E, -r, --regexp-extended
                 use extended regular expressions in the script
                 (for portability use POSIX -E).
  -s, --separate
                 consider files as separate rather than as a single,
                 continuous long stream.
      --sandbox
                 operate in sandbox mode (disable e/r/w commands).
  -u, --unbuffered
                 load minimal amounts of data from the input files and flush
                 the output buffers more often
  -z, --null-data
                 separate lines by NUL characters
      --help     display this help and exit
      --version  output version information and exit

If no -e, --expression, -f, or --file option is given, then the first
non-option argument is taken as the sed script to interpret.  All
remaining arguments are names of input files; if no input files are
specified, then the standard input is read.

GNU sed home page: <https://www.gnu.org/software/sed/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-sed@gnu.org>.
composer about
composer self-update
composer require <vendor/packagename>
composer global require <vendor/packagename>