Monday, March 23, 2015

fedora: How to find out which package provides a specific file

If you need to find out, for example, which package in fedora provides htpasswd command, you may do it with the command:
yum provides \*bin/htpasswd

How to set up authentication for your website with nginx

You can set up basic authentication with nginx to restrict access to your website:

Install httpd-tools package first:
sudo yum install httpd-tools

If you are on Ubuntu install that package:
sudo apt-get install apache2-utils

Add to your nginx config:
server {
auth_basic "closed site";
auth_basic_user_file conf/htpasswd;

Go to /etc/nginx and create folder conf:
cd /etc/nginx
sudo mkdir conf

Then you need to generate file htpasswd that contains authentication data:
sudo htpasswd -c htpasswd admin

Sunday, March 22, 2015

byobu: Vertical window split issue

Vertical split with default keys configuration in byobu (which is Shift+F2) doesn't work. I decided to change it to Ctrl+F1 instead. To do it open keybinding file:
sudo vim /usr/share/byobu/keybindings/f-keys.tmux

And replace line
bind-key -n S-F2 display-panes \; split-window -v

bind-key -n C-F1 display-panes \; split-window -v

Make sure that tmux keybinding is active and default one. Open file

and check that it contains
source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.tmux

How to download tracks from deezer

UPDATE 07/11/2015: Use DeezerDownloader (-- link removed in accordance with the DMCA) to download tracks


Old article (method described below does not work anymore): 

There is a nice service which allows you to download tracks from deezer. All you need to do is to copy and past unique link of the track from deezer. It would be good to automate that process for albums and playlists.

adeezer project was created exactly for that purpose. It is cross platform and is known to work on Windows and Linux (should also work fine on OSX).

Download and extract the latest version from here or clone the repository with command:
git clone

The recommended way of using adeezer is with virtualenv, but you can just install all dependencies and start using it:
pip install -r requirements.txt

Some examples of using the script:

  • Download the playlist with id 101
    python -p 101

  • Download the album with id 321
    python -a 321

  • Download all your favourite tracks
    python -f 1000

    Where 1000 is your deezer id. You can also use your username or email instead of id.

  • All tracks are downloaded in your <home_directory>/Downloads/<item_id>. To populate ID3 tags of downloaded tracks use that command:
    python <path_to_folder> "<album_name>"

    Windows users might have some problems with quick start, because python and pip is not installed in their system by default. Here is quick start guide for them:
    1. Download and install ActivePython 2.7 from

    2. Download and extract adeezer from

    3. Install dependencies. Run from commmand prompt:
    pypm install mutagen progressbar2 requests selenium wsgiref

    4. In Command prompt go to the directory with and use any command from that article to download tracks

    How to create git commit template

    At work we integrated git with JIRA. If commit starts with our project name in JIRA and contains issue id, it will be automatically linked to that issue. For example:

    PROJECT-10 Fix timezone

    That pattern requires that every commit starts with the same characters "PROJECT-". Git supports commit templates, so every new commit message will include text from this template.

    To make it work you just need to create a simple text file and configure git to use this file:
    git config --local commit.template /path/to/git-commit-template.txt

    How to find outdated python packages in your environment

    The easiest way to find out if updated version of any installed package is available is to run that command:
    pip list --outdated

    There is also a special package for that task which is called pip-tools