Tips


Internet Libre -- Open internet
Here is the list of open services (GNU licence) that can replace GAFAM services
- Signal for messages, chat, video chat, calls, etc
it is compatible with pidgin, a linux opensource chat and visio app
- Framasoft offer many services (spreadsheet, doodles, pads, etc.)
- Posteo is a mail provider for 1€/month that is eco friendly
- General Magic for maps
- sox is an audio Swiss Knife for linux, for instance to convert from wav to mp3 do:
     sox fichier.wav fichier.mp3

Basic git workflow. Tuto for new users here.
I am not fan of git, but I teach coding in python and colleagues do use git that is convenient for teamwork I must admit. So here is a reminder for myself of a typical workflow :       (All command from the git followed directory)
  • git status ---> tell me how my local directory is compared to online repo
  • git pull ---> update my local files according to what is online, good to do before working so that I work on the most updated version of files.
 Now I can work on the files I have locally. Whenever I create a new file that must be tracked by git (for future upload to the online repo), I have to tell it to git :
  • git add [fichier]
Now, two thing can happen :

I have not finished to work :
  • git stash ---> put aside my work for a future commit
I have finished my work :
  • git commit -m "short explanation of modif" ---> update your local tracking of files for a future push
  • git push ---> put in the online repo all the commited modifications


Thunderbird is very helpful to save time when reading emails. You can customize the keyboard shortcuts using the plugin "Dorando keyconfig". The most useful shortcut I use are:
m: to set the message as "read" or "not read"
a: to archive the message
s: star the message
1: important tag
4: to do tag
0: remove tags
F8: toggle message window (remaped to F2)

I also use "archive this" to create shortcuts to move emails into a TODO folder. Outil > Préférence des modules > Archive This
dans l'onglet Touche, définir les commandes associées à aux différents favoris
dans l'onglet Favoris, associé pour cette touche un dossier où placer le mail

"CardBook" is an excellent addon for email addresses. it allows to see address book associated to different email adresses.

On linux with a 1080p resolution, thunderbird text looks really small. Here is a workaround I found on the web, using the terminal

cd ~/.thunderbird/*.default
mkdir chrome
touch userChrome.css
gedit userChrome.css
Copy/paste the following text into the file and save/quit (vous may modify the police though) then run
hexdump -C userChrome.css
/* 
 * Make all the default font sizes 9 pt:
 */
* { 
    font-size: 9pt !important; 
    font-family: Arial !important; 
}

Geany is my favorite text and code editor, it is very light and customisable: on ubuntu you can download all the plugins with the command:
sudo apt-get install geany-plugin-*
Then you can activate the plugin via the menu Tools/Plugin manager. I advise you to use geany-latex, geany-macro, multiterms, extra-selection, spell check. Here are the personalized building commands I use in Geany:

  • for pdflatex:
    pdflatex --file-line-error-style -synctex=1 "%f"

    pdflatex -interaction=batchmode --shell-escape --file-line-error-style -synctex=1 "%f" && rm %e.log
  • For a latex compilation with on fly installation of missing packages and with simplified output messages :
    texliveonfly --compiler=pdflatex --arguments='--file-line-error-style -synctex=1 --shell-escape' "%f" && rm %e.log 
  • for bibtex with silent output :
    bibtex -terse  "%e"
  • to show the pdf (with synctex to show current paragraph):
    qpdfview --unique %e.pdf#src:%f:%l:0 &
  • to export a bib file based on the aux file of the current document (require JabRef see below):
    java -jar ~/bin/JabRef-3.8.2.jar -a %e.aux,%e.bib -n true -i,bibtex ~/Ma_base_de_papier.bib
  • to convert all svg files in Images directory into pdf
    for file in ./Images/*.svg; do inkscape $file --export-pdf="${file%.svg}.pdf" && inkscape $file --export-png="${file%.svg}.png" --export-dpi=300 ; done
  • here is a small script dolatex to put in your /usr/local/bin folder to be able to compile in one command a latex document, while keeping in a hidden directory all the auxilary files.
  • alternatively, this command do the same:
    texfot texliveonfly --compiler=pdflatex --arguments='-output-directory=.metafiles --file-line-error-style -synctex=1 --shell-escape' "%f" && mv .metafiles/%e.pdf ./%e.pdf
In these commands:
%f represents the full file name
%e represents the file name without extension
%f:%l:%0 indicates to show pdf at the page corresponding to the current line of the tex file opened in Geany.

You can also synchronize geany with the pdf viewer "qpdfview" as explained here. In short, to go from clik in pdf to correct line in tex file just set this in qpdfview's "Source editor" setting: geany %1:%2:%3

Color scheme You can find here color scheme for geany. You can define the color scheme by changing the .conf files in
/home/.config/geany/colorschemes
For instance, put a very contrasted color for the selection field: I use dark-color with selection color #00b4ff

Geany works on linux, mac and window.

To use spell check you need to install dictionaries, for instance on Ubuntu you have to install the following packages :
myspell-fr-gut
myspell-en-us
for french and american english.
I use textidot as well to check for basic mistakes :

java -jar textidote.jar --html example.tex > report.html



To work with collaborators and keep track of the changes made in a document, I use latexdiff as follow
latexdiff old.tex new.tex > diff.tex

Texlive - Latex - tlmgr
Texlive install allows you to compile latex document for instance with pdf latex. After a texlive installation, you must add the texlive directory to your path so that you can run the various commands included in texlive. Adding a directory to your path permanently can be done by adding the location of this directory into the environment file as follows :
gedit /etc/environment
Edit the file to add for instance at the end of the file
:/usr/local/texlive/2019/bin/x86_64-linux
inside the quotes.
Then if you want to use tlmgr to install package using texlive package management tool, you need to add the same directory to the path of your root account. This can be done (carefully and in the same way) using the command
sudo visudo
then you can run
sudo tlmgr install package-to-install

This commands works in geany when you want to compile and install on fly the missing paskages :
texliveonfly --compiler=pdflatex --arguments='--file-line-error-style -synctex=1 --shell-escape' "%f" && rm %e.log 
but I prefer to run texliveonfly  manually and use the script that simplify errors, below


Latex - Shorten the output !
The texfot script by Karl Berry has been recently added to TeX Live; the command line
> texfot pdflatex mylatexfile.tex

 will greatly improve the terminal output of the latex command.

One can also create a package that include personal preamble to focus on important texte in tex files.

The texmf directory in the home folder contains a lot of configuration files and style for your personal use. When a change is made, one needs to run

sudo texconfig rehash

Libreoffice Impress is the tool I use now to create the slides for my talks, mainly because I can work on both my linux desktop and on my Mac OS laptop. I use a homemade templates where I have chosen latex font (latin modern) for the text. This allows to use texmath (a libreoffice extension) to add equations and text that look exactly like the text written in libreoffice. I use another extension (Expand Animation) to export the slides in pdf including the animation as various pages of the final pdf. One very good point of libreoffice is that you can define a lot of keyboard shortcut (and even save this configuration file to have the same shortcut on all your computers). The final good point is that "odp" files will very likely be more easy to open after 10 years since it is an open format.
You can find here the various extensions, font files and templates I use for my slides.

Images in Impress :
- Sadly, Impress is not yet compatible with svg and the only way to import figure from Inkscape is to save them in jpeg (with a 150ppi resolution at least), or to open it with inkscape, select all objects, and copy them into the impress file.
- For figures produced with gnuplot, namely eps files, here is a function you can put in your .bash_aliases in home directory
function eps2png {
    gs -dSAFER -dBATCH -dNOPAUSE -dEPSCrop -r300 -sDEVICE=pngalpha -sOutputFile="$(echo "$1" | cut -f 1 -d '.').png" "$1"
    }

Then use eps2png myfile.eps to convert it to png.

For poster, I use Impress as well with a A0 page format (cf. template). If you are late for printing your poster, you may want to split it to several A3 pages to print it in your lab. You can do this as follow with the package mutool:
mutool poster -x 2 -y 4 PosterInput.pdf Poster-2x4.pdf
This will produce the 8 pages in A3 landscape required for your poster. Alternatively, you may want the 16 pages in A4 portrait
mutool poster -x 4 -y 4 PosterInput.pdf Poster-4x4.pdf

Jabref is a very good GNU bibliography manager working on every platform. It can run plugins that are very helpful, and it links your pdf files to your entries in your database. You can download jabref 5 beta here (best version available at the moment due to change with javafx). Jabref is a wonderful tool if you use it systematically: each time you download a paper, add it to your jabref database to store it. No more trouble to remember where you put a paper: You can just search for it in jabref. You can create groups which means that you don’t need to copy your files into many different folders, just put them into several groups
Create a database from the paper you are writing: you just have many citations in a paper and you would like to explore them. No problem: use the tools -> New subdatabase based on AUX file. It will create a database with all the paper you have cited. Then, because your database know where the files are, you can explore all the files easily...
Another interesting feature is the html export of your database. This produce the nice bibliography table of publication page of this blog.
Remark: jabref sometimes uses to much ressources, I use this command to start jabref and limit the memory usage up to 200Mo:
java -Xmx200m -jar /home/gatien/bin/Jabref/JabRef-4.1.jar

Create new entries from DOI or Arxiv number : Select the group in wich you want the entry to be put, choose BibTeX → New entry... In the lower part, there is the box "ID-based entry generator". In the field "ID type", "DOI" should be already selected. The field "ID" is focused. Enter the DOI here and press Enter to generate an entry based on the Id. You can also click on "Generate". Then, http://dx.doi.org/ (provided by http://crossref.org/) is used to convert the given DOI to a BibTeX entry. The found entry is opened in an entry editor. In case an error occurs, a popup is shown.

Get fulltext : for arxiv paper, you get automatically put the PDF with the bibtex bey as a name into your customized folder by going to General Tap, and then click on the wen "get fulltext". 

KeePassX is a GNU password manager that stores all your logins and password into a database that is encrypted. So if you'd like to just remember one strong password, try this very good tool. Your password database will be locked after a given time if you let it open. Your clipboard can also be cleaned after half a minut for instance. For Linux, an autotype function exists so that you can login easily.
There is an addon for firefox to access your keepassx database called "KeePass Tusk".

Inkscape is an awesome vectorial drawing program. You can plot curves using their mathematical expressions or create latex formula thanks to its plugins. The fill and stroke panel (in object) is a central panel you should use all the time to set the color, the fillings and the line types. Don't worry if you don't find at the beginning all the tools you look for: search more you will see in the end nothing is better than inkscape as a (free) vectorial drawing program.

svg2tikz is a command line tool and extension to produce tikz code that can be put in tex file to generate figures.

Rsync is a linux command that you can use to compare two directories and update one according to the other one. I use it to synchronise my desktop and laptop data whenever I work outside the lab. You can synchronize your file remotly using an ssh connection. To synchronize exactly two directories run
rsync -avh source/ dest/ --delete
If you want to synchronize through en ssh connection run
rsync -avh login@serveurname:/source/ dest/ --delete
Remarque :  don't forget the final "/" after source en dest so that files in source are synchronize with files in dest.

sshfs is useful to work on files that are on another computer as if they were on your own computer. It just mounts the remote folder somewhere in your file system.

sshfs user@host:/path/to/folder1/ /path/to/target/folder2/
The content of  folder1 will appear in folder2. To unmount the folder write:
fusermount -u /path/to/target/folder2/

Gnuplot is a very good tool to create plots and even why not to draw few things. You must use it with scripts and latex terminal. Create your own linestyles, and then re-use all the time the same script files.

I use gnuplot with the two following scripts to create my figures:

  • The first script is a bash script (figmaker.txt) that execute a gnuplot script (plotmaker.txt), then it runs latex to create the text and then it converts the figure into eps. Don’t use files called figure in the folder where you execute these two scripts. The gnuplot script (plotmaker.txt) contains the instructions to plot. You must modify it according to what you want to plot.
  •  The figmaker.txt script is just a text file with a bash script inside to run gnuplot and latex and clean the directory afterwards. To execute it, just write
    ./figmaker.txt
    into
    a terminal. Use the commande: sudo chmod +x figmaker
    to
    give the execution rights to this file if you cannot run it. 

Latex2rtf is a linux tool to convert file.tex into a file.rtf that can be opened with MS Word or Libreoffice. This convert the bibliography as well if command is run in a folder with all metafile associated to the tex document (bbl, aux, etc). Research projects are often requested in MS Word format even though they are much simpler to write in latex. Hence, I write now my project in tex and convert them into rtf at the end before submiting the project.
Latex2rtf is a debian package that can be installed from standard online repository (e.g. on ubuntu)

Hevea is a latex to html converter. You can find Hevea here.

Pandoc is a universal document converter. It uses as input documents in markdown, reStructuredText, textile, HTML, DocBook, LaTeX, MediaWiki markup, TWiki markup, OPML, Emacs Org-Mode, Txt2Tags, Microsoft Word docx, LibreOffice ODT, EPUB, or Haddock markup. Many output format are available.
For instance, to convert a wikipedia page, copy paste in the text file "wiki.txt" its wiki code. Then, use the command to get a tex file:
pandoc wiki.txt -f mediawiki -t latex --standalone -o output.tex
After a few corrections of the compilation error of latex (for instance if the wiki page contains greek latters directly written in greek not using math environement), you will get a nice latex version of the wikipedia article.

    pdfunite or pdftk are linux comand lines to merge pdf. You just write in a terminal:
    pdfunite file1.pdf file2.pdf file3.pdf merged.pdf
    and the file merged.pdf will include the former files.
    Alternatively for pdftk you should write:
    pdftk file1.pdf file2.pdf file3.pdf output merged.pdf


    pdfbook est un excellent créateur de livret pour l'impression au format 4 pages par feuille avec un rendu livre format A5. Le logiciel s'utilise en ligne de commande :
    pdfbook monfichier.pdf
    il produira un fichier monfichier-book.pdf à imprimer en 1 page par feuille et recto-verso (bord long).

    lpr is the standard command line printing tool :
    -P printername
    -o page-ranges=1-4,8

    -o sides=two-sided-long-edge

    Convert is a command line tool to convert files between different file format. For instance, you can use it to convert a list of jpeg files (notes1.jpeg notes2.jpeg etc) into a pdf by

    convert -rotate 90 ./notes*.jpeg notes.pdf

    If it does not work you may have to do

    sudo gedit /etc/ImageMagick-6/policy.xml
    

    and replace the line

    <policy domain="coder" rights="none" pattern="PDF" />
    

    with

    <policy domain="coder" rights="read|write" pattern="PDF" />
    


    Mediawiki and libreoffice Writer. You can export a libreoffice write document to the txt format that is compatible with mediawiki syntax. This is a convenient way of sharing document for a collaborative edition of teaching materials. On ubuntu, you need to install the package
    libreoffice-wiki-publisher
    and restart libreoffice. Then you can export a document in the mediawiki text format.

    Bash script.
    The following command move an open file in my Download directory to my article folder :
    cp $(lsof -w +D /home/gatien/Downloads | grep ".pdf$" | awk '{print $9}' | head -1 ) /home/gatien/Dropbox/DocumentsDropbox/Articles/

    Maple. Useful commands

    • lprint(...) show the result of command "..." as maple 2d output so that it is easier to copy it to another command
    • ctrl+L permet d'entrer un numéro d'équation pour utiliser la sortie (par exemple pour définir la sortie d'une commande de dérivation comme une fonction)
    Revtex. Useful commands
    • To cite an article with text before or after the citation write \cite{[{text before}][{ text after }]bibtexkey}
    Useful folders and tips for Ubuntu.
    • Put your bibliography file into the directory ~/texmf/bibtex/bib/mybiblio.bib such that bibtex see this file in any folder where you have a tex document. You can use a hard link to put your bib file where you like although having it available in your tex tree, with the command line:
      ln tarketfile linkfile
    • Put your personal style file in ~/texmf/tex/latex/yourowndir/filename.sty following the TeX directory structure. You can check that the files are found with
      kpsewhich filename.sty
    • I like the templates folder in the home directory : the files there are available on right click > new document. The problem with that is that your template may not be synchronize between different computer if you use rsync on specific folders of your home like I do. My solution is to put links into the Template folder that link toward your synchronized templates elsewhere :

    ln -s ~/Documents/Gatien_pro/Templates/* ~/Templates/
    ln -s ~/Documents/Gatien_pro/Templates/* ~/Modèles/

    Menu of ubuntu may look small on a 1080 resolution : on peut définir une police large dans Préférence/Accessibilité.

    • You can control the time after which the screen brightness decreases with the following command line (here the time is set to 120 seconds)
      gconftool --type int --set /apps/gnome-power-manager/backlight/idle_dim_time 120


    Nautilus. To create personalized shortcuts for nautilus you can follow thoses steps, here for instance to open a terminal with F12 :

    1. Create a script called Terminal (yes, without a extension) inside the folder ~/.local/share/nautilus/scripts with the following content:
      #!/bin/sh
      gnome-terminal
      
    2. Make it executable, then close any Nautilus instance:
      $ chmod +x Terminal
      $ nautilus -q
      
    3. Create (or edit) the ~/.config/nautilus/scripts-accels file adding these lines:
      F12 Terminal
      ; Commented lines must have a space after the semicolon
      ; Examples of other key combinations:
      ; <Control>F12 Terminal
      ; <Alt>F12 Terminal
      ; <Shift>F12 Terminal
       
       

    VLC  Here is a good plugin for VLC that save and load your playlist at startup and closing
    https://addons.videolan.org/p/1154016/

     

     
    Ubuntu 18.04 - Good to know
    Les lanceurs d'application se trouve dans les répertoire
    /usr/share/applications/ 
    ou
    ~/.local/share/applications

    Le chemin où placer ses scripts perso est
    /usr/local/bin/ 

    One can access windows network folders with samba. On my RED box I have shared a folder called USBbox to access a hard drive connected to the box. In a terminal, to see the share folders, run

     smbtree -N

     Then in nautilus, if you click on "Autres emplacements", next at the bottom in "connexion à un serveur" you should write 

    smb://192.168.1.1/USBbox

    Then, the folder will be available and can be added to bookmarked folders.

    Bose Revolve on ubuntu

    To use the bluetooth speaker bose revolved you need to edit the file
        sudo gedit /etc/pulse/daemon.conf     
     
    and uncomment:

    default-sample-format = s16le
    default-sample-rate = 48000

    A nice way to do testing is running the command 
    aplay /usr/share/sounds/alsa/Front_Left.wav
    aplay /usr/share/sounds/alsa/Front_Right.wav


    Dual boot Linux / Mac OS X 
    Mac OS X has protection against non-experts users called SIP, that prevent using sudo with complete modification rights. Boot in recovery mode (cmd+R at startup) and open a terminal to do
    csrutil disable
    Then restart in normal mode and follow install instruction of rEFInd that uses a script to install the EFI boot loader. This will install the boot loader rEFInd on the ESP partition by default. This partition must be empty enough, so if you have mounted it manually with errors during the mount, you create file.rec into the ESP partition which occupies a lot of disk space. Remove them to let space for the installation of your EFI boot loader.
    mkdir /Volumes/ESP
    sudo mount -t msdos /dev/disk0s1 /Volumes/ESP

    Keyboard pc105 configuration defaut
    no dead key = any level produces a character
    shift = key with big up arrow on the left
    altgr = right alt key on the right of space key
    By default you have :
    level 1 = lower case letters (nothing to do to access it)
    level 2 = upper case letters (press shift+key)
    level 3 = press Altgr+key
    level 4 = press Altgr+Shit+key
    compose key = allows to combine keys with a sequence of keys instead of pressing them simultaneously. not so convenient, I don't use it.

    My keyboard pc105 configuration (ubuntu) with a layout generator
    with the command line, install gnome-tweak to have access to special menu. Launch tweak using the activity menu. In "Keyboard & Mouse" onglet, desactivate "Show Extended Input Sources". Then, click on "Additional layout Option", in "key to choose the 3rd level", I check "Caps Lock", and in "key to choose the 5th level" I choose "<Less/Greater> chooses 5th level".
    This gives access to eight levels as explained in UniKeyBoard Github Repo written in english for users of german keyboards. Indeed, with the above config, you have
    By default you have :
    level 1 = lower case letters (nothing to do to access it)
    level 2 = upper case letters (press Shift+key)
    level 3 = press CapsLock+key
    level 4 = press CapsLock+Shit+key
    level 5 = press <>+key
    level 6 = press <>+Shift+key
    level 7 = press <>+CapsLock+key
    level 8 = press <>+CapsLock+Shit+key (This not very convenient ! I don't manage to go this high in level anyway, help is welcome)
    Let's now write our own layout.

    1. Create new symbols file:
      sudo touch /usr/share/X11/xkb/symbols/frmath 
    2. Dans le fichier de configuration des menus pour les langues, via la commande:
      sudo gedit /usr/share/X11/xkb/rules/evdev.xml
      Ajouter ceci qu meme niveau que les differents layout existant:
             <layout>
            <configItem>
              <name>frmath</name>
              <!-- Keyboard indicator for French layouts -->
              <shortDescription>fr</shortDescription>
              <description>French with math unicode</description>
              <languageList>
                <iso639Id>fra</iso639Id>
              </languageList>
            </configItem>
            <variantList>
            </variantList>
          </layout>
    3.  Delete xkb cache :

      sudo dpkg-reconfigure xkb-data 
      

        4. Our file frmath is empty. I have modified a script to make layout file for azerty keybord. You can find th tool here. you run the script as follows :

    python fr_keyboard_generator.py frmath_layout.txt

    you can modify the file frmath_layout.txt according to your need. Just keep in mind that the separator is the character ¦
    Then paste the text in custom_layout file doing
     

    sudo gedit /usr/share/X11/xkb/symbols/frmath

        5. Then run
    sudo dpkg-reconfigure xkb-data 

        6. Then restart X for instance, log out and log in, or press ALT+F2, then the "r" key for restart, then the "enter" key.

    Notes : The following command is useful to set the keyboard layout :

    setxkbmap frmath 

    Notes : Names for keys for xkb are defined in

     /usr/include/X11/keysymdef.h.

    On peut aller chercher les symboles unicode sur :

    https://en.wikipedia.org/wiki/List_of_Unicode_characters


    One can use unicode characters in latex with the package UCS. One must add these lines in the preamble of the latex file :

    \usepackage[mathletters]{ucs}
    \usepackage[utf8x]{inputenc}


    Layout for Vim like navigation

    I have created a layout that replace the base layout with navigation keys. It is inspired from this. To download this layout click here. I use AltGr+Space to switch layout, from the navigation to the frmath layout.

    Tuto pour comprendre xkb ici

    Exchange the ctrl and cmd keys on Ubuntu 18.04:
    I exchange these two keys to save finger pain when you often use the ctrl key.

    To do so, edit X Keyboard Extension using
    sudo gedit /usr/share/X11/xkb/symbols/pc

    Make the following changes. Ensure your file looks like this:
    key <LCTL> {    [ Super_L       ]   };
    key <LWIN> {    [ Control_L     ]   };
    ...
    key <RCTL> {    [ Super_R       ]   };
    key <RWIN> {    [ Control_R     ]   };


    Clear xkb's cache with the command:
    sudo rm -rf /var/lib/xkb/*

    Restart your computer.The keys should be exchanged at startup


    WIFI channel

    Le logicie linssid permet de scanner les réseaux wifi alentour et de choisir le meilleurs canal wifi pour son routeur ou sa box internet. Le choix du canal d'une box se fait en se connectant à l'adresse IP de sa box, par exemple 192.168.1.1

    --- Software I used in the past ---

    Sharelatex is a convenient tool to write articles in latex with:

    • online simultaneous editing (you can just edit tex file in a browser!)
    • full history to see who did what and review the changes
    • offline mode (though rather hard to install at the moment)
    You can register here to start using sharelatex. Sharelatex is GNU General Public Licence software.