22 Sep 2016
|
bash
Copy a set of files present in a directory in another directory conserving the structure
To want to copy only the cuts.csv
files from the processed
directory to the processed_SD
one, conserving the sub-directory architecture :
# In the processed directory
find */interval_0[0-9]/cuts.csv -type f | xargs -i cp "{}" ../processed_SD/ --parents`
/processed ---------------> /processed_SD
|
+-- arrow
| |
| +-- interval_00
| | |
| | +-- image.jpg
| | +-- cuts.csv
| |
| +-- interval_01
| | |
| | +-- cuts.csv
| |
| :
|
+-- game_of_thrones
|
+-- interval_00
| |
| +-- cuts.csv
:
14 Sep 2016
|
bash
Quand on écrit une commande, on peut en rediriger la sortie standard vers un fichier : commande > file
ou à la fin d’un fichier : commande >> file
Si on souhaite en plus logger dans ce fichier les erreurs de commande
, faire ceci : commande > file 2>&1
. Le flux 1 est le standard, le flux 2 est l’erreur, et 2>&1
renvoie 2 vers le pointeur de 1.
Particulièrement utile pour une commande cron qui peut être amenée à bugger, cas où c’est le seul moyen de voir l’output d’erreur.
18 May 2016
|
vim
In Vim, the <ESC> and <CTRL> keys are hard to reach, but used a lot.
New way to get out Insert mode
Change the <ESC> key to jk
.
It allows efficient escape from Insert mode, as your fingers should already be on j
and k
keyboard keys.
In ~/.vimrc
:
Remap <CAPS LOCK> to <CTRL>
The <CTRL> key is hard to reach and the <CAPS LOCK> key is useless.
We have to remap at the system level.
For Ubuntu 14.04, modify the /etc/default/keyboard
file with replacing:
with:
We then have to restart the computer.
(cf. original post)
12 Apr 2016
|
python
Problem : In ipython, the reload of the import is not automatically done when launching new script or launching new command
One simple solution is just to run the 2 following commands :
%load_ext autoreload
autoreload 2
If you want to make this change permanently, you can write in your ipython profile (find it with ipython locate
).
For instance, if the result of ipython locate
is “~/.ipython”, you can edit “~/.ipython/profile_default/ipython_config.py”:
c = get_config()
c.InteractiveShellApp.extensions = ['autoreload']
c.InteractiveShellApp.exec_lines = ['%autoreload 2']
31 Mar 2016
|
bash
Problem : It can be cool to have some syntax color highlight when quickly checking the content of a file with “cat”
Goal : We are going to use pigmentize and create an alias called “pcat” (pygmentized cat)
Setup :
- install pigmentize
sudo apt-get install python-pygments
- open your bashrc and add the line “alias pcat=’pygmentize -g’”
- source your bashrc (source ~/.bashrc)
- you can now use the following cmd : “pcat filename”