search

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

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

Make sure that tmux keybinding is active and default one. Open file
/usr/share/byobu/keybindings/f-keys

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

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