Download video from YouTube and convert it to mp3 in Linux

To download video from YouTube you can use some site in Internet, but many of them have ads, viruses and don’t do what you need.

But you can use simple program youtube-dl. It is free, open source, work in console and can download video, audio from YouTube in one click.

To install youtube-dl use simple commands:

1. Install python:

sudo apt install python3
sudo ln -s /usr/bin/python3 /usr/local/bin/python

2. Install youtube-dl:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

How to use youtube-dl:

To get all supported formats from YouTube video use command:

youtube-dl -F https://www.youtube.com/watch?v=QpqdtB4ssX0

Thic sommand show you all video formats and id’s

To download some format use flag -f and ID from previous command:

youtube-dl -f 18 https://www.youtube.com/watch?v=QpqdtB4ssX0

That’s all, video starts download. You can use it in terminal and don’t need to open suspicious sites.

You can also download playlists of video from YouTube the same way.

Convert video to mp3 audio.

And you can convert video to mp3 using program ffmpeg. To install ffmpeg use command:

sudo apt install ffmpeg

To convert video to mp3 use command:

ffmpeg -i video.mp4 -acodec libmp3lame audio.mp3

How to Enable Auto Login in Windows 10

To enable automatic login in Windows 10 use program netplwiz. Open Run command line (Win+R) and enter command netplwiz:

In next window uncheck option “User must enter a user name and password to use this computer.”

Enter password from your Windows 10 account and reboot computer.

Configure thumbnails for video files in nextcloud

Nextcloud use ffmpeg to generate thumbnails from video files, so you need to install ffmpeg on your server first:

sudo apt install ffmpeg

Now configure nextcloud. Open configuration file /config/config.php and add this lines:

'enable_previews' => true,
'enabledPreviewProviders' => array (
        0 => 'OC\\Preview\\Image',
        1 => 'OC\\Preview\\Movie',
        2 => 'OC\\Preview\\TXT',
),

That’s all, it is very simple 😉

How to Install NGINX and PHP 7.4 on Debian 10

Step 1: Install Nginx

Firstly install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release

Then we need to add the Nginx mainline package to our repository so that when we run apt install nginx, we will download the mainline version instead of the old stable version.

echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" 
    | sudo tee /etc/apt/sources.list.d/nginx.list

Next we need to download the signing key so that we can verify its authenticity

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

If it prints out OK! then you are good to go!

Now update package repositories and install Nginx:

sudo apt update
sudo apt install nginx

That’s it! You have now installed the latest release of Nginx on Debian 10. You should now start it!

sudo systemctl start nginx.service

And Don’t forget to make it automatically start on system boot as well.

sudo systemctl enable nginx.service

Step 2: Install PHP 7.4

To install PHP 7.4 we need to add repository. Since PHP 7.4 didn’t come with Debian 10 it is required to add the following repository. Write this commands:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Update package repositories:

sudo apt update

And now install PHP 7.4:

sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-imap

It is recommended to raise the memory limit to improve the overall performance. Your PHP configuration is located in /etc/php/7.4/fpm/php.ini.

sudo vim /etc/php/7.4/fpm/php.ini

Replace it with memory_limit = 256 and save document with :wq command. How to edit files in text editor Vim you can read here: How to exit Vim? And other required commands.

Step 3: Configure Nginx

Add nginx to www-data group

sudo usermod -a -G www-data nginx

Change owner of directory to www-data

sudo chown -R www-data /usr/share/nginx/html

Go into your default.conf file

sudo vim /etc/nginx/conf.d/default.conf

Replace your existing configuration file with the one below

server {
    listen       80;
    server_name  localhost;

    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

   location / {
    if ($request_uri ~ ^/(.*)\.html$) {
        return 302 /$1;
        }
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
        location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

Restart Nginx server:

service nginx restart

Now you can cteate test file fith information about PHP version:

nano /usr/share/nginx/html/phpinfo.php
phpinfo();

In Web-browser write IP address of server:
http://192.168.1.1/phpinfo.php

That’s all Nginx Server with PHP 7.4 installed.

Change default Grub 2 theme

Different themes for Grub 2 boot loader you can find on Gnome-Look website: https://www.gnome-look.org/browse?cat=109&ord=latest

To change Grub them use three simple steps:

1. Copy folder with theme into Grub themes directory:

/boot/grub/themes

2. Edit Grub configuration file /etc/default/grub and write there GRUB_THEME parameter:

GRUB_THEME=/boot/grub/themes/theme_folder/theme.txt

3. Update Grub configuration:

update-grub

Best three Grub themes:

1. Vimix

2. Tela

3. CyberRe

How to block Windows 10 Update

Windows 10 offers less UI control over the updating behavior of the operating system than previous versions of Windows , There is no option to turn off Windows Updates using the Control Panel or Settings app in Windows 10, it checks for updates automatically and install any updates they find, whether you like it or not.

To completely block all updates of Windows 10 use Windows Update Blocker tool.

How it works? Just download Windows Update Blocker – it’s freeware program and run it.

Here you can download Windows Update Blocker and get full instruction how to completely disable update of Windows 10.

Install Composer and Laravel

First install Composer package manager on on your project:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

Now install Composer global:

php composer.phar global require laravel/installer

Install Composer to your project (change site-name to your project name):

php composer.phar create-project --prefer-dist laravel/laravel site-name "8.*"

You don’t need Windows anymore

Microsoft Windows is a proprietary operating system which has captured 80% personal computers in the world and using their monopoly position dictates their rules of the game.

In addition, Microsoft collects your personal information and sells it to third parties, which endangers your security.

To change the situation, many people are looking for alternative operating systems, and one such alternatives is GNU Linux.

Many years Linux was leader operating system on web servers and mainframes, but on personal computers it occupied a miserable 3%. But now the situation has changed and GNU Linux is the best free and open source alternative for proprietary Microsoft Windows.

Javascript: Closures, callback, context

A closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.

window.onload = function(){
    var item = document.querySelector(".items .item");
    item onClick = activeItem;

    function activeItem() {
        console.log(item);
    }
}

In this example inner function activeItem() have access to global variable item. This called closure – when inner function have access to all variables, defined in global function.