Monday, December 14, 2015

fedora: Disable Komodo Edit file association

from file

Thursday, December 10, 2015

bash: How to clean logs

One of the fastest and easiest ways is just like this:
> /var/log/syslog

bash: How to remove all *.pyc files

Remove all *.pyc files from the current directory (and subdirectories):
find . -name \*.pyc -delete

Sunday, November 15, 2015

firefox: Enable tracking protection for normal session

Firefox 42 includes very interesting feature - Tracking protection. By default it is active only in the Private mode. When the Firefox team presented a new video that described the usage of the Memory tab in the Developer toolbar, they show that the CNN website normally consumes about 40 Mb of memory and with Tracking protection on it consumes about 10 Mb. If you want to enable this feature not only for the private sessions, but also for the normal sessions, you can do that by typing about:config in the address bar and changing the value of the privacy.trackingprotection.enabled to true: There is also a really interesting setting privacy.trackingprotection.updateURL, which means, that, I believe, you can host your own tracking protection list (See shavar project, blocking list format is here). When Tracking protection has blocked some resources, it shows a shield icon near the address bar. If you open the Developer console (F12 or Ctrl+Shift+K) you can see what resources were blocked: Together with AdBlock extension it could be a nice way to improve your browsing expierence.

Change colours in byobu

Colour settings file for the byobu located in the folder ~/.byoubu, if you use tmux, it will be color.tmux:
BYOBU_ACCENT - is the colour of the window delimiter; BYOBU_HIGHLIGHT - is the colour of the current highlighted window; MONOCHROME - background colour of the window title in the bottom panel;

fedora: Automatically start application during the boot

To start an application automatically in fedora, you need to create a *.desktop file in the directory ~/.config/autostart, for example:
gedit ~/.config/autostart/flux.desktop
The content of the file can be something like:
[Desktop Entry]
Exec=/home/jsn/app/xflux -l 52.3837151 -g 4.8806328

Tuesday, November 10, 2015

fedora: How to add user to sudoers

You can add user to the sudoers with command:
usermod username -a -G wheel
Log out is required.

Wednesday, October 7, 2015

How to open browser (Chrome, Firefox) on the remote machine via terminal

You can open a chrome window on the remote machine via terminal with X11 forwarding. First of all, some configuration needs to be done. Open on your machine (client) ssh configuration:
vim ~/.ssh/config
Make sure that it contains:
Host *
  ForwardX11 yes
Check that on the server (remote machine) X11 forwarding is enabled. Open this file:
vim /etc/ssh/sshd_config
and check that it contains:
X11Forwarding yes
X11DisplayOffset 10
Now you can connect from your machine to the remote server with command:
ssh -Y your_name@server
Check with (env command) that environmental variable DISPLAY is something like localhost:10.0. If not, set it with command:
export DISPLAY=localhost:10.0
To check that everything was set up correctly, run on the remote server:
You should be able to see a window of the xclock application. Now you are ready to run chrome with command:
I had some permission issue that prevented chrome from starting, I managed to fix it by changing user data directory:
google-chrome --user-data-dir=.chrome_profile
This also might be useful:
google-chrome --no-sandbox 
Firefox can be launched just with:
Make sure that you have permissions for the .mozilla and .cache directory on the remote machine

git: How to change the author of the commit

If you want to change the author of the specific commit (for example the latest one), run rebase command:
git rebase -i HEAD~1
HEAD~1 points to the latest commit, but it can be a commit id or branch name. To mark a commit for edit, replace `pick` with `e`: Replace commit author:
git commit --amend --author "Your Name <>" 
Finish rebase:
git rebase --continue

Tuesday, September 15, 2015

How to unset environmental variable

For example, you set DJANGO=true environmental variable with command:
export DJANGO=true
To unset it run this command:
unset DJANGO

Sunday, September 13, 2015

How to display all available package versions in Ubuntu

To display all available package versions use next command:
apt-cache madison
For example:
vagrant@vagrant:~$ apt-cache madison redis-server
redis-server | 2:3.0.2-3~bpo8+1 | jessie-backports/main amd64 Packages
redis-server | 2:2.8.17-1+deb8u1 | jessie/updates/main amd64 Packages
redis-server | 2:2.8.17-1 | jessie/main amd64 Packages
     redis | 2:2.8.17-1 | jessie/main Sources
     redis | 2:2.8.17-1+deb8u1 | jessie/updates/main Sources

Friday, May 22, 2015

How to configure dnsmasq to forward all requests to specific address

For example you have a virtual machine, which you use for local development, and you want all requests to the (name of the website that you are developing) forwarded to the virtual machine. We will use dnsmasq to achieve it.

Install dnsmasq:
sudo yum install dnsmasq

Start it with command:
sudo service dnsmasq start

Check if it was started without any errors:
sudo service dnsmasq status

If there is an error that dnsmasq failed to start because port 53 is already in use, you can check what process listening this post with command:
sudo netstat -tulpn | grep :53

If the process is dnsmasq itself it probably means that you have libvirt installed that has its own dnsmasq copy. To resolve that conflict we need to configure dnsmasq. Configuration file we are going to store in /etc/dnsmasq.d/vm.conf. By default dnsmasq uses file /etc/dnsmasq.conf for configuration. If you open that file, you will be able to see lots of examples and configuration descriptions. Lets left this file intact (almost) and allow dnsmasq to extent configuration with files from dnsmasq.d directory by adding (uncommenting) line:
# Include all files in a directory which end in .conf

Now create file /etc/dnsmasq.d/vm.conf with the following content:

The first line determines what interface dnsmasq will be listening. To check all available interfaces use command ifconfig.

Basicly you need to listen to localhost or You can probably do it with:

The last line of the configuration file says that all requests to (including subdomains, like will be redirected to (that's my virtual machine).

Also you need to add to the file /etc/dhcp/dhclient.conf (or create the file if it does not exist):
prepend domain-name-servers;

You also need to restart your system. Instead of restarting the system you may try to restart following services:
sudo service dnsmasq restart
sudo service NetworkManager restart

To check that everything works correctly, use command:

The output should show that the request was redirected to

Thursday, May 21, 2015

vagrant: How to automatically update Guest Additions

To autmatically update Guest Additions on your vagrant machine you need to install vagrant-vbguest plugin. From the folder with Vagrantfile run the command:
vagrant plugin install vagrant-vbguest

Next time you start it with vagrant up, Guest Additions will be updated

Wednesday, May 20, 2015

fedora 21: How to add and preserve DNS server

Normally NetworkManager handels all DNS configuration. Every time when new network connection was established (?) it regenerates file /etc/resolv.conf which contains DNS server data, so editing this file is useless.

To add DNS server on top of the DNS servers list from your connections you need to create or edit file /etc/dhcp/dhclient.conf and add the following line:
prepend domain-name-servers;

Where is address of DNS server.

After applying changes you need to reboot or restart NetworkManager service:
sudo service NetworkManager restart

Tuesday, May 19, 2015

fedora 21: How to mount remote filesystem via SSH

If you use vagrant for development you might need an access to the filesystem of the virtual machine. There is a way to mount a folder from your virtual machine to your local machine so you will be able to open and edit with your favourite code editor.

First step is to install fuse-sshfs package:
sudo yum install fuse-sshfs

Then you can mount folder from the virtual machine with command:
sshfs -o idmap=user vagrant@ /home/jsn/vagrant/vm

The first path is the path inside the virtual machine and the second one is for local machine.

Wednesday, April 29, 2015

fedora: How to automatically shutdown your system

The easiest way to shutdown your system is to use shutdown command:
sudo shutdown

It will start shutdown process immediaetely.

To shutdown your system in specific time use this command:
sudo shutdown 11:50

And to shutdown your system in 2 hours (120 mins) use this command:
sudo shutdown +120

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