That’s a bunch of tips I keep here to remind them. Some are stupid, some are in French, others are useful :).
Ubuntu
Enable vertical scrolling with two fingers
– install xserver-xorg-input-synaptics
– do -l
pour voir les options disponibles.
– change an option: synclient VertTwoFingerScroll=1 VertEdgeScroll=0
– permanent changes: add these lines to /etc/rc.local (avant le exit 0)
Starting scripts etc
– executer une simple commande au démarrage:
Ajouter les lignes à /etc/rc.local (avant le exit 0)
– executer un script au démarrage:
Ajouter le script dans /etc/rc0.d (et il faut qu’il soit executable)
– executer un script à l’extinction:
Ajouter le script dans /etc/rc6.d (et il faut qu’il soit executable)
Find some text in files
grep -rnw
Launch a wine application
wine wine-civ5/drive_c/Program\ Files\ \(x86\)/Steam/Steam.exe
Use openvpn with vpngate
See here.
Make sublime text open in a new window
add flag -n. Sublime is called by subl via command line.
Fix the bluetooth headset
pactl list cards short
to get the id
then: pactl set-card-profile x a2dp
where x is the id of the device.
Get all hidden files in the current directory
ls -a | grep "^\."
Find out who is running python for instance
ps x | grep python
Monitor temperature
– install package lm-sensors
– run: sensors
– to run it continously: watch sensors
Install cleanly syncthing
See this
sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install syncthing-gtk
Then go launch syncthing-gkt via menu, go in UI settings, select “Start Syncthing-GTK …”,, in “advance”, select “Keep syncthing binary up to date”
See also: https://apt.syncthing.net/
Automatize tasks
sudo apt-get install gnome-schedule
Make the script you want to run executable.
Add for instance ~/Documents/backup_deep_blue.sh to the task
Force sublime NOT to remember the last file opened
– sublime 3: put “hot_exit”:false in User settings
– sublime 2: idem + “remember_open_files”: false
Install properly todotxt
– Download tar from https://github.com/ginatrapani/todo.txt-cli/releases
– move where desired
– make todo.sh executable: sudo chmod+x todo.sh
– edit .bashrc for convenience:
PATH=$PATH:$HOME/Programmes/todo.txt_cli-2.10
alias t='todo.sh'
export TODOTXT_DEFAULT_ACTION=ls
– Put the path to todo.txt in todo.cfg:
export TODO_DIR="/home/earendil/ElvenInn"
– create the folder for actions:
mkdir -p ElvenInn/todo.actions.d
– put the path to actions inthe config file:
export TODO_ACTIONS_DIR="$TODO_DIR/.todo.actions.d"
– General principle to add actions here
download single file in .todo.actions.d, name it exactly like the action (does not work for schedule up to now).
Install properly owncloud
See this.
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list" sudo apt-get update
if after we get this error:
W: GPG error: http://download.opensuse.org Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 977C43A8BA684223
do:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 977C43A8BA684223 sudo apt-get update
(Found here)
then:
sudo apt-get install owncloud
Then if error 404, try to move the directory owncloud in /var/www/ into /var/www/html/
How to use a newer version of nemo (for instance)
find a ppa, for instance ppa:gwendal-lebihan-dev/cinnamon-nightly
. Then:
sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-nightly sudo apt-get update sudo apt-get -traring install nemo
OR enable backports. On Mint, see sources in the menu, then tick “enable backports”. Then in synaptic, highlight the package in the “package” menu, select “force version”. Or in command line:
sudo apt install -t jessie-backports package
Where “Jessie” is the name of the current mint version, and “package” is the name of the package. Not working well… Finally, the best way is to google “name of the package” + ppa
Pour configurer mercurial proprement
– Installer mercurial des depots.
– changer le fichier de configuration /etc/mercurial/hgrc en rajoutant les lignes :
[web] cacerts=
pour que hg ne vérifie pas les certificats
Vérifier aussi que c’est le cas dans le fichier /etc/mercurial/hgrc.d/cacerts.rc
– installer le plugin dans eclipse: help>install new software
mettre http://mercurialeclipse.eclipselabs.org.codespot.com/hg.wiki/update_site/stable dans le “work with” et ne sélectionner que les stable releases
Pour faire un nouveau projet avec un repo
– file>new>project (second)
– choisir mercurial project
– mettre l’adresse du repo, par exemple:
https://internal.crisis-economics.eu/scm/hg/interbank
plus les username et password.
Compile bibliography for latex
pdflatex document bibtex biblio pdflatex document pdflatex document
Cleanly install California
git clone
sudo apt-get install yelp-tools libgtk-3-dev libecal-1.2 libgdata-dev libgirepository1.0-dev
Concatenate pdfs
gs -q -sPAPERSIZE=a4 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=Pre-tenancy-2016.pdf Pre-tenancy-2016-page1.pdf Pre-tenancy-2016-page2.pdf
Python
How to autoreload the modules in ipython at each execution
%load_ext autoreload %autoreload 2
Compile c code with python
gcc *.c -o ElsaABM.so -lm -shared -fPIC -I/usr/include/python2.7/ -lpython2.7
Get all files in a directory in python
from os import listdir from os.path import isfile, join onlyfiles = [ f for f in listdir(mypath) if isfile(join(mypath,f)) ]
Install easily the python module statsmodel
sudo easy_install statsmodel
(pip does not work yet)
Install mysqldb python module
sudo apt-get install python-mysqldb
Install descartes python module
sudo pip install descartes
Export and reimport cinnamon configuration
– install dconf:
sudo apt-get install dconf-cli
– dump configuration:
dconf dump /org/cinnamon/ > config_cinnamon.txt
– On new computer, load configuration:
dconf load /org/cinnamon/ < config_cinnamon.txt
Import a module from another place
import sys sys.path.insert(1, 'path')
Open jupyter notebook in another browser
– make a profile:
jupyter notebook --generate-config
– find the line c.NotebookApp.browser in .jupyter/jupyter_notebook_config.py and put for instance:
c.NotebookApp.browser = u'chromium-browser'
Use latex with pandas
just write “$N_f$”, but not ‘$N_f$’ !
Use interface design produced by QT designer
See here
– Convert file:
pyuic4 design.ui -o design.py
– Use the design:
import sys from PyQt4 import QtGui import design class ExampleApp(QtGui.QMainWindow, design.Ui_MainWindow): def __init__(self, parent=None): super(ExampleApp, self).__init__(parent) self.setupUi(self) def main(): app = QtGui.QApplication(sys.argv) form = ExampleApp() form.show() app.exec_() if __name__ == '__main__': # if we're running file directly and not importing it main() # run the main function
Get the name of the parameters of a function
Use f.func_code.co_varnames
or f.func_code.co_varnames[:f.func_code.co_argcount]
Matplotlib
Move the legend
bb = leg.legendPatch.get_bbox() xOffset = xOffset newX0 = bb.x0 + xOffset newX1 = bb.x1 + xOffset bb.set_points([[newX0, bb.y0], [newX1, bb.y1]]) leg.set_bbox_to_anchor(bb)
Note: there is a function in general_tools
Change the font for matplotlib
matplotlib.rc('font', family='sans-serif')
or:
from matplotlib import rcParams rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['Verdana']
Change the ticks
tick_params(labelsize = 22)
or: ax.tick_params(labelsize = 22)
Fit the figure with graph+legend
savefig('name.png', bbox_inches='tight')
Nice plots
pd.options.display.mpl_style = 'default' matplotlib.rc('font', family='sans-serif')
Get axis object from figure
To get current axis:
ax = plt.gca()
Or from an existing figure:
fig.get_axes()
Plotly
List of colorscales in plotly:
[‘Blackbody’,’Bluered’,’Blues’,’Earth’,’Electric’,’Greens’,’Greys’,’Hot’,’Jet’,’Picnic’,’Portland’,’Rainbow’,’RdBu’,’Reds’,’Viridis’,’YlGnBu’,’YlOrRd’]
Git
Simple stuff
Push
git push -u origin master
Not sure what -u does, but it is supposed to be important :).
Fetch
git fetch origin
Fetch the latest information about the remote branches. Does not modify local files.
Put aside some uncommited changes
git stash
– Redo them:
git stash apply
– have the list of stash:
git stash list
Set sublime text as editor (for commit)
git config --global core.editor "subl -n -w"
Set meld as default difftool and mergetool
git config --global diff.tool meld
git config --global merge.tool meld
Change the commit message of the last commit (NOT PUSHED!)
git commit --amend
Stat of diff
git diff --stat branch
Untrack a file
git rm --cached filename
Have pretty log
git log --pretty=oneline
Tags
– list of tags: git tag
– new annotated tag: git tag -a v2.0
– view stuff tagged: git show v2.0
– push tags: git push origin --tags
Merge
Merge
if you want to merge pouet into master:
git checkout master
git merge pouet
Merge last two commits
See here.
git rebase --interactive HEAD~2
– in the editor, put s on the second line:
pick b76d157 b
s a931ac7 c
– in the new editor, put the new commit message
Avoid commits from merges
See here.
Rebase instead of merge when pulling
Should be used when the modifications from remote and from local are quite independent. Makes a linear history of commits, as if the two developers work one after the other.
git pull --rebase origin master
Changing history
Revert a commit (creates a new commit)
git revert d24dfga
where d24dfga is the hash of the commit you want to remove.
From here.
Delete a commit (not already push to repository)
See this (2nd answer).
git reset --hard HEAD~1
Force changed history to remote
This is dangerous because all the other guys have to fix manually their own repository.
git push --force
Windows
Create bootable windows usb from ubuntu
See here
in short: format with table of partition gpt and fat32 (primary)
copy files directly from the iso
If the OS you are making a bootable USB for is Windows 7, browse the efi/microsoft folder and copy the entire boot folder from this path one level up in the efi folder. Merge folders if boot already exists.
Here is what to do if you don’t have the bootx64.efi file in efi/boot folder. Browse into the mounted Windows ISO image into the sources folder. Open install.wim with your archive manager (you will need 7z installed). Go to the path ./1/Windows/Boot/EFI and extract the file bootmgfw.efi anywhere you want. Rename it to bootx64.efi and put it on the USB drive, in the efi/boot folder. If you can’t find bootmgfw.efi in install.wim then you probably have a 32 bit Windows ISO or other types of images (recovery disks, upgrade versions).
Ce tuto n’a pas marché avec le p34g, donc j’ai suivi le tuto qui est dans la meme page pour un boot en bios (legacy), en mettant le flag –force pour lle grub-install:
sudo grub-install --force --target=i386-pc --boot-directory="/media/earendil/win7/boot" /dev/sdb
Get rid of the message: “Setup was unable to create a new system partition” at windows 7 installation
This was for the p34g, with usb3 stick on usb 2 port and hand made bootable BIOs legacy windows stick under ubuntu. Just disconnect the usb drive, reconnect it, refresh.
how to shut down blindly windows 7
Win 7: windows key, right arrow, enter to shutdown
windows key, right, right, up, enter to restart
General
Force BIOS
appuyer sur F2 (pour le p34g) AVANT d’allumer le pc.
Bypass a certification issue in firefox when there is no “I understand the risks” option
visit the about:certerror page.
Google Scholar
Commentaire sur rue89
Il faut des connaissances rudimentaires en HTML pour modifier le code de la page qui héberge son article.
J’ai suivi la doc de Google Scholar :
* Lien
Ensuite j’ai pris exemple sur HAL en regardant les balises meta dans leur code source : Lien
Il faut mettre toutes les balises « DC. » et « citation_ » bien remplies dans chaque page qui contient un article.
Ensuite on soumet la page à Google Scholar : Lien
Et voilà … C’est sur que l’idéal serait un espèce de générateur de balises tout fait qui pond une page dédiée à un article. Voir un gestionnaire d’archive personnel. A réfléchir …
install Brave browser
See here
wget -O brave.deb https://laptop-updates.brave.com/latest/mint64 sudo dpkg -i ./brave.deb