Friday, May 3, 2013

Download YouTube videos with youtube-dl

Install & using

1. install youtube-dl
sudo apt-get update && sudo apt-get install youtube-dl
2. use this command to download files from YouTube
youtube-dl -o [name of output file] [YouTube URL]
3. To view all options youtube-dl, paste this in command line
man youtube-dl
To quit from manual press q key

Examples

1. Download classic flv type and save it as file.flv
youtube-dl -o file.flv "http://www.youtube.com/watch?v=Y54ABqSOScQ"
 
2. Download Full HD mp4 file and save it as file.mp4
 
youtube-dl -o file.mp4 -f 37 "http://www.youtube.com/watch?v=Y54ABqSOScQ"

This table from Wikipedia may be useful
Comparison of YouTube media types
Comparison of YouTube media types (Wikipedia)

Installing FFMPEG on CentOS with ATRPMS repo

  1. Import Key
    rpm --import http://packages.atrpms.net/RPM-GPG-KEY.atrpms 
     
  2. Create repo file
    vim /etc/yum.repos.d/atrpms.repo
    
    [atrpms]
    name=Fedora Core $releasever - $basearch - ATrpms
    baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
    gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
    gpgcheck=1
    enabled=0
    
    [atrpms-testing]
    name=Fedora Core $releasever - $basearch - ATrpms
    baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/testing
    gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
    gpgcheck=1
    enabled=0
     
    
  3. Install from Atrpms (example output)
    [root@computer ~]# yum --enablerepo=atrpms* install ffmpeg
    
    Loaded

Thursday, May 2, 2013

NGINX location priority rules


NGINX is great. Fast, efficient, etc. But the “location” rules are a bit cryptic and not very well explained in the manuals.

There are 4 types of location rule, and are applied with the following priorities:

1: Exact matches
There can be only one exact match – the clue is in the name!
location = /foo/bar {
# exact match
}

2: High priority prefix
There can be more than one match, the longest one takes priority
location ^~ /foo {
# request beginning with /foo
}

3: Regex
There can be more than one match, the first one found takes priority. There are two variants
location ~ .foo$ {
# case-sensitive regex
}
location ~* .foo$ {
# case-insensitive regex
}
4: Low priority prefix
There can be more than one match, the longest one takes priority
location /foo {
# request beginning with /foo
}