fedora aeroplane mode always on

Under Fedora 23, somehow the aeroplane mode went on (plane icon shown in top right corner). I tried to switch it off but could not. After a reboot, the aeroplane is still switch on and there is no way to switch it off. So, neither wire connection nor wifi connection can be switch on.

After a while and some browsing, this solution worked for me:

rfkill unblock all

Note, however, that on my system rfkill was not installed… so i got the RPM (rfkill-0.5.6.fc23.x86_64.rpm) from another source, copied it on a usb key and install it as follows:

sudo rpm -ivh fkill-0.5.6.fc23.x86_64.rpm
Posted in Linux | Tagged | Leave a comment

packet_write_wait: Connection to XXX : Broken pipe

In general, I can connect to a remote machine via SSH without any troubles but occasionally in some particular setup, although I can connect to the remote machine and type commands in a shell, the connection is broken after a few minutes of connection.

This happens when we do not interact with the terminal (i.e., we do not type anything on the keyboard).

In such case, the following error message appears:

A line showing packet_write_wait: Connection to XXX : Broken pipe

Solution:

On the host, add those lines in the file ~/.ssh/config in your home directory

Host *
  ServerAliveInterval 30
  ServerAliveCountMax 5

If the file config does not exist, just create it.

The ServerAliveInternal pings the server with a null packet every 30 seconds. As for the second line, I have not check whether it is required or not.

Posted in Linux | Tagged | 11 Comments

pytest-cov collects no data on Travis

I recently switched from nosetests to pytest and pytest-cov for one of my Python project (http://easydev-python.readthedocs.io).

Locally, everything seemed to work fine and once on Travis, all tests passed as expected.

Yet, before the coverage report, I noticed this warning:

 Coverage.py warning: No data was collected"

and more importantly, the final coverage reported was 0% !!

I later realised that one __init__.py file in the test/ directory was present locally but not in the github source code. After a commit, travis found the missing file and the coverage came back to normal.

So, this __init__.py seems important for pytest-cov

Posted in Python | Tagged , , | 12 Comments

Remove extension in a bash script

Imagine a bunch of files with extension fastq.dsrc, the following script will decompress the files by looping over the N files. One issue was to remove the extension in the script. See below the usage of //

for filename in `ls *.fastq.dsrc`
do
dsrc d $filename ${filename/.dsrc/}
done
Posted in Linux | Tagged | Leave a comment

git synchronisation of a forked repository

Let us assume you have forked a repository (from https://github.com/project/repository_name). You now have a local version at a given time of the repository repository_name.

git pull https://github.com/project/repository_name
cd repository_name

Time flyes and you come back to the local repository and you are not synchronised anymore. So, you need to fetch the new commits from the upstream repo, pull and push into your repository. this is done as follows:

git remote add upstream https://github.com/project/repository_name.git
git fetch upstream
 
git pull
git merge upstream/master
git push
Posted in Uncategorized | Leave a comment

gimp: how to make a transparent background

How to make a transparent background/selection on an image using GIMP

    1. Open your image.
    2. Select the area you want to make transparent.

    1. Select the appropriate selection tool from the Tool window or the Tools – Selection Tools menu on the Layer window. I usually use the magic wand/fuzzy select (Select contiguous region) tool or the Select regions by color tool.
    2. Click in the region you want selected. Use shift-click to add more regions/colors.Tip: It’s easier if you zoom in (View – Zoom menu) to see finer details of exactly what you’re selecting.

    3. In the Layer window (the one showing your image), select Layer – Transparency – Add Alpha Channel.If this is blanked out then it’s already done. This makes sure your image can store transparency data
    4. Select Edit – Clear. This makes the selection transparent.
    5. Save the file. Note: If you save it as a PNG file, be sure to select the ‘Save colour values from transparent pixels’ option in the Save as PNG dialog box.

Posted in photos | Tagged | 37 Comments

lost your linux root password ?

Lost your root password ?

Under Fedora, at boot time, press e, select the kernel and add 1 (run level), which will let you enter into a shell session, where you can edit the /etc/passwd file to reset the password.

You can change a user’s password using the passwd command

passwd username

Under ubuntu, once you press the e, add 1 at the end of the line that starts with “linux (see image below) . Once done, press F10

Posted in Linux | Tagged | Leave a comment

vim: multiple buffers

In order to work with several view ports of the same file in the same Vim window, type:

:sp

You may also open another file in the same window. To do so issue the command::

    :sp filename

To switch between buffers, use ctrl+w

To open a vertical buffer use :vsp filename.

Posted in Linux | Tagged | Leave a comment

vim: create function to remove white spaces

In the .vimrc file, add the following lines ( here ^M is a special character for the return carriage created using CTRL+V):

#remove tabs
function removeM()
%s/^M//
:endfunction
 
function removeWhiteSpace()
%s/^ \+ $//
%s/^ $//
%s/ \+$//
%s/ $//
:endfunction

those functions call then be called within vim typing:

call removeWhiteSpace()

some Explanation of the function removeWhiteSpace().

  1. first line replaces a line that starts and ends with white spaces
  2. second line replaces a single white space that is alone on a line.
  3. third line replaces the end of a line that finishes with trailing spaces
  4. same as 3 but for the single white space case
Posted in Linux | Tagged | Leave a comment

yumex-dnf is locked

Under Fedora 23, starting yumex-dnf, I got a message that yumex-dnf was locked. I could not find any lock file in /var/cache/dnf and therefore was stuck. Finally, running

yumex-dnf --exit

did kill the faulty process and could start yumex-dnf again…

Posted in Linux | Tagged | 11 Comments