- (256)How to set margins
\usepackage{vmargin}
\setmarginsrb{ leftmargin }{ topmargin }{ rightmargin }{ bottommargin }{ headheight }{ headsep }{ footheight }{ footskip }
From: https://tex.stackexchange.com/questions/108574/changing-margins-on-thesis/108578#108578
- (263)Drawing grids in TikZ
millimetric grid:
\draw[step=.1cm,lightgray,very thin] (0,0) grid (10,10);
\draw[step=1cm,black,very thin] (0,0) grid (10,10);
useful grid to place objects
\draw[step=.5cm,lightgray,very thin] (0,0) grid (10,10);
\draw[step=1cm,gray,thin] (0,0) grid (10,10);
- (264)To place a node above another (e.g. for intermediate nodes for angular arrows) in TikZ
\path (MF4.north) -- ++(0,.5) node (midconso3b) {}; % to see it, use {$\times$}
- (265)To enable use of \mbox or \scalebox (\LaTeX) with \matrix (\TikZ)
[ampersand replacement=\&] + use \& as separator in matrix
- (266)The Syntax of Partway Modifiers in TikZ
(1,2)!.75!(3,4)
The meaning of this is: "Use the coordinate that is three quarters on the way from (1,2) to (3,4)."
The second coordinate may be prefixed by an angle, separated with a colon, as in (1,1)!.5!60:(2,2).
The general meaning of a !factor!angle:b is "First, consider the line from a to b. Then rotate this line by angle around the point a. Then the two endpoints of this line will be a and some point c. Use this point c for the subsequent computation, namely the partway computation."
- (44)How to label things and reference them?
\label{labelname} to label
\ref{labelname} to reference
For tables and figures make sure the \label{} comes inside \caption{}
- (45)How to get the euro symbol in LaTeX
\documentclass[10pt]{article}
\usepackage{eurosym}
\begin{document}
You owe me \euro{10.00}.
- (46)Good presentations with math in PDFs!
ps2pdf:
latex presentation.tex
bibtex presentation
latex presentation.tex
latex presentation.tex
dvips -Ppdf -G0 presentation.dvi -o presentation.ps
ps2pdf -sPAPERSIZE=a4 presentation.ps presentation.pdf
acroread presentation.pdf
so "-Ppdf -G0" is the graal to use math in PDF
- (111)Prettier font for PDF
It is better to use OT1 fonts than T1:
\usepackage[latin1]{inputenc}
\usepackage[OT1]{fontenc}
is better than:
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
- (114)Manage font/indent/spaces inside the bibliography (does not work with PowerDot)
\newcommand{\bibfont}{\tiny} % Bibliography's font size
\setlength{\bibhang}{4ex} % Indent of Bibliography entries
\setlength{\bibsep}{3pt} % Separation between BiB entries
- (152)How to get pretty Cross and Check marks
\usepackage{pifont}
Check (valid, comme une racine carree) symbol : \ding{52}
Cross (invalid, comme une croix) symbol : \ding{56}
\usepackage{bbding}
Check = \Checkmark
Cross = \XSolidBrush
- (157)Some versions of PDFtricks do not generate the temporary eps->pdf picture files correctly
use the patch below:
< \immediate\write18{dvips -o \PDFTfigname.ps \PDFTfigname}
< \PDFTWarning{pdftricks}{PS generated -- \PDFTfigname.ps}}{}
< \IfFileExists{\PDFTfigname.ps}{%
< \immediate\write18{pstopdf \PDFTfigname.ps}
< \PDFTWarning{pdftricks3}{\PDFTfigname.ps converted to \PDFTfigname.pdf}}{}
< \IfFileExists{\PDFTfigname.pdf}{%
< \immediate\write18{pdfcrop \PDFTfigname.pdf}
< \immediate\write18{mv \PDFTfigname-crop.pdf \PDFTfigname.pdf}
< \PDFTWarning{pdftricks3}{\PDFTfigname.pdf cropped}}{}
---
> \immediate\write18{dvips -E -o \PDFTfigname.eps \PDFTfigname}
> \PDFTWarning{pdftricks}{EPS generated -- \PDFTfigname.eps}}{}
> \IfFileExists{\PDFTfigname.eps}{%
> \immediate\write18{epstopdf \PDFTfigname.eps}
> \PDFTWarning{pdftricks3}{\PDFTfigname.eps converted to \PDFTfigname.pdf}}{}
- (158)List of Bugs in PDFTricks
BUG1: PDFTricks requires you enable shell-escape (but you can use latex's runtime option --shell-escape).
BUG2: \begin{pdfpic} MUST be at the very beginning of the line (first char)!
BUG3: PDFTricks generates the temporary files using the "article" class, which creates problems (e.g.: justification of text to too small margins), if you're using larger classes, like a0poster.
BUG4: within \begin{psinputs}\end{psinputs}, only \usepackage are taken into account. So it is impossible to add, for instance, \input{} and have common definitions of macros for every picture.
- (160)PowerDot does not like the \onslide in titles of the slides
If I put an \onslide command in the title of the slide, then each slide will appear X times (where X is the number of overlays I'm creating in the slide with the \onslide in the title). This is because the \onslide command will appear also in the "TOC menu" on the left of each slide
The solution is to set the bm= and toc= in the options of the slides, to override the not-working-TOC
- (203)Absolute Positioning of Graphics (particularly in Beamer)
textpos was what you are looking for.
you can use the following macro:
%the needed packages
\usepackage[absolute,showboxes]{textpos}
\usepackage{graphicx}
%adjust the TPHorizModule and TPHorizModule units to the displayed mm %grid
\TPGrid{210}{297}
%puts a graphic at the absolute position described by the grid
%#1 x, #2 y, #3 width, #4 height, #5 x-ref-ratio, #6 y-ref-ratio, #7 graphic
\newcommand\putpic[7]{%
\begin{textblock}{#3}[#5,#6](#1,#2)%
\includegraphics[width=#3\TPHorizModule,height=#4\TPVertModule]{#7}%
\end{textblock}%
}
\putpic{20}{20}{100}{100}{graphics/mypic}
(from: http://old.nabble.com/Absolute-Positioning-Graphics...-Grid--td19273385.html)
Eventually \begin{textblock*} allows to enter abolute coordinates rather than TPGrid-related ones.
- (208)How to use normal text in math mode
Use the $\text{}$ command, which is included in the \usepackage{amsmath}
e.g., ...the i$^\text{th}$ value is...
- (212)On the use of counters
\newcounter{plip} % defines the counter
\setcounter{plip}{3} % sets the value
\addtocounter{plip}{-1} % modifies the value
plipVal=\number\value{plip} % prints the value as a number
plipStr=\arabic{plip} % prints the value as a string in arabic format
- (213)On the use of counters and lengths
Counters store only int values.
Lengths store double values, but with a unit.
To store a double without unit, use pgf package (see hint 500) (for instance to use in \makebox(__,__){}).
- (241)Solving the infinite loop problem of kpsewhich (\subset Kpathsea) (and csqtly the freezing of texlive pkg installation in OpenBSD)
[stupidities]
- fsck
- rm -fR ~/.texlive*
- work with a different terminal program
[compile test .tex files]
- pdftex -recorder story # [then see see .fls files?]
pdflatex -recorder sample2e
[problems finding the .pool files or texmf.cnf?]
- pdftex -ini \\dump
pdftex \\end
[search path problem?]
- kpsewhich -prog pdflatex -debug 6 pdftex.map
- pdflatex -kp 6 nfssfont
- texconfig conf
- kpsewhich uses $PATH? => simplify it
[font problem? & texmf trees]
- tlmgr generate updmap
- sudo mktexlsr
sudo -H updmap-sys --nohash --nomkmap --syncwithtrees
sudo -H updmap-sys --nohash --nomkmap --enable Map mymap1.map
sudo -H updmap-sys --nohash --nomkmap --enable Map mymap2.map
...
sudo -H updmap-sys
- mktexfmt --all
- (mktextfm <fontname>)
----------------
So path searching is not slow and CPU usage is slow, which
indicates waiting for I/O. This could be loading files
(.pool file, format, ...), console output, or file output.
You didn't mention of whether files are on local disk or
network, USB, etc.
1. on general principles, I'd do a disk cleanup and run
chkdsk /f to make sure disks are OK.
2. check for signs of trouble in the event viewer.
3. run "pdftex -recorder story" and and "pdflatex -recorder
sample2e" to check for files in unexpected locations,
especially network or USB drives.
4. try a different terminal program -- there have been
reports of widely varying performance between different
terminals, remote ssh, etc.
----------------
Can come from kpsewhich (in KPathSea pkg)
----------------
> maybe compare the output of
>
> kpsewhich -prog pdflatex -debug 6 pdftex.map
>
> and
>
> pdflatex -kp 6 nfssfont
And study the output of
texconfig conf
-----------------
BTW, before you begin to study large .fls files, you can test more
simple things. For instance
pdftex -ini \\dump
doesn't load a format file. If this is slow, maybe pdftex has
problems finding the pool file or texmf.cnf.
Then you could try
pdftex \\end
which doesn't make much more than to load a format file.
What also comes to my mind: Check your environment variables! No
TeX-related environment variable is required. This is a nasty thing
on Cygwin because Cygwin inherits the Windows environment.
This means that you'll definitely run into trouble if you have another
TeX distribution on Windows which makes use of environment variables.
I doubt that this is the problem because you said that you just
replaced the binary. But it makes sense to check this anyway.
Curious things can happen. My first attempt to compile TeXLive failed
because Cygwin appends UNIX directories to the Windows path. I had to
set PATH=/usr/local/bin:/usr/bin:/bin explicitly on Cygwin in order to
get it compiled.
--------------------
<Jaj-J> t'as essayé de supprimer les trucs dans ton home?
<Jaj-J> user: ton .texlive?
<user> Jaj-J: yop, sans succes ;{
<user> Jaj-J: en tous les cas tout se rapporte à un kpsewhich mal configuré ...
<Jaj-J> user: et c'est quoi ça?
<user> Jaj-J: un truc pour indexer les fichiers texmf apparemment
<user> Jaj-J: genre kpsewhich color.sty
<user> Jaj-J: devrait retourner /usr/local/share/texmf-dist/tex/latex/graphics/color.sty en 2 sec
<Jaj-J> user: ah ok
<Jaj-J> user: et toi il retourne quoi?
<user> Jaj-J: moi il rame 2 minutes @home et part en bcl @work
<Jaj-J> user: ah ouais :)
<user> Jaj-J: apparemment je commence à approcher de la solution avec la commande : kpsewhich -debug 6 color.sty
<user> Jaj-J: il semble que les ls-R soit en cause et il y a une cmd pour les refaire
<user> Jaj-J: je crois que c mktexlsr
----------------------
For that I would like to use the
'tlmgr generate updmap'
procedure with a local file
'updmap-local.cfg' in my 'library/texmf/web2c/' folder.
-----------------------
pdflatex -kp 6 nfssfont # attend un <nom de font> puis lance mktextfm <nom de font>
-----------------------
A personal version of the pdftex.map, etc., files are created in
~/.texlive2009/ not in your personal tree at ~/Library/texmf/. Take a
look there.
Also, for personal maps you need to invoke
updmap --enable Map mymap.map
for each of the map files you want to activate. NOTE: there is no sudo
used for personal map since that would create the files with root as
owner in your personal texlive2009 tree.
I usually discourage doing things this way. I'd install the fonts in
the proper subdirectories of /usr/local/texlive/texmf-local/, run
sudo mktexlsr
and then
sudo -H updmap-sys --enable Map mymap.map
-----------------------
#!/bin/bash
sudo mktexlsr
sudo -H updmap-sys --nohash --nomkmap --syncwithtrees
sudo -H updmap-sys --nohash --nomkmap --enable Map mymap1.map
sudo -H updmap-sys --nohash --nomkmap --enable Map mymap2.map
...
sudo -H updmap-sys
on the system wide method. This will first get all the maps entered in
updmap.cfg, enable each of the maps you want without taking the time
to rebuild the pdftex.map, etc., and finally rebuild the the system
wide pdftex.cfg, etc., maps.
If you are trying for a purely personal configuration use
updmap ...
instead of
sudo -H updmap-sys ...
above.
If you want to build a global map that includes the fonts in your
personal texmf tree use
sudo updmap-sys ...
instead of
sudo -H updmap-sys
since the distribution files are owned by root when installed with
MacTeX.
--------------------------
Am 05.11.2009 um 23:02 schrieb Herbert Schulz:
> sudo mktexlsr
This command creates up-to-date ls-R "hash" files of the system -
not needed privately
> sudo -H updmap-sys --nohash --nomkmap --syncwithtrees
This command just updates the system-wide updmap.cfg file - not
needed privately
> sudo -H updmap-sys --nohash --nomkmap --enable Map mymap1.map
> sudo -H updmap-sys --nohash --nomkmap --enable Map mymap2.map
> ...
The commands above just record changes in the system-wide updmap.cfg
file. No MAP file is rebuilt, so the commands run quite fast. Last
step in this scheme is the following command which actually rebuilds
the system's MAP files:
> sudo -H updmap-sys
Using just 'updmap' instead of 'sudo -H updmap-sys' or 'sudo updmap-
sys' will work on the private fonts and MAP files set. This private
setup will contain all MAP file fragments enabled by the system,
except they are extra disabled privately.
Mostly from: http://www.tug.org/pipermail/pdftex/2007-September/007360.html
[!!!! Solution !!!!]
For some time now, I had in my .bashrc:
# NOTE: the // indicates to LaTeX to get recursively into the subdirs.
for i in . ~/.TeX/installedPkgs/* ~/.TeX/installedPkgs2//*
do
export TEXINPUTS=${i}//:$TEXINPUTS
export BIBINPUTS=${i}//:$BIBINPUTS
export BSTINPUTS=${i}//:$BSTINPUTS
done
Unfortunately, in my new machine, these directories point to nothing that exists. It seems that either the 'inexistant dirs' or the use of '//*' in the pathes makes kpsewhich loop infitely. The solution consists simply in unsetting the vars TEXINPUTS BIBINPUTS and BSTINPUTS.
- (251)How to use TikZ for drawing pics?
- Come back to normal font in italic mode: [font=\normalfont]
- Basic syntax for node: \node[opts] (name) at (position) {text};
- To make lighter/stronger colors: [fill=red!20]
- Place nodes relatively: [above/below/left/right,node distance=5mm and 5mm]
or \usetikzlibrary{positioning}(?) and "[above=1cm of <node name>]"
- To draw a grid (millimetric paper):
\draw[step=.1cm,lightgray,very thin] (0,0) grid (15,15);
\draw[step=1cm,gray,thin] (0,0) grid (15,15);
- Change the opacity of an object: [draw opacity=0.5]
- Make a gradient: \usetikzlibrary{fadings} + [left color=#1!10,right color=#1!90]
- Add a shadow: \usetikzlibrary{shadows} + [rectangle, drop shadow={opacity=0.25,color=#1!50}]
- To create a style for all objects of a type:
\begin{tikzpicture}[abox/.style={draw=black,thick,font=\bf}]
- To parametrize the style:
\begin{tikzpicture}[abox/.style args={<args pattern>, e.g. #1/#2/#3}{draw=#1,text=#2,text width=#3,font=\bf}, hardware/.style={abox=blue/black/2cm}]
- To modify an existing style: \begin{tikzpicture}[*every* abox/.style...]
- To make calculations (-/+ only) on coordinates: \usetikzlibrary{calc} + \node[...] (A) at ($ (0,0) + .1*(rand,rand) $);
- Thanks to TikZ it is possible to separate the elements (\node) from their presentation (style) and placement (\matrix)
- To draw the bounding box as seen by LaTeX and created by TikZ: add, AT THE END:
\draw[thick] (current bounding box.south west) rectangle
(current bounding box.north east);
- (252)Come back to normal font in italic mode
\normalfont
- (267)To generate the pics in their BoundingBoxes, rather than a full page in TikZ
\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\newlength{\imagewidth}
\newlength{\imagescale}
- (271)How to manage un-hyphened words without breaking penalties, etc.
1. Writing an article, I used the word "émerge" and it appeared at the end of a line totally outboxed.
You can reproduce a similar situation using a4paper and babel French, making a paragraph filled with "émerge" words. The tenth occurence will not be hyphenized and will appear on the second line (difference with my case in which it appeared outboxed on the first line) whereas it should be possible to hyphenize the first "é-" on the first line and the "-merge" and the second line.
2. Using é\-mer\-ge would do the job. However, trying to make the solution more global using "\hyphenation{é-mer-ge}" in the preamble of the document does not work.
3. I'm sure playing with penalties would work, but I would fear using such an intrusive solution in a full article.
4. Juan told me about the following package, with the following options:
\usepackage[babel=true,kerning=true,protrusion=true,spacing=true,expansion=true,tracking=true]{microtype}
It seems that it works like word, playing with the size of the spaces between the words (and even with the size of the letters?) nut the result is pretty.
- (276)T1 vs. OT1 fonts
The default LaTeX font encoding is OT1, the encoding of the original Computer Modern TeX font. It contains only the 128 characters of the 7-bit ASCII character set. When accented characters are required, TeX creates them by combining a normal character with an accent. While the resulting output looks perfect, this approach stops the automatic hyphenation from working inside words containing accented characters. Besides, some of Latin letters could not be created by combining a normal character with an accent, to say nothing about letters of non-Latin alphabets, such as Greek or Cyrillic.
Conclusion: it's better use T1 fonts
From: http://en.wikibooks.org/wiki/LaTeX/Internationalization
- (283)How to make a scientific conference poster?
Just use both a0poster and textpos packages:
http://www.tex.ac.uk/CTAN/macros/latex/contrib/textpos/textpos.html
http://nxg.me.uk/docs/posters/
The philosophy is quite simple: you write textboxes that you place on a grid.
- (318)What to do in Beamer or Moderncv when the French "guillemet" has to be used at the begining of an item?
When in beamer using:
\item <<~test~>> do not work in beamer
or in moderncv:
\cventry{date}
{title}
{Project}
{}
{<<~place~>>}
{content}
it will not work, as < is mistakenly interpreted.
=>you have to force a space after the class's command:
in beamer: \item\ <<~test~>>
in moderncv:
\cventry{date}
{title}
{Project}
{}
{\ <<~place~>>}
{content}
- (321)How to use colors in tables with \multicolumns?
\begin{table}
\begin{tabular}{ccc}
\rowcolor[rgb]{1,0,0}
Hello & \multicolumn{2}{>{\columncolor[rgb]{1,0,0}}c}{Goodbye}
\end{tabular}
\end{table}
- (322)How to make breakable tables?
\usepackage{longtable} and use \begin{longtable} rather of \begin{tabular}
- (323)How to print the value of a counter or length?
You can insert the value of a variable with \the:
\the\oddsidemargin
- (331)What is the minimal list of document to learn/use LaTeX?
Apprends_LaTeX.pdf (http://www.babafou.eu.org/Apprends_LaTeX/Apprends_LaTeX.pdf)
Beamer3.pdf (???)
FAQ LaTeX http://(www.tex.ac.uk)
JMPL.ps.gz (http://tug.ctan.org/info/JMPL.ps.gz)
lxmanuel.pdf (https://www.ntg.nl/doc/bayart/lxmanuel.pdf -> https://www.ntg.nl/literatuur/bayart/lxmanuel.pdf)
TikZ-Impatient.pdf (http://math.et.info.free.fr/TikZ/bdd/TikZ-Impatient.pdf)
beameruserguide.pdf (http://tug.ctan.org/macros/latex/contrib/beamer/doc/beameruserguide.pdf)
bibstyles.html (See http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.html =>
http://web.archive.org/web/20080207003225/http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.html)
bibstyles.pdf (http://web.archive.org/web/20080207003225/http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.pdf)
downes-short-math-guide.pdf (http://tex.loria.fr/general/downes-short-math-guide.pdf)
epslatex.pdf (ftp://ftp.dante.de/tex-archive/info/epslatex.pdf)
latex_maths+pix.pdf (http://www-h.eng.cam.ac.uk/help/documentation/docsource/latex_maths+pix.pdf)
lshort.pdf (https://tobi.oetiker.ch/lshort/lshort.pdf)
pgfmanual.pdf (http://www.texample.net/media/pgf/builds/pgfmanualCVS2012-11-04.pdf)
symbols-a4.pdf (http://ctan.tetaneutral.net/info/symbols/comprehensive/symbols-a4.pdf)
textpos.pdf (http://ctan.math.washington.edu/tex-archive/macros/latex/contrib/textpos/textpos.pdf)
Tutorial (http://www.andy-roberts.net/writing/latex)
WikiBooks_LaTeX.pdf (https://en.wikibooks.org/wiki/LaTeX)
advancedlatex.ps (http://www-h.eng.cam.ac.uk/help/documentation/docsource/latex_advanced.pdf http://pcleon.if.ufrgs.br/pub/latex/latex_advanced.o.ps)
guide-local.pdf (Tout ce que vous avez toujours voulu savoir sur LaTeX sans jamais... http://lozzone.free.fr/latex/guide-local.pdf)
latex-introduction.pdf (???)
mil.pdf (Math into LATEX, http://tex.loria.fr/general/mil.pdf)
usrguide.pdf (http://latex-project.org/guides/usrguide.pdf)
visualFAQ.pdf (https://www.tug.org/texlive//devsrc/Master/texmf-dist/doc/latex/visualfaq/visualFAQ.pdf)
visualTikZ (https://ctan.crest.fr/tex-archive/info/visualtikz/VisualTikZ.pdf)
https://www.latex4technics.com/
http://www.texample.net/
http://detexify.kirelabs.org/classify.html
- (337)How to change the name of the bibliography?
\renewcommand{\bibname}{Journal2}
\renewcommand{\refname}{Journal2}
- (363)A basic LaTeX file for Beamer presentation
\documentclass[french,
t,% 't' (resp. 'c') places text vertically at top/center of the slides
xcolor={pdftex,svgnames}, % dvipsnames, dvipsnames*, svgnames, svgnames*, x11names,
]{beamer} %
\usetheme{default} % AnnArbor,Antibes,Bergen,Berkeley,Berlin,Boadilla,CambridgeUS,Copenhagen,Darmstadt,Dresden,Frankfurt,Goettingen,Hannover,Ilmenau,JuanLesPins,Luebeck,Madrid,Malmoe,Marburg,Montpellier,PaloAlto,Pittsburgh,Rochester,Singapore,Szeged,Warsaw,boxes,default
% PDF settings / links
\usepackage{hyperref}
\hypersetup{%
pdftitle={...},%
pdfauthor={...},%
pdfsubject={...},%
pdfkeywords={...},%
colorlinks=true,%
urlcolor=blue,%
linkcolor=%
}
% Correct French/English indentation and splitting of words
\usepackage{babel}
% Correct management of accentuated chars in input file
\usepackage[utf8]{inputenc}
%\usepackage[latin1]{inputenc}
% Correct font for the generation of docs with accentuated chars
\usepackage[T1]{fontenc} % Can handle hyphenation of words with accented characters
%%\usepackage[OT1]{fontenc} % Might generated bad looking PDFs
% Access to many maths symbols
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amsfonts}
% Insertion of images generated by external tools
\usepackage{graphicx}
% To generate pretty & scalable images directly in LaTeX
\usepackage{tikz}
% \draw[decorate,decoration={coil,amplitude=1.5cm, segment length=.4cm}] (5,5.5) -- (5,1.5) ;
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.pathmorphing,snakes}
% To position nodes outside tikzpicture env (e.x. in itemize)
\usetikzlibrary{tikzmark}
% To compute positions
%\usetikzlibrary{calc}
% To position text blocks absolutely
\usepackage[absolute,overlay]{textpos}
% To insert colorized code blocks ===> REQUIRES \begin{frame}[*fragile*]{...}
\usepackage{listings}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
% To print numbers correctly
\usepackage{numprint}
% Remove navigation bar
%\beamertemplatenavigationsymbolsempty
\setbeamertemplate{navigation symbols}{}
% Remove outline at top
\setbeamertemplate{headline}{}
% Add slide counter
\addtobeamertemplate{navigation symbols}{}{%
\usebeamerfont{footline}%
\usebeamercolor[fg]{footline}%
\hspace{1em}%
\insertframenumber/\inserttotalframenumber
}
% Info for title page
\title[<short>]{...}
\author[<short>]{... \and ... \inst{2}}
\institute[<short>]{
\inst{1}%
...
\and
\inst{2}%
...}
\date[<short>]{\today{}}
\subject{...}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% The title page
\begin{frame}
\titlepage
\end{frame}
% The TOC
\begin{frame}{Table of contents}
\tableofcontents
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\part{}
\section{}
\subsection{}
% First slide
\begin{frame}{...}
\only<1-2>{...} % Shows the elements greyed when slide(s) is not the one indicated
\uncover<3->{...} % Only shows the elements when slide(s) is the one indicated
\begin{figure}
\begin{center}
\includegraphics[width=0.65\textwidth]{...}
\end{center}
% To resize a picture
% or \scalebox{<factor>}{...}
\resizebox{<horizontal size>}{<vertical size>}{%
\begin{tikzpicture}
///
\end{tikzpicture}
}
\end{figure}
\begin{block}{Un bloc normal}
Texte du block \texttt{block}
\end{block}
\begin{alertblock}{Un bloc très alerte}
Texte du block \texttt{alertblock}
\end{alertblock}
\begin{exampleblock}{Un bloc exemplaire}
Exemple de block \texttt{exampleblock}
\end{exampleblock}
\begin{definition}
environnement definition
\end{definition}
\begin{example}
environnement example
\end{example}
\begin{proof}
environnement proof
\end{proof}
\begin{theorem}
environnement theorem
\end{theorem}
\end{frame}
\begin{columns}[options] % 't' (resp. 'c') places text vertically at top/center of the slides
\begin{column}[t]{0.40\textwidth}
contenu
\end{column}
\begin{column}[c]{0.59\textwidth}
contenu
\end{column}
\end{columns}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
- (364)A basic file for an article/report/book
\documentclass[11pt,french,a4paper,twoside]{article} % draft % report/book
\usepackage{hyperref}
\hypersetup{%
pdftitle={...},%
pdfauthor={...},%
pdfsubject={...},%
pdfkeywords={...}%
}
% To load many pre-defined color names
\usepackage[pdftex,svgnames]{xcolor} % dvipsnames, dvipsnames*, svgnames, svgnames*, x11names,
% Correct French/English indentation and splitting of words
\usepackage{babel}
% Correct management of accentuated chars in input file
\usepackage[latin1]{inputenc}
%\usepackage[utf8]{inputenc}
% Correct font for the generation of docs with accentuated chars
\usepackage[T1]{fontenc} % Can handle hyphenation of words with accented characters
%%\usepackage[OT1]{fontenc} % Might generated bad looking PDFs
% Access to many maths symbols
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amsfonts}
% Insertion of images generated by external tools
\usepackage{graphicx}
% To include pdfs
\usepackage[final]{pdfpages}
% To generate pretty & scalable images directly in LaTeX
\usepackage{tikz}
% \draw[decorate,decoration={coil,amplitude=1.5cm, segment length=.4cm}] (5,5.5) -- (5,1.5) ;
\usetikzlibrary{decorations.text}
\usetikzlibrary{decorations.shapes}
\usetikzlibrary{decorations.pathmorphing,snakes}
% To print numbers correctly
\usepackage{numprint}
\usepackage{vmargin}
%\setpapersize{A4}
%\setmarginsrb{ leftmargin }{ topmargin }{ rightmargin }{ bottommargin }{ headheight }{ headsep }{ footheight }{ footskip }
%\setmargrb{ leftmargin }{ topmargin }{ rightmargin }{ bottommargin }%
%%\pagestyle{empty}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
% The title page
% Info for title page
\title[<short?>]{...}
\author[<short?>]{...}
\date[<short?>]{\today{}}
\maketitle
% The TOC
\tableofcontents
\part{}
%\chapter{} %% For report/book
\section{}
\subsection{}
\subsubsection{}
\setboolean{@twoside}{false}
\includepdf[pages=-, offset=75 -75]{file.pdf}
\includegraphics[width=.3\linewidth]{file.png}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
- (473)How to access quickly the documentation of a LaTeX package?
texdoc <pkg name>
texdoc texdoc
texdoc beamer
From: http://www.planet-libre.org/post/10552
- (500)How to make integer/float computations?
\usepackage{pgf}
\pgfmathsubtract{.1}{.3}
\pgfmathresult
- (530)The modified "moderncv.cls" that allows to set the ratio of space for the columns in \cvlanguage
%% start of file `moderncv.cls'.
%% Copyright 2006-2010 Xavier Danaux (xdanaux@gmail.com).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
%-------------------------------------------------------------------------------
% identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{moderncv}[2010/05/24 v0.8 modern curriculum vitae document class]
%-------------------------------------------------------------------------------
% debugging
%-------------------------------------------------------------------------------
\newif\if@DEBUG\@DEBUGfalse
%-------------------------------------------------------------------------------
% class options
%
% (need to be done before the external package loading, for example because
% we need \paperwidth, \paperheight and \@ptsize to be defined before loading
% geometry and fancyhdr)
%-------------------------------------------------------------------------------
% paper size option
\DeclareOption{a4paper}{
\setlength\paperheight{297mm}
\setlength\paperwidth{210mm}}
\DeclareOption{a5paper}{
\setlength\paperheight{210mm}
\setlength\paperwidth{148mm}}
\DeclareOption{b5paper}{
\setlength\paperheight{250mm}
\setlength\paperwidth{176mm}}
\DeclareOption{letterpaper}{
\setlength\paperheight{11in}
\setlength\paperwidth{8.5in}}
\DeclareOption{legalpaper}{
\setlength\paperheight{14in}
\setlength\paperwidth{8.5in}}
\DeclareOption{executivepaper}{
\setlength\paperheight{10.5in}
\setlength\paperwidth{7.25in}}
\DeclareOption{landscape}{
\setlength\@tempdima{\paperheight}
\setlength\paperheight{\paperwidth}
\setlength\paperwidth{\@tempdima}}
% font size options
\newcommand\@ptsize{}
\DeclareOption{10pt}{\renewcommand\@ptsize{0}}
\DeclareOption{11pt}{\renewcommand\@ptsize{1}}
\DeclareOption{12pt}{\renewcommand\@ptsize{2}}
% draft/final option
\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\DeclareOption{final}{\setlength\overfullrule{0pt}}
% nolmodern option
\newif\if@lmodern\@lmoderntrue
\DeclareOption{nolmodern}{\@lmodernfalse}
% nocolor option
\newif\if@color\@colortrue
\DeclareOption{nocolor}{\@colorfalse}
% CJK option
%\newif\if@CJK\@CJKfalse
%\DeclareOption{CJK}{\@CJKtrue}
% execute default options
\ExecuteOptions{a4paper,11pt,color,final}
% process given options
\ProcessOptions\relax
\input{size1\@ptsize.clo}
%-------------------------------------------------------------------------------
% required packages
%-------------------------------------------------------------------------------
% \AtEndPreamble hook (loading tetoolbox instead of defining the macro, as to avoid incompatibilities with etoolbox (and packages relying on it) defining the macro too)
\RequirePackage{etoolbox}
%\let\@endpreamblehook\@empty
%\def\AtEndPreamble{\g@addto@macro\@endpreamblehook}
%\let\moderncv@document\document
%\def\document{\endgroup\@endpreamblehook\begingroup\moderncv@document}
% if... then... else... constructs
\RequirePackage{ifthen}
% pdf vs ps compilation
\RequirePackage{ifpdf}
% color
\ifpdf
\RequirePackage[pdftex]{color}
\else
\RequirePackage[dvips]{color}
\fi
% font encoding
\RequirePackage[T1]{fontenc}
% scalable Computer Modern fonts
%\usepackage{type1cm}
% latin modern fonts
%\AtEndOfClass{%
\if@lmodern
\RequirePackage{lmodern}\fi%}
% symbols like \Telefon, \Mobilefone, \Letter and \Email
\RequirePackage{marvosym}
% extended characters of T1 in .ps + other guillemets
%\RequirePackage{ae,aecompl,aeguill}
% page geometry
\addtolength{\oddsidemargin}{-54pt}
\addtolength{\textwidth}{109pt}
\addtolength{\topmargin}{-70pt}
\addtolength{\textheight}{122pt}
\addtolength{\marginparsep}{-5pt}
\addtolength{\marginparwidth}{-10pt}
% hyperrefs
\RequirePackage{url}
\urlstyle{tt}
% load hyperred at the end of the preamble to pass options required by loaded packages (like CJK)
\AtEndPreamble{
\@ifpackageloaded{CJK}
{
\ifpdf\RequirePackage[pdftex,CJKbookmarks]{hyperref}
\else\RequirePackage[dvips,CJKbookmarks]{hyperref}\fi}
{
\ifpdf\RequirePackage[pdftex]{hyperref}
\else\RequirePackage[dvips]{hyperref}\fi}
\AtBeginDocument{
\hypersetup{
breaklinks,
baseurl = http://,
pdfborder = 0 0 0,
pdfpagemode = UseNone,% do not show thumbnails or bookmarks on opening
% pdfstartview = FitH,
pdfstartpage = 1,
pdfcreator = \LaTeX{} with `moderncv' package,
pdfproducer = \LaTeX{},
bookmarksopen = true,
pdfauthor = \@firstname~\@familyname,
pdftitle = \@title,
pdfsubject = \@firstname~\@familyname,
pdfkeywords = \@firstname~\@familyname{} curriculum vit\ae{}}}
\pagenumbering{arabic}% has to be issued after loading hyperref
}
% graphics
\ifpdf
\RequirePackage[pdftex]{graphicx}
\else
\RequirePackage[dvips]{graphicx}\fi
% GM: For float number computations
\RequirePackage{pgf}
% headers and footers
\RequirePackage{fancyhdr}
\fancypagestyle{plain}{
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\fancyhf{}}
\pagestyle{plain}
% compatibility package with older versions of moderncv
\RequirePackageWithOptions{moderncvcompatibility}
%-------------------------------------------------------------------------------
% class definition
%-------------------------------------------------------------------------------
% minimal base settings
\setlength\lineskip{1\p@}
\setlength\normallineskip{1\p@}
\renewcommand\baselinestretch{}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0pt}
\setlength\columnsep{10\p@}
\setlength\columnseprule{0\p@}
% TO BE TESTED
%\setlength\arraycolsep{5\p@}
%\setlength\tabcolsep{6\p@}
%\setlength\arrayrulewidth{.4\p@}
%\setlength\doublerulesep{2\p@}
%\setlength\tabbingsep{\labelsep}
%\setlength\fboxsep{3\p@}
%\setlength\fboxrule{.4\p@}
\pagestyle{empty}
\raggedbottom
\onecolumn
%-------------------------------------------------------------------------------
% style commands definitions
%-------------------------------------------------------------------------------
% symbols used
\providecommand*{\listitemsymbol}{\Neutral}%{{\fontencoding{U}\fontfamily{ding}\selectfont\tiny\symbol{'102}}}
\providecommand*{\addresssymbol}{}
\providecommand*{\mobilesymbol}{\Mobilefone}
\providecommand*{\phonesymbol}{\Telefon}
\providecommand*{\faxsymbol}{\FAX}
\providecommand*{\emailsymbol}{\Letter}
\providecommand*{\homepagesymbol}{{\Large\ComputerMouse}}
% colors
\definecolor{firstnamecolor}{rgb}{0,0,0}
\definecolor{familynamecolor}{rgb}{0,0,0}
\definecolor{titlecolor}{rgb}{0,0,0}
\definecolor{addresscolor}{rgb}{0,0,0}
\definecolor{quotecolor}{rgb}{0,0,0}
\definecolor{sectionrectanglecolor}{rgb}{0,0,0}
\definecolor{sectiontitlecolor}{rgb}{0,0,0}
\definecolor{subsectioncolor}{rgb}{0,0,0}
\definecolor{hintcolor}{rgb}{0,0,0}
% fonts
\providecommand*{\firstnamefont}{}
\providecommand*{\familynamefont}{}
\providecommand*{\titlefont}{}
\providecommand*{\addressfont}{}
\providecommand*{\quotefont}{}
\providecommand*{\sectionfont}{}
\providecommand*{\subsectionfont}{}
\providecommand*{\hintfont}{\small\sffamily}
% styles
\providecommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
\providecommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
\providecommand*{\titlestyle}[1]{{\titlefont\color{titlecolor}#1}}
\providecommand*{\addresstyle}[1]{{\addressfont\color{addresscolor}#1}}
\providecommand*{\quotestyle}[1]{{\quotefont\color{quotecolor}#1}}
\providecommand*{\sectionstyle}[1]{{\sectionfont\color{sectiontitlecolor}#1}}
\providecommand*{\subsectionstyle}[1]{{\subsectionfont\color{subsectioncolor}#1}}
\providecommand*{\hintstyle}[1]{{\hintfont\color{hintcolor}#1}}
% themes: casual (default), classic, ...
\newcommand*{\moderncvtheme}[2][]{
\def\@moderncvtheme{#2}
\def\@moderncvthemeoptions{#1}}
\moderncvtheme{casual}% default theme
\AtEndPreamble{\RequirePackage[\@moderncvthemeoptions]{moderncvtheme\@moderncvtheme}}
%-------------------------------------------------------------------------------
% structure commands definitions
%-------------------------------------------------------------------------------
\newcommand*{\firstname}[1]{\def\@firstname{#1}}
\newcommand*{\familyname}[1]{\def\@familyname{#1}}
\renewcommand*{\title}[1]{\def\@title{#1}}
\newcommand*{\address}[2]{\def\@addressstreet{#1}\def\@addresscity{#2}}
\newcommand*{\mobile}[1]{\def\@mobile{#1}}
\newcommand*{\phone}[1]{\def\@phone{#1}}
\renewcommand*{\fax}[1]{\def\@fax{#1}}
\newcommand*{\email}[1]{\def\@email{#1}}
\newcommand*{\homepage}[1]{\def\@homepage{#1}}
\newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}}
\def\@photowidth{0pt}
\newcommand*{\photo}[2][64pt]{\def\@photowidth{#1}\def\@photo{#2}}
\newcommand*{\quote}[1]{\def\@quote{#1}}
% length used by the moderncv layout
% quote length
\newlength{\quotewidth}
% section lengths
\newlength{\hintscolumnwidth}
\newlength{\separatorcolumnwidth}
\setlength{\separatorcolumnwidth}{0.025\textwidth}
\newlength{\maincolumnwidth}
% doubleitem lengths
\newlength{\doubleitemmaincolumnwidth}
% listitem lengths
\newlength{\listitemsymbolwidth}
\settowidth{\listitemsymbolwidth}{\listitemsymbol{}~}
\newlength{\listitemmaincolumnwidth}
% listdoubleitem lengths
\newlength{\listdoubleitemmaincolumnwidth}
% recompute all the lengths that depends on the text width
\newcommand{\doubleitemcolumnratio}{.5} % GM
\pgfmathsubtract{1}{\doubleitemcolumnratio} % GM
\newcommand{\doubleitemcolumnratioc}{\pgfmathresult} % GM
\newcommand{\cvlanguageratio}{.5} % GM
\pgfmathsubtract{1}{\cvlanguageratio} % GM
\newcommand{\cvlanguageratioc}{\pgfmathresult} % GM
\newcommand*{\recomputethemelengths}{}
\newcommand*{\recomputelengths}{%
\setlength{\quotewidth}{0.65\textwidth}%
% main lenghts
\setlength{\maincolumnwidth}{\textwidth}%
\addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
\addtolength{\maincolumnwidth}{-\hintscolumnwidth}%
% listitem lengths
\setlength{\listitemmaincolumnwidth}{\maincolumnwidth}%
\addtolength{\listitemmaincolumnwidth}{-\listitemsymbolwidth}%
% doubleitem lengths
\setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth}%
\addtolength{\doubleitemmaincolumnwidth}{-\hintscolumnwidth}%
\addtolength{\doubleitemmaincolumnwidth}{-\separatorcolumnwidth}%
\setlength{\doubleitemmaincolumnwidth}{\doubleitemcolumnratio\doubleitemmaincolumnwidth}% GM
% listdoubleitem lengths
\setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth}%
\addtolength{\listdoubleitemmaincolumnwidth}{-\listitemsymbolwidth}%
\setlength{\listdoubleitemmaincolumnwidth}{0.475\listdoubleitemmaincolumnwidth}%
% fancyhdr lengths
\renewcommand{\headwidth}{\textwidth}%
\recomputethemelengths}
\setlength{\hintscolumnwidth}{0.15\textwidth}
\recomputelengths
% makes the cv title
%\newcommand*{\maketitle}{}%
\title{}% to avoid LaTeX complaining that \maketitle is a called without first a call to \title
% draws a colored rectangle
% usage: \colorrule[optional height]{width}
%\newcommand*{\colorrule}[2][1ex]{{\color{sectionrectanglecolor}{\rule{#2}{#1}}}}
% usage: \section{<title>}
\newcommand*{\section}[1]{%
\vspace*{2.5ex}%
\parbox[m]{\hintscolumnwidth}{\raggedleft\hintfont{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}}}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{part}{#1}%
\hspace{\separatorcolumnwidth}%
\parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}\\[1ex]}
% \cvline[1ex]{\color{sectionrectanglecolor}\rule[0]{\hintscolumnwidth}{1ex}}{\sectionstyle{#1}}}% gives bad alignment of rectangle; too bad m{width} columns seem not to work as a valid column definition for tabular environments
% starred variant, which is identical but defined to allow its use (e.g. for natbib compatibility, who uses \section*{} for the bibliography header)
\AtEndPreamble{%
\@ifpackageloaded{natbib}
{
\RequirePackage{suffix}
\WithSuffix\newcommand\section*{\section}
}{}
}
% usage: \subsection{title}
\newcommand*{\subsection}[1]{%
\cvline[0.5ex]{}{%
\subsectionstyle{#1}%
% \phantomsection{}% reset the anchor for hyperrefs
% \addcontentsline{toc}{chapter}{#1}% does not work, the bookmark is placed at the same level as sections (placed themselves at part level to be visible, as hyperref does not allow sections without parents...)
}}
% usage: \cvline{margintext}{linetext}
\newcommand*{\cvline}[3][.25em]{%
\begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
\raggedleft\hintfont{#2} &{#3}%
\end{tabular}\\[#1]}
% usage: \cvdoubleitem{subtitle}{text}{subtitle}{text}
\newcommand*{\cvdoubleitem}[4]{%
\cvline{#1}{\begin{minipage}[t]{\doubleitemmaincolumnwidth}#2\end{minipage}%
\hfill%
\begin{minipage}[t]{\hintscolumnwidth}\raggedleft\hintfont{#3}\end{minipage}\hspace*{\separatorcolumnwidth}\begin{minipage}[t]{\doubleitemmaincolumnwidth}#4\end{minipage}}}
% usage: \cvlistitem[symbol]{point1}
\newcommand*{\cvlistitem}[2][\listitemsymbol{}]{%
\cvline[0pt]{}{#1~\begin{minipage}[t]{\listitemmaincolumnwidth}#2\end{minipage}}}
% usage: \cvlistdoubleitem[symbol]{point1}{point2}
\newcommand*{\cvlistdoubleitem}[3][\listitemsymbol{}]{%
\cvline[0pt]{}{#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
\hfill%
\ifthenelse{\equal{#3}{}}%
{}%
{#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#3\end{minipage}}}}
% usage: \cventry{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
\newcommand*{\cventry}[6]{%
\cvline{#1}{%
{\bfseries#2}%
\ifthenelse{\equal{#3}{}}{}{, {\slshape#3}}%
\ifthenelse{\equal{#4}{}}{}{, #4}%
\ifthenelse{\equal{#5}{}}{}{, #5}%
.%
\ifx&%
\else{\newline{}\begin{minipage}[t]{\linewidth}\small#6\end{minipage}}\fi%
}}%
% usage (inside 'language' cvsection environment): \cvlanguage{name}{level}{comment}
\newcommand*{\cvlanguage}[3]{%
\cvline{#1}{\begin{minipage}[t]{\cvlanguageratio\maincolumnwidth}\textbf{#2}\end{minipage}\hfill\begin{minipage}[t]{\cvlanguageratioc\maincolumnwidth}\raggedleft\footnotesize\itshape #3\end{minipage}}} %GM
% usage (inside 'computer skills' cvsection environment): \cvcomputer{category}{programs}{category}{programs}
\newcommand*{\cvcomputer}[4]{%
\cvdoubleitem{#1}{\small#2}{#3}{\small#4}}
% usage: \link[optional text]{link}
\newcommand*{\link}[2][]{%
\ifthenelse{\equal{#1}{}}%
{\href{#2}{#2}}%
{\href{#2}{#1}}}
% usage: \httplink[optional text]{link}
\newcommand*{\httplink}[2][]{%
\ifthenelse{\equal{#1}{}}%
{\href{http://#2}{#2}}%
{\href{http://#2}{#1}}}
% usage: \emaillink[optional text]{link}
\newcommand*{\emaillink}[2][]{%
\ifthenelse{\equal{#1}{}}%
{\href{mailto:#2}{#2}}%
{\href{mailto:#2}{#1}}}
% usage: \nopagenumbers{}
\newif\if@displaypagenumbers\@displaypagenumberstrue
\newcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
\AtEndPreamble{%
\AtBeginDocument{%
\if@displaypagenumbers%
\@ifundefined{r@lastpage}{}{%
\ifthenelse{\pageref{lastpage} > 1}{%
\fancypagestyle{plain}{%
\fancyfoot[r]{\addressfont\color{quotecolor}\footnotesize\thepage/\pageref{lastpage}}}%
\pagestyle{plain}}{}}%
\AtEndDocument{\label{lastpage}}\else\fi}}
% thebibliography environment, for use with BibTeX and possibly multibib
\newcommand{\refname}{Publications}
\newlength{\bibindent}
\setlength{\bibindent}{1.5em}
% bibliography item label
\newcommand*{\bibliographyitemlabel}{}% use \@biblabel{\arabic{enumiv}} for BibTeX labels
%\newif\if@multibibfirstbib\@multibibfirstbibfalse
% bibliography head (section, etc}, depending on whether multibib is used
\newcommand*{\bibliographyhead}[1]{\section{#1}}
\AtEndPreamble{\@ifpackageloaded{multibib}{\renewcommand*{\bibliographyhead}[1]{\subsection{#1}}}{}}
% thebibliography environment definition
\newenvironment{thebibliography}[1]%
{%
\bibliographyhead{\refname}%
\small%
\begin{list}{\bibliographyitemlabel}%
{%
\setlength{\topsep}{0pt}%
\setlength{\labelwidth}{\hintscolumnwidth}%
\setlength{\labelsep}{\separatorcolumnwidth}%
\leftmargin\labelwidth%
\advance\leftmargin\labelsep%
\@openbib@code%
\usecounter{enumiv}%
\let\p@enumiv\@empty%
\renewcommand\theenumiv{\@arabic\c@enumiv}}%
\sloppy\clubpenalty4000\widowpenalty4000%
% \sfcode`\.\@m%
% \sfcode `\=1000\relax%
}%
{%
\def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
\end{list}%
}
\newcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}
\let\@openbib@code\@empty
% itemize, enumerate and description environment
\setlength{\leftmargini} {1.2em}
\leftmargin\leftmargini
\setlength{\leftmarginii} {1em}
\setlength{\leftmarginiii} {1.87em}
\setlength{\leftmarginiv} {1.7em}
\setlength{\leftmarginv} {1em}
\setlength{\leftmarginvi} {1em}
\setlength{\labelsep} {.5em}
\setlength{\labelwidth} {\leftmargini}
\addtolength{\labelwidth} {-\labelsep}
\@beginparpenalty -\@lowpenalty
\@endparpenalty -\@lowpenalty
\@itempenalty -\@lowpenalty
% itemize labels
\newcommand\labelitemi{\listitemsymbol{}}
\newcommand\labelitemii{{\large\bfseries-}}
\newcommand\labelitemiii{\textperiodcentered}%{\textasteriskcentered}
\newcommand\labelitemiv{\textperiodcentered}
% enumerate labels
\renewcommand\theenumi{\@arabic\c@enumi}
\renewcommand\theenumii{\@alph\c@enumii}
\renewcommand\theenumiii{\@roman\c@enumiii}
\renewcommand\theenumiv{\@Alph\c@enumiv}
\newcommand\labelenumi{\theenumi.}
\newcommand\labelenumii{(\theenumii)}
\newcommand\labelenumiii{\theenumiii.}
\newcommand\labelenumiv{\theenumiv.}
\renewcommand\p@enumii{\theenumi}
\renewcommand\p@enumiii{\p@enumii(\theenumii)}
\renewcommand\p@enumiv{\p@enumiii\theenumiii}
% description label
\newcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\bfseries#1}
% hooks to adjust spacing (idea by Jakob Schiøtz; see http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/tweaklist.sty)
\RequirePackage{tweaklist}% distributed with moderncv, not found on ctan and slightly modified
\renewcommand*{\itemhook}{
\setlength{\topsep}{0pt}%
\setlength{\itemsep}{0pt}}
\renewcommand*{\enumhook}{\itemhook{}}
\renewcommand*{\deschook}{\itemhook{}}
% classical \today definition
\def\today{\ifcase\month\or
January\or February\or March\or April\or May\or June\or
July\or August\or September\or October\or November\or December\fi
\space\number\day, \number\year}
\endinput
%% end of file `moderncv.cls'.
- (575)How to split an image in several parts (e.g., print A0poster into A4 sheets)?
I had to split a map design into more pieces to fit A4 paper recently. I used Imagemagick - it's THE tool for doing such repetitive image tasks for me. It's command-line only, so that may dissuade some users, but for me, it's a plus.
To split an image into 2088x2953-pixel sub-images, you just have to execute something like this: "convert -crop 2088x2953 final_3.jpg a4_%d.jpg"
or
http://posterazor.sourceforge.net/index.php?page=screenshots&lang=english
From: http://boardgamegeek.com/thread/503605/easy-split-a3-to-a4-and-few-more-things
or
http://pdfposter.origo.ethz.ch/
From: http://nxg.me.uk/docs/posters/
- (577)How to solve encoding problems between [X]emacs and aspell
(a.k.a. "aspell and its process have different coding maps")?
In /etc/aspell.conf or ~/.aspell.conf add the following line:
encoding iso-8859-15
From: http://forum.ubuntu-fr.org/viewtopic.php?id=122209
Also to be tested:
http://superuser.com/questions/191271/ispell-and-its-process-have-different-character-maps
- (600)How to add some space between bibitems when using bibTeX?
Before the bib commands, add (.6\baselineskip represents the space to add):
\makeatletter
\newcommand{\adjustmybblparameters}{\setlength{\itemsep}{.6\baselineskip}\setlength{\parsep}{0pt}}
\let\ORIGINALlatex@openbib@code=\@openbib@code
\renewcommand{\@openbib@code}{\ORIGINALlatex@openbib@code\adjustmybblparameters}
\makeatother
From: ftp://ftp.tex.ac.uk/tex-archive/biblio/bibtex/contrib/doc/btxFAQ.pdf\usepackage{xifthen}
\newcounter{dobyear}\setcounter{dobyear}{ }
%fill in your birth~s year above
\newcounter{dobmonth}\setcounter{dobmonth}{ }
%fill in your birth~s month in numeric value above
\newcounter{dobday}\setcounter{dobday}{ }
%fill in your birth~s day above
\newcounter{age}\setcounter{age}{\the\year %G~??%@ \thedobyear}
%this compares your~s birth year to the current year and stores the value in a new counter
\newtest{\conditiona}{%
\cnttest{\the\month}{=}{\thedobmonth} \AND %
\cnttest{\the\day}{>=}{\thedobday}%
}
%this sets the condition -Y´if the current month is the same as your birth month and the current day is greater or equal than your birth day
\newtest{\conditionb}{%
\cnttest{\the\month}{>}{\thedobmonth}%
}
%this sets the condition: ´if we the current month is after your birth month´
\ifthenelse{\conditiona \OR \conditionb}{}{\addtocounter{age}{-1}}
%this adjusts your age if one of the two conditions above is true, i.e. current time is later than your birthday of this year.
- (693)Basic LaTeX Makefile
clean:
rm -f *~ *.log *.aux *.nav *.out *.snm *.toc *.pdf *.ps
rm -fr auto/
%pdf: %tex
pdflatex $< && pdflatex $<
- (763)How to save an email to disk in GMail?
1. Open your browser and log into your gmail account
2. Open the email you want to save
3. On the top-right, there is a little triangle next to the \"Reply\" button. Click that, and select \"Show Original\"
4. The original, raw email opens in a new window or tab
5. Right-click on this new window, and select \"Save as...\"
6. When saving the file, make sure the extension of the filename is \"eml\". So for example \"MyEmail.eml\"
From http://rolfje.wordpress.com/2011/10/18/gmail-save-an-email-to-disk/
- (1408)How to put a footnote inside a table in LaTeX?
- One way to overcome this issue is by using longtable.
- Also, the tabularx package also handles footnotes correctly.
- Another, more appropriate solution would be using the minipage
environment. But, the footnote is placed right below the table, and
it will not work with Floats).
- The footnote package brings a more elegant solution. It provides the
savenotes environment, which collects all footnotes inside the
tabular where they get stuck and “releases” them at the end. Here is
an example:
\documentclass[12pt]{article}
\usepackage{footnote}
\begin{document}
\begin{savenotes}
\begin{table}[ht]
\centering
\begin{tabular}{|l|c|c|}
\hline
A & 1 & 2 \footnote{This is the first footnote.} \\
\hline
B & 2 & 1 \\
\hline
C & 3\footnote{This is the second footnote.} & 3 \\
\hline
\end{tabular}
\caption{A table caption.}
\end{table}%
\end{savenotes}
\end{document}
From: http://texblog.org/2012/02/03/using-footnote-in-a-table/
- (3852)How to beautifully display Menus/Key to hit in a LaTeX text?
Use: https://www.ctan.org/pkg/menukeys
NOTE: Works also for mac keyboards keys
From: https://tex.stackexchange.com/questions/19646/how-to-typeset-special-apple-mac-keyboard-symbols
- (3855)How to insert an animated GIF in a Beamer presentation?
(works only with some PDF viewers!!!)
- Split the GIF into individual frames into a directory
convert -coalesce animation.gif gif/frame-%d.png
- Use "animate" package
\animategraphics[<options>]{<frame rate>}{<path prefix>}{<start frame>}{<end frame>}
From: https://tex.stackexchange.com/questions/349077/get-animated-gifs-into-latex-presentation/349100#349100
https://ctan.org/pkg/animate
- (3871)How to include BibTeX contents in a lst-listings block?
BibTeX highlighting is not supported by default, but the following definitions are sufficient:
\begin{filecontents*}{\jobname.bib}
@article{myarticle,
language = {English},
title = {MWE title},
abstract = {MWE abstract},
keywords = {MWE;Stack Overflow;BibTeX},
}
\end{filecontents*}
\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\lstset{%
backgroundcolor=\color[gray]{.85},
basicstyle=\small\ttfamily,
breaklines = true,
keywordstyle=\color{red!75},
columns=fullflexible,
}%
\lstdefinelanguage{BibTeX}
{keywords={%
@article,@book,@collectedbook,@conference,@electronic,@ieeetranbstctl,%
@inbook,@incollectedbook,@incollection,@injournal,@inproceedings,%
@manual,@mastersthesis,@misc,@patent,@periodical,@phdthesis,@preamble,%
@proceedings,@standard,@string,@techreport,@unpublished%
},
comment=[l][\itshape]{@comment},
sensitive=false,
}
\begin{document}
\lstinputlisting[language=BibTeX]{\jobname.bib}
\end{document}
From: https://tex.stackexchange.com/questions/85998/include-bibtex-contents-in-a-listings-block/86022#86022
- (2067)How to set LaTeX options when converting with pandoc?
Use -V
e.g.:
pandoc -V papersize:"a4paper" \
-V geometry:margin=1cm \
github.com_AnthonyCalandra_modern-cpp-features_README.md
-o github.com_AnthonyCalandra_modern-cpp-features_README.pdf
From: https://github.com/jgm/pandoc/issues/600
http://stackoverflow.com/questions/13515893/set-margin-size-when-converting-from-markdown-to-pdf-with-pandoc
- (2157)How to correctly format month in BibTeX files?
Q13: Should I use words or numerals for the month, edition, etc., fields, and why?
You should always use the three letter month macros (undelimited) for the name of the month (jan, feb,
mar, apr, may, jun, jul, aug, sep, oct, nov, dec) as this lets each .bst file format the month names as is
required for that bibliography style. There is usually no excuse for doing things like:
month = "{Sept.}",
to compensate for .bst files that do not format their month names correctly, because such things are easy to
manually fix within the .bst file. Just find the month macro definitions:
MACRO {sep} {"Sep."}
and correct them as needed.
If you should need a “multiple month,” you can still build one using the BibTEX concatenation operator
“#” in conjunction with the month name macros:
month = jun # "/" # jul,
However, the edition field poses a bit of a challenge. The BibTEX standard way of specifying edition numbers
is to use ordinal words with capital first letters such as “First”, “Second”, “Third” and so forth. The problem
is that some bibliography styles use words for edition numbers while others use numerical values (e.g., “First”,
“1st”, “1”, etc.). Converting between these forms is currently non-trivial because the algorithms and lookup
tables required for such conversions can become quite complex. Bibstyle files made with recent versions of
makebst use an algorithm that will convert edition numbers as needed up to about the fifth. After that,
they will fallback and use the form as it is given in the edition field. But, when converting between the
Arabic-numeral (e.g., “17”) and Arabic-ordinal (e.g., “17th”) forms, which is a much easier task, they are
usually smart enough to handle any number.
So, with this in mind, it might be a good idea to use “First”, “Second” all the way up to “Fifth” an
From: http://mirrors.ctan.org/biblio/bibtex/contrib/doc/btxFAQ.pdf
- (2158)How to index BibItem according to their keyword field?
Here is a solution using the imakeidx package (it should work with
other approaches to indexes as well):
\usepackage{imakeidx}
\makeindex[name=keywords, title=List of Keywords]
BibLaTeX has commands for producing index entries: first of all we
have to define the format for the index. keywords in BibLaTeX is a
field with comma separated values, thus we can use \forcsvfield to
parse single keywords, and to pass them to the handler which consists
of a call \index[keywords].
\DeclareIndexFieldFormat{keywords}{\forcsvfield{\index[keywords]}{keywords}}
Then we have to ensure that the keywords are inserted in the keyword
index: a possibility is to add the call to \indexfield{keywords} every
time a bibitem is processed.
\AtEveryBibitem{\indexfield{keywords}}
If the custom style has an instruction to print the keywords (e.g.,
\usebibmacro{keywords}) then \indexfield{keywords} could be inserted
in the macro.
Finally:
\printindex[keywords]
From: https://tex.stackexchange.com/questions/82726/use-content-of-keyword-field-of-a-bibtex-entry-to-build-an-index-when-using-bibl
- (2201)How to insert a new line without \newline command?
You can use:
\par to obtain a new paragraph. It is different from \newline or \\ which produce a line break.
\linebreak command, to break the line and justify the line before.
- (2505)Is there an equivalent to \nonumber for slides in Beamer?
\begin{frame}[noframenumbering]
\titlepage
\end{frame}
From: https://tex.stackexchange.com/questions/30461/beamer-nonumber-equivalent-for-slides
- (2545)How to change the size of circle around nodes in TikZ automata?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture} [->,auto,node distance=0.6cm,line width=0.4mm]
\node[state,initial,inner sep=1pt,minimum size=0pt] (q) {$q$};
\node[state,accepting,inner sep=1pt,minimum size=0pt] (p) [right=of q] {$p$};
\end{tikzpicture}
\end{document}
From: https://tex.stackexchange.com/questions/29151/tikz-automata-size-of-circle-around-nodes
- (2546)How to bend the arrows in TikZ automata?
You can add bend left or bend right or bend left=<degree> or bend right=<degree> to the edges. Here is an example:
\usetikzlibrary{positioning,automata}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid]
\node[state,initial] (q_0) {$q_0$};
\node[state] (q_1) [right=of q_0] {$q_1$};
\node[state,accepting] (q_2) [right=of q_1] {$q_2$};
\path[->] (q_0) edge node [above] {0} (q_1)
edge [loop above] node {1} ()
edge [bend left=45] node [below] {1} (q_2)
edge [bend right] node [below] {0} (q_2)
(q_1) edge node [above] {1} (q_2);
\end{tikzpicture}
From: https://tex.stackexchange.com/questions/111849/draw-an-automaton-with-more-states-and-bent-arrows
- (2675)What is the difference between \input vs. \include in LaTeX?
\input{filename} imports the commands from filename.tex into the target file; it's equivalent to typing all the commands from filename.tex right into the current file where the \input line is.
\include{filename} essentially does a \clearpage before and after \input{filename}, together with some magic to switch to another .aux file, and omits the inclusion at all if you have an \includeonly without the filename in the argument. This is primarily useful when you have a big project on a slow computer; changing one of the include targets won't force you to regenerate the outputs of all the rest.
\include{filename} gets you the speed bonus, but it also can't be nested, can't appear in the preamble, and forces page breaks around the included text.
From: https://tex.stackexchange.com/questions/246/when-should-i-use-input-vs-include
- (2692)How to use an itemize into a picture caption (+ How to align captions)?
SOLUTION1:
put the caption into a minipage
SOLUTION2:
\usepackage{caption}
\usepackage{enumitem}
\begin{figure}
\centering
\includegraphics[scale=0.3]{HP.png}
\captionsetup{singlelinecheck=off}
\caption[]{text1:
\begin{itemize}[label={--}]
\item blue: 0.1 -- 0.36
\item green: 0.36 -- 0.98
\item red: 0.98 -- 3.5
\item purple: 3.5 +
\end{itemize}
text2}
\end{figure}
From: https://tex.stackexchange.com/questions/344307/itemise-within-a-caption-doesnt-work
https://tex.stackexchange.com/questions/383017/minipage-with-image-on-one-side-bullet-points-on-other-with-bullet-points-alli
- (2695)How to determine the height of the current line?
\baselineskip
From: https://tex.stackexchange.com/questions/100922/determine-height-of-the-line-you-are-in
- (2696)How to get the available height of a beamer slide?
The \textheight of a beamer frame includes the title
\paperheight
\beamer@frametextheight
From: https://tex.stackexchange.com/questions/384615/is-textheight-in-beamer-slides-with-a-title-wrong
https://tex.stackexchange.com/questions/278429/is-there-a-simple-command-for-the-available-height-in-a-beamer-slide
- (2697)How to align the content text to the top/center on each/a single slide in beamer?
Use the optional arguments t and c of the beamer class resp. its frame environment.
\documentclass[t]{beamer} % For all slides: align to t=TOP
\begin{document}
\begin{frame}
Some text.
\end{frame}
\begin{frame}[c] % for this particular silde: align to c=CENTER
Some text.
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/6830/slidestop-for-a-single-slide-in-beamer
- (2698)How to change the Spacing between Frame Title and Content in Beamer?
\addtobeamertemplate{frametitle}{\vspace*{-1.4cm}}{\vspace*{0.2cm}}
- First vspace moves the Frame title
- Second vspace moves the text coming after the frame title so this allows to move the title up or down and fix the space between title and body in one go!
From: https://latex.org/forum/viewtopic.php?t=15137
- (2719)How do I provide a username and password (containing special chars) when running \"git clone git@remote.git\"?
You need to use the http version of the remote url &amp; protect the username &amp; password\'s special chars:
git clone https://user%2B1:Welcome%401234@actual-git-url-for-the-repo
To compute the protected versions of username (and password :{) :
https://www.urlencoder.org/
From: https://stackoverflow.com/questions/10054318/how-do-i-provide-a-username-and-password-when-running-git-clone-gitremote-git/55721882#55721882
- (2770)How to display a pretty checkmark in LaTeX?
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\checkmark
\usepackage{pifont}% http://ctan.org/pkg/pifont
\newcommand{\cmark}{\ding{51}}% or \newcommand{\cmark}{\ding{52}}%
\newcommand{\xmark}{\ding{53}}% or \newcommand{\xmark}{\ding{54}}% or \newcommand{\xmark}{\ding{55}}%
In some LaTeX installations (XeLaTeX), you can directly use the following UTF-8 chars:
\begin{document}
\begin{tabular}{c c c}
Symbol & Unicode Codepoint (Hex) & Name\\
☐ & U+2610 & BALLOT BOX (checkbox)\\
☒ & U+2612 & BALLOT BOX WITH X (square with cross)\\
✗ & U+2717 & BALLOT X (cross)\\
✘ & U+2718 & HEAVY BALLOT X (bold cross)\\
× & U+00D7 & MULTIPLICATION SIGN (z notation Cartesian product)\\
╳ & U+2573 & BOX DRAWINGS LIGHT DIAGONAL CROSS\\
☓ & U+2613 & SALTIRE (St Andrew's Cross)\\
✕ & U+2715 & MULTIPLICATION X\\
✖ & U+2716 & HEAVY MULTIPLICATION X\\
❌ & U+274C & CROSS MARK\\
❎ & U+274E & NEGATIVE SQUARED CROSS MARK\\
⨉ & U+2A09 & N-ARY TIMES OPERATOR\\
\end{tabular}
\end{document}
From: https://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark
https://tex.stackexchange.com/questions/42619/x-mark-to-match-checkmark
https://en.wikipedia.org/wiki/X_mark
https://en.wikipedia.org/wiki/Check_mark
- (2771)How to draw a square of Xcm in LaTeX filled with color?
SOLUTION1: with \rule
\documentclass{article}
\usepackage{xcolor}
\newcommand\crule[3][black]{\textcolor{#1}{\rule{#2}{#3}}}
\begin{document}
\crule{1cm}{1cm} \crule[blue]{1cm}{1cm} \crule[red!50!white!100]{1cm}{1cm}
\end{document}
SOLUTION2: with \fbox
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\fboxsep=4mm \fboxrule=1mm
\fcolorbox{black}{blue!40!white}{\null}
\end{document}
SOLUTION3: with TikZ
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\newcommand{\mycbox}[1]{\tikz{\path[draw=#1,fill=#1] (0,0) rectangle (1cm,1cm);}}
\begin{document}
\lipsum[1-2]
\mycbox{blue}
\mycbox{red}
\end{document}
From: https://tex.stackexchange.com/questions/106984/how-to-draw-a-square-of-1cm-in-latex-filled-with-color
- (2775)How do I force a column-break in a multi-column page?
use:
\vfill\null % or \vspace*{\fill}
\columnbreak % if not using multicols pkg: \vfill\eject or \vfill\break
or use:
\raggedcolumns
From: https://tex.stackexchange.com/questions/8683/how-do-i-force-a-column-break-in-a-multi-column-page
--
Use \newpage for beaking columns. A twocolumn document is for TeX the same as two half pages side by side
Use \clearpage for a new page.
From: https://tex.stackexchange.com/questions/10760/how-do-i-force-a-column-break-in-a-two-column-document
- (2810)How to remove the "Projet" watermark when generating MCQ with auto-multiple-choice/AMC?
Use option "nowatermark":
\usepackage[nowatermark]{automultiplechoice}
From: https://project.auto-multiple-choice.net/issues/535#note-3
- (2811)How to ensure copies do no get mixed when generating MCQ with randomization with automultipechoice/AMC and printing twosided?
When using randomization of questions/response, individual "copies" might not endup with the exact same number of pages, due to different page breaks.
When printing in two-sided mode, the first page of copy n+1 might thus get printed as the last page of copy n :{
To garantee each new copy start on an odd page, use \AMCcleardoublepage (or \cleardoublepage ?) at the end of the code of each copy (i.e. before the closing bracket of \onecopy{250}{...}).
From: https://project.auto-multiple-choice.net/boards/2/topics/1965?r=1974
- (2844)How to get Gif and/or moving images into a LaTeX presentation?
1. Convert the animation into single images
convert -coalesce <video>.gif <singleimages>.png
Make sure you resulting images are named <singleimages>-0 and so on.
2a. Using package animate
\documentclass{beamer}
\usepackage{animate}
\begin{document}
\begin{frame}{Embedded Animation}
\animategraphics[loop,controls,width=\linewidth]{10}{singleimages-}{0}{16}
\end{frame}
\end{document}
2b. Using package xmpmulti
\documentclass{beamer}
\usepackage{xmpmulti}
\begin{document}
\begin{frame}
\transduration<0-16>{0}
\multiinclude[<+->][format=png, graphics={width=\textwidth}]{something}
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/240243/getting-gif-and-or-moving-images-into-a-latex-presentation
- (2863)How to get multiple bibliographies (one being a list of papers manually made with bibentry) with natbib/chapterbib?
NEW SOLUTION:
Use biblatex package
% To insert list of papers splitted in sections
\usepackage[
backend=bibtex, % Tool used to compile biblio files (can also be "biber")
style=alphabetic, % style equiv to alpha.bst / style=authoryear
natbib=true % allows creating citations but not having a section with the biblio references
]{biblatex} %
\addbibresource{mypapers.bib}
...
\begin{document}
\begin{refsection}
\section{section1}
\section{section2}
...
\nocite{*}
\printbibliography
\end{refsection}
\end{document}
From: https://www.overleaf.com/learn/latex/Biblatex_citation_styles
https://www.overleaf.com/learn/latex/Articles/Getting_started_with_BibLaTeX
NOTE: the equivalent of bibentry::\bibentry{} is biblatex::\fullcite{}
From: https://tex.stackexchange.com/a/135950
OLD SOLUTION:
PROBLEM: Using \begin{cbunit} does not work and \include{} adds a pagebreak
SOLUTION: use \include{} but remove the pagebreak with \let\clearpage\relax
---- test_bib.tex
\documentclass[]{article}
\usepackage{bibentry}
\usepackage[sectionbib]{natbib}
\usepackage{chapterbib}
%\sectionbib{\subsection}{subsection}
\begin{document}
\nobibliography{demo31,demo32} % use nobibliography* ?
\nocite{*}
\begingroup
\let\clearpage\relax
\include{section1}
\include{section2}
\endgroup
\end{document}
---- section1.tex
\bibliographystyle{alpha}
\nobibliography{demo31}
\section{First Bibunit environment with bibentry}
This is some \emph{bibentry}:
\begin{itemize}
\item \cite{Graves2008LSTM}~\bibentry{Graves2008LSTM}
\item \cite{stallman_steady_1965}~\bibentry{stallman_steady_1965}
\end{itemize}
---- section2.tex
\section{Second Bibunit environment with bibentry}
This is some \emph{bibentry}:
\begin{itemize}
\item \cite{taniguchi_evaluation_1993}
\item \cite{anderson_heat_2005}
\end{itemize}
\bibliographystyle{alpha}
\bibliography{demo32}
---- demo31.bib
@Article{Graves2008LSTM,
author = {Graves, Alex and Liwicki, Marcus},
OPTauthor = {Graves, Alex and Liwicki, Marcus and Fern{\'a}ndez, Santiago and Bertolami, Roman and Bunke, Horst and Schmidhuber, J{\"u}rgen},
biburl = {https://www.bibsonomy.org/bibtex/25bd21ef550347f35dff2155f6abe44d6/dblp},
ee = {https://www.wikidata.org/entity/Q51848038},
journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
number = 5,
pages = {855--868},
title = {A Novel Connectionist System for Unconstrained Handwriting Recognition.},
url = {http://dblp.uni-trier.de/db/journals/pami/pami31.html\%23GravesLFBBS09},
volume = 31,
year = 2009,
}
@article{stallman_steady_1965,
title = {Steady one-dimensional fluid flow in a semi-infinite porous medium with sinusoidal surface temperature.},
volume = {70},
doi = {10.1029/JZ070i012p02821},
number = {12},
journal = {Journal of Geophysical Research},
author = {Stallman, R W},
year = {1965},
pages = {2821--2827}
}
---- demo32.bib
@article{anderson_heat_2005,
title = {Heat as a {Ground} {Water} {Tracer}},
volume = {43},
doi = {10.1111/j.1745-6584.2005.00052.x},
number = {6},
journal = {Ground Water},
author = {Anderson, Mary P.},
year = {2005},
pages = {951--968}
}
@article{taniguchi_evaluation_1993,
title = {Evaluation of vertical groundwater fluxes and thermal properties of aquifers based on transient temperature-depth profiles.},
volume = {29},
doi = {10.1029/93WR00541},
journal = {Water Resources Research},
author = {Taniguchi, M},
year = {1993},
note = {D031},
pages = {2021--2026}
}
From: https://tex.stackexchange.com/questions/389425/why-does-chapterbib-include-references-from-the-entire-document-at-the-end-of-ea/542831#542831
https://stackoverflow.com/questions/1209065/how-to-have-no-pagebreak-after-include-in-latex/10066885#10066885
https://tex.stackexchange.com/questions/243650/bibentry-command-do-not-work-with-bibunit-environment
- (2864)How to prevent \include to insert a \pagebreak?
\begingroup
\let\clearpage\relax
\include{file1}
\include{file2}
\endgroup
\include{file3}
From: https://stackoverflow.com/questions/1209065/how-to-have-no-pagebreak-after-include-in-latex/10066885#10066885
- (2865)How to create different bibliographies with shared references?
Does not work with bibunits => use natbib+chapterbib
BEWARE: it is VERY important to use the [sectionbib] option on the *natbib* package, not the *chapterbib* directly
\usepackage[sectionbib]{natbib}
\usepackage{chapterbib}
From: https://tex.stackexchange.com/questions/229846/different-bibliographies-for-each-chapter-with-shared-references/300144#300144
- (2866)How to create a list of references?
NEW SOLUTION:
Use biblatex package
% To insert list of papers splitted in sections
\usepackage[
backend=bibtex, % Tool used to compile biblio files (can also be "biber")
style=alphabetic, % style equiv to alpha.bst / style=authoryear
natbib=true % allows creating citations but not having a section with the biblio references
]{biblatex} %
\addbibresource{mypapers.bib}
...
\begin{document}
\begin{refsection}
\section{section1}
\section{section2}
...
\nocite{*}
\printbibliography
\end{refsection}
\end{document}
From: https://www.overleaf.com/learn/latex/Biblatex_citation_styles
https://www.overleaf.com/learn/latex/Articles/Getting_started_with_BibLaTeX
NOTE: the equivalent of bibentry::\bibentry{} is biblatex::\fullcite{}
From: https://tex.stackexchange.com/a/135950
OLD SOLUTION:
Use natbib+bibentry
\bibliographystyle{alpha}
\nobibliography{demo31} % Creates the biblio files, but not does not insert the final bibliography section
\section{First Bibunit environment with bibentry}
This is some \emph{bibentry}:
\begin{itemize}
\item \cite{Graves2008LSTM}~\bibentry{Graves2008LSTM} % inserts the shortcut key + the full layouted reference text
\item \cite{stallman_steady_1965}~\bibentry{stallman_steady_1965}
\end{itemize}
Thanks Fran�ois Jaquenet
- (2869)How to make accent work in the bibtex references?
If you use UTF-8 accentuated char (é) or LaTeX equiv (\'e) in a bibtex file you'll get an error
For instance with default bib package:
---
! Package inputenc Error: Invalid UTF-8 byte sequence.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.22 \bibitem[é�05]{anderson_heat_2005}
---
or with natbib:
---
! Package natbib Error: Bibliography not compatible with author-year citations.
(natbib) Press <return> to continue in numerical citation style.
See the natbib package documentation for explanation.
Type H <return> for immediate help.
...
l.5 ...mmand\NAT@force@numbers{}\NAT@force@numbers
---
You MUST tell BibTeX not to interpret the char and to leave it to LaTeX by surrounding the accentuated text with additional {}.
For instance:
@article{key,
...
author="Th{\'{e}}venaz, Jacques",
...
}
From: https://tex.stackexchange.com/questions/134116/accents-in-bibtex/134123#134123
- (2871)How to cite a patent?
Most bibstyles do not support them => use @Misc{} and find the good fields for your readers to be able to find the doc (at least number / year / url ?).
IEEEtran's BibTeX package (https://www.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/bibtex) defines the following entry:
@Patent{IEEEexample:uspat,
author = "Ronald E. Sorace and Victor S. Reinhardt and
Steven A. Vaughn",
assignee = "Hughes Aircraft Company",
address = "Los Angeles, CA",
title = "High-Speed Digital-to-{RF} Converter",
nationality = "United States",
number = "5668842",
dayfiled = "28",
monthfiled = feb,
yearfiled = "1995",
day = "16",
month = sep,
year = "1997"
}
From: https://academia.stackexchange.com/questions/41688/how-to-represent-and-cite-a-patent-using-bibtex#41728
- (2873)How to use comments in BibTeX files?
INSIDE an entry: prefix with OPT
@article{key,
...
OPTpages={34--35},
...
}
OUTSIDE an entry: anything outside en entry is ignore by default by BibTeX
blablabla
@article{key,
...
}
The entry it self: prefix the @ with any char (%/=/...) or remove the '@' et voila!
%@article{key,
...
}
Also Emacs uses @Comment anywhere...
From: https://tex.stackexchange.com/questions/21709/comments-in-bibtex/21710#21710
- (2920)How to change the inernal/2nd level/nested itemize bullet characters?
Without any package, the correct command to be redefined is \labelitemii (note the second i).
\documentclass{article}
\renewcommand{\labelitemii}{$\star$} % <-- the trick
\begin{document}
\begin{itemize}
\item one \dots{}
\begin{itemize}
\item Language Models
\item Vector Space Models
\end{itemize}
\item two \dots{}
\item three \dots{}
\end{itemize}
\end{document}
From: https://tex.stackexchange.com/questions/36443/how-to-change-the-nested-itemize-bullet-characters/36448#36448
- (2921)How to vertically align text (in side-by-side) minipages?
Use [t] as the option:
\begin{minipage}[t]{0.5\textwidth}:
From: https://tex.stackexchange.com/questions/81955/align-text-in-minipage-at-same-height#81956
- (2922)How to insert an image in a \cventry in moderncv?
Use the \includegraphics command from the graphicx package
BEWARE: use \textwidth rather than \linewidth
From: https://tex.stackexchange.com/questions/101766/inserting-an-image-in-cventry-in-moderncv/535993#comment1353933_535993
- (2923)How to create an empty box?
SOLUTION1:
\framebox(200,300){}
SOLUTION2:
\fbox{\phantom{This is my answer}}
From: https://tex.stackexchange.com/questions/208128/how-to-make-an-empty-box/513588#513588
- (2924)How to hide some text in LaTeX?
\phantom{This is my answer}
From: https://tex.stackexchange.com/questions/208128/how-to-make-an-empty-box/513588#513588
- (2925)How to create a blank that has the size of a given text in LaTeX?
My Text 1: blabla \\
\phantom{My Text1:} rest of the text [aligned with ':' of above line]
From: https://tex.stackexchange.com/questions/208128/how-to-make-an-empty-box/513588#513588
- (2926)How to wrap text in LaTeX tables?
Use p{width} for your column specifiers instead of l/r/c.
\begin{tabular}{|p{1cm}|p{3cm}|}
This text will be wrapped & Some more text \\
\end{tabular}
From: https://stackoverflow.com/questions/790932/how-to-wrap-text-in-latex-tables#790944
- (2927)How to increase/decrease Column and Row padding in tables?
\bgroup
\def\arraystretch{1.5}% 1 is the default, change whatever you need
\begin{tabular}{|c|...}
...
\end{tabular}
\egroup
From: https://tex.stackexchange.com/questions/31672/column-and-row-padding-in-tables/31681#31681
- (2928)How to limit the scope of a command in LaTeX?
Use \bgroup / \begingroup and \egroup / \endgroup
In the example below, the \arraystretch command is redefined only for the table surrounded by \bgroup / \egroup
\bgroup
\def\arraystretch{1.5}% 1 is the default, change whatever you need
\begin{tabular}{|c|...}
...
\end{tabular}
\egroup
From: https://tex.stackexchange.com/questions/31672/column-and-row-padding-in-tables/31681#31681
https://stackoverflow.com/questions/1209065/how-to-have-no-pagebreak-after-include-in-latex/10066885#10066885
- (2930)How to start itemize on same line as text?
SOLUTION1: minipages
\documentclass{article}
\newenvironment{example}
{\textbf{Example:}\begin{minipage}[t]{0.8\linewidth}\begin{itemize}}
{\end{itemize}\end{minipage}}
\begin{document}
\begin{example}
\item These are first examples.
\item Second examples.
\item And more.
\end{example}
\end{document}
SOLUTION2: Hacking the length before the bullet
\documentclass{article}
\usepackage{enumitem}
\usepackage{lipsum} % just for the example
\newlength{\jeroenlen}
\newenvironment{example}
{\settowidth{\jeroenlen}{\textbf{Example:}}%
\begin{description}[leftmargin=\jeroenlen,labelwidth=0pt,labelsep=0pt]
\item[\textbf{Example:}]%
\begin{itemize}[leftmargin=1.5em,labelsep=.5em]}
{\end{itemize}\end{description}}
\begin{document}
\lipsum[2]
\begin{example}
\item Such and such
\item So and so
\item Enough
\end{example}
\lipsum[3]
\end{document}
From: https://tex.stackexchange.com/questions/147710/how-to-start-itemize-on-same-line-as-text/147717#147717
- (2931)How to have multiple references to the same footnote?
You can do it without any package:
First sentence.\footnote{\label{footnote-label} footnote content}
Second sentence.\textsuperscript{\ref{footnote-label}}
This solution as the advantage that hyperref behaves as expected
== You can create macros to generalize it:
\newcommand{\savefootnote}[2]{\footnote{\label{#1}#2}}
\newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}}
First sentence.\savefootnote{footnote-label}{footnote content}
Second sentence.\repeatfootnote{footnote-label}
From: https://tex.stackexchange.com/questions/10102/multiple-references-to-the-same-footnote-with-hyperref-support-is-there-a-bett/54240#54240
- (2939)How to add sound to a presentation?
PRELIMINARY NOTE: there are so many PDF readers, each one complying to various degrees and versions of the PDF specifications, that it is impossible to devise a solution that will work everywhere.
SOLUTION1: using links to external files & player
+ pros:
+ works mostly everywhere if OS configured correctly
- cons:
- sound files must be provided together with the presentation and put in the correct dir
- some PDF reader will require to provide the player name in the 'run:' command, making it less portable
1. \usepackage[...]{hyperref}
2. \href{run:sound.wav}{click to play the sound!}
3. Configure your system to play the sound:
---- /etc/mailcap or ~/.mailcap)
audio/*; /usr/bin/play %s
----
From: https://web.archive.org/web/20170226134025/http://www.bio.lmu.de/~benda/software/latex/
SOLUTION2: with attachfile/attachefile2
- cons: [DOES NOT WORK here]
1. \usepackage{attachfile} % or attachfile2
2. \textattachfile{myvideo.mp4}{\includegraphics[width=1cm]{myicon}}
From: https://tex.stackexchange.com/a/408492
SOLUTION3: with multimedia (included in beamer)
- cons: [DOES NOT WORK here]
1. \usepackage{multimedia}
2. \sound[inlinesound]{\includegraphics{example-image}}{1024Tone.wav}
From: https://tex.stackexchange.com/a/408506
SOLUTION4: with pdf-pc
- cons: for a specific PDF viewer (see Tip#2940)
\documentclass{beamer}
\usepackage{pdfpc-commands}
\begin{document}
% Full frame movie exmaple
\begin{frame}{Example}
Open with: \texttt{pdfpc video-example.pdf}
\vspace{25pt}
A full frame video using \textbf{commands from \texttt{pdfpc-commands}} is on the next slide.
\end{frame}
\fullFrameMovie[loop]{apollo17.avi}{apollo17.jpg}{\copyrightText{Apollo 17, NASA}}
% Inline movie example => similar to SOLUTION5?
\begin{frame}{Example 2}
A video using the \textbf{commands from \texttt{pdfpc-commands}} is on this slide. The video is set to start at 5 seconds and end at 12 seconds.
\vspace{20pt}
\inlineMovie[loop&autostart&start=5&stop=12]{apollo17.avi}{apollo17.jpg}{height=0.7\textheight}
\end{frame}
% Inline movie example2 => similar to SOLUTION1
\begin{frame}{Example 3}
A video using the \textbf{basic syntax} is on this slide. The video is set to start at 5 seconds and end at 12 seconds.
\vspace{20pt}
\href{run:apollo17.avi?autostart&loop&start=5&stop=12}{\includegraphics[height=0.7\textheight]{apollo17.jpg}}
}
From: https://tex.stackexchange.com/questions/345431/how-to-include-multimedia-files-in-beamer/444158#444158
SOLUTION5: movie15 [DEPRECATED] / media9
- cons: [uses flash => DEPRECATED]
\documentclass{beamer}
\usepackage{media9}
\begin{document}
\begin{frame}{embedded files} % SWF Player & Media file embedded in pdf file
\includemedia[
width=0.4\linewidth,
totalheight=0.225\linewidth,
activate=pageopen,
passcontext, %show VPlayer's right-click menu
addresource=eso50supernova.m4v,
flashvars={
%important: same path as in `addresource'
source=eso50supernova.m4v
}
]{\fbox{Click!}}{VPlayer.swf}
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/345431/how-to-include-multimedia-files-in-beamer/345433#345433
SOLUTION6: with libreoffice
+ pro:
+ as the resulting presentation is only images, people can not copy your text (weak "IP"/"Copyright" Protection)
- cons:
- works well if you only add a few audio files (e.g. single file recording of your voice teaching the whole presentation), otherwise synchronizing modifications in LaTeX & LibreOffice will become difficult
0. Create your presentation as usual (e.g. with beamer) and generate a PDF
1. Convert the pdf into a LibreOffice/Impress/odp presentation
convert -quality 98 -resize 1753x1240 -extent 1753x1240 -gravity center -units PixelsPerInch -density 150x150 <source.pdf> <destination.odp> # See Tip#2941
# NOTE: Here, you could simply open the PDF in LibreOffice and let it recover, however the results would be worse, like loosing text: for instance ligation like 'fi', large braces, maths formulae...
2. Add your sound file in LibreOffice (see Tip#2905)
- (2940)How to add a timer to a PDF presentation?
PRELIMINARY NOTE: as this is a dynamic/presentation-time stuff, it depends highly on the PDF viewer used.
SOLUTION1: tdclock package
+ pro: done inside latex file
- con: works with AcroRead only
Example file: http://mirror.ctan.org/macros/latex/contrib/tdclock/tdclock-beamer-example.tex
SOLUTION2: use specific PDF viewer: impress [NICE!] or pdf-presenter-console (pdfpc) [DOES NOT WORK HERE]
+ PDF-pc: https://pdfpc.github.io/
+ Impressive: http://impressive.sourceforge.net/
=> CLI: impressive -d 10:00 presentation.pdf # --tracking -f -g 800x600 -L margin=16,alpha=1,time=BR,title=BL,page=BR,status=TL
=> Keys: T to display timer / R to reset timer
=> also can do a lot of interesting stuff like "Highlight boxes" or "Spotlight effect"
- (2942)How to embed a (data, bib, etc) file in your LaTeX file?
Example for a datafile:
\begin{filecontents*}{\jobname.dat}
001001=aaaaaaaa
001002=bbbbbbbb
001002=cccccccc
\end{filecontents*}
From: https://tex.stackexchange.com/questions/59929/numbers-in-newcommand/59956#59956
- (2958)How to create a node that surrounds/includes other nodes?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows, decorations.markings,shapes,arrows,fit}
\tikzstyle{box}=[draw, minimum size=2em, text width=4.5em, text centered]
\tikzstyle{bigbox}=[draw, inner sep=20pt]
\begin{document}
\begin{tikzpicture}
\node[box] (A) at ( -2,1) {$A$};
\node[box] (B) at ( 1,1) {$B$};
\node[box] (C) at ( 4,1) {$C$};
\node[bigbox, fit=(A)(B)(C)] (D) {};
\node[above left] at (D.south east) {D};
\end{tikzpicture}
\end{document}
+--------------+
| +-+ +-+ +-+ |
| |A| |B| |c| |
| +-+ +-+ +-+ |
| D |
+--------------+
From: https://tex.stackexchange.com/questions/223820/tikz-text-location-within-node#223825
- (2959)Setting text color in TikZ without changing line color?
You should set the color using text=red instead of color=red:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\tikzset{curveinscope/.style={every path/.style={draw=white, double distance=1pt, line width=2pt, double=blue, text=red}}}
\begin{scope}[curveinscope]
\node at (1,0) {X};
\draw (0,0) -- (2,2);
\draw (2,1) -- (0,1);
\end{scope}
\end{tikzpicture}
\end{document}
From: https://tex.stackexchange.com/questions/20807/setting-text-color-in-tikz-without-changing-line-color-conflict-with-double#20809
- (3027)How to set/add a user-writable directory where to install packages in MikTeX?
1. Open a terminal
2. Run miktex-console
3. Go to Settings
4. Click the Directories tab
5. Click the Add toolbar button
6. Select the TEXMF root directory you want to add
From: https://miktex.org/howto/miktex-console
- (3050)How to create an "outline" frame/slide in Beamer?
SOLUTION1: one-shot
\begin{frame}{Outline}
\tableofcontents
\end{frame}
SOLUTION2: before every new section
\AtBeginSection[]
{
\begin{frame}<beamer>
\frametitle{Outline for section \thesection}
\tableofcontents[currentsection]
\end{frame}
}
From: https://tex.stackexchange.com/questions/26712/how-to-make-outline-frame-in-beamer/26713#26713
- (3070)What are the possible dimensions/sizes/units that LaTeX understands?
From the plain TeX reference (http://nwalsh.com/tex/texhelp/Plain.html#dimensions):
pt: Point
pc: pica (12 pt)
in: inch (72.27 pt)
bp: Big point (72 bp = 1 in)
cm: Centimeter
mm: Millimeter
dd: Didot point (1157 dd = 1238 pt)
cc: cicero (12 dd)
sp: Scaled point (65536 sp = 1 pt), the smallest TeX unit
ex: Nominal x-height
em: Nominal m-width
From: https://tex.stackexchange.com/questions/41370/what-are-the-possible-dimensions-sizes-units-latex-understands#41371
- (3071)How to remove the Navigation Bar of a Beamer presentation?
Put this line in the preamble:
\beamertemplatenavigationsymbolsempty
Or this one:
\setbeamertemplate{navigation symbols}{}
From: http://jhshi.me/2013/12/02/remove-the-navigation-bar-of-beamer/index.html
https://tex.stackexchange.com/questions/686/how-to-get-rid-of-navigation-symbols-in-beamer
- (3099)How to remove table of contents at top (in the header) of each slide in Beamer?
\setbeamertemplate{headline}{}
From: https://tex.stackexchange.com/questions/41829/beamer-no-table-of-contents-at-top/41842#41842
- (3100)How to insert a backslash or a tilde (~) in LaTeX?
- backslash (in text-mode)
\textbackslash
- lower tilde in math mode
$\sim$ (or \texttildelow from textcomp package)
- raised tilde in text-mode
~{} and \textasciitilde
From: https://tex.stackexchange.com/questions/9363/how-does-one-insert-a-backslash-or-a-tilde-into-latex/9365#9365
- (3101)How to align inline images vertically?
If you want all your images to be 10% below the baseline you can use \raisebox{-.1\height}{\includegraphics[...]{...}}
Note that \raisebox allows the use of \height, \depth, \width and \totalheight (=height+depth) which represent the original dimension of the to be raised box. As said, \depth is zero and so \totalheight is identical to \height for images.
From: https://tex.stackexchange.com/questions/15853/vertical-alignment-of-inline-images/15858#15858
- (3105)How to create a slider in TikZ?
SOLUTION1
\usetikzlibrary{calc}
\def\SLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,0);
\coordinate (end) at (#1,0);
\coordinate (mark) at ($(start)!#2!(end)$);
\draw[line width=0.2cm, line cap=round, lightgray] (start) -- (end);
\shade[ball color=blue!30!cyan] (mark) circle(0.15cm);
}
}
SLIDER \SLIDER{2.5cm}{0.7}
SOLUTION2:
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) circle(.15) ;
}
}
\def\SquareSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) +(-.15,-.15) rectangle +(.15, .15) ;
}
}
\def\TriangleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, bottom color=lightgray, top color=black, middle color=lightgray] (start) rectangle (end);
\shade[draw=darkgray, rounded corners=0.2mm, ball color=blue!20!cyan] (mark) ++(-.15,-.15) -- ++(.15,-.15) -- ++(.15,.15) -- ++(0,.3) -- ++(-.3,0) -- cycle ;
}
}
\CircleSLIDER{2.5cm}{0.4}
\SquareSLIDER{2.5cm}{0.7}
\TriangleSLIDER{2.5cm}{0.3}
SOLUTION3:
\usetikzlibrary{calc}
\def\CircleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) circle(.15) ;
}
}
\def\SquareSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray,fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) +(-.15,-.15) rectangle +(.15, .15) ;
}
}
\def\TriangleSLIDER#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,-0.1cm);
\coordinate (end) at (#1,0.1cm);
\coordinate (mark) at ($(start|-0,0)!#2!(end|-0,0)$);
\fill[rounded corners=0.1cm, draw=gray, fill=lightgray] (start) rectangle (end);
\fill[draw=gray, rounded corners=0.2mm, fill=blue!20!cyan] (mark) ++(-.15,-.15) -- ++(.15,-.15) -- ++(.15,.15) -- ++(0,.3) -- ++(-.3,0) -- cycle ;
}
}
SOLUTION4:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,shadows,shadows.blur}
\def\IosSevenSlider#1#2{
\tikz[baseline=-0.1cm]{
\coordinate (start) at (0,0);
\coordinate (end) at (#1,0);
\coordinate (mark) at ($(start)!#2!(end)$);
\useasboundingbox (start|- 0,-.25) rectangle (end|- 0, .25);
\draw[line width=0.4mm, line cap=round, blue!50!cyan]
(start) -- (mark) edge[lightgray] (end);
\node[fill=white, draw=lightgray, very thin,
blur shadow={shadow xshift=0pt, shadow opacity=20, shadow yshift=-0.9mm,
shadow blur steps=6, shadow blur radius=0.3mm},
circle, minimum size=0.25cm, inner sep=0pt] at (mark) {};
}
}
\begin{document}
\setlength{\fboxsep}{0pt}
\fbox{\IosSevenSlider{2.5cm}{0.7}}
\end{document}
SOLUTION5 (with gradient):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\slider#1#2{% 1: length, 2: position of the mark (0 to 1)
\tikz[baseline=0cm]{
\coordinate (start) at (0,0);
\coordinate (end) at (#1,0);
\coordinate (mark) at ($(start)!#2!(end)$);
\fill[left color=blue, right color=red, fill, shading angle=95, rounded corners] (start)[above=.7em] rectangle (end)[below=.7em] ;
\path[
fill=blue!30!cyan,
] (mark) + (-.3em, -.2em) -- +(0em, -.4em) -- +(.3em, -.2em) -- +(.3em, .9em) -- +(-.3em, .9em) -- cycle;
}
}
\begin{document}
COOL \slider{2.5cm}{0.7} PARANO
\end{document}
From: https://tex.stackexchange.com/questions/181319/sliders-in-latex#181331
- (3106)How to solve "Package tikz Error" with '!' char?
The problem comes from french babel option's active chars. We need to deactivate them, then reactivate them:
\shorthandoff{:!}
\begin{tikzpicture}
...
\end{tikzpicture}
\shorthandon{:!}
From: https://www.mathematex.fr/viewtopic.php?p=148290&sid=5e1288d938869bc01d05a49b4f3648dd#p148290
- (3107)How to draw a red X over an external image using Pgf/TikZ?
\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (img) {\includegraphics{foo.png}};
\draw[red, line width=1mm]
(img.south west) -- (img.north east)
(img.south east) -- (img.north west);
\end{tikzpicture}
\end{document}
From: https://tex.stackexchange.com/questions/15990/draw-red-x-over-an-external-image-using-pgf-tikz#15991
- (3108)How to change Beamer's itemize font size?
\setbeamerfont{itemize/enumerate body}{}
\setbeamerfont{itemize/enumerate subbody}{size=\small}
\setbeamerfont{itemize/enumerate subsubbody}{size=\footnotesize}
From: https://latex.org/forum/viewtopic.php?t=8515
- (3111)How to put the caption below a code listing?
\begin{lstlisting}[caption={My Caption},captionpos=b]
...
\end{lstlisting}
From: https://tex.stackexchange.com/questions/303498/how-to-put-the-caption-below-the-listing/384269#384269
- (3112)How to open any LaTeX package doc from CLI?
texdoc <pkg name>
e.g. from lstlistings:
texdoc listings
From: https://tex.stackexchange.com/questions/303498/how-to-put-the-caption-below-the-listing#comment-735718
- (3113)How to change the starting value of an enumerate list?
\begin{enumerate}
\setcounter{enumi}{4}
\item fifth element
\end{enumerate}
(If you have lists at deeper levels of nesting, the relevant counters are enumii, enumiii and enumiv.)
From: https://tex.stackexchange.com/questions/142/how-can-i-make-an-enumerate-list-start-at-something-other-than-1#149
- (3114)How to format & color code inline?
Use package listing and \lstinline{...} instead of \texttt{...}
Thanks Ch. Gravier
- (3115)How to use square bracket in itemize environments?
PROBLEM:
\\[] and \item[] are defined keywords (resp. define vert. spacing & bullet char)
SOLUTION: Protect the [] inside {}
\begin{itemize}
\item {[José2009]} writes that ...
\end{itemize}
From: https://tex.stackexchange.com/questions/305167/using-square-bracket-in-text-mode#comment-960689
- (3116)How to change the fontsize for only a specific lstlisting?
You can set the option directly with the lstlisting environment option basicstyle
\documentclass{article}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[
basicstyle=\tiny, %or \small or \footnotesize etc.
]
int isJava = 1;
\end{lstlisting}
\end{document}
From: https://tex.stackexchange.com/questions/180222/how-to-change-font-size-for-specific-lstlisting#180223
- (3118)How to make lstlistings copy-pastable from PDF?
The technique relies on:
* the listings option columns=fullflexible in order not to insert superfluous spaces
* the listings option literate to map characters to their exact ASCII counterparts.
* the package accsupp to get some magic done between Unicode and ASCII spaces in order to preserve indentation (this is essential in some cases, for instance to copy-paste Python code)
\documentclass{article}
\usepackage[T1]{fontenc}%required
\usepackage{textcomp}
\usepackage{listings}
\lstset{
upquote=true,
columns=fullflexible,
literate={*}{{\char42}}1
{-}{{\char45}}1
}
\begin{document}
\begin{lstlisting}
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&\'()*+,-./:;<=>?@[]^_`{|}~
\end{lstlisting}
\end{document}
The complete technique with accsup to preserve indentation:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{listings}
\lstset{
upquote=true,
columns=fullflexible,
literate={*}{{\char42}}1
{-}{{\char45}}1
{\ }{{\copyablespace}}1
}
\usepackage[space=true]{accsupp}
% requires the latest version of package accsupp
\newcommand{\copyablespace}{
\BeginAccSupp{method=hex,unicode,ActualText=00A0}
\ %
\EndAccSupp{}
}
\begin{document}
\lstinputlisting{foo.c}
\end{document}
From: https://www.monperrus.net/martin/copy-pastable-listings-in-pdf-from-latex
https://tex.stackexchange.com/questions/142617/copy-pasting-leading-whitespace-and-blank-lines-in-listings-package-pdf/142765#142765
- (3126)How to color/indent code in a tabular environment?
SOLUTION1: Define a column as containing code
\documentclass{article}
\usepackage{xcolor}
\definecolor{greencyan}{rgb}{0.5, 1.0, 0.83}
\definecolor{marine}{rgb}{0.0, 0.5, 1.0}
\definecolor{firebrick}{rgb}{0.7, 0.13, 0.13}
\usepackage{listings}
\lstset{
language=haskell,
basicstyle=\ttfamily,
commentstyle=\color{gray}\textit,
keywordstyle=\color{firebrick},
numberstyle=\color{marine},
stringstyle=\color{greencyan},
breaklines=true
}
\usepackage{array}
\usepackage{collcell}
\newcolumntype{H}{>{\collectcell\lstinline}l<{\endcollectcell}}
\begin{document}
\begin{tabular}{Ll} % GM: Should be Hl???
[] & empty list initiation \\
++ & list concatenation \\
x:list & prepend x to list \\
head list & first element of a list \\
tail list & all but first element of a list \\
init list & last element of a list \\
last list & all but last element of a list
\end{tabular}
\end{document}
SOLUTION2: If structure is all you're after, you can just set the descriptions as \comments within an lstlisting environment:
\usepackage{xcolor}
\definecolor{greencyan}{rgb}{0.5, 1.0, 0.83}
\definecolor{marine}{rgb}{0.0, 0.5, 1.0}
\definecolor{firebrick}{rgb}{0.7, 0.13, 0.13}
\usepackage{listings}
\lstset{
language=haskell,
basicstyle=\ttfamily,
commentstyle=\color{gray}\textit,
keywordstyle=\color{firebrick},
numberstyle=\color{marine},
stringstyle=\color{greencyan},
breaklines=true,
mathescape
}
\newcommand{\comment}{\textrm}
\begin{document}
\begin{lstlisting}
[] $\comment{empty list initiation}$
++ $\comment{list concatenation}$
x:list $\comment{prepend x to list}$
head list $\comment{first element of a list}$
tail list $\comment{all but first element of a list}$
init list $\comment{last element of a list}$
last list $\comment{all but last element of a list}$
\end{lstlisting}
\end{document}
From: https://tex.stackexchange.com/questions/371936/define-a-tabular-column-to-be-a-lstlisting-environment#372077
- (3127)How to use curly braces in lstinline?
You can\'t protect them, so youneed to use another char to mark the function call boundaries.
\\documentclass{article}
\\usepackage{listings}
\\begin{document}
\\lstinline|&lt;Button onClick={this.handleClick}&gt;Button component&lt;/Button&gt;|
\\end{document}
From: https://tex.stackexchange.com/questions/264293/cant-escape-curly-braces-in-lstinline#264294
- (3150)How to allow line breaks in (formatted) URLs?
\usepackage{xurl}
From: https://tex.stackexchange.com/questions/3033/forcing-linebreaks-in-url/407368#407368
https://ctan.org/tex-archive/macros/latex/contrib/xurl
- (3278)What is the format for author's names in BibTeX?
BibTeX divides a person's name into four parts:
- First: First names or given names
- Last: Last name or family name
- von: a particle (e.g., de, de la, der, van, von)
- jr: a suffix (e.g., Jr., Sr., III)
BibTeX's internal name parser knows three ways these name parts can be combined:
- Method 1: First von Last
- Method 2: von Last, First
- Method 3: von Last, Jr, First
From: https://www.bibtex.com/f/author-field/
- (3287)How to create a dark theme for Beamer presentations?
\documentclass{beamer}
\usetheme{Warsaw}
\setbeamercolor{normal text}{fg=white,bg=black!90}
\setbeamercolor{structure}{fg=white}
\setbeamercolor{alerted text}{fg=red!85!black}
\setbeamercolor{item projected}{use=item,fg=black,bg=item.fg!35}
\setbeamercolor*{palette primary}{use=structure,fg=structure.fg}
\setbeamercolor*{palette secondary}{use=structure,fg=structure.fg!95!black}
\setbeamercolor*{palette tertiary}{use=structure,fg=structure.fg!90!black}
\setbeamercolor*{palette quaternary}{use=structure,fg=structure.fg!95!black,bg=black!80}
\setbeamercolor*{framesubtitle}{fg=white}
\setbeamercolor*{block title}{parent=structure,bg=black!60}
\setbeamercolor*{block body}{fg=black,bg=black!10}
\setbeamercolor*{block title alerted}{parent=alerted text,bg=black!15}
\setbeamercolor*{block title example}{parent=example text,bg=black!15}
\begin{document}
\begin{frame}
\frametitle{Test Frame}
\framesubtitle{Test Frame}
Test
\begin{enumerate}
\item Test
\end{enumerate}
\begin{block}{Test}
Test
\end{block}
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/57477/beamer-dark-theme#57478
- (3300)How to change font type (e.g. text in bold/italics) only on some overlays in Beamer?
You can use the <x> notation with \text*{...} commands:
\textbf<2>{Example Text}
\textit<2>{Example Text}
\textsl<2>{Example Text}
\textrm<2>{Example Text}
\textsf<2>{Example Text}
\textcolor<2>{orange}{Example Text}
\alert<2>{Example Text}
\structure<2>{Example Text}
From: https://www.overleaf.com/learn/latex/Beamer_Presentations:_A_Tutorial_for_Beginners_(Part_4)%E2%80%94Overlay_Specifications#Overlays_and_text_formatting
- (3301)How to change the order of appearance of environments in Beamer?
You can use the <x> notation on \begin{...}<x>\end{...}
\begin{frame}
\frametitle{Maths Blocks}
\begin{theorem}<1->[Pythagoras]
$ a^2 + b^2 = c^2$
\end{theorem}
\begin{corollary}<3->
$ x + y = y + x $
\end{corollary}
\begin{proof}<2->
$\omega +\phi = \epsilon $
\end{proof}
\end{frame}
Result: Order of appearance:
- Box1 at top
- Box3 at bottom
- Box2 in the middle
From: https://www.overleaf.com/learn/latex/Beamer_Presentations:_A_Tutorial_for_Beginners_(Part_4)%E2%80%94Overlay_Specifications#Overlays_and_environments
- (3302)How to make a table appear piece-by-piece in Beamer?
Use \onslide<x> at the end of the line.
\setbeamercovered{invisible}
\begin{frame}
\frametitle{Tables}
\begin{table}
\begin{tabular}{l | c | c | c | c }
Competitor Name & Swim & Cycle & Run & Total \\
\hline \hline
John T & 13:04 & 24:15 & 18:34 & 55:53 \onslide<2-> \\
Norman P & 8:00 & 22:45 & 23:02 & 53:47 \onslide<3->\\
Alex K & 14:00 & 28:00 & n/a & n/a \onslide<4->\\
Sarah H & 9:22 & 21:10 & 24:03 & 54:35
\end{tabular}
\caption{Triathlon results}
\end{table}
\end{frame}
From: https://www.overleaf.com/learn/latex/Beamer_Presentations:_A_Tutorial_for_Beginners_(Part_4)%E2%80%94Overlay_Specifications#Overlays_and_tables
- (3303)How to get a correct alignment of pictures included with \only{} in Beamer?
This is a well known fact; the beamer documentation mentions it in Section 9.5 Dynamically Changing Text or Images:
The trouble with this approach [using the \only command] is that it may lead to slight, but annoying differences in the heights of the lines, which may cause the whole frame to “wobble” from slide to slide. This problem becomes much more severe if the replacement text is several lines long. To solve this problem, you can use two environments: overlayarea and overprint. The first is more flexible, but less user-friendly.
So, you can use an overlayarea:
\documentclass{beamer}
\begin{document}
\begin{frame}
\begin{overlayarea}{\textwidth}{\textheight}
\only<1>{\includegraphics[width=\textwidth]{test}}
\only<2>{\includegraphics[width=\textwidth]{test}}
\only<3>{\includegraphics[width=\textwidth]{test}}
\end{overlayarea}
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/55809/problem-with-only-and-alignment-of-graphics-pdf-in-beamer
- (3304)How to display stuff piece-by-piece/on overlays in Beamer?
SOLUTION1: Generic but not that flexible: \pause
The \pause command allows to reveal parts of a frame one after the other.
SOLUTION2: Specific for items \item<x>
\begin{frame}
\frametitle{More Lists}
\begin{enumerate}[(I)]
\item<1-> Point A
\item<2-> Point B
\begin{itemize}
\item<3-> part 1
\item<4-> part 2
\end{itemize}
\item<5-> Point C
\item<6-> Point D
\end{enumerate}
\end{frame}
SOLUTION3: Generic solution for everything else: \onslide
\begin{frame}
\frametitle{Overlays}
\onslide<1->{First Line of Text}
\onslide<2->{Second Line of Text}
\onslide<3->{Third Line of Text}
\end{frame}
From: https://www.overleaf.com/learn/latex/Beamer_Presentations:_A_Tutorial_for_Beginners_(Part_4)%E2%80%94Overlay_Specifications#Overlay_specifications
- (3308)What is the name of LaTeX's default font?
The default font is "Computer Modern"
From: https://tex.stackexchange.com/questions/272607/what-is-the-name-of-latexs-default-style-and-why-was-it-chosen-for-latex
- (3329)How to emphasize parts of an lstlisting (a.k.a. How to insert LaTeX commands in a code listing)?
1. Use the escapechar directive of the lstlisting env to define an escape char that is compatible with the programming language you're prettyfying
2. In the listing, protect the LaTeX commands (e.g. \textbf{}) with this escape char
\documentclass{article}
\usepackage{listings}
\lstset{language=C, basicstyle=\ttfamily}
\begin{document}
\begin{lstlisting}[escapechar=@]
fun(foo, bar, @\textbf{baz}@ );
\end{lstlisting}
\end{document}
From: https://stackoverflow.com/questions/2704072/how-do-i-emphasize-parts-of-an-lstlisting/9438643#9438643
- (3330)How to uncover an lstlisting on a particular slide using \onslide or \uncover in Beamer?
PROBLEM:
Verbatim material cannot appear in an argument to another command (up to a certain point you could try using an external file and inputting it with \lstinputlisting) and use \uncover or \onslide.
SOLUTION:
The best approach here is to use the onlyenv environment for your listing (since the frame contains verbatim material it requires the fragile option):
\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]
\begin{overlayarea}{\linewidth}{3cm}
\onslide<1->{Hi}
\begin{onlyenv}<2->
\begin{lstlisting}
int i = 0;
\end{lstlisting}
\end{onlyenv}
\end{overlayarea}
\end{frame}
\end{document}
NOTE In the code above there's an optional overlayarea environment to prevent possible "jumps" if there are several overlays that have to be kept in line.
From: https://tex.stackexchange.com/questions/271243/uncover-lstlisting-on-a-particular-slide-using-onslide-or-uncover/271249#271249
- (3332)How to add indent/horizontal space (\hspace) before \lstlisting?
You cannot use \hspace, but you can use \lstlisting options:
SOLUTION1:
Use the key xleftmargin= of \lstlisting.
NOTE: You also have to change the caption margin via \captionsetup{margin=} from caption.
SOLUTION2:
Nest the \lstlistingsenvironment in an adjustwidth environment (from changepage).
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\usepackage{changepage}
\lstset{language=C}
\usepackage{caption}
\captionsetup[lstlisting]{singlelinecheck = off, format = plain}
\begin{document}
\section{A first section}
Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
{
\captionsetup[lstlisting]{margin = 4.8mm}
\begin{lstlisting}[caption ={My caption}, label = lst1, xleftmargin=4.8mm]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write('Case insensitive ');
Write('Pascal keywords.');
\end{lstlisting}
}
\begin{adjustwidth}{4.8mm}{}
\begin{lstlisting}[caption ={My caption}, label = lst1]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write('Case insensitive ');
Write('Pascal keywords.');
\end{lstlisting}
\end{adjustwidth}
\end{document}
From: https://tex.stackexchange.com/questions/437036/is-it-possible-to-add-hspace-before-beginlstlisting/437039#437039
- (3333)How to wrap lines in a \lstlisting?
Use the \lstlisting option "breaklines=true"
NOTE: you can add a "continuation" marker on wrapped lines with option "postbreak"
\documentclass{article}
\usepackage{lmodern} % for bold teletype font
\usepackage{amsmath} % for \hookrightarrow
\usepackage{xcolor} % for \textcolor
\usepackage{listings}
\lstset{
basicstyle=\ttfamily,
columns=fullflexible,
frame=single,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
}
\begin{document}
\begin{lstlisting}[language=java]
public class MeasureStationControllerV0Test {
MeasureStationControllerV0 controller;
MeasureStation ms = new MeasureStation();
MeasureStationConfiguration config = new MeasureStationConfiguration();
DataServer dataserver = new DataServer();
\end{lstlisting}
\end{document}
From: https://tex.stackexchange.com/questions/116534/lstlisting-line-wrapping/116572#116572
- (3343)How to number slides in a (multi-part/section) Beamer presentation?
- Add the counters in the slides's footline:
\setbeamertemplate{footline}{\hfill\insertframenumber/\inserttotalframenumber}
- You can change the counter manually with:
\addtocounter{framenumber}{50}
- Or you can make Beamer compute the "last slide" number (of this part) automatically:
\begin{frame}[label=lastframe]
text
\end{frame}
- You can also cross-ref counters from external files if your document is split in multiple files
Assuming your first part is called part1.tex then you can do the following in your document to automatically resume the frame numbers:
\documentclass{beamer}
\usetheme{Boadilla}
\setbeamertemplate{footline}{\hfill\insertframenumber/\inserttotalframenumber}
\usepackage{zref-xr}
\zxrsetup{toltxlabel}
\zexternaldocument*[main-]{part1}
\usepackage{refcount}
\setcounterref{framenumber}{main-lastframe} % Reuses counter from part1.tex
\begin{document}
\begin{frame}
text
\end{frame}
\begin{frame}
text
\end{frame}
\begin{frame}
text
\end{frame}
\end{document}
From: https://tex.stackexchange.com/questions/423074/how-to-number-slides-in-a-beamer-class-presentation-consisting-of-multiple-parts
- (3389)How to insert a smiley in LaTeX?
SOLUTION1: wasysym
\documentclass{article}
\usepackage{wasysym}
\begin{document}
wasysym: \smiley{} \frownie{} \blacksmiley{}
\end{document}
SOLUTION2: MnSymbol
\documentclass{article}
\usepackage{MnSymbol}
\begin{document}
MnSymbol: \(\smile{} \frown{}\)
\end{document}
From: https://tex.stackexchange.com/questions/3695/smileys-in-latex
- (3390)How to draw an arrow with triangle head?
SOLUTION1: LaTeX
\documentclass{article}
\usepackage{amsmath}
\usepackage{wasysym}
\usepackage{booktabs}
\providecommand\rightarrowRHD{\relbar\joinrel\mathrel\RHD}
\providecommand\rightarrowrhd{\relbar\joinrel\mathrel\rhd}
\providecommand\longrightarrowRHD{\relbar\joinrel\relbar\joinrel\mathrel\RHD}
\providecommand\longrightarrowrhd{\relbar\joinrel\relbar\joinrel\mathrel\rhd}
\makeatletter
\providecommand*\xrightarrowRHD[2][]{\ext@arrow 0055{\arrowfill@\relbar\relbar\longrightarrowRHD}{#1}{#2}}
\providecommand*\xrightarrowrhd[2][]{\ext@arrow 0055{\arrowfill@\relbar\relbar\longrightarrowrhd}{#1}{#2}}
\makeatother
\begin{document}
\begin{tabular}{lcccc}
\toprule
type & displaystyle & textstyle & scriptstyle \\
\midrule
filled short & $\displaystyle a \rightarrowRHD b$ & $\textstyle a \rightarrowRHD b$ & $\scriptstyle a \rightarrowRHD b$ \\
empty short & $\displaystyle a \rightarrowrhd b$ & $\textstyle a \rightarrowrhd b$ & $\scriptstyle a \rightarrowrhd b$ \\
filled long & $\displaystyle a \longrightarrowRHD b$ & $\textstyle a \longrightarrowRHD b$ & $\scriptstyle a \longrightarrowRHD b$ \\
empty long & $\displaystyle a \longrightarrowrhd b$ & $\textstyle a \longrightarrowrhd b$ & $\scriptstyle a \longrightarrowrhd b$ \\
filled superscript & $\displaystyle a \xrightarrowRHD{c} b$ & $\textstyle a \xrightarrowRHD{c} b$ & $\scriptstyle a \xrightarrowRHD{c} b$ \\
empty superscript & $\displaystyle a \xrightarrowrhd{c} b$ & $\textstyle a \xrightarrowrhd{c} b$ & $\scriptstyle a \xrightarrowrhd{c} b$ \\
filled sup+super & $\displaystyle a \xrightarrowRHD[d]{c} b$ & $\textstyle a \xrightarrowRHD[d]{c} b$ & $\scriptstyle a \xrightarrowRHD[d]{c} b$ \\
empty sub+super & $\displaystyle a \xrightarrowrhd[d]{c} b$ & $\textstyle a \xrightarrowrhd[d]{c} b$ & $\scriptstyle a \xrightarrowrhd[d]{c} b$ \\
\bottomrule
\end{tabular}
\end{document}
SOLUTION2: TikZ
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\usepackage{xparse}
\usepackage{xspace}
\makeatletter
\NewDocumentCommand{\myarrow}{%
s
O{}
m
m
O{1cm}
}{%
\begin{tikzpicture}[baseline=-0.5ex] {
\node[inner sep=0](@1) at (0,0) {#3};
\node[inner sep=0](@2) at (#5,0) {#4};
\IfBooleanTF #1 {
\draw [arrows={-Triangle[open]},shorten >= 2pt,shorten <= 2pt](@1)--(@2) node[pos=.5,above,inner sep=1pt] {#2};}
{\draw [arrows={-Triangle},shorten >= 2pt,shorten <= 2pt](@1)--(@2) node[pos=.5,above,inner sep=1pt] {#2};}}
\end{tikzpicture}\xspace
}
\makeatother
\begin{document}
Some text \myarrow{$x$}{$y$}, and other text.
White triangle with the starred version: \myarrow*{$x$}{$y$} and other text.
Specify the superscript as optional argument \myarrow*[$i$]{$x$}{$y$}.
Finally you can also set the distance between the two nodes: \myarrow[$i$]{$x$}{$y$}[2cm]
It works also math mode: \[ \myarrow*[$i$]{$x$}{$y$}\]
\end{document}
From: https://tex.stackexchange.com/questions/301314/triangle-arrows-with-text-above/301383#301383
https://latexdraw.com/exploring-tikz-arrows/#t-1610685307382
- (3391)How to draw a warning sign (triangle with exclamation point) in LaTeX?
SOLUTION1: with bclogo
\usepackage{bclogo}
...
\bcattention{}
...
SOLUTION2: with fourrier
\documentclass{article}
\usepackage{fourier}
\begin{document}
\danger
\end{document}
SOLUTION3: without any package
\documentclass{article}
\begin{document}
{\fontencoding{U}\fontfamily{futs}\selectfont\char 66\relax}
\end{document}
SOLUTION4: by creating one's own UTF-8 char
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage{newunicodechar}
\newcommand\Warning{%
\makebox[1.4em][c]{%
\makebox[0pt][c]{\raisebox{.1em}{\small!}}%
\makebox[0pt][c]{\color{red}\Large$\bigtriangleup$}}}%
\newunicodechar{&#9888;}{\Warning}
\begin{document}
Do&#9888;not&#9888;put your finger on the power plug.
\end{document}
SOLUTION5: with STIX font
\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{STIXGeneral}
\newcommand\warningsign{&#9888;}
\begin{document}
\warningsign Warning
\end{document}
SOLUTION6: with FontAwesome
\documentclass{article}
\usepackage{fontawesome}
\begin{document}
\faWarning{} Warning: This product contains peanuts
\end{document}
From: https://tex.stackexchange.com/questions/159669/how-to-print-a-warning-sign-triangle-with-exclamation-point
- (3392)How to write striked-through text in LaTeX (a.k.a. Comment barrer du texte en LaTeX)?
\documentclass{article}
\usepackage[normalem]{ulem} in the preamble gives you two ways to strike out text (and a couple more for underlining):
\begin{document}
\sout{text to be striked out} % a horizontal line through text
\xout{text to be crossed out} % many short diagonal lines crossing out the letters
\end{document}
BEWARE:
ulem affects some bibliography styles: some italicised text becomes underlined :{ The "normalem" option fixes that.
From: https://jansoehlke.com/2010/06/strikethrough-in-latex/
- (3393)How to reserve a space that is exactly the size of some given text in LaTeX (a.k.a. How to hide a text with a specific size in Beamer)?
Use boxes! (\parbox{}, \fbox{}, \savebox{})
\newsavebox{\fullname}
\sbox{\fullname}{John Jacob Jingleheimer Schmidt}
...
\usebox{\fullname}! His name is my name, too!
Whenever we go out, the people always shout!
There goes \\usebox{\fullname}! Ya da da da da da da.
E.g. to hide text on a Beamer presentation:
\invisible{\usebox{\fullname}}
\onlyslide<x>{\usebox{\fullname}}
From: https://latexref.xyz/_005csbox-_0026-_005csavebox.html
- (3402)How to import code to be prettified from external file?
\\lstinputlisting[language=java]{test.java}
From: https://www.overleaf.com/learn/latex/code_listing#Importing_code_from_a_file
- (3411)How to adding [fragile] to a org-beamer slide?
** My slide
:PROPERTIES:
:BEAMER_OPT: fragile
:END:
From: https://lists.gnu.org/archive/html/emacs-orgmode/2016-07/msg00116.html
- (3418)How to add a (e.g. blank) background to a picture (e.g. png) with transluscent background?
\\documentclass{article}
\\usepackage{xcolor}
\\usepackage{graphicx}
\\begin{document}
\\framebox{\\includegraphics{rgba16.png}}
\\colorbox{red}{\\includegraphics{rgba16.png}}
\\colorbox{white}{\\includegraphics{rgba16.png}}
\\colorbox{yellow}{\\includegraphics{rgba16.png}}
\\end{document}
From: https://www.latex4technics.com/?note=140C
- (3424)How to create an "empty" slide, with only a large picture on it in Beamer?
SOLUTION: the trick is to use the [plain] slide type
{
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{figure}}
\begin{frame}[plain]
\end{frame}
}
From: https://tex.stackexchange.com/questions/3915/image-on-full-slide-in-beamer-package
- (3466)How to insert pretty symbols/icons?
Pretty icons can be found in fontawesome (https://fontawesome.com/)
You can use most of it in LaTeX with package "fontawesome5":
texdoc fontawesome5 [NOTE: "fontawesome" also exists but is older]
Also see: https://www.nerdfonts.com/
Also see: https://tug.org/FontCatalogue/
From: https://texdoc.org/serve/fontawesome5.pdf/0
https://github.com/xdanaux/fontawesome-latex/issues/20
- (3474)How to change the aspect ratio of Beamer presentations from 4:3 to 16:9?
\documentclass[aspectratio=169]{beamer}
From: https://tex.stackexchange.com/questions/14336/latex-beamer-presentation-package-169-aspect-ratio
- (3487)How to draw on an image with TikZ?
SOLUTION1: create a node for the image, then a node for the annotation
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=\textwidth]{some_image.jpg}};
\draw[red,ultra thick,rounded corners] (7.5,5.3) rectangle (9.4,6.2);
\end{tikzpicture}
\end{document}
SOLUTION2: Use package "callouts"
\documentclass[11pt]{scrartcl} % use larger type; default would be 10pt
\usepackage[wby]{callouts}
\begin{document}
% pic-source: http://upload.wikimedia.org/wikipedia/commons/1/16/Mycena_interrupta.jpg
\begin{annotate}{\includegraphics[width=1\textwidth]{Mycena_interrupta}}{1}
% \helpgrid
\note{0,0}{Center}
\callout{4,3}{Mushrom}{3,2}
\arrow{-3,-2.4}{-4.5,-3}
%And raw tikz
\draw[very thick,red] (-4,4) rectangle (-3,3);
\end{annotate}
\end{document}
SOLUTION3: Use package "tikz-imagelabels"
\documentclass{standalone}
\usepackage{tikz-imagelabels}
\begin{document}
\begin{annotationimage}{width=6cm}{pleiades.jpg}
\draw[annotation left = {Atlas at 0.3}] to (0.11,0.4);
\draw[annotation left = {Pleione at 0.55}] to (0.11,0.49);
\draw[annotation left = {Alcyone at 0.8}] to (0.39,0.45);
\draw[annotation below = {Merope at 0.5}] to (0.58,0.28);
\draw[annotation right = {Electra at 0.3}] to (0.84,0.45);
\draw[annotation right = {Caleano at 0.75}] to (0.85,0.64);
\draw[annotation above = {Maia at 0.4}] to (0.67,0.72);
\draw[annotation above = {Taygeta at 0.9}] to (0.78,0.82);
\draw[image label = {M45 at south east}];
\end{annotationimage}
\end{document}
SOLUTION4: With a GUI: you can use "ktikz" or "qtikz" or "tikzit"
Also see Tip#3488 for finding annotation coordinates.
From: https://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz
- (3489)How to find the coordinate where to draw in TikZ?
SOLUTION1a: Draw gridlines on top of your figure
\draw[step=1.0,black,thin] (0.5,0.5) grid (5.5,4.5); % to put at the end (=> on top)
SOLUTION1b: Draw gridlines on top of your figure
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{some_image.jpg}};
%----- here
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[help lines,xstep=.1,ystep=.1] (0,0) grid (1,1);
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x/10,0) {0.\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (0,\y/10) {0.\y}; }
\end{scope}
%----- here
\end{tikzpicture}
\end{document}
SOLUTION3: on the web https://ff.cx/latex-overlay-generator/
From: https://tex.stackexchange.com/questions/45808/tikz-grid-lines
https://tex.stackexchange.com/questions/9559/drawing-on-an-image-with-tikz
- (3543)How to insert slides from an existing PDF without doing it page per page in a Beamer presentation?
- Use pdfpages
- To insert the slides from external PDF:
{
\setbeamercolor{background canvas}{bg=} %c'est ça le secret
\includepdf[pages=...]{fichier.pdf}
}
Thanks ÉM
- (3545)How to define once and for all the default PATH where LaTeX (graphicx package) will look for images (a.k.a. How to make \includegraphics use relative paths)?
\graphicspath{{subdir1/}{subdir2/}{subdir3/}...{subdirn/}}
From: https://tex.stackexchange.com/questions/139401/how-to-use-graphicspath/139403#139403
- (3546)How to compile everything (LaTeX+BibTeX) in AucTeX/Emacs?
C-c C-a (TeX-command-run-all) will do the job in AUCTeX 11.89.
From: https://stackoverflow.com/questions/32904909/emacs-auctex-commandto-compile-and-view/38377679#38377679
- (3578)How to (re)set the main document in Overleaf?
- Overleaf will automagically choose a document in the project which includes the \documentclass[...]{...} as the main document.
To set another document as the main document on a project:
- Click into the menu in the top lefthand corner
- Go to "Main document"
- Select the correct .tex file
From: https://www.overleaf.com/learn/how-to/Set_Main_Document
- (3579)How to change the spell check language in Overleaf?
- Goto project settings menu
- Choose the spell check language from the dropdown menu
From: https://www.overleaf.com/learn/how-to/Can_I_change_the_spell_check_language_to_e.g._Spanish%3F
- (3585)How to solve the block boxes that appear when using colortbl (in merged cells only?)?
\rowcolor{white} for the first row works great!
From: https://latex.org/forum/viewtopic.php?p=73217&sid=dec16045f2740b28cc00cd5bc39085f2#p73217
- (3614)How to highlight rows/columns in a table with color in LaTeX?
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\def\ra{some text}
%%%% For rows
\begin{table}[ht]
\centering
\begin{tabular}{c|ccccccc}
\hline
& col1 & col2 & col3 & col4 & col5 & col6 & col7 \\
\hline
\rowcolor{LightCyan}
row1& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row2& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
\rowcolor{LightCyan}
row3& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row4& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
\rowcolor{LightCyan}
row5& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row6& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
\hline
\end{tabular}
\end{table}
%%%% For columns
\newcolumntype{g}{>{\columncolor{Gray}}c}
\begin{table}[ht]
\centering
\begin{tabular}{c|g|c|g|c|g|c|g}
\hline
&col1 &col2 &col3 &col4 & col5 &col6 &col7\\
\hline
row1& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row2& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row3& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row4& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row5& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
row6& \ra & \ra & \ra & \ra & \ra & \ra & \ra \\
\hline
\end{tabular}
\end{table}
From: https://texblog.org/2011/04/19/highlight-table-rowscolumns-with-color/
- (3629)How to get syntax coloring for language not supported by lstlisting?
PROBLEM: some languages, like YAML are not supported by lstlisting.
SOLUTION: use the "minted" package
----- Include inline code -----
\documentclass{article}
\usepackage{minted}
\begin{document}
\begin{minted}{python}
import numpy as np
def my_add(genl1, genl2):
return genl1 + genl2
print( my_add(1, 2) )
\end{minted}
\end{document}
----- Include external file code -----
\documentclass{article}
\usepackage{minted}
\title{Importing files using minted}
\begin{document}
The next code will be directly imported from a file:
\inputminted{octave}{BitXorMatrix.m}
\end{document}
From: https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted
https://tex.stackexchange.com/questions/428700/include-only-a-part-of-external-file-in-minted
- (3697)How to change spacing before longtable?
PROBLEM: Using \hspace[*] does not work
You need to set the length \LTleft, if you want to change the position of the longtable (as default it is centered).
From: https://tex.stackexchange.com/questions/384844/hspace-does-not-work-before-longtable/384847#384847
- (3730)How to use multiple keywords in biblatex::\printbibliography{} to filter the bibliography?
I] If you want to combine keywords with "AND"
The right syntax is:
\printbibliography[keyword={key_1}, keyword={key_2}, keyword={key_3}]
And for omitting those specific keywords the syntax is:
\printbibliography[notkeyword={key_1}, notkeyword={key_2}, notkeyword={key_3}]
Same works with category and notcategory.
From: https://tex.stackexchange.com/questions/183243/use-multiple-keywords-in-printbibliography-to-filter-the-bibliography
II] If you want to combine keywords with "OR"
Biblatex supplied a filter that works:
\defbibfilter{example}{%
keyword=key_1 or keyword=key_2 or keyword=key_3
}
\printbibliography[filter=example, title={References}]
Note
You can break lines in \defbibfilter like so:
\defbibfilter{example}{%
keyword=key_1 % <---- This will work fine
or keyword=key_2
or keyword=key_3
}
You can NOT use spaces in \defbibfilter like so:
\defbibfilter{example}{%
keyword = key_1 % <---- This will NOT work
or keyword=key_2
or keyword=key_3
}
Also, \defbibfilter doesn't need to be in preamble.
From: https://tex.stackexchange.com/questions/367083/use-multiple-keywords-or-in-printbibliography-to-filter-the-bibliography
- (3738)How to prevent counting of backup slides in Beamer presentations?
The "hack" consists in saving the page counter value on the last slide we want, then set this backup value back into the page counter on the last slide:
\documentclass{beamer}
\usepackage{beamerthemesplit}
\usepackage{lipsum}
\usetheme{Madrid}
\newcommand{\backupbegin}{
\newcounter{finalframe}
\setcounter{finalframe}{\value{framenumber}}
}
\newcommand{\backupend}{
\setcounter{framenumber}{\value{finalframe}}
}
\begin{document}
% Your normal slides go here
\frame{\lipsum[1]}
\frame{\lipsum[2]}
\appendix
\backupbegin
% And your backup slides here
\frame{\lipsum[3]}
\backupend
\end{document}
From: https://tex.stackexchange.com/questions/70448/dont-count-backup-slides
- (3739)Howto prevent a slide to be counted in the total page number in Beamer (e.g. for transition slides)?
\addtocounter{framenumber}{-1}
From: https://stackoverflow.com/questions/3635386/increase-page-numbers-in-latex-beamer#3651849
- (3741)What are the predefined names for colors in LaTeX (a.k.a. What colors correctly go together? a.k.a. What are good color themse for Beamer presentations)?
From: https://latexdraw.com/predefined-latex-colors-dvipsnames/
https://latexcolor.com/
- (3742)Where to get a very neutral slide theme (based on grey levels)?
From: https://deic.uab.cat/~iblanes/beamer_gallery/individual/Warsaw-seagull-default.html
- (3743)Where to find themes for Beamer presentation and have a peek at what they look like?
https://deic.uab.cat/~iblanes/beamer_gallery/index_by_theme_and_color.html
- (3786)How to draw Neural Networks in TikZ?
Simple Example:
\documentclass[border=3pt,tikz]{standalone}
\usepackage{tikz}
\usepackage{listofitems} % for \readlist to create arrays
\tikzstyle{mynode}=[thick,draw=blue,fill=blue!20,circle,minimum size=22]
\begin{document}
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\readlist\Nnod{4,5,5,5,3} % number of nodes per layer
% \Nnodlen = length of \Nnod (i.e. total number of layers)
% \Nnod[1] = element (number of nodes) at index 1
\foreachitem \N \in \Nnod{ % loop over layers
% \N = current element in this iteration (i.e. number of nodes for this layer)
% \Ncnt = index of current layer in this iteration
\foreach \i [evaluate={\x=\Ncnt; \y=\N/2-\i+0.5; \prev=int(\Ncnt-1);}] in {1,...,\N}{ % loop over nodes
\node[mynode] (N\Ncnt-\i) at (\x,\y) {};
\ifnum\Ncnt>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[thick] (N\prev-\j) -- (N\Ncnt-\i); % connect arrows directly
}
\fi % else: nothing to connect first layer
}
}
\end{tikzpicture}
\end{document}
Complete set of examples:
% Author: Izaak Neutelings (September 2021)
% Inspiration:
% https://www.asimovinstitute.org/neural-network-zoo/
% https://www.youtube.com/watch?v=aircAruvnKk&list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi&index=1
\documentclass[border=3pt,tikz]{standalone}
\usepackage{amsmath} % for aligned
%\usepackage{amssymb} % for \mathbb
\usepackage{tikz}
%\usepackage{etoolbox} % for \ifthen
\usepackage{listofitems} % for \readlist to create arrays
\usetikzlibrary{arrows.meta} % for arrow size
\usepackage[outline]{contour} % glow around text
\contourlength{1.4pt}
\tikzset{>=latex} % for LaTeX arrow head
\usepackage{xcolor}
\colorlet{myred}{red!80!black}
\colorlet{myblue}{blue!80!black}
\colorlet{mygreen}{green!60!black}
\colorlet{myorange}{orange!70!red!60!black}
\colorlet{mydarkred}{red!30!black}
\colorlet{mydarkblue}{blue!40!black}
\colorlet{mydarkgreen}{green!30!black}
\tikzstyle{node}=[thick,circle,draw=myblue,minimum size=22,inner sep=0.5,outer sep=0.6]
\tikzstyle{node in}=[node,green!20!black,draw=mygreen!30!black,fill=mygreen!25]
\tikzstyle{node hidden}=[node,blue!20!black,draw=myblue!30!black,fill=myblue!20]
\tikzstyle{node convol}=[node,orange!20!black,draw=myorange!30!black,fill=myorange!20]
\tikzstyle{node out}=[node,red!20!black,draw=myred!30!black,fill=myred!20]
\tikzstyle{connect}=[thick,mydarkblue] %,line cap=round
\tikzstyle{connect arrow}=[-{Latex[length=4,width=3.5]},thick,mydarkblue,shorten <=0.5,shorten >=1]
\tikzset{ % node styles, numbered for easy mapping with \nstyle
node 1/.style={node in},
node 2/.style={node hidden},
node 3/.style={node out},
}
\def\nstyle{int(\lay<\Nnodlen?min(2,\lay):3)} % map layer number onto 1, 2, or 3
\begin{document}
% NEURAL NETWORK with coefficients, arrows
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\message{^^JNeural network with arrows}
\readlist\Nnod{4,5,5,5,3} % array of number of nodes per layer
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\edef\lay{\Ncnt} % alias of index of current layer
\message{\lay,}
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n] (N\lay-\i) at (\x,\y) {$a_\i^{(\prev)}$};
%\node[circle,inner sep=2] (N\lay-\i') at (\x-0.15,\y) {}; % shifted node
%\draw[node] (N\lay-\i) circle (\R);
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect arrow] (N\prev-\j) -- (N\lay-\i); % connect arrows directly
%\draw[connect arrow] (N\prev-\j) -- (N\lay-\i'); % connect arrows to shifted node
}
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layers};
\node[above=8,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
%% NEURAL NETWORK using \foreach's remember instead of \readlist
%\begin{tikzpicture}[x=2.2cm,y=1.4cm]
% \message{^^JNeural network with arrows}
% \def\Ntot{5} % total number of indices
% \def\nstyle{int(\lay<\Ntot?min(2,\lay):3)} % map layer number onto 1, 2, or 3
%
% \message{^^J Layer}
% \foreach \N [count=\lay,remember={\N as \Nprev (initially 0);}]
% in {4,5,5,5,3}{ % loop over layers
% \message{\lay,}
% \foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle; \prev=int(\lay-1);}]
% in {1,...,\N}{ % loop over nodes
% \node[node \n] (N\lay-\i) at (\x,\y) {$a_\i^{(\prev)}$};
%
% % CONNECTIONS
% \ifnum\Nprev>0 % connect to previous layer
% \foreach \j in {1,...,\Nprev}{ % loop over nodes in previous layer
% \draw[connect arrow] (N\prev-\j) -- (N\lay-\i); % connect arrows directly
% }
% \fi
%
% }
% }
%
% % LABELS
% \node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
% \node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layers};
% \node[above=8,align=center,myred!60!black] at (N\Ntot-1.90) {output\\[-0.2em]layer};
%
%\end{tikzpicture}
% NEURAL NETWORK with coefficients, uniform arrows
\newcommand\setAngles[3]{
\pgfmathanglebetweenpoints{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#1}{center}}
\pgfmathsetmacro\angmin{\pgfmathresult}
\pgfmathanglebetweenpoints{\pgfpointanchor{#2}{center}}{\pgfpointanchor{#3}{center}}
\pgfmathsetmacro\angmax{\pgfmathresult}
\pgfmathsetmacro\dang{\angmax-\angmin}
\pgfmathsetmacro\dang{\dang<0?\dang+360:\dang}
}
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\message{^^JNeural network with uniform arrows}
\readlist\Nnod{4,5,5,5,3} % array of number of nodes per layer
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n] (N\lay-\i) at (\x,\y) {$a_\i^{(\prev)}$};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\setAngles{N\prev-1}{N\lay-\i}{N\prev-\Nnod[\prev]} % angles in current node
%\draw[red,thick] (N\lay-\i)++(\angmin:0.2) --++ (\angmin:-0.5) node[right,scale=0.5] {\dang};
%\draw[blue,thick] (N\lay-\i)++(\angmax:0.2) --++ (\angmax:-0.5) node[right,scale=0.5] {\angmin, \angmax};
\foreach \j [evaluate={\ang=\angmin+\dang*(\j-1)/(\Nnod[\prev]-1);}] %-180+(\angmax-\angmin)*\j/\Nnod[\prev]
in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\setAngles{N\lay-1}{N\prev-\j}{N\lay-\N} % angles out from previous node
\pgfmathsetmacro\angout{\angmin+(\dang-360)*(\i-1)/(\N-1)} % number of previous layer
%\draw[connect arrow,white,line width=1.1] (N\prev-\j.{\angout}) -- (N\lay-\i.{\ang});
\draw[connect arrow] (N\prev-\j.{\angout}) -- (N\lay-\i.{\ang}); % connect arrows uniformly
}
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layers};
\node[above=8,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
% NEURAL NETWORK with coefficients, no arrows
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\message{^^JNeural network without arrows}
\readlist\Nnod{4,5,5,5,3} % array of number of nodes per layer
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\message{\lay,}
\foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n] (N\lay-\i) at (\x,\y) {$a_\i^{(\prev)}$};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
%\draw[connect] (N\prev-\j.0) -- (N\lay-\i.180); % connect to left
}
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layer};
\node[above=8,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
% NEURAL NETWORK with coefficients, shifted
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\message{^^JNeural network, shifted}
\readlist\Nnod{4,5,5,5,3} % array of number of nodes per layer
\readlist\Nstr{n,m,m,m,k} % array of string number of nodes per layer
\readlist\Cstr{\strut x,a^{(\prev)},a^{(\prev)},a^{(\prev)},y} % array of coefficient symbol per layer
\def\yshift{0.5} % shift last node for dots
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\message{\lay,}
\foreach \i [evaluate={\c=int(\i==\N); \y=\N/2-\i-\c*\yshift;
\index=(\i<\N?int(\i):"\Nstr[\lay]");
\x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n] (N\lay-\i) at (\x,\y) {$\Cstr[\lay]_{\index}$};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
%\draw[connect] (N\prev-\j.0) -- (N\lay-\i.180); % connect to left
}
\fi % else: nothing to connect first layer
}
\path (N\lay-\N) --++ (0,1+\yshift) node[midway,scale=1.5] {$\vdots$};
}
% LABELS
\node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layers};
\node[above=10,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
% NEURAL NETWORK no text
\begin{tikzpicture}[x=2.2cm,y=1.4cm]
\message{^^JNeural network without text}
\readlist\Nnod{4,5,5,5,3} % array of number of nodes per layer
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\message{\lay,}
\foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n] (N\lay-\i) at (\x,\y) {};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
%\draw[connect] (N\prev-\j.0) -- (N\lay-\i.180); % connect to left
}
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=5,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=2,align=center,myblue!60!black] at (N3-1.90) {hidden layer};
\node[above=10,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
% NEURAL NETWORK no text - large
\begin{tikzpicture}[x=2.3cm,y=1.0cm]
\message{^^JNeural network large}
\readlist\Nnod{6,7,7,7,7,7,4} % array of number of nodes per layer
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\message{\lay,}
\foreach \i [evaluate={\y=\N/2-\i; \x=\lay; \n=\nstyle;
\nprev=int(\prev<\Nnodlen?min(2,\prev):3);}] in {1,...,\N}{ % loop over nodes
% NODES
%\node[node \n,outer sep=0.6,minimum size=18] (N\lay-\i) at (\x,\y) {};
\coordinate (N\lay-\i) at (\x,\y);
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
%\draw[connect] (N\prev-\j.0) -- (N\lay-\i.180); % connect to left
\node[node \nprev,minimum size=18] at (N\prev-\j) {}; % draw node over lines
}
\ifnum \lay=\Nnodlen % draw last node over lines
\node[node \n,minimum size=18] at (N\lay-\i) {};
\fi
\fi % else: nothing to connect first layer
}
}
\end{tikzpicture}
% DEEP CONVOLUTIONAL NEURAL NETWORK
\begin{tikzpicture}[x=1.6cm,y=1.1cm]
\large
\message{^^JDeep convolution neural network}
\readlist\Nnod{5,5,4,3,2,4,4,3} % array of number of nodes per layer
\def\NC{6} % number of convolutional layers
\def\nstyle{int(\lay<\Nnodlen?(\lay<\NC?min(2,\lay):3):4)} % map layer number on 1, 2, or 3
\tikzset{ % node styles, numbered for easy mapping with \nstyle
node 1/.style={node in},
node 2/.style={node convol},
node 3/.style={node hidden},
node 4/.style={node out},
}
% TRAPEZIA
\draw[myorange!40,fill=myorange,fill opacity=0.02,rounded corners=2]
%(1.6,-2.5) rectangle (4.4,2.5);
(1.6,-2.7) --++ (0,5.4) --++ (3.8,-1.9) --++ (0,-1.6) -- cycle;
\draw[myblue!40,fill=myblue,fill opacity=0.02,rounded corners=2]
(5.6,-2.0) rectangle++ (1.8,4.0);
\node[right=19,above=3,align=center,myorange!60!black] at (3.1,1.8) {convolutional\\[-0.2em]layers};
\node[above=3,align=center,myblue!60!black] at (6.5,1.9) {fully-connected\\[-0.2em]hidden layers};
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
%\pgfmathsetmacro\Nprev{\Nnod[\prev]} % array of number of nodes in previous layer
\message{\lay,}
\foreach \i [evaluate={\y=\N/2-\i+0.5; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
%\message{^^J Layer \lay, node \i}
% NODES
\node[node \n,outer sep=0.6] (N\lay-\i) at (\x,\y) {};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\ifnum\lay<\NC % convolutional layers
\foreach \j [evaluate={\jprev=int(\i-\j); \cconv=int(\Nnod[\prev]>\N); \ctwo=(\cconv&&\j>0);
\c=int((\jprev<1||\jprev>\Nnod[\prev]||\ctwo)?0:1);}]
in {-1,0,1}{
\ifnum\c=1
\ifnum\cconv=0
\draw[connect,white,line width=1.2] (N\prev-\jprev) -- (N\lay-\i);
\fi
\draw[connect] (N\prev-\jprev) -- (N\lay-\i);
\fi
}
\else % fully connected layers
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
}
\fi
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=3,align=center,mygreen!60!black] at (N1-1.90) {input\\[-0.2em]layer};
\node[above=3,align=center,myred!60!black] at (N\Nnodlen-1.90) {output\\[-0.2em]layer};
\end{tikzpicture}
% AUTOENCODER
\begin{tikzpicture}[x=2.1cm,y=1.2cm]
\large
\message{^^JNeural network without arrows}
\readlist\Nnod{6,5,4,3,4,5,6} % array of number of nodes per layer
% TRAPEZIA
\node[above,align=center,myorange!60!black] at (3,2.4) {encoder};
\node[above,align=center,myblue!60!black] at (5,2.4) {decoder};
\draw[myorange!40,fill=myorange,fill opacity=0.02,rounded corners=2]
(1.6,-2.7) --++ (0,5.4) --++ (2.8,-1.2) --++ (0,-3) -- cycle;
\draw[myblue!40,fill=myblue,fill opacity=0.02,rounded corners=2]
(6.4,-2.7) --++ (0,5.4) --++ (-2.8,-1.2) --++ (0,-3) -- cycle;
\message{^^J Layer}
\foreachitem \N \in \Nnod{ % loop over layers
\def\lay{\Ncnt} % alias of index of current layer
\pgfmathsetmacro\prev{int(\Ncnt-1)} % number of previous layer
\message{\lay,}
\foreach \i [evaluate={\y=\N/2-\i+0.5; \x=\lay; \n=\nstyle;}] in {1,...,\N}{ % loop over nodes
% NODES
\node[node \n,outer sep=0.6] (N\lay-\i) at (\x,\y) {};
% CONNECTIONS
\ifnum\lay>1 % connect to previous layer
\foreach \j in {1,...,\Nnod[\prev]}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (N\prev-\j) -- (N\lay-\i);
\draw[connect] (N\prev-\j) -- (N\lay-\i);
%\draw[connect] (N\prev-\j.0) -- (N\lay-\i.180); % connect to left
}
\fi % else: nothing to connect first layer
}
}
% LABELS
\node[above=2,align=center,mygreen!60!black] at (N1-1.90) {input};
\node[above=2,align=center,myred!60!black] at (N\Nnodlen-1.90) {output};
\end{tikzpicture}
% NEURAL NETWORK activation
% https://www.youtube.com/watch?v=aircAruvnKk&list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi&index=1
\begin{tikzpicture}[x=2.7cm,y=1.6cm]
\message{^^JNeural network activation}
\def\NI{5} % number of nodes in input layers
\def\NO{4} % number of nodes in output layers
\def\yshift{0.4} % shift last node for dots
% INPUT LAYER
\foreach \i [evaluate={\c=int(\i==\NI); \y=\NI/2-\i-\c*\yshift; \index=(\i<\NI?int(\i):"n");}]
in {1,...,\NI}{ % loop over nodes
\node[node in,outer sep=0.6] (NI-\i) at (0,\y) {$a_{\index}^{(0)}$};
}
% OUTPUT LAYER
\foreach \i [evaluate={\c=int(\i==\NO); \y=\NO/2-\i-\c*\yshift; \index=(\i<\NO?int(\i):"m");}]
in {\NO,...,1}{ % loop over nodes
\ifnum\i=1 % high-lighted node
\node[node hidden]
(NO-\i) at (1,\y) {$a_{\index}^{(1)}$};
\foreach \j [evaluate={\index=(\j<\NI?int(\j):"n");}] in {1,...,\NI}{ % loop over nodes in previous layer
\draw[connect,white,line width=1.2] (NI-\j) -- (NO-\i);
\draw[connect] (NI-\j) -- (NO-\i)
node[pos=0.50] {\contour{white}{$w_{1,\index}$}};
}
\else % other light-colored nodes
\node[node,blue!20!black!80,draw=myblue!20,fill=myblue!5]
(NO-\i) at (1,\y) {$a_{\index}^{(1)}$};
\foreach \j in {1,...,\NI}{ % loop over nodes in previous layer
%\draw[connect,white,line width=1.2] (NI-\j) -- (NO-\i);
\draw[connect,myblue!20] (NI-\j) -- (NO-\i);
}
\fi
}
% DOTS
\path (NI-\NI) --++ (0,1+\yshift) node[midway,scale=1.2] {$\vdots$};
\path (NO-\NO) --++ (0,1+\yshift) node[midway,scale=1.2] {$\vdots$};
% EQUATIONS
\def\agr#1{{\color{mydarkgreen}a_{#1}^{(0)}}}
\node[below=17,right=11,mydarkblue,scale=0.95] at (NO-1)
{$\begin{aligned} %\underset{\text{bias}}{b_1}
&= \color{mydarkred}\sigma\left( \color{black}
w_{1,0}\agr{0} + w_{1,1}\agr{1} + \ldots + w_{1,n}\agr{n} + b_1^{(0)}
\color{mydarkred}\right)\\
&= \color{mydarkred}\sigma\left( \color{black}
\sum_{i=1}^{n} w_{1,i}\agr{i} + b_1^{(0)}
\color{mydarkred}\right)
\end{aligned}$};
\node[right,scale=0.9] at (1.3,-1.3)
{$\begin{aligned}
{\color{mydarkblue}
\begin{pmatrix}
a_{1}^{(1)} \\[0.3em]
a_{2}^{(1)} \\
\vdots \\
a_{m}^{(1)}
\end{pmatrix}}
&=
\color{mydarkred}\sigma\left[ \color{black}
\begin{pmatrix}
w_{1,0} & w_{1,1} & \ldots & w_{1,n} \\
w_{2,0} & w_{2,1} & \ldots & w_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
w_{m,0} & w_{m,1} & \ldots & w_{m,n}
\end{pmatrix}
{\color{mydarkgreen}
\begin{pmatrix}
a_{1}^{(0)} \\[0.3em]
a_{2}^{(0)} \\
\vdots \\
a_{n}^{(0)}
\end{pmatrix}}
+
\begin{pmatrix}
b_{1}^{(0)} \\[0.3em]
b_{2}^{(0)} \\
\vdots \\
b_{m}^{(0)}
\end{pmatrix}
\color{mydarkred}\right]\\[0.5em]
{\color{mydarkblue}a^{(1)}}
&= \color{mydarkred}\sigma\left( \color{black}
\mathbf{W}^{(0)} {\color{mydarkgreen}a^{(0)}}+\mathbf{b}^{(0)}
\color{mydarkred}\right)
%\color{black},\quad \mathbf{W}^{(0)} \in \mathbb{R}^{m\times n}
\end{aligned}$};
\end{tikzpicture}
\end{document}
From: https://tikz.net/neural_networks/
- (3813)How to control spacing in a TikZ tree?
- In case you want to only move a single node you can also use left/right/xshift/yshift:
child{node [left=1.5cm] {b}
child{node [right=1.5cm] {b}
child{node [xshift=1.5cm] {b}
child{node [yshift=1.5cm] {b}
- If you want to configure space between siblings:
Use "sibling distance=...pt"
Refer to Section 18.4 Specifying Options for Trees and Children of the pgfmanual.
- You can also use the "tikz-qtree" package, which automatically guarantees that nodes won't overlap.
From: https://tex.stackexchange.com/questions/19379/how-to-control-spacing-in-a-tikz-tree
- (3814)How to Draw Trees in TikZ?
== Simple tree with coloring (of whole child vs. only node)
\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node {parent}
child [red] {node {child 1}}
child {node [red] {child 2}};
\end{tikzpicture}
\end{document}
== With direction of "growth"
\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node {parent} [grow = up]
child [red] {node {child 1} edge from parent [dashed]}
child {node [red] {child 2} edge from parent [blue] node [right, brown] {x}};
\node at (2,0) {o} [grow = north east]
child {[fill] circle (2pt)}
child {[fill] circle (2pt)};
\node at (4,0) {x} [grow = 300]
child {node {a}}
child {node {b}};
\end{tikzpicture}
\end{document}
== With squared lines & comments on edges
\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}
[
level 1/.style = {red, sibling distance = 4cm},
level 2/.style = {blue, sibling distance = 2.5cm},
level 3/.style = {teal, level distance = 1cm},
edge from parent fork down
]
\node {parent}
child {node {child 1}
child {node [circle, fill, minimum size = 4pt, inner sep = 0] {}}
child {node [circle, fill, minimum size = 4pt, inner sep = 0] {}}
edge from parent [dashed]}
child {node {child 2}
child [growth parent anchor = east] {node [draw] {grandchild 1}
child [anchor = west, parent anchor = south east, child anchor = north west] {node [draw] {great-grandchild}}}
child {node {grandchild 2}}
edge from parent node [right] {x}};
\end{tikzpicture}
\end{document}
== Like a filesystem
\documentclass[border=0.2cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}
[
level 1/.style = {red},
level 2/.style = {blue},
level 3/.style = {teal},
every node/.append style = {draw, anchor = west},
grow via three points={one child at (0.5,-0.8) and two children at (0.5,-0.8) and (0.5,-1.6)},
edge from parent path={(\tikzparentnode\tikzparentanchor) |- (\tikzchildnode\tikzchildanchor)}]
\node {parent}
child {node {child 1}
child {node [circle, fill, minimum size = 4pt, inner sep = 0] {}}
child {node [circle, fill, minimum size = 4pt, inner sep = 0] {}}
edge from parent [dashed]}
child [missing] {}
child [missing] {}
child {node {child 2}
child {node {grandchild 1}
child {node {great-grandchild}}}
child [missing] {}
child {node {grandchild 2}}
edge from parent node [draw = none, left] {x}};
\end{tikzpicture}
\end{document}
From: https://latexdraw.com/draw-trees-in-tikz/
- (3967)How to get italics/bold work with \texttt{...}?
The basic font does not support that. You need to use another font that supports it, like "Bera Mono":
[...]
\usepackage[T1]{fontenc}
\usepackage{libertine}%% Only as example for the romans/sans fonts
\usepackage[scaled=0.85]{beramono}
[...]
\begin{document}
\texttt{\textbf{foo}}
From: https://tex.stackexchange.com/questions/215482/how-do-i-get-texttt-with-bold-face-in-latex/215483#215483
- (3968)How to change the color of a text between two slides in Beamer without rewriting all the text?
\color<x-y>{color}{text}
From: https://tex.stackexchange.com/questions/23695/beamer-color-overlay-with-more-than-one-color
- (3992)How to insert a footnote in a caption in LaTeX?
\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}
\centering
\includegraphics{foo} ...
\caption[Caption for LOF]{Real caption\footnotemark}
\end{figure}
Anywhere on the same page where the float appears\footnotetext{blah}
but at least before the next footnote\footnote{the nextone}
\end{document}
From: https://tex.stackexchange.com/a/10185
- (3993)How to add MS-Word-like comments in LaTeX?
- todonotes http://ctan.org/pkg/todonotes
- trackchanges http://sourceforge.net/projects/trackchanges/
- changebar http://tug.ctan.org/pkg/changebar
- Easy Review https://ctan.org/tex-archive/macros/latex/contrib/easyreview
\remove{OLD TEXT}, \replace{OLD TEXT}{NEW TEXT}, \comment{TEXT}{COMMENT}, \highlight{TEXT}, and \alert{TEXT}.
- changes.sty http://tug.ctan.org/cgi-bin/ctanPackageInformation.py?id=changes
\added[Author]{new text} \deleted[Author]{old text} \replaced[Author]{new text}{old text}
- latexdiff generates a nicely rendered diff.
- Tips for collaboratively editing a LaTeX document
https://stackoverflow.com/questions/539791/tips-for-collaboratively-editing-a-latex-document/539848#539848
- https://stackoverflow.com/questions/193298/best-practices-in-latex
From: https://stackoverflow.com/questions/615738/adding-ms-word-like-comments-in-latex
- (3999)How to find erroneous utf-8 chars in a LaTeX/BibTeX file (a.k.a. How to solve error "Package inputenc Error: Unicode character ̈X (U+YYYY)")?
- Add \DeclareUnicodeCharacter{0308}{HERE!HERE!} to your LaTeX file header
- Compile the document
- Open the resulting PDF and search for "HERE!HERE!" string
From: https://tex.stackexchange.com/questions/570324/what-is-this-error-about-package-inputenc-error-unicode-character-%CC%88-u0308
- (4000)How to find erroneous utf-8 chars in a LaTeX/BibTeX file (a.k.a. How to solve error "Package inputenc Error: Unicode character ̈X (U+YYYY)")?
- Add \DeclareUnicodeCharacter{0308}{HERE!HERE!} to your LaTeX file header
- Compile the document
- Open the resulting PDF and search for "HERE!HERE!" string
From: https://tex.stackexchange.com/questions/570324/what-is-this-error-about-package-inputenc-error-unicode-character-%CC%88-u0308
- (4021)How to create a second reference/pointer to an existing footnote?
SOLUTION1: automatic & clean
- Add package "scrextend" or "footmisc"
- Create a \label{} inside the first footnote
- Reference this label with \footref{} or
----
\documentclass{article}
\usepackage{scrextend}
% or
% \usepackage{footmisc}
\begin{document}
Company SplishSplash\footnote{This is a registered trade name.
All rights are reserved.\label{refnote}}
produces not only SplishPlump\footref{refnote}
but also SplishPlash\footref{refnote}.
\end{document}
----
SOLUTION2: manual solutions - will not create the clickable box with hyperref
\footnote{text bla bla \label{xx}} ... \textsuperscript{\ref{xx}}
\footnote{text bla bla \label{xx}} ... \footnotemark[\ref{xxx}]
SOLUTION3: also see the \usepackage{fixfoot}
From: https://tex.stackexchange.com/questions/35043/reference-different-places-to-the-same-footnote
- (4088)How to load fonts in LaTeX?
\usepackage{fontspec}
\setmainfont[%
Path = /Library/Fonts/ ,
UprightFont = MOND ,
BoldFont = BD ,
ItalicFont = IT ,
Extension = .otf
]{GARA} % {contains only what is common among all file names (usually basename of font family)}
With setmainfont you're essential building case-sensitive font paths.
- Path=working directory for fonts
- BoldFont=filename segment of path
- ItalicFont=filename segment of path
- Extension=file extension of path
From: https://tex.stackexchange.com/questions/320096/xelatex-fontspec-cannot-find-fonts#320197
- (4089)How to find the "real" file name of a font, to use with package "fontspec"?
I don't know what is really going on, I have TexLive installed on both laptop and desktop computers. In one installation the font name with spaces works but not in the other. I'm too tired to check their versions or how they differ.
The solution for me is simply to:
fc-list | grep "the font name"
and look at its real file name. Use that instead.
From: https://tex.stackexchange.com/questions/224296/spaces-in-font-names/587079#587079
- (257)Set backup dir
(setq bkup-backup-directory-info '( (t "~/.xemacs_backup/" full-path prepend-name search-upward)))
- (258)Modify mode options by hooking on file extension
(add-hook 'text-mode-hook 'myctextmode) ; no-conversion,raw-text,undecided,utf-8,iso-8859-1,ctext
(defun myctextmode ()
(set-buffer-file-coding-system 'ctext)
)
(add-hook 'latex-mode-hook 'mylatexmode)
(defun mylatexmode ()
"Sets LaTeX mode properly"
(interactive)
(command-execute (quote LaTeX-install-toolbar))
(command-execute (quote LaTeX-mode))
(command-execute (quote font-lock-mode))
(command-execute (quote font-lock-mode))
(command-execute (quote font-lock-mode))
)
- (259)Adding a file extension
(add-to-list 'auto-mode-alist '("\\.tikz$" . LaTeX-mode))
- (260)Insertion of comments
tu peux aussi utiliser M-; (comment-dwim) dwim -> do-what-i-mean.
Thanks to Juan
- (261)Save a configuration of the frames into a register
Ahh, puis aussi pour garder une configuration de ta fenêtre dans un registre, c'est pratique, surtout si tu veux basculer entre plusieurs modes de travail (M-x window-configuration-to-register)
Thanks to Juan
- (262)Move from/to start/end of a region
Il y a un truc que j'utilise pas mal, c'est C-x C-x, ça te permet de basculer entre debut et fin d'une région (même si elle n'est pas sélectionnée), p. ex. si tu viens de faire un C-y, tu fais un C-x C-x puis C-M-\ et la région est indentée. Puis un mode que je trouve pas mal est icomplete (c'est la completion pour les commandes).
- (41)Count total/current number of chars
The command C-x = (what-cursor-position) provides information about
point and about the column the cursor is in. It prints a line in the
echo area that looks like this:
Char: x (0170) point=65986 of 563027(12%) column 44
(In fact, this is the output produced when point is before `column 44'
in the example.)
The two values after `Char:' describe the character following point,
first by showing it and second by giving its octal character code.
`point=' is followed by the position of point expressed as a character
count. The front of the buffer counts as position 1, one character
later as 2, and so on. The next, larger number is the total number of
characters in the buffer. Afterward in parentheses comes the position
expressed as a percentage of the total size.
- (49)Files Encoding
See keywords:
-> set-buffer-file-coding-system (CTL-x RET f ISO-8859-1)
-> et file-coding-system pour 'file-names' ?
- (50)How to enter a newline character in a regex?
Type C-q C-j to enter a newline character (at the query-replace prompt).
- (52)Copy / Cut rectangles of text (e.g., table column!, thanks to Vaillant Jerome)
Pour ajouter un rectangle de texte (comme par exemple "// " en debut
de ligne) : marquer le coin supérieur gauche du rectangle avec
"M-space" puis deplacez vous au coin inférieur droit et faites un "C-x
C-r t" puis taper votre texte dans le minibuffer. C-x C-r est
associable aux autres commandes d'édition : C-x C-r k coupe le
rectangle selectionne et C-x C-r y le colle (a partir de la position
courante du curseur)
SOUS XEMACS C'est C-x r t !!
http://linuxfr.org/tips/152.html
- (53)Open compressed files
Cette ligne (à mettre dans .emacs) permet à emacs d'acceder de manière
transparente aux fichiers compressés. (auto-compression-mode 1) foX
- (54)Replace RegExp
In replace-regexp, the newstring need not be constant. It can refer to
all or part of what is matched by the regexp.
`\&' in newstring stands for the entire text being replaced.
`\d' in newstring, where d is a digit, stands for whatever matched the
d'th __parenthesized (with "\(" and "\)")__ grouping in regexp.
par exemple : C-M-% \(\w*\) RET '\1' remplace "mot" par "'mot'"
- (55)ESC-<value> (used to repeat commands or set vars)
ESC-<chiffre> <cmd>
=> reprete <chiffre> fois la commande
ESC-<chiffre> CTL-x f
=> definit la variable de position de column pour ESC-q.
La fonciton associée est function set-fill-column
- (56)Undo M-q
>M> Hello,
>M> Is there a way to undo the effect of M-q (fill-paragraph)? I like to
>M> write my blog post with emacs, and use M-q to make the text more
>M> readable, but when I copy the text into "blogger" I need to remove
>M> line breaks. Thanks for any help.
Use longlines-mode instead of fill-paragraph.
Solution crade : ESC-<tres gros chiffre> CTL-X F puis ESC-Q sur les
paragraphes (cf plus haut pour le nom de la fonction)
- (42)Selecting the current function/method (cc/jde-mode, thanks to pappy)
use C-M-h
It calls the lisp function (mark-defun)
http://linuxfr.org/tips/60.html
- (43)Coding system (ISO-8859-1 and UTF-8) and hooks
If you add
(modify-coding-system-alist 'file "mon_projet" 'iso-latin-1)
to your .xemacs/custom.el , then al the files containing "mon_projet" will use
latin-1 as default (i.e. iso-8859-1)
Also, see keywords:
-> set-buffer-file-coding-system (CTL-x RET f ISO-8859-1)
-> file-coding-system for the 'file-names' ?
To get UTF-8 to work, use xemacs-mule in a version >= 21.5.(28)
- (67)Change the directory where XEmacs stores its backup files
(require 'backup-dir)
(setq bkup-backup-directory-info '( (t "~/.xemacs_backups/") full-path prepend-name search-upward))
------ exemple -----
http://www.xemacs.org/Documentation/packages/html/edit-utils_12.html
Allows backup files to be optionally stored in some directories, based on the value of the alist, bkup-backup-directory-info. This variable is a list of lists of the form (FILE-REGEXP BACKUP-DIR OPTIONS ...). If the filename to be backed up matches FILE-REGEXP, or FILE-REGEXP is t, then BACKUP-DIR is used as the path for its backups. Directories may begin with "/" to specify an absolute pathname.
(require 'backup-dir)
(setq bkup-backup-directory-info
'(("/home/greg/.*" "/~/.backups/" ok-create full-path prepend-name)
("^/[^/:]+:" ".backups/") ; handle EFS files specially: don't
("^/[^/:]+:" "./") ; search-upward... its very slow
(t ".backups/"
full-path prepend-name search-upward)))
- (69)Mode to get functions/methods folding (reduction to one a "+" sign+ 1 line+"...")
Hide/Show method bodies in any programming environnement
use (ESC-x) hs-minor-mode
- (70)Narrow the working region
- to narrow: CTL-x n n
- to unnarrow: CTL-x n p
- (74)Move word by word
CTL-arrows
- (75)Swap letters or words or lines
- To swap letters, place the cursor on the second letter and use C-t
- To swap words, place the cursor on the first letter of the second word and use ESC-t
- To swap lines use C-x C-t
Note: bash uses similar key commands as emacs, thus this works in bash too :)
- (76)Change to upper/lower-case
- Select a region then press ESC-u to uppercase, ESC-l to lowercase, or ESC-c to capitalize (first letter to uppercase, remaining letters in lowercase)
Note: works with bash too ;)
- (84)Prefix a bunch of lines
- select a region
- type C-x string-rectangle or "C-x r t"
- type the cars you want to add a the beginning of the lines
- type "enter"
Very useful to comment a region in tex with %, in bash with # or in C++ with //
- (99)Get help
- C-h C-h then ? gives help on the help :)
- C-h b Table of all key bindings.
- C-h C-p Table of all mouse-button bindings.
- C-h a Type a substring; it shows a hypertext list of
functions and variables that contain that substring.
- C-h v Type a variable name; it displays its documentation and value.
- C-h c Type a command key sequence;
it displays the function name that sequence runs.
- C-h w Type a command name; it displays which keystrokes invoke that command.
- C-h l Recent input keystrokes and minibuffer messages.
- C-h C-h ? -> help on help
- C-h a -> a propos of a command
- C-h b -> list of all key bindings
- C-h c -> type key seq => show command
- C-h p -> mouse bondings
- C-h l -> recent keystrokes (last commands)
- C-h v -> Type a variable name; it displays its documentation and value.
- C-h w -> Type a command name; it displays which keystrokes invoke that command.
- (107)Select/Copy/Cut and history
- Mark start of selection with C-Space, then move
- Select all the buffer with C-x h
- Copy with ESC-w
- Cut with C-w
- Paste with C-y ('yank')
- If you cut something new, YOU DIDN'T loose the previous cut things. You can access them after yanking by using ESC-y to switch between alternatives
- (109)find function associated to a key-binding
C-x K
- (125)How to get (some parts of) the JDE completion to work?
Remember to add the 'jde.jar' to the classpath of the JDE mode
- (126)Work with java files
Use the JDE mode:
-> functions to generate templates called jde-gen-XXX
e.g.:
jde-gen-get-set for getters and setters
jde-gen-action-listener for action listener
jde-gen-class for a class
jde-gen-case
jde-gen-catch (GENERATES an EMPTY statement)
jde-gen-for
jde-gen-main
jde-gen-to-string-method
jde-gen-println
...
-> CTL-x CTL-v is the beginning of any command
e.g.:
CTL-c CTL-\ backslash-region
CTL-c CTL-c comment-region
CTL-x CTL-v . jde-complete-in-line
CTL-x CTL-v CTL- . jde-complete
CTL-c CTL-v t jde-gen-try-catch-wrapper (WRAPPER means some text is already written and it is wrapped in try-catch)
CTL-c CTL-v CTL-g jde-open-class-at-point (needs the selection of a class name to be opened)
C-c C-v C-l jde-gen-println
C-c C-v C-p save project
C-c C-v C-s open the list of files in the project
C-c C-v C-w help on symbol
C-c C-v C-x open supper class
C-c C-v C-z add import for class at point
C-c C-v C-n browse JDK doc
- (127)Rename a file/buffer
ESC-x rename-file
ESC-x rename-buffer
(even by doing the first then the second, it seems that C-x C-s still save under the old name of the file...)
- (128)Copy and cut a rectangular selection
- Select upper left corner (C-space)
- Select lower right corner (just position the cursor here)
- Cut with C-x C-r C-k (kill-rectangle)
- Paste with C-x C-r C-y (yank-rectangle)
- (132)Make UTF-8 work ;)
You need to install the 21.5 series, compiled with "./configure --with-mule"
- (133)Install all packages
1. Download the "sumo" files in the packages repository
2. To install the Sumo tarballs, simply unpack them to: /usr/local/lib/xemacs/
(from: http://www.xemacs.org/Install/index.html)
- (134)Frames
- make a new frame C-x 5f
- delete a frame C-x 50
- split the window, horizontally C-x 2
- switch to a split window C-x o
- make into one window C-x 1
(from http://burtleburtle.net/justine/Tech/xcomm.html)
- (135)Search and replace
- begin a search and replace ESC-%
- replace all occurrences at once !
- replace Space
- skip the replace n
- stop the search and replace ESC
- recursive edit (temporarily suspend, make edits) C-r
- continue with the search and replace ESC-C-c
- (167)What to do if Xemacs is VEEEEEEEEERY slow to open when the network is bad
This come from the fact that it tries to resolve some names calling "gethostbyname"
solution on the net 1 : they say to add "127.0.0.1 localhost" to /etc/hosts
Did not work
solution on the net 2 : to change order of name lookup to files THEN network in /etc/nsswitch.conf or /etc/host.conf
MY SOLUTION for openBSD : add these two lines to /etc/resolv.conf.tail:
lookup file bind
domain <mydomain>
- (168)Tip for insertion of text
C-u C-y inserts buffered text while keeping cursor where started the insertion instead of moving the cursor at the end of the insertion
- (169)Text jutification
set-justification-full/left/right/center
- (171)Quote a control sequence
Use CTL-q <key> in [X]Emacs: it prints (quotes) command received by the interpreter without interpreting it (similarly to CTL-v <key> in XTerm)
- (176)How to bind keys correctly in the config file so that they work under xemacs -nw too
http://www.nongnu.org/emacs-tiny-tools/keybindings/index-body.html
- (196)file coding systems in Emacs
Emacs assigns a name to each coding system. Most coding systems are used for one language, and the name of the coding system starts with the language name. Some coding systems are used for several languages; their names usually start with `iso'. There are also special coding systems no-conversion, raw-text and emacs-mule which do not convert printing characters at all.
In addition to converting various representations of non-ASCII characters, a coding system can perform end-of-line conversion. Emacs handles three different conventions for how to separate lines in a file: newline, carriage-return linefeed, and just carriage-return.
C-h C coding RET
Describe coding system coding.
C-h C RET
Describe the coding systems currently in use.
M-x list-coding-systems
Display a list of all the supported coding systems.
- (214)How to make xemacs open file in only one instance?
- In .bashrc, add:
alias xemacs='~/.myxemacs'
- In .myxemacs paste (remember to set the execution bit):
#/bin/sh
gnuclient $@ || xemacs $@
- In .xemacs/init.el add:
(gnuserv-start)
- (269)My (structured) config file
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GLOBAL BEHAVIOUR OF XEMACS ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Adds the place where new package are installed to load-path
(add-to-list 'load-path "~/.xemacs/addons/")
; Access Unicode files transparently
(require 'un-define)
; Prevent narrowing to a region? Why? Useful?
(put 'narrow-to-region 'disabled nil)
; Possible completions are printed in the mini-buffer
(require 'iswitchb)
(icomplete-mode)
;(load "icicles-xmas.el")
;(load "icicles-menu-xmas.el")
;(require 'icicles)
;(icy-mode 1)
; Live spelling correction
(flyspell-mode 1)
; Enabling the use of the mouse wheel
(autoload 'mwheel-install "mwheel" "Enable mouse wheel support.") ;
(mwheel-install)
(custom-set-variables
'(toolbar-visible-p nil)
'(line-number-mode t)
'(column-number-mode t)
'(paren-mode (quote sexp) nil (paren))
'(current-language-environment "Latin-1")
'(default-input-method "latin-1-prefix")
'(global-font-lock-mode t nil (font-lock))
'(kept-new-versions 10)
'(kept-old-versions 10)
'(pui-package-install-dest-dir "/usr/local/lib/xemacs/")
'(query-user-mail-address nil)
'(user-mail-address "liar@noaddress.org")
'(version-control t)
)
; A macro to comment a region whathever the current mode
(defun uncomment-region (beg end)
"Uncomment a region of text"
(interactive "r")
(comment-region beg end -1));
; Some useful key associations
(global-set-key [f4] (quote toggle-language))
(global-set-key [f5] (quote ispell-buffer))
(global-set-key [f6] (quote ispell-continue))
(global-set-key [f8] (quote mylatexmode))
(global-set-key [f9] (quote dabbrev-expand))
(global-set-key [f10] (quote compile))
(global-set-key [f11] (quote comment-region))
(global-set-key [f12] (quote uncomment-region))
; Default coding systems
;(set-file-coding-system 'no-conversion)
;(set-default-file-coding-system 'no-conversion)
;(setq file-coding-system 'no-conversion)
;;(add-hook 'latex-mode-hook 'set-buffer-file-coding-system 'no-conversion)
;;(add-hook 'tex-mode-hook 'set-buffer-file-coding-system 'no-conversion)
;;(add-hook 'text-mode-hook 'set-buffer-file-coding-system 'no-conversion)
;;(setq default-buffer-file-coding-system 'no-conversion)
;(set-coding-priority-list '(utf-8))
;(set-coding-category-system 'utf-8 'utf-8)
;;(set-buffer-file-coding-system 'utf-8)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; FONTS ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-faces
'(default ((t (:size "13pt" :family "Fixed"))) t)
'(bold ((t (:size "14" :family "helvetica" :bold t))) t)
'(bold-italic ((t (:size "14" :family "helvetica" :bold t :italic t))) t)
'(font-latex-bold-face ((((class color) (background light)) (:foreground "DarkOliveGreen" :size "13" :bold t))))
'(font-latex-italic-face ((((class color) (background light)) (:foreground "DarkOliveGreen" :size "13" :italic t))))
'(italic ((nil (:family "helvetica" :bold nil :italic t))) t)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; EDIFF MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-variables
'(ediff-cmp-options nil)
'(ediff-diff-options "-a")
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; GNUPLOT MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-variables
'(calc-gnuplot-name "/usr/local/bin/gnuplot" t)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; C SHARP MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(load "csharp-mode.el")
(load "hide-show-csharp.el")
;(load "flymake.el")
;(load "flymake-for-csharp.el")
;(load "yasnippet-bundle.el")
;;(load "csharp/csde.el")
;;(load "/usr/local/lib/xemacs/xemacs-packages/lisp/vm/vm.el")
;;(load "/usr/local/lib/xemacs/xemacs-packages/lisp/gnus/mm-bodies.el")
;;(load "/usr/local/lib/xemacs/xemacs-packages/lisp/x-symbol/x-symbol.el")
(defun mycsharp ()
(require 'un-define)
; (set-coding-priority-list '(utf-8))
; (set-coding-category-system 'utf-8 'utf-8)
;; (require 'flymake-for-csharp)
;; (flymake-mode)
(hs-minor-mode 1)
(setq hs-isearch-open t)
(local-set-key "\C-c>" 'hs-hide-block)
(local-set-key "\C-c<" 'hs-show-block)
; (local-set-key "\C-w>" 'hs-hide-all)
; (local-set-key "\C-w<" 'hs-show-all)
)
(add-hook 'csharp-mode-hook 'mycsharp)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; TEXT MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Allow accentuated characters
(defun myctextmode ()
(set-buffer-file-coding-system 'ctext)
)
(add-hook 'text-mode-hook 'myctextmode) ; no-conversion,raw-text,undecided,utf-8,iso-8859-1,ctext
(add-hook 'text-mode-hook 'turn-on-auto-fill) ; set automatic fill-mode
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; LATEX MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'tex-site) ; make the LaTeX menu appear when loading .tex files
;(add-hook 'tex-mode-hook 'reftex-mode) ; loads references management tools
;(add-hook 'latex-mode-hook 'reftex-mode) ; loads references management tools
(add-hook 'tex-mode-hook 'turn-on-auto-fill) ; loads management of auto-fill
(add-hook 'latex-mode-hook 'turn-on-auto-fill) ; loads management of auto-fill
(add-to-list 'auto-mode-alist '("\\.tikz$" . LaTeX-mode)) ; adds the extension .tikz as a LaTeX mode extension
(custom-set-variables
'(LaTeX-eqnarray-label "Equation:") ; Changes some name for the ref tags
'(LaTeX-equation-label "Equation:")
'(LaTeX-figure-label "Figure:")
'(LaTeX-float "")
'(LaTeX-section-label (quote (("part" . "Part:") ("chapter" . "Chapter:") ("section" . "Section:") ("subsection" . "SSection:") ("subsubsection" . "SSSection:"))))
'(LaTeX-table-label "Table:")
'(TeX-PDF-mode t)
'(LaTeX-mode-hook (quote (reftex-mode)))
'(TeX-file-extensions (quote ("tex" "sty" "cls" "ltx" "texi" "texinfo" "dtx" "tikz"))) ; adds the extension .tikz as a LaTeX mode extension
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ASPELL MODE ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq-default ispell-program-name "aspell")
(setq current-language 1)
(ispell-change-dictionary "british")
(defun set-language-english ()
;Set english as ispell language
(setq current-language 1)
(ispell-change-dictionary "british")
(force-mode-line-update)
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space t)
)
(defun set-language-french ()
;Set french as ispell language
(setq current-language 0);
(ispell-change-dictionary "francais")
(force-mode-line-update);
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space nil)
)
(defun set-language-portuguese ()
;Set pt-br as ispell language
(setq current-language 2);
(ispell-change-dictionary "pt_BR")
(force-mode-line-update);
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space nil)
)
(defun toggle-language ()
"Toggle language between french/english/pt_BR"
(interactive)
(cond ((eq current-language 1)
(set-language-french))
((eq current-language 0)
(set-language-portuguese))
((eq current-language 2)
(set-language-english))
(t (set-language-french))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MAKE BACKUPS IN A GLOBAL DIRECTORY ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'backup-dir)
(setq bkup-backup-directory-info '( (t "~/.xemacs_backup/" full-path prepend-name search-upward)))
(setq version-control 3)
(setq kept-new-versions 5)
(setq kept-old-versions 0)
- (273)Generating the "words" file (wordlist), to enable ispell-complete-word for aspell
0. List available dicts
aspell dump dicts
1. For each interesting dict, generate wordlist
aspell --lang <lang> dump master > words.<lang>
3. Concatenate all lists into one and move it to a central repository
cat words.* > words
mv words <centralized wordlist dir (ex: /usr/local/share/dict/)>
5. Tell (X)emacs where to find the wordlist file
(setq ispell-alternate-dictionary "/usr/local/share/dict/")
- (295)How to make Xemaces support UTF8 under OpenBSD?
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="C"
export LC_TIME="C"
export LC_NUMERIC="C"
export LC_MONETARY="C"
export LC_MESSAGES="en_US.UTF-8"
export LC_ALL=""
AND
Change font to one that accepts accents (see .Xdefaults Xterm configuration)
Emacs.default.attributeFont: <use xfonsel to get one>
- (332)How to count # of cars?
M-=
- (383)Key bindings for ESS (mode for R)
From: http://ess.r-project.org/Manual/ess.html#Latest-version
C-h m
A complete list of keybindings that are available in each ESS mode
and brief description of that mode is available
M-x customize-group RET ess RET
A full list of them however is available by using the Custom
facility within emacs.
see http://ess.r-project.org/Manual/ess.html#Customization
- (402)How to generate a sequence?
C-u M-! seq 2 10
- (403)How to insert the result of a shell command?
C-u M-! echo "reversed" | rev
- (415)How to customize/configure ESS?
http://ess.r-project.org/Manual/ess.html#Customization
- (416)How to remove bad indentation of single '#' comments in ESS?
ESS -> Edit -> Fancy Comments = off
- (580)How to make backups in a global directory?
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; MAKE BACKUPS IN A GLOBAL DIRECTORY ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require 'backup-dir)
(setq bkup-backup-directory-info '( (t "~/.xemacs_backup/" full-path prepend-name search-upward)))
(setq version-control 3) ; activate multi-backups
(setq kept-new-versions 5) ; number of most recent backups to save
(setq kept-old-versions 0) ; number of most older backups to save
(setq auto-save-interval 50) ; nb new cars between auto save
(setq auto-save-timeout 10) ; nb sec between auto save
(defun make-auto-save-file-name () ; changing dir of saves
"Return file name to use for auto-saves of current buffer..."
(if buffer-file-name
(concat
"~/.xemacs_backup/"
"#"
(file-name-nondirectory buffer-file-name)
"#")
(expand-file-name
(concat "#%" (buffer-name) "#"))))
- (581)How to open UTF-8 files in Xemacs?
If you want XEmacs to load UTF-8 files correctly, add the following lines to your ~/.xemacs/init.el:
(require 'un-define)
(set-coding-priority-list '(utf-8))
(set-coding-category-system 'utf-8 'utf-8)
From: http://www.maruko.ca/i18n/
- (777)How to remove welcome tab in emacs?
Add the following to your .emacs:
(setq inhibit-startup-message t)
- (782)Something like my ideal .emacs
;; Set default encoding
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
;; Make dired list files like ls -ahl would do
(setq dired-listing-switches "-ahl")
;; Make dabbrev be case sensitive
;(setq dabbrev-case-fold-search "case-fold-search")
;(setq dabbrev-case-replace nil)
;; Manage aspell
(setq-default ispell-program-name "aspell")
(setq current-language 1)
(ispell-change-dictionary "british")
(defun set-language-english ()
;Set english as ispell language
(setq current-language 1)
(ispell-change-dictionary "british")
(force-mode-line-update)
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*");
(setq sentence-end-double-space t)
)
(defun set-language-french ()
;Set french as ispell language
(setq current-language 0);
(ispell-change-dictionary "francais");
(force-mode-line-update);
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*");
(setq sentence-end-double-space t)
)
(defun toggle-language ()
"Toggle language between french/english"
(interactive)
(cond ((eq current-language 1)
(set-language-french))
((eq current-language 0)
(set-language-english))
(t (set-language-french))
)
)
;; A macro to move quickly within a page
(defun moveup ()
"move 5 lines up"
(interactive)
(previous-line)
(previous-line)
(previous-line)
(previous-line)
(previous-line)
)
;; A macro to move quickly within a page
(defun movedown ()
"move 5 lines down"
(interactive)
(next-line)
(next-line)
(next-line)
(next-line)
(next-line)
)
;; A macro to imitate CTL-ALT-up of Xemacs
(defun moveupc ()
"move 5 lines up and recenter"
(interactive)
(moveup)
(recenter)
)
;; A macro to imitate CTL-ALT-down of Xemacs
(defun movedownc ()
"move 5 lines down and recenter"
(interactive)
(movedown)
(recenter)
)
;; M-Del delete word, does not go to next parenthesis!
(global-unset-key "\C-\M-d")
(global-set-key "\C-d" 'delete-char)
(global-set-key "\C-\M-d" 'kill-word)
(global-set-key (kbd "<escape> <deletechar>") 'kill-word)
(global-set-key (kbd "<escape> DEL") 'backward-kill-word)
(global-set-key [(control tab)] 'other-window)
(global-set-key (kbd "C-M-<up>") (quote moveupc))
(global-set-key (kbd "C-M-<down>") (quote movedownc))
(global-set-key (kbd "C-<up>") (quote moveup))
(global-set-key (kbd "C-<down>") (quote movedown))
;; Requires configuration of .Xdefaults/.Xresources
;;*vt100.modifyOtherKeys: 1
;;*vt100.formatOtherKeys: 1
(global-set-key (kbd "[37;6u") 'query-replace-regexp)
;;·keybiding·for·ssh·console·mode!!!$
(global-set-key (kbd "M-[ 1 ; 5 A") (quote moveup))
(global-set-key (kbd "M-[ 1 ; 5 B") (quote movedown))
(global-set-key (kbd "M-[ 1 ; 5 C") (quote forward-word))
(global-set-key (kbd "M-[ 1 ; 5 D") (quote backward-word))
;; Emacs 24 now differenciates ESC- and M-!!!
(global-set-key (kbd "<escape> u") 'upcase-word)
(global-set-key (kbd "<escape> l") 'downcase-word)
(global-set-key (kbd "<escape> c") 'capitalize-word)
(global-set-key (kbd "<escape> t") 'transpose-words)
(global-set-key (kbd "<escape> q") 'fill-paragraph)
(global-set-key (kbd "<escape> %") 'query-replace)
(global-set-key (kbd "<escape> #") 'query-replace-regexp)
(global-set-key (kbd "M-#") 'query-replace-regexp)
(global-set-key (kbd "<escape> C-%") 'query-replace-regexp)
(global-set-key (kbd "<escape> x") 'execute-extended-command)
(global-set-key (kbd "<escape> $") 'ispell-word)
(global-set-key (kbd "<escape> g g") 'goto-line)
(global-set-key (kbd "<escape> <deletechar>") (quote kill-word))
;; Some useful key associations
(global-set-key [f4] (quote toggle-language))
(global-set-key [f5] (quote ispell-buffer))
(global-set-key [f6] (quote ispell-continue))
(global-set-key [f9] (quote dabbrev-expand))
(global-set-key [f10] (quote whitespace-cleanup))
(global-set-key [C-f10] (quote menu-bar-open))
(global-set-key [f11] (quote comment-or-uncomment-region))
(global-set-key [f12] (quote comment-or-uncomment-region))
;; Problems with copy/paste/yank from/to other applications
;; From: http://www.emacswiki.org/emacs/CopyAndPaste
(setq select-active-regions t) ; active region sets primary X11 selection
(global-set-key [mouse-2] 'mouse-yank-primary) ; make mouse middle-click only paste from primary X11 selection, not clipboard and kill ring.
(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)
;;(global-set-key [(shift delete)] 'clipboard-kill-region)
;;(global-set-key [(control insert)] 'clipboard-kill-ring-save)
;;(global-set-key [(shift insert)] 'clipboard-yank)
;;(custom-set-variables
;; '(inhibit-startup-screen t))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ediff-merge-split-window-function (quote split-window-vertically))
'(ediff-split-window-function (quote split-window-horizontally))
'(inhibit-startup-screen t)
'(jde-gen-println
(quote
("(beginning-of-line)" "'> \"System.out.println(\" ~ \");\"")))
'(jde-global-classpath
(quote
("/home/guillaume/Work/Code/presans-commons/presans-commons-1.0.jar" "/home/guillaume/Work/Code/presans-crawling/presans-crawling-1.0.jar" "/home/guillaume/Work/Code/presans-indexing/presans-indexing-1.0.jar" "/home/guillaume/Work/Code/presans-jsofia/presans-jsofia-1.0.jar" "/home/guillaume/Work/Code/presans-machinelearning/presans-machinelearning-1.0.jar" "/home/guillaume/Work/Code/presans-searching/presans-searching-1.0.jar" "" "/home/guillaume/Work/Code/presans-lib/jars/spring-expression-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/xml-writer-0.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/heritrix-commons-3.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/nekohtmlSamples.jar" "/home/guillaume/Work/Code/presans-lib/jars/wikixmlj-modded.jar" "/home/guillaume/Work/Code/presans-lib/jars/secondstring.jar" "/home/guillaume/Work/Code/presans-lib/jars/proxytoys-1.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/mg4j-1.1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/guava-r08.jar" "/home/guillaume/Work/Code/presans-lib/jars/jakarta-oro-2.0.8.jar" "/home/guillaume/Work/Code/presans-lib/jars/juniversalchardet-1.0.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/libstemmer.jar" "/home/guillaume/Work/Code/presans-lib/jars/icu4j-53_1.jar" "/home/guillaume/Work/Code/presans-lib/jars/libidn-0.6.5.jar" "/home/guillaume/Work/Code/presans-lib/jars/htmllexer.jar" "/home/guillaume/Work/Code/presans-lib/jars/lucene-highlighter-4.0-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-collections-3.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/org.arabidopsis.ahocorasick-1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/jnisvmlight.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-logging-1.0.4.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-pool-1.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/kryo-1.01.jar" "/home/guillaume/Work/Code/presans-lib/jars/fastutil-6.4.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/terrier-3.0-core.jar" "/home/guillaume/Work/Code/presans-lib/jars/xom-1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/heritrix-engine-3.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/servlet-api.jar" "/home/guillaume/Work/Code/presans-lib/jars/ezmorph-1.0.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/stanford-ner-2011-06-19.jar" "/home/guillaume/Work/Code/presans-lib/jars/tika-parsers-0.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/postgresql-8.4-701.jdbc4.jar" "/home/guillaume/Work/Code/presans-lib/jars/jbibtex-1.0.14.jar" "/home/guillaume/Work/Code/presans-lib/jars/spring-asm-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/dsiutils-2.0.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/opencsv-2.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/wstx-asl-3.2.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/spring-beans-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-cli-1.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/log4j-1.2.15.jar" "/home/guillaume/Work/Code/presans-lib/jars/cls.jar" "/home/guillaume/Work/Code/presans-lib/jars/mongo-2.10.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/jargs.jar" "/home/guillaume/Work/Code/presans-lib/jars/antlr.jar" "/home/guillaume/Work/Code/presans-lib/jars/jwf.jar" "/home/guillaume/Work/Code/presans-lib/jars/jdom-1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/je-4.1.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/junidecode-0.1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-io-2.4.jar" "/home/guillaume/Work/Code/presans-lib/jars/junit-4.8.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-beanutils-1.8.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-net-1.4.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/liblinear-1.9-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/jtidy-r938.jar" "/home/guillaume/Work/Code/presans-lib/jars/tika-core-0.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/xstream-1.3.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-beanutils-core-1.8.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-lang-2.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/fast-md5.jar" "/home/guillaume/Work/Code/presans-lib/jars/spring-aop-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/htmlparser.jar" "/home/guillaume/Work/Code/presans-lib/jars/sux4j-3.0.4.jar" "/home/guillaume/Work/Code/presans-lib/jars/joda-time-1.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/xpp3_min-1.1.4c.jar" "/home/guillaume/Work/Code/presans-lib/jars/cglib-2.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-validator-1.3.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/weka.jar" "/home/guillaume/Work/Code/presans-lib/jars/archive-overlay-commons-httpclient-3.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-codec-1.9.jar" "/home/guillaume/Work/Code/presans-lib/jars/xstream-benchmark-1.3.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/tika-app-0.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/models.jar" "/home/guillaume/Work/Code/presans-lib/jars/stax-1.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/mysql-connector-java-5.1.13-bin.jar" "/home/guillaume/Work/Code/presans-lib/jars/colt-1.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/geoip-1.2.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/ia-web-commons-1.0-20131207.033010-102.jar" "/home/guillaume/Work/Code/presans-lib/jars/jena-2.6.4.jar" "/home/guillaume/Work/Code/presans-lib/jars/arq-2.8.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/cpdetector_1.0.7.jar" "/home/guillaume/Work/Code/presans-lib/jars/libsvm.jar" "/home/guillaume/Work/Code/presans-lib/jars/json-20090211.jar" "/home/guillaume/Work/Code/presans-lib/jars/jsap-2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/dom4j-1.6.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/wayback-core-1.6.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/spring-core-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/lucene-core-4.0-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/lucene-memory-4.0-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/lucene-queryparser-4.0-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/commons-beanutils-bean-collections-1.8.3.jar" "/home/guillaume/Work/Code/presans-lib/jars/heritrix-modules-3.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/je-4.0.71.jar" "/home/guillaume/Work/Code/presans-lib/jars/jsonic-1.2.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/chardet.jar" "/home/guillaume/Work/Code/presans-lib/jars/bzip2.jar" "/home/guillaume/Work/Code/presans-lib/jars/nekohtml.jar" "/home/guillaume/Work/Code/presans-lib/jars/stax-api-1.0.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/spring-context-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/presans-lib/jars/protobuf-java-2.5.0.jar" "/home/guillaume/Work/Code/presans-lib/jars/cglib-nodep-2.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/bcprov-ext-jdk16-145.jar" "/home/guillaume/Work/Code/presans-lib/jars/jericho-html-2.6.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/json-lib-2.4-jdk15.jar" "/home/guillaume/Work/Code/presans-lib/jars/lucene-analyzers-common-4.0-SNAPSHOT.jar" "/home/guillaume/Work/Code/presans-lib/jars/jettison-1.0.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/xercesImpl.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/doublon/commons-io-2.0.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/naming-core-0.8.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/commons-lang3-3.0.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/commons-pool-1.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/commons-logging-1.1.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/commons-io-2.0.1.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/slf4j-api-1.6.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/log4j-1.2.17.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/slf4j-log4j12-1.6.6.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/naming-java-0.8.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/lingpipe-3.8.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-deps/crfpp-1.0.2.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-libs/grobid-core-0.2.8.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-libs/grobid-trainer-0.0.16.jar" "/home/guillaume/Work/Code/presans-lib/jars/grobid-libs/grobid-home-0.2.13.jar" "" "." "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-expression-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/heritrix-commons-3.2.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/groovy-all-1.6.3.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/bsh-2.0b5.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/guava-r08.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jna-3.2.3.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-logging-1.0.4.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/kryo-1.01.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/poi-scratchpad-2.5.1-final-20040804.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/heritrix-engine-3.2.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jline-0.9.94.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-cli-1.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/ant-1.7.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-asm-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/fastutil-5.0.7.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-beans-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jets3t-0.5.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/httpcore-4.3.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/je-4.1.6.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/org.restlet-1.1.10.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/aopalliance-1.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/htmlparser-1.6.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-aop-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/joda-time-1.6.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/com.noelios.restlet.ext.jetty-1.1.10.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/archive-overlay-commons-httpclient-3.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-net-2.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jetty-6.1.26.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/itext-1.3.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/ia-web-commons-1.0-20131207.033010-102.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/mg4j-1.0.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/json-20090211.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/junit-3.8.2.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/libidn-1.15.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/reflectasm-0.8.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/ant-launcher-1.7.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-lang-2.6.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-core-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/javaswf-CVS-SNAPSHOT-1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/com.noelios.restlet-1.1.10.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/heritrix-modules-3.2.0.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-io-1.4.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/servlet-api-2.5-20081211.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/freemarker-2.3.19.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/poi-2.5.1-final-20040804.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jetty-ajp-6.1.11.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/spring-context-3.0.5.RELEASE.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-collections-3.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jericho-html-2.6.1.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jetty-sslengine-6.1.26.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/jetty-util-6.1.26.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/dnsjava-2.0.3.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/commons-codec-1.6.jar" "/home/guillaume/Work/Code/heritrix-3.2.0/lib/minlog-1.2.jar")))
'(jde-make-working-directory "~/Work/Code/dist")
'(jde-run-working-directory "~/Work/Code/dist")
'(show-paren-mode t)
'(vc-follow-symlinks t)
'(minibuffer-prompt ((t (:inverse-video t))))
'(mode-line ((t (:background "yellow" :foreground "black" :box (:line-width -1 :style released-button)))))
'(mode-line-highlight ((t (:box (:line-width 2 :color "grey90" :style released-button)))))
'(show-paren-match ((t (:background "yellow"))))
'(whitespace-newline ((t (:background "grey70"))))
'(whitespace-space ((t (:background "white")))))
(if (display-graphic-p)
; if in Xwindow, set small fonts
(custom-set-faces
'(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 100 :width normal :foundry "unknown" :family "Ubuntu Mono")))))
; if in -nw mode, set colors & fonts
(custom-set-faces
'(font-lock-comment-face ((t (:foreground "brightblack" :slant italic))))
'(font-lock-constant-face ((t (:foreground "magenta"))))
'(font-lock-keyword-face ((t (:foreground "brightred"))))
'(font-lock-string-face ((t (:foreground "brightblue"))))
'(font-lock-type-face ((t (:foreground "yellow"))))
'(font-lock-variable-name-face ((t (:foreground "green"))))
'(highlight ((t (:background "brightcyan" :weight semi-bold))))
'(minibuffer-prompt ((t (:inverse-video t))))
'(mode-line ((t (:background "yellow" :foreground "black" :box (:line-width -1 :style released-button)))))
'(mode-line-highlight ((t (:box (:line-width 2 :color "grey90" :style released-button)))))
'(show-paren-match ((t (:background "yellow"))))
'(whitespace-newline ((t (:background "grey70"))))
'(whitespace-space ((t (:background "white")))))
)
;; use spaces instead of tabs (tab=4 spaces)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
;; show whitespace chars
(require 'whitespace)
(setq-default whitespace-style '(face tabs newline empty trailing indentation::space)) ;add "lines" to visualize lines that are too long
(global-whitespace-mode 1)
;; puts the scrollbars on the right
(set-scroll-bar-mode 'right)
;; Disable auto-indentation in fundamental&org modes
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
;;(setq electric-indent-mode nil)
;; TO TEST:
;; (add-hook 'fundamental/org-mode-hook
;; (lambda ()
;; (setq electric-indent-mode nil)
;; )
;; )
;; ===== From: http://homepages.inf.ed.ac.uk/s0243221/emacs/
; HighLight current line
(global-hl-line-mode 1)
;; Show line-number in the mode line
(line-number-mode 1)
;; Show column-number in the mode line
(column-number-mode 1)
;; === Change backup behaviour
(setq make-backup-files nil)
;; Enable backup files.
(setq make-backup-files t)
;; Enable versioning with default values (keep five last versions, I think!)
(setq version-control t)
;; Save all backup file in this directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Deletion.html
; deletes excess backup files silently
(setq delete-old-versions t)
; number of oldest-backups to keep
(setq kept-old-versions 2)
; number of newest-backups to keep
(setq kept-new-versions 8)
;; For heritrix crawlers
(add-to-list 'auto-mode-alist '("\\.cxml$" . nxml-mode))
;; For PSQL files
(add-to-list 'auto-mode-alist '("\\.psql$" . sql-mode))
;; For Groovy/Grails/gsp
;;; (add-to-list 'load-path "~/.emacs.d/") ;; !!!emacs now warns not to do that!!!
(require 'cl)
(add-to-list 'load-path "~/.emacs.d/groovy-mode/")
;; For gsp
(add-to-list 'auto-mode-alist '("\\.gsp$" . nxml-mode))
;; use groovy-mode when file ends in .groovy or has #!/bin/groovy at start
(autoload 'groovy-mode "groovy-mode" "Major mode for editing Groovy code." t)
(add-to-list 'interpreter-mode-alist '("groovy" . groovy-mode))
(add-to-list 'auto-mode-alist '("\.groovy$" . groovy-mode))
;; overwrite default c indentation with 2 spaces to the same amount as "tab-width"
(setq-default c-basic-offset tab-width) ;; TODO: already in hook below
;; remove automatic insertion of closing brackets
;(groovy-electric-mode nil) ;; TODO: already set in hook below
;; make Groovy mode electric by default.
(add-hook 'groovy-mode-hook
(lambda ()
(require 'groovy-electric)
; (groovy-electric-mode nil) ; TODO: does not work
(setq-default c-basic-offset tab-width)) ; TODO: does not work
)
;; Show only the last opened file, not the list of opened files
(setq inhibit-startup-buffer-menu t)
(tool-bar-mode -1)
(put 'downcase-region 'disabled nil)
;(server-start)
;; OrgMode
(setq org-default-notes-file "~/.emacs.d/notes.org")
(global-set-key "\C-cc" 'org-capture)
; For Java
;; Define my correct email address (for java docs)
(setq user-mail-address "gm@presanstroll.com")
(add-to-list 'load-path "~/.emacs.d/jdee-2.4.1/lisp")
(autoload 'jde-mode "jde" "JDE mode" t)
(setq auto-mode-alist (append '(("\\.java\\'" . jde-mode)) auto-mode-alist))
(setq browse-url-browser-function (quote browse-url-firefox))
(setq jde-key-bindings (quote
;; C-c C-e => external tool (firefox @docs)
;; C-c C-v => commands (build, etc?)
;; C-c C-g => generate single lines of code (case, catch, if, comments, etc.)
;; C-c C-f => generate full wrappers (switch-case, if-then-else, forloop)
(("[? ? ?]" . jde-run-menu-run-applet)
("[? ? ?]" . jde-build)
("[? ? ?]" . jde-compile)
("[? ? ?]" . jde-debug)
("[? ? ?]" . jde-find)
("[? ? ?]" . jde-open-class-at-point) ; COOL
("[? ? ?]" . jde-bsh-run) ; COOL
("[? ? ?]" . jde-help-browse-jdk-doc) ; GM
("[? ? ?]" . jde-save-project)
("[? ? ?]" . jde-wiz-update-class-list)
("[? ? ?]" . jde-run)
("[? ? ?]" . speedbar-frame-mode)
("[? ? ?]" . jde-jdb-menu-debug-applet) ; GM
("[? ? ?]" . jde-help-symbol) ; GM
("[? ? ?]" . jde-show-superclass-source)
("[? ? ?]" . jde-open-class-at-point) ; COOL
("[? ? ?a]" . jde-wiz-implement-interface)
("[? ? ?c]" . jde-gen-class) ; GM
; ("[? ? ?c]" . jde-gen-case) ; GM
("[? ? ?d]" . jde-gen-switch) ; GM "d" is close to "s"
("[? ? ?e]" . jde-wiz-extend-abstract-class)
("[? ? ?f]" . jde-gen-try-finally-wrapper) ; COOL
("[? ? ?g]" . jde-wiz-get-set-methods) ; GM
("[? ? ?i]" . jde-import-find-and-import) ; GM
; ("[? ? ?i ?o]" . jde-import-organize) ; GM
("[? ? ?j]" . jde-javadoc-autodoc-at-line)
("[? ? ?l]" . jde-gen-println) ; GM
("[? ? ?m]" . jde-gen-main-method) ; GM
("[? ? ?o]" . jde-wiz-override-method)
("[? ? ?s]" . sr-speedbar-toggle) ; GM
("[? ? ?t]" . jde-gen-tostring-method) ; GM
("[? ? ?u]" . jde-gen-if-else-wrapper) ; GM
; ("[? ? ?]" . jde-gen-ife) ; GM "u" is close to "i"
("[? ? ?y]" . jde-gen-try-catch-wrapper) ; COOL "y" is close to "t"
; ("[? ? ?]" . jde-gen-try-catch-wrapper) ; COOL "y" is close to "t"
("[? ? ?z]" . jde-import-all)
("[? ? ?]" . jde-run-etrace-prev)
("[? ? ?]" . jde-run-etrace-next)
; ("[(control c) (control v) (control ?.)]" . jde-complete)
; ("[(control c) (control v) ?.]" . jde-complete-in-line)
("[(control c) (control v) (control ?.)]" . jde-complete-in-line) ; GM
("[(control c) (control v) ?\t]" . jde-complete) ; GM
)))
;; >jde-abbrev-mode M-x ... RET
;; >jde-browse-class M-x ... RET
;; >jde-browse-class-at-point M-x ... RET
;; >jde-bsh-run M-x ... RET
;; >jde-bug-display-path-info M-x ... RET
;; >jde-bug-set-breakpoint M-x ... RET
;; >jde-bug-step-into M-x ... RET
;; >jde-bug-step-into-all M-x ... RET
;; >jde-bug-step-over M-x ... RET
;; >jde-bug-toggle-breakpoint M-x ... RET
;; >jde-build M-x ... RET
;; >jde-checkstyle M-x ... RET
;; >jde-compile M-x ... RET
;; >jde-complete M-x ... RET
;; >jde-complete-in-line M-x ... RET
;; >jde-complete-menu M-x ... RET
;; >jde-create-new-project M-x ... RET
;; >jde-customize-variable M-x ... RET
;; >jde-db-get-class M-x ... RET
;; >jde-db-set-app-args M-x ... RET
;; >jde-db-set-args M-x ... RET
;; >jde-debug-clear-breakpoint M-x ... RET
;; >jde-debug-list-breakpoints M-x ... RET
;; >jde-debug-quit M-x ... RET
;; >jde-debug-run M-x ... RET
;; >jde-debug-set-breakpoint M-x ... RET
;; >jde-debug-step-into M-x ... RET
;; >jde-debug-step-over M-x ... RET
;; >jde-debug-toggle-breakpoint M-x ... RET
;; >jde-describe-path M-x ... RET
;; >jde-electric-return M-x ... RET
;; >jde-find M-x ... RET
;; >jde-find-class-source M-x ... RET
;; >jde-gen-bean M-x ... RET
;; >jde-gen-case M-x ... RET
;; >jde-gen-catch M-x ... RET
;; >jde-gen-class M-x ... RET
;; >jde-gen-eif M-x ... RET
;; >jde-gen-else M-x ... RET
;; >jde-gen-embrace M-x ... RET
;; >jde-gen-equals-method M-x ... RET
;; >jde-gen-exception M-x ... RET
;; >jde-gen-finally M-x ... RET
;; >jde-gen-for M-x ... RET
;; >jde-gen-fori M-x ... RET
;; >jde-gen-foriter M-x ... RET
;; >jde-gen-get-set M-x ... RET
;; >jde-gen-get-set-methods M-x ... RET
;; >jde-gen-hashcode-method M-x ... RET
;; >jde-gen-if M-x ... RET
;; >jde-gen-if-else-wrapper M-x ... RET
;; >jde-gen-ife M-x ... RET
;; >jde-gen-main-method M-x ... RET
;; >jde-gen-method M-x ... RET
;; >jde-gen-object-methods M-x ... RET
;; >jde-gen-property M-x ... RET
;; >jde-gen-section-comment M-x ... RET
;; >jde-gen-switch M-x ... RET
;; >jde-gen-tostring-method M-x ... RET
;; >jde-gen-try M-x ... RET
;; >jde-gen-try-catch-wrapper M-x ... RET
;; >jde-gen-try-finally-wrapper M-x ... RET
;; >jde-gen-while M-x ... RET
;; >jde-help-beanshell M-x ... RET
;; >jde-help-browse-jdk-doc M-x ... RET
;; >jde-help-class M-x ... RET
;; >jde-help-symbol M-x ... RET
;; >jde-import-all M-x ... RET
;; >jde-import-all-unique M-x ... RET
;; >jde-import-at-point M-x ... RET
;; >jde-import-find-and-import M-x ... RET
;; >jde-import-kill-extra-imports M-x ... RET
;; >jde-import-organize M-x ... RET
;; >jde-import-sort M-x ... RET
;; >jde-javadoc-customize M-x ... RET
;; >jde-junit-test-class M-x ... RET
;; >jde-keys M-x ... RET
;; >jde-load-all-project-files M-x ... RET
;; >jde-load-project-file M-x ... RET
;; >jde-make M-x ... RET
;; >jde-open-class-at-point M-x ... RET
;; >jde-open-class-source M-x ... RET
;; >jde-open-project-file M-x ... RET
;; >jde-project-create-project M-x ... RET
;; >jde-rename-class M-x ... RET
;; >jde-run M-x ... RET
;; >jde-run-main-class M-x ... RET
;; >jde-save-project M-x ... RET
;; >jde-set-compile-options M-x ... RET
;; >jde-set-global-classpath M-x ... RET
;; >jde-show-class-source M-x ... RET
;; >jde-show-help M-x ... RET
;; >jde-show-project-options M-x ... RET
;; >jde-show-run-options M-x ... RET
;; >jde-show-speedbar M-x ... RET
;; >jde-wiz-extend-abstract-class M-x ... RET
;; >jde-wiz-get-set-methods M-x ... RET
;; >jde-wiz-implement-interface M-x ... RET
;; >jde-wiz-override-method M-x ... RET
- (808)How to associate a file extension to an [X]emacs-mode?
(add-to-list 'auto-mode-alist '("\\.m$" . matlab-mode))
From: https://ccrma.stanford.edu/guides/planetccrma/Silly.html
- (880)How to make [X]Emacs copy/paste/yank buffers compatible with other applications?
X11 Copy & Paste to/from Emacs:
If you are having issues with cutting and pasting between emacs and other applications, it may be an issue with interactions between the UI’s clipboard or selection buffer and the emacs. Windows has a single clipboard buffer. X11 has more then one buffer. Consider these solutions:
XEmacs:
(setq interprogram-cut-function 'own-clipboard)
(setq interprogram-paste-function 'get-clipboard)
GNU Emacs 21.2.1 & newer:
(setq x-select-enable-clipboard t)
See also http://www.oreillynet.com/lpt/wlg/6162 which suggests
(setq x-select-enable-clipboard t) ; as above
(setq interprogram-paste-function 'x-cut-buffer-or-selection-value)
GNU Emacs CVS / 23 :
This has recently been expanded with more possible customisations.
The following represents something extremely close in “feel” to other modern X11 desktop apps, but with “bonus” kill ring features. “feel”? that is to say, the precise key bindings are different to other X11 apps unless maybe you also turn on cua-mode, but the behaviour is very similar to C-x/C-c/C-v clipboard in other apps:
clipboard and primary X11 selections are kept separate, yet clipboard X11 selection and kill-ring are friends.
It is perhaps easier for some to learn that different keys doing similar things than the same keys doing different things, i.e. a newbie to emacs might analogise:
C-w ? Cut (really kill)
M-w ? Copy (really kill-ring-save)
C-y ? Paste (really yank)
M-y (after C-y) ? Historic Paste of old cuts/copies “bonus” (really yank-pop, that is to say the kill-ring cometh)
and with the following customizations, that analogy might actually work out okay:
; (transient-mark-mode 1) ; Now on by default: makes the region act quite like the text "highlight" in many apps.
; (setq shift-select-mode t) ; Now on by default: allows shifted cursor-keys to control the region.
(setq mouse-drag-copy-region nil) ; stops selection with a mouse being immediately injected to the kill ring
(setq x-select-enable-primary nil) ; stops killing/yanking interacting with primary X11 selection
(setq x-select-enable-clipboard t) ; makes killing/yanking interact with clipboard X11 selection
;; these will probably be already set to these values, leave them that way if so!
; (setf interprogram-cut-function 'x-select-text)
; (setf interprogram-paste-function 'x-cut-buffer-or-selection-value)
; You need an emacs with bug #902 fixed for this to work properly. It has now been fixed in CVS HEAD.
; it makes "highlight/middlebutton" style (X11 primary selection based) copy-paste work as expected
; if you're used to other modern apps (that is to say, the mere act of highlighting doesn't
; overwrite the clipboard or alter the kill ring, but you can paste in merely highlighted
; text with the mouse if you want to)
(setq select-active-regions t) ; active region sets primary X11 selection
(global-set-key [mouse-2] 'mouse-yank-primary) ; make mouse middle-click only paste from primary X11 selection, not clipboard and kill ring.
;; with this, doing an M-y will also affect the X11 clipboard, making emacs act as a sort of clipboard history, at
;; least of text you've pasted into it in the first place.
; (setq yank-pop-change-selection t) ; makes rotating the kill ring change the X11 clipboard.
Alternate method (recent Emacs):
Not sure when this appeared in GNU emacs, or if it’s how the developers intended things, buts it’s useful for me (I habitually use emacs from CVS, BTW, so not sure when this tip first applies): The “x-select-enable-clipboard t” method seems to resuscitate the “traditional” (and IMHO deeply strange) emacs interaction with the X11 primary and clipboard selections. EVERYTHING you highlight as a region winds up in both PRIMARY and CLIPBOARD X11 selections. That is… painful. (but N.B. no longer true in CVS emacs, which has x-select-enable-primary to manage primary behaviour separately as above).
But, some heroic emacs developer saw fit to produce the following functions, though they are by default bound to X keys I doubt many people have (actual keys called cut/copy/paste), so one can put the following in .emacs instead:
(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)
If you want to keep the C-w, M-w, and C-y original settings, there is another way is to bind these keys by using the default X11: – XinShi
(global-set-key [(shift delete)] 'clipboard-kill-region)
(global-set-key [(control insert)] 'clipboard-kill-ring-save)
(global-set-key [(shift insert)] 'clipboard-yank)
The emacs menu bar cut/copy/paste probably uses these too I think, but of course you’ve turned that off as you’ve been told that having the menu bar on will impede learning emacs. :-)
This produces behaviour I like: The current region becomes PRIMARY as one might expect (like most freedesktop.org compliant apps, so it can be directly middle-button pasted in X apps), but CLIPBOARD is NOT munged by merely highlighting a region (again like most freedesktop.org compliant apps, and unlike x-select-enable-clipboard) - Iff you kill and yank, it interacts with the X CLIPBOARD in a vaguely sane manner (as if C-w/M-w/C-y were like C-x/C-c/C-v in other X11 apps, roughly). This makes interacting with other X11 applications pleasant I think - you just learn that emacs uses different keys for cut/copy/paste, basically - though of course this behaviour might cause people to think the kill ring was a mere clipboard, which it isn’t, as a press of M-y after a few kills will readily demonstrate :-).
clipboard-yank in particular seems eerily smart.
From: http://www.emacswiki.org/emacs/CopyAndPaste
- (916)How to bind/map special keys (e.g. ctrl or tab) in emacs?
(global-set-key "\C-d" 'delete-char)
(global-set-key "\C-\M-d" 'kill-word)
(global-set-key [(control tab)] 'other-window)
old Emacs Emacs 19.30+ and XEmacs19.14+
[C-tab] [(control tab)]
[A-1] [(alt ?1)]
[S-up] [(shift up)]
[H-prior] [(hyper prior)] ;; prior = PgUp
[M-f1] [(meta f1)]
From: http://www.faqs.org/faqs/GNU-Emacs-FAQ/keybindings-pointer/
- (933)How to change the behaviour of (ESC)-Delete in Emacs? DOES NOT WORK
(global-set-key [delete] 'delete-char)
(global-set-key [M-delete] 'kill-word)
From: http://www.emacswiki.org/emacs/BackspaceKey
- (1339)How to upper/lower case a region in Emacs?
C-x C-l
Convert region to lower case (downcase-region).
C-x C-u
Convert region to upper case (upcase-region).
https://www.gnu.org/software/emacs/manual/html_node/emacs/Case.html
- (1025)How to switch case sensitivity in emacs searches?
Typing M-c within an incremental search toggles the case sensitivity of that search. The effect does not extend beyond the current incremental search to the next one, but it does override the effect of adding or removing an upper-case letter in the current search.
From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Search-Case.html
- (1237)How to align vertically code around = signs using Emacs?
M-x align-regex =
From: https://twitter.com/UnixToolTip/status/460820965870809088
- (1273)How to remove the toolbar/icon menu in Emacs 24?
Add the following line in your .emacs:
(tool-bar-mode -1)
From: http://www.emacswiki.org/emacs/ToolBar
- (1275)How to search sequences of words, ignoring punctuation or spaces between them, in Emacs?
M-s w
From: https://twitter.com/UnixToolTip/status/488724721438310400
- (1871)How to draw graphics in Emacs (org-mode)?
1. Insert a "code block" to make org-mode understand you'll draw with Ditaa:
#+BEGIN_SRC ditaa :file figure1.png
+-------+
| Hello |
+-------+
#+END_SRC
2. Enter the drawing and hit C-c ', this will edit the code block in
its language’s mode (the so-called "artist mode" for Ditaa code)
More info at: http://www.lysator.liu.se/~tab/artist/
3. You can execute the code org-mode with: C-c C-c
From: http://www.johndcook.com/blog/2016/06/15/ascii-art-diagrams-in-emacs-org-mode/
- (1296)How to make dabbrev be case sensitive in Emacs 24+?
(setq dabbrev-case-fold-search "case-fold-search") ; is it a string?
(setq dabbrev-case-replace nil)
or use http://www.emacswiki.org/emacs/HippieExpand
From: http://stackoverflow.com/questions/4384204/autocomplete-and-camelcase
- (1387)How to remember the commands to move in a text in Emacs?
The commands are somewhat mnemonic:
"f" stands for "forward"
"b" stands for "backward"
"n" stands for "next"
"p" stands for "previous"
"a" stands for "beginning" (like the beginning of the alphabet)
"e" stands for "end"
Move by
Forward Backward
character C-f C-b
word M-f M-b
line C-n C-p
screen C-v M-v
Move to
Begin of End of
line C-a C-e
sentence M-a M-e
paragraph M-{ M-}
buffer M-< M->
From: http://www.johndcook.com/emacs_move_cursor.html
- (1227)How to send the contents of a region to a shell command in Emacs?
M-|
From: https://twitter.com/UnixToolTip
- (1215)How to mark/select the whole buffer in emacs?
M-x mark-whole-buffer
It is generally bound to C-x h.
From:http://www.gnu.org/software/emacs/manual/html_node/eintr/mark_002dwhole_002dbuffer.html
- (1175)How to change colors for emacs in console (code, current line, info bars, spaces)?
(custom-set-faces
;; COLORS FOR SOURCE CODE
'(font-lock-comment-face ((nil (:foreground "brightblack" :slant italic))))
'(font-lock-constant-face ((nil (:foreground "magenta"))))
'(font-lock-keyword-face ((nil (:foreground "brightred"))))
'(font-lock-string-face ((nil (:foreground "brightblue"))))
'(font-lock-type-face ((nil (:foreground "yellow"))))
'(font-lock-variable-name-face ((nil (:foreground "green"))))
;; COLORS FOR CURRENT LINE
'(highlight ((nil (:background "brightcyan" :weight semi-bold))))
;; COLORS FOR SPACES
'(whitespace-newline ((nil (:background "grey70"))))
'(whitespace-space ((nil (:background "white"))))
;; COLORS FOR INFO BARS BETWEEN SPLITTED WINDOWS
'(minibuffer-prompt ((nil (:inverse-video t))))
'(mode-line ((nil (:background "yellow" :foreground "black" :box (:line-width -1 :style released-button)))))
'(mode-line-highlight ((nil (:box (:line-width 2 :color "grey90" :style released-button)))))
)
Also See tip 228 & 1172
- (1174)How to change the color (face) setting for the current line highlighting?
(global-hl-line-mode 1) ;; highlight current line -- see hl-line.el
(custom-set-faces
'(highlight ((t (:background "grey80" :foreground "black" :bold t)))) ;; highlight current line
)
From: http://stackoverflow.com/questions/17842144/emacs-colors-why-it-is-gray-on-current-line-zenburn-theme
- (1129)How to search across multiple buffers in Emacs?
1. Open the list of opened buffers (C-x C-b)
2. Select/Mark the wanted buffers (m - mark / u - unmark)
3. Enter the searched regex: M-s a C-s
4. Move to next entry with C-s
From: http://stackoverflow.com/questions/2641211/emacs-interactively-search-open-buffers/2641321#2641321
- (1109)How to prevent Emacs to open the list of opened files when opening multiple/several files?
In Emacs 22+, add the following line in your .emacs:
(setq inhibit-startup-buffer-menu t)
For Emacs 21 and before, you could add the following workaround to your .emacs which will force Emacs to only have one window visible upon startup:
(add-hook 'after-init-hook 'delayed-delete-other-windows)
(defun delayed-delete-other-windows ()
"need the call to happen after startup runs, so wait for idle"
(run-with-idle-timer 0 nil 'delete-other-windows))
From: http://stackoverflow.com/questions/4196768/emacs-how-do-i-stop-buffer-list-from-showing-when-opening-3-files
http://www.gnu.org/software/emacs/manual/html_node/emacs/Action-Arguments.html#index-inhibit_002dstartup_002dbuffer_002dmenu-4132
- (1097)How to render visible the spaces/tabulations in an (X)Emacs buffer?
Use whitespace-mode. Add these lines to your .emacs:
(require 'whitespace)
(global-whitespace-mode 1)
You can cleanup (remove empty lines, replace tabs by spaces, etc.)
your buffer or a region with "M-x whitespace-cleanup" or bind it to a
key, like F10:
(global-set-key [f10] (quote whitespace-cleanup))
You can configure which characters to render visible and how with:
(setq-default whitespace-style '(face tabs tab-mark spaces space-mark newline newline-mark empty trailing indentation::space))
- "face" tells emacs to highlight the chars using faces (fonts/bolds)
- "tabs" shows tabs
- "tab-mark" marks tabs with '>>'
- "spaces" shows spaces
- "space mark" marks spaces with '.'
- "newline" ??
- "newline-mark" marks newlines with '$'
- "empty" remove empty lines
- "trailing" removes trailing spaces at end of lines
- "indentation::space" uses spaces instead of tabs for indentation
- "lines" changes colour of lines that are too long
From: http://www.emacswiki.org/emacs/WhiteSpace
- (1093)How to use Spaces instead of Tabs in SublimeText2?
Bottom right hand corner on the status bar, click Spaces: N (or Tab Width: N, where N is an integer), ensure it says Tab Width: 4 for converting from four spaces, and then select Convert Indentation to Tabs from the contextual menu that will appear from the initial click.
Similarly, if you want to do the opposite, click the Spaces or Tab Width text on the status bar and select from the same menu.
---
Ctrl+Shift+p then type "indent"
---
On main menu;
View -> Indentation -> Convert Indentation to Tabs / Spaces
---
To configure Sublime to always use tabs try the adding the following to preferences->settings-user:
{
"tab_size": 4,
"translate_tabs_to_spaces": false
}
From: http://stackoverflow.com/questions/9575739/how-to-replace-four-spaces-with-a-tab-in-sublime-text-2
http://www.sublimetext.com/docs/2/indentation.html
- (1068)How to kill until begining of line in [X]emacs?
KillingAndYanking a line backwards can be done with C-0 C-k or C-u 0 C-k.
From: http://www.emacswiki.org/emacs/BackwardKillLine
- (1067)How to tell [X]emacs to use (4) spaces instead of tabulation when indenting?
;;;;;;;;;; C-mode
; use spaces instead of tabs (tab=4 spaces)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
;;;;;;;;;; Java-mode
Tab width
The most important thing to remember is that Java files use a different style. Therefore, to customize Java indentation, use the java-mode-hook:
(add-hook 'java-mode-hook (lambda ()
(setq c-basic-offset 4)))
The ‘c-basic-offset’ variable controls the basic “unit” of the indentation engine. When you hit the TAB key, you tell the indentation engine to indent to “the right place”. This will insert tabs and spaces as required. Therefore, hitting TAB will usually advance point by 4 when indenting Java source.
When you read other people’s Java source, however, tab characters will still be 8 wide.
Here is how to fix it:
(add-hook 'java-mode-hook (lambda ()
(setq c-basic-offset 4
tab-width 4
indent-tabs-mode t)))
This says that hitting TAB should advance point by 4, that tab characters in source files should display 4 wide, and that Emacs should use tab characters when it can. Therefore, the TAB key will insert tab characters, and they will display 4 wide.
If you set ‘indent-tabs-mode’ to nil, then Emacs will insert 4 spaces instead.
From: http://www.emacswiki.org/emacs/IndentingJava
- (1057)How to select/delete lines matching a regular expression?
M-x occur
To delete them:
M-x flush-lines them
From: https://twitter.com/UnixToolTip/status/398837555409743872
- (1422)How to set the file-coding-system in Emacs 24?
C-x <RET> f coding <RET>
Use coding system coding to save or revisit the file in the current buffer (set-buffer-file-coding-system). You can also invoke this command by clicking with Mouse-3 on the coding system indicator in the mode line (see Mode Line).
C-x <RET> c coding <RET>
Specify coding system coding for the immediately following command (universal-coding-system-argument).
C-x <RET> r coding <RET>
Revisit the current file using the coding system coding (revert-buffer-with-coding-system).
M-x recode-region <RET> right <RET> wrong <RET>
Convert a region that was decoded using coding system wrong, decoding it using coding system right instead.
An easy way to visit a file with no conversion is with the M-x find-file-literally command. See Visiting.
If a piece of text has already been inserted into a buffer using the wrong coding system, you can redo the decoding of it using M-x recode-region. This prompts you for the proper coding system, then for the wrong coding system that was actually used, and does the conversion. It first encodes the region using the wrong coding system, then decodes it again using the proper coding system.
From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Text-Coding.html
--
To get current coding system used for opening and saving files
describe-coding-system
To set a encoding system for current buffer:
set-buffer-file-coding-system
To permanently choose a encoding system in emacs for opening and saving, just put this in your emacs init file:
;; UTF-8 as default encoding
(set-language-environment "UTF-8")
From: http://ergoemacs.org/emacs/emacs_encoding_decoding_faq.html
- (1444)How to prevent ESS-mode from over-indenting/tabbing comments?
PROBLEM: In Emacs-Speaks-Statistics (ESS) mode for Emacs, when editing
R code, any comment lines (those starting with #) automatically get
tabbed to the far right, instead of being aligned to the far left or
previous line of code.
From the ESS manual:
"By default, comments beginning with ‘###’ are aligned to the beginning of the line. Comments beginning with ‘##’ are aligned to the current level of indentation for the block containing the comment. Finally, comments beginning with ‘#’ are aligned to a column on the right (the 40th column by default, but this value is controlled by the variable comment-column,) or just after the expression on the line containing the comment if it extends beyond the indentation column."
Solution: Use either ## or ###
From: http://stackoverflow.com/questions/780796/emacs-ess-mode-tabbing-for-comment-region
- (1445)How to avoid "Symbolic link to SVN-controlled source file; follow link? (yes or no)"?
M-x customize-variable RET vc-follow-symlinks RET
From: https://groups.google.com/forum/#!topic/comp.emacs/iiYJL04M7lA
- (1498)How to get a listing of the JDEE key bindings?
M-x jde-keys
- (1507)How to define the user email address in Emacs?
In your ~/.emacs, add:
(setq user-mail-address "cheney@torture.gov")
From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-Examples.html
- (1531)How to use OrgMode?
- Views
Cycling (outline): TAB (current entry) / S-TAB (whole buffer)
Agenda (dates): C-c C-[ + M-x org-agenda / C-c C-o on a date / View d/w/vm / Filter:"/" / prev/nxt: f/b / Show holydays: H
Sparse Tree (regex matches): C-c "/" d (DEADLINE) / C-c C-v (TODO) / C-u r <regex>
Column View (properties): C-x C-x C-c / Quit: q / Edit: e
Time Sorted: C-c a L
Context around point: C-c C-r
- Type faces
*bold*
_underline_
/italic/
+strike through+
=code=
~verbatim~
#comment
- Outline */**/***, 1./2./3., */+/*
Insert: ESC-RET (current level) / C-RET (after subtree)
De-/promote: ESC-<left/right>
Change Type (headline <-> item): C-c <-/*>
- Status TODO/DONE
Cycling: C-c C-t or S-right
Define more: #+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
(setq org-todo-keywords (sequence "TODO(t)" "LATER(l)" "CANCELLED(c)" "DELEGATED(d)" "|" "DONE(o)")
- Priorities [A/B/C]
Cycling: S-<up/down>
- Properties :PROPERTIES: ... :END:
Insert: C-x C-o p
View/Edit: TAB on ...
- Checkboxes [ ] (at leaf level)
Cycling: C-c C-c
[/] or [%] at upper level => counts checked ones
- Tags :<name>: (at outline level)
Defining: C-c C-c
- Time Stamps
Defining: C-c . (date), C-u C-c . (date+time) C-c C-d (DEADLINE) C-c C-s (SCHEDULED)
Show agenda for date at cursor: C-c C-o
Start/Stop clock: C-c C-x C-<i/o>
- Links <<internal>> [[find text]] [[*find headline]] [[ID][description]]
Insert/Edit: C-c C-l
Insert file link with completion: C-u C-c C-l
Open in Emacs: C-c C-o
Types: file:<path> / file:<xxx>.org::<texttofind> / file:<xxx>.org::*<headlinetofind> / http:<url> / mailto:<@> / shell:<cmd> / docview:<xxx>.pdf::<page>
- Tables
TAB: next cell
ESC-<arrow>: swap/move entries
Re-align: C-c C-c
Insert HLine below: C-c -
Sort lines in region: C-c ^
Sum numbers: C-c +
Computations: = (column formula) / := (field formula) / $<i> (col i value) / :=vsum(@II..@III) (sum fromm hline2 to hline3) / C-u C-c * (reapply all formulas) / C-} (toggle coord grid)
- Code
Insert: #+BEGIN_SRC <language>
Edit with syntax/exit editing: C-c '
- Configuration Markups
Define startup behaviour: #+STARTUP: overview/content/showall logdone indent
- Export (C-x C-e)
Add default Markups: C-x C-e #
ASCII: C-c C-e t u
HTML: C-c C-e h h
LaTeX: C-c C-e l l
PDF: C-c C-e l p
Markups: #+TITLE: / #+OPTIONS: toc:2 / #+OPTIONS: H:4 / #+BEGIN_QUOTE / #+BEGIN_CENTER / #+BEGIN_EXAMPLE
Markups for code: #+BEGIN_SRC <language> / #+INCLUDE: "<filename>" src <language>
Markups for tables: #+CAPTION: / #+NAME: <internallink>
- Embedded LaTeX
Insert: just type in LaTeX commands!
Preview/EXit: C-c C-x C-l / C-c C-c
- Capture-mode
(setq org-default-notes-file (concat org-directory "/notes.org"))
(define-key global-map "\C-cc" 'org-capture)
Create new note: C-c c
From: http://orgmode.org/talks.html
http://www.youtube.com/watch?v=oJTwQvgfgMM
https://en.wikipedia.org/wiki/Org-mode
http://orgmode.org/org.html
Why to focus on content first?
http://wcm1.web.rice.edu/my-academic-book-in-plain-text.html
http://users.ha.uth.gr/tgd/pt0501/09/Tufte.pdf
- (1543)How to disable auto-indentation of new lines in fundamental/org mode in Emacs 24++?
Turn off electric-indent-mode in ~/.emacs:
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1)).
That works with any Emacs version.This annoyance or shiny-new-feature,
depending on your point of view, was introduced as the default in
Emacs 24.4.
Another solution might be to add:
(electric-indent-mode 'off)
or a more specific version for particular modes:
;; TO TEST:
;; (add-hook 'fundamental/org-mode-hook
;; (lambda ()
;; (setq electric-indent-mode nil)
;; )
;; )
From: http://emacs.stackexchange.com/questions/5939/how-to-disable-auto-indentation-of-new-lines
- (1574)How to get/see/display/show current value of a variable in Emacs?
CTL-h v <var name>
From: https://www.gnu.org/software/emacs/manual/html_node/eintr/See-variable-current-value.html
- (1575)How to get the directory part of the path of a filename in Lisp Emacs?
(file-name-directory "lewis/foo")
;; => "lewis/"
From: http://ftp.gnu.org/old-gnu/Manuals/elisp-manual-21-2.8/html_chapter/elisp_25.html#SEC394
- (1576)How to get current buffer filename as a variable in Lisp Emacs?
(file-name-directory buffer-file-name)
;; => "/usr/user/lewis/manual/"
From: https://www.gnu.org/software/emacs/manual/html_node/elisp/Buffer-File-Name.html
- (1580)How to access the menu in Emacs -nw (console mode)?
M-x menu-bar-open, which is usually bound to F10
You can reassign it to C-F10 by adding the following line to your .emacs:
(global-set-key [C-f10] (quote menu-bar-open))
From: http://stackoverflow.com/questions/21135598/how-to-bind-f1-f12-key-as-keyboard-macro-in-emacs
http://stackoverflow.com/questions/21135598/how-to-bind-f1-f12-key-as-keyboard-macro-in-emacs/21136389#21136389
- (1581)How to detect if started in XWindow/-nw mode for Emacs?
The variable window-system is nil if the selected frame is on a text-only terminal.
(if (window-system) (<ifcase=Xwindow-mode>) (<elsecase=nw-mode>))
NOTE: deprecated in favor of display-graphic-p
(if (display-graphic-p) (<ifcase=Xwindow-mode>) (<elsecase=nw-mode>))
From: http://stackoverflow.com/questions/3861857/emacs-check-for-no-window-system-in-emacs
http://stackoverflow.com/questions/5795451/how-to-detect-that-emacs-is-in-terminal-mode
- (1624)How to insert HMTL template in a buffer in Emacs?
M-x auto-insert
From: http://stackoverflow.com/questions/12562113/how-to-remove-file-template-in-emacs
- (1631)How to save customiations in Emacs without using the menus?
M-x custom-save-all
Function: Save all customizations in `custom-file'
- (1676)How to make DEL/BACKSPACE behave correctly (i.e. differently) with Emacs?
How to make emacs inside screen correctly manage BACKSPACE/DEL Key?
[WHAT WORKED FOR ME: adding '(normal-erase-is-backspace nil) into the variable settings]
Every keyboard has a large key, a little ways above the RET or ENTER key, which you normally use outside Emacs to erase the last character that you typed. We call this key DEL.
When Emacs starts up using a window system, it determines automatically which key should be DEL. In some unusual cases Emacs gets the wrong information from the system. If the DEL key deletes forwards instead of backwards, that is probably what happened--Emacs ought to be treating the DELETE key as DEL, but it isn't.
With a window system, if the DEL key says BACKSPACE and there is a DELETE key elsewhere, but the DELETE key deletes backward instead of forward, that too suggests Emacs got the wrong information--but in the opposite sense. It ought to be treating the BACKSPACE key as DEL, but it isn't.
[THIS WAS MY CASE]
On a text-only terminal, if you find the DEL key prompts for a Help command like Control-h, instead of deleting a character, it means that key is actually sending the BS character. Emacs ought to be treating BS as DEL, but it isn't.
In all of those cases, the immediate remedy is the same: use the command M-x normal-erase-is-backspace-mode. That should make the proper DEL key work. On a text-only terminal, if you do want to ask for help, use F1 or C-?.
[THIS DID NOT WORK FOR ME]
To fix the problem automatically for every Emacs session, you can put one of the following lines into your .emacs file (Section 32.7). For the first case above, where DEL deletes forwards instead of backwards, use this line:
(normal-erase-is-backspace-mode 0)
For the other two cases, use this line:
(normal-erase-is-backspace-mode 1)
[THIS WORKED]
Another way to fix the problem for every Emacs session is to customize the variable normal-erase-is-backspace: the value t specifies the mode where BS or BACKSPACE is DEL, and nil specifies the other mode. Section 32.2.2.
From: http://www.nongnu.org/emacsdoc-fr/manuel/lossage.html
http://www.gnu.org/software/emacs/manual/html_node/emacs/DEL-Does-Not-Delete.html#DEL-Does-Not-Delete
- (1679)How to byte-compile everything in the .emacs.d directory?
C-u 0 M-x byte-recompile-directory
will compile all the .el files in the directory and in all subdirectories below.
The C-u 0 part is to make it not ask about every .el file that does not have a .elc counterpart.
From: http://stackoverflow.com/questions/1217180/how-do-i-byte-compile-everything-in-my-emacs-d-directory
- (1693)How to load a package in Emacs?
There are various ways according to how the package is written:
; For R
(add-to-list 'load-path "~/.emacs.d/elpa/ess-20160305.530/lisp/")
(load "ess-site")
; For Java
(add-to-list 'load-path "~/.emacs.d/elpa/jdee-20151217.1405/")
(require 'jdee)
- (1696)How to close an XML tag in NXML mode?
insert end tag: C-c C-f
=> The ‘f’ is mnemonic for finish.
finish inserting tag on the same line: "<tag" + C-c C-i => <tag></tag>
finish inserting tag as a block: "<tag" + C-c C-b => <tag>\n</tag>
=> The ‘i’ is mnemonic for inline and the ‘b’ is mnemonic for block.
set nxml to automatically complete tags:
M-x customize-variable <RET> [nxml-slash-auto-complete-flag|nxml-auto-insert-xml-declaration-flag] <RET>
From: https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html#Inserting-end_002dtags
https://www.gnu.org/software/emacs/manual/html_mono/nxml-mode.html
https://www.emacswiki.org/emacs/CloseXmlTag
- (1746)How to customize a set of variables in Emacs?
M-x customize-group <name of package>
- (1747)How to customize a font in Emacs?
1. Place the cursor on a line with the caracteristics you want to change (e.g. space or comment in code)
2. M-x customize-face
- (1748)Neat extensions for Emacs?
[Prettyfying the GUI]
- mode-icons Display icons in the mode bar (read/write, encoding, type of file...)
https://github.com/ryuslash/mode-icons/
- awesome-tab Display buffers in (grouped) tabs
https://github.com/manateelazycat/awesome-tab
- all-the-icons Display icons for file/buffer type in the tabs
https://github.com/domtronn/all-the-icons.el
[Do almost anything in text mode]
- org-mode Mode for TODO-list / planification / GTD and a LOT more (ASCII-drawing, spreadsheet, code notebook, etc.)
[Programming language tools] [Also see Tip#3357]
- lsp Mode for live code checking, completion, running, debugging, documentation, etc. NEEDS installing server part for each language
https://emacs-lsp.github.io/lsp-mode/page/languages/
TIPS: Open a file with the correct extension for the language you want to be supported, then run M-x lsp , and lsp will tell you what to do : propose to auto-install supported language server, or give name of extrernal ls (language server) to install.
- lsp-ui Higher level UI modules of lsp-mode
https://github.com/emacs-lsp/lsp-ui
- lsp-ivy LSP integration with "Incremental Vertical completYon"
- dap-mode Debugging
https://github.com/emacs-lsp/dap-mode
- treemacs Project exploration
https://github.com/Alexander-Miller/treemacs
- lsp-treemacs To display everything as a tree (Project structure, Symbols in file, Call stack, Errors list)
- eglot Client part of lsp
TIPS: Open a file with the correct extension for the language you want to be supported, then run M-x eglot , and it will try to auto-install supported language server.
- flycheck-* Mode for checking code in various languages
- flymake-* syntax-checker for various languages
- ac-* Mode for auto-completion
- company Modular text completion framework
- helm-lsp Helm is an Emacs incremental and narrowing framework
- EIN IPython Notebook (a.k.a. Jupyter Notebook) in Emacs!
- org-ref To manage bib entries in .bib file and their insertion in .org files
- pdf-tools (a.k.a. PDFView) To manipulate (select text, annotate, etc.) PDF files [NOTE install through apt package "elpa-pdf-tools"]
- org-xournalpp To manipulate PDF / draw
- org-krita To draw "graphically"
[Auto-fill new buffers]
- autoinsert Automatically insert text when opening a new buffer
- insert-shebang Insert an automatically generated #!/bin/shell
[Java]
- SrSpeedBar A lateral buffer with the list of files/directories of the project
- jdee Mode for java projects (execution/compilation, completion, imports, partial refactoring)
- lsp-java Mode for using Eclipse formatting, factoring, running, debugging, access to documentation, etc
https://emacs-lsp.github.io/lsp-java/
NEEDS: Requires initialization with C-u M-x lsp-install-server + jdtls
NEEDS: (require 'lsp-java) (add-hook 'java-mode-hook #'lsp)
[HTML/XML]
- nxml Mode for XML files
- emmet-mode Unofficial Emmet's support for emacs
https://emmet.io/
- w3 Mode for browsing the web
[R]
- ess + lsp Mode for R code, completion, flycheck, etc
https://github.com/REditorSupport/languageserver
NEEDS R::install.packages(c("languageserver", "lintr"))
NEEDS (add-hook 'ess-r-mode-hook 'eglot-ensure)
[Python]
- lsp-pyls Mode
https://github.com/palantir/python-language-server
NEEDS: (add-hook 'python-mode-hook #'lsp)
[LaTeX]
- AucTeX + lsp Mode for LaTeX/BibTeX
- digestif/texlab Mode for lsp for LaTeX completion, documentation
https://github.com/astoff/digestif
https://github.com/latex-lsp/texlab
- gscholar-bibtex Mode to get publications info in .bib format directly from GScholar & PubMed
[Git]
- magit Interface for Git
[Readers]
- nov Featureful EPUB reader mode
- elfeed Emacs Atom/RSS feed reader
[Other stuff]
- shift-number Increase/decrease the number at point (C-c +/-)
- gnuplot-mode Major mode for editing gnuplot scripts
- markdown-mode+ Mode for .md file (like README.md @github)
- yaml-mode Major mode for editing YAML files
- lsp-yaml Mode for live checking YAML files
https://github.com/redhat-developer/yaml-language-server
- lsp-docker Mode that uses Docker to run the lsp Language Servers
https://github.com/emacs-lsp/lsp-docker/
- (1751)How to automatically close the last XML tag in nxml-mode in Emacs?
C-c C-f
From: https://www.emacswiki.org/emacs/CloseXmlTag
- (1753)How to highlight/edit Java properties files in Emacs?
M-x conf-javaprop-mode
NOTE: Beware, indentation is not taken into account. To indent, use jdee-mode
From: http://emacsblog.org/2007/03/01/quick-tip-highlighting-java-properties-files/
- (1807)How to start emacs' server from .emacs (a.k.a. How to start emacs' server only if it is not already started)?
NEW SOLUTION:
Simply define the following alias in your .bashrc:
alias emacs='emacsclient -a '\'''\'' -c'
From: https://stackoverflow.com/questions/5570451/how-to-start-emacs-server-only-if-it-is-not-started/21555855#21555855
OLD SOLUTION:
;(load "server")
(require 'server)
(unless (server-running-p) (server-start))
To open a new file in the already opened Emacs:
emacsclient <file.ext>
From: https://stackoverflow.com/questions/5570451/how-to-start-emacs-server-only-if-it-is-not-started
- (1808)How to open .jsp file with Emacs?
Recommended: Single Major Modes
web-mode.el is major mode can be used to edit any web template (jsp,
php, erb, django, ctemplate). It can downloaded on http://web-mode.org
This major mode offers css and js compatibility. This mode is actively
maintained. Code is hosted on github and a package is available
through the MELPA repository.
From: https://www.emacswiki.org/emacs/JspMode
- (1816)How to script Emacs' functions (a.k.a How to apply Emacs' functions without opening Emacs)?
You can use:
- emacs -batch -eval "xxx"' or
- directly write a (non-shell) script file starting with "#!/usr/bin/emacs -script" (for emacs 22+)
NOTE1: in batch-mode, Emacs does not execute your init files. To be
able to use the functions from packages, you have to call
"progn(package-initialize)", then load/require the package, then set
the buffer major mode.
NOTE2: In the (non)shell-script version, you have to use "(find-file
(nth 3 command-line-args))" to open the file provided on the command
line. To determine the position (here "3"), you can use "(error (nth 3
command-line-args))"
NOTE3: In the (non)shell-script version, the whole source should be a
single function (i.e. surrounded by "(...)")
EXAMPLE1: basic indenting of C files
emacs -batch sample.c --eval "(indent-region (point-min) (point-max) nil)" -f save-buffer
EXAMPLE2: advanced indenting of Java files
emacs -batch sample.java --eval "(progn(package-initialize)(require 'whitespace)(setq-default indent-tabs-mode nil)(setq-default tab-width 4)(setq indent-line-function 'insert-tab)(global-whitespace-mode 1)(require 'jdee)(jdee-mode)(whitespace-cleanup)(indent-region (point-min) (point-max) nil)(whitespace-cleanup)(save-buffer))"
EXAMPLE3: script to clean & organize Java's imports
-- START ./cleanimports.emacsscript
#!/usr/bin/emacs --script
;;; Usage: ./cleanimports.emacsscript <file.java>
;; This script is equivalent to:
;; emacs test.java -batch -eval "(progn(package-initialize)(require 'jdee)(jdee-mode)(jdee-import-kill-extra-imports)(save-buffer))"
;; emacs test.java -batch -eval "(progn(package-initialize)(require 'jdee))" -f jdee-mode -f jdee-import-kill-extra-imports -f save-buffer
(progn(package-initialize)
(require 'jdee)
(find-file (nth 3 command-line-args))
(jdee-mode)
(jdee-import-kill-extra-imports)
(jdee-import-organize)
(save-buffer)
)
-- END cleanimports.emacsscript
From: https://www.emacswiki.org/emacs/BatchMode
https://stackoverflow.com/questions/8379301/apply-a-function-to-all-buffers-in-emacs
- (1829)How to disable auto-indentation in fundamental-mode n Emacs?
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1)).
From: https://emacs.stackexchange.com/questions/5939/how-to-disable-auto-indentation-of-new-lines
- (1835)How to enable opening of large files in Emacs?
By default Emacs shows an error when opening file larger than 10MB :{
;; warn when opening files bigger than 100MB
(setq large-file-warning-threshold 100000000)
Alternative, you can set it to nil, which will suppress the warning
permanently, regardless of the size of the file you’re trying to open.
P.S. By the way, it’s not particularly wise to edit huge files (say
bigger than 1GB) in Emacs directly. If you need to do something like
this I’d suggest taking a look at the excellent vlfi package.
From: http://emacsredux.com/blog/2014/05/16/opening-large-files/
- (1836)More info on the Emacs packages repositories
- ELPA is the original. I don't think it's really maintained anymore, but I'm not sure. I don't use it.
- GNU is "official". It's maintained along with Emacs.
- Marmalade is basically a website where you can upload a complete package.
- Melpa takes a URL to e.g. a github repo, and builds a package automatically from it.
- Org mode has its own package.el repo (http://orgmode.org/elpa/).
From: https://stackoverflow.com/questions/14836958/updating-packages-in-emacs
- (1837)How to update Emacs packages at startup? [[TO VERIFY]]
(package-initialize)
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
'("org" . "http://orgmode.org/elpa/"))
(when (not package-archive-contents)
(package-refresh-contents))
From: https://stackoverflow.com/questions/14836958/updating-packages-in-emacs
- (1839)How to configure Emacs' indenting style?
A] Change a single setting on the fly
1. Go to a line/position of an element which style you want to edit
2. Hit C-c C-o (c-set-offset)
3. Emacs automatically proposes the style to change according to the current line/position
4. Hit enter if it is indeed the style you want to change
5. Choose the new indentation style:
0 No extra indentation.
+ Indent one basic offset.
- Outdent one basic offset.
++ Indent two basic offsets
-- Outdent two basic offsets.
* Indent half basic offset.
/ Outdent half basic offset.
B] Change a single setting definitively
1. See A] for how to test & find the names of the settings you want to change
2. Add a hook that changes these settings for the current buffer's mode in your .emacs:
- General form
(defun my-c-mode-hook ()
(c-set-offset 'syntactic-symbol offset))
(add-hook 'c-mode-hook 'my-c-mode-hook)
- Example
(defun my-java-mode-hook ()
(c-set-offset 'arglist-intro '+) ;;; NOTE the ' before the +, as it is a special function
(c-set-offset 'arglist-cont-nonempty '+)
(c-set-offset 'arglist-close '0)
(message "DEBUG: my-java-mode-hook executed"))
(add-hook 'java-mode-hook 'my-java-mode-hook)
C] Create your own style on-the-fly
1. Open a file for which you want to define a style
2. Set the buffer mode to java (M-x java-mode)
3. Goto Menu Java>Style>Guess style from this buffer (M-x c-guess-buffer)
4. Goto Menu Java>Style>View the last guessed style (M-x c-guess-dump-guessed-style)
5. Change the c-offsets-alist part of the guessed style (See above for possible option names & values)
6. Goto Menu Java>Style>Install the last guessed style (M-x c-guess-install)
D] Change completely the style
1. See C] to create your own style on-the-fly
2. Copy the complete style definition to your .emacs
3. Create a hook to apply this style at the opening of the major-mode of this king of buffer (See B])
NOTE: I'm not sure this D] step actually works...
From: https://www.gnu.org/software/emacs/manual/html_node/efaq/Customizing-C-and-C_002b_002b-indentation.html
https://www.gnu.org/software/emacs/manual/html_node/ccmode/Adding-Styles.html
https://www.gnu.org/software/emacs/manual/html_node/ccmode/c_002doffsets_002dalist.html
- (1872)How to use Emacs (org-mode) as a spreadsheet?
1a. Start a table, by starting a line with "| <some text>", then hiting <tab>
1b. Add more columns with more "|" + <tab>
1c. You can set a separator line by starting a line with "|-", then hiting <tab>
1d. Swap columns with M-left/right
1e. Swap lines with M-up/down
1f. Turn on/off references visualization with: C-c }
2a. You can enter a formula in a field with ":=<formula>". If you want
a "column formula" (i.e. repeated over all the column), use
"=<formula>"
2b. You can reference a field with @<line#>$<col#>
2c. C-c ? gives you the reference of the current field
2d. You can manipulate ranges with @x$y..@n$m
3a. Hitting C-c C-c (or C-u C-c * for a column formula or C-c C-c if
you're on the #+TBLFM line.) will replace the formula(e) with the
result(s) of the calculation(s)
3b. The #+TBLFM final line contains all the formulas for the table
above.
4a. With C-c = (or C-u C-c = for field formulae) you can interactively
edit formulae
4b. C-c ' is even more interactive: When the cursor is above a
reference, the corresponding field in the table gets
highlighted. You can actually select the references on which the
formula applies by using the S-<left/right/up/down> keys.
5a. You can use calc or lisp in the formulae with '(<formula>). Adding
";N" at the end of a formula indicates to treat data as number
instead of string.
5b. You can debug the formulae with C-c { and hit C-c C-c (or C-u C-c *
for a column). C-c { also exits the debugger
6. If you have both Gnuplot and Gnuplot-mode installed, you can plot
the table with C-c " g or M-x org-plot/gnuplot !
7. You can even name the fields/cells (see
http://orgmode.org/org.html#Advanced-features)
From: http://orgmode.org/worg/org-tutorials/org-spreadsheet-intro.html
http://orgmode.org/worg/org-tutorials/org-spreadsheet-lisp-formulas.html
http://orgmode.org/manual/Formula-syntax-for-Calc.html#Formula-syntax-for-Calc
- (1904)How to change font size in Emacs?
C-x C-+ to increase
C-x C-- to decrease
From: https://twitter.com/UnixToolTip/status/782983731149766656
- (1930)How to search in Emacs, ignoring punctuation or spaces between words?
M-s w <expression>
From: https://twitter.com/UnixToolTip/status/800755780039352320
- (1944)How to define correctly up/down keys in Emacs' Shell mode?
(add-hook 'shell-mode-hook
(lambda ()
(define-key shell-mode-map (kbd "<M-up>") 'comint-previous-input)
(define-key shell-mode-map (kbd "<M-down>") 'comint-next-input)
)
)
From: http://www.johndcook.com/blog/2016/11/30/setting-up-emacs-shell-on-a-mac/
- (3867)How to solve error 'Project ~/.emacs.d/...<faulty_pkg>... at ... cannot be read'?
Seems that removing "~/.emacs.d/.local/cache/<faulty_pkg>" is sufficient
From: https://github.com/Alexander-Miller/treemacs/issues/586#issuecomment-892726329
- (3868)How to create LaTeX citations the org-mode way?
# # In the header:
#+LATEX_HEADER: \usepackage{biblatex}
#+BIBLIOGRAPHY: SomeFile.bib
#+CITE_EXPORT: biblatex alphabetic
* Some text
this is a goodref: [cite:@RefName]
# # In the footer:
* References
#+PRINT_BIBLIOGRAPHY:
From: https://orgmode.org/manual/Citations.html
https://stackoverflow.com/questions/73790997/emacs-org-mode-latex-export-doesnt-export-bibliography/73798326#73798326
- (3870)How to setup Emacs to use a given Python virtualenv?
Use pyvenv package, with "pyvenv-workon" function.
From: https://stackoverflow.com/questions/38535499/how-to-setup-emacs-to-use-a-given-python-virtualenv/54010183#54010183
- (2011)How to re-open the *scratch* buffer in Emacs?
Simply manually switch to this buffer, it'll be recreated if necessary:
C-x b *scratch* RET
From: https://stackoverflow.com/questions/234963/re-open-scratch-buffer-in-emacs#235069
- (2037)How to search ignoring punctuation or spaces between words in Emacs?
M-s w
(note: on my machine Meta=Left-Alt
From: https://twitter.com/UnixToolTip/status/851837344147812353
- (2042)How to (quickly) byte-compile everything in the emacs.d directory?
emacs --batch --eval '(byte-recompile-directory "~/.emacs.d" 0 t)'
From: http://stackoverflow.com/questions/1217180/how-do-i-byte-compile-everything-in-my-emacs-d-directory
- (2049)How to resize margins when exporting LaTeX-PDF in org-mode?
The simplest way to tweak the formatting of a LaTeX export is by passing appropriate options for the class you are using. In this case, try adding a line like:
#+LaTeX_CLASS_OPTIONS: [margin=0.5in]
If that approach doesn't work out, you could also try something like this, using the geometry package:
#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
From: https://emacs.stackexchange.com/questions/7996/is-there-a-way-to-resize-margins-when-exporting-pdf-in-org-mode#8000
- (2070)Basic OrgMode file
#+STARTUP: showall indent
# To reload config: C-c C-c
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: | CANCELED(c)
#+OPTIONS: title:0
#+OPTIONS: author:nil date:nil
#+TITLE:
#+AUTHOR:
#+OPTIONS: toc:nil
//#+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
#+LATEX_HEADER: \usepackage{vmargin}\setmarginsrb{2cm}{1cm}{2cm}{1cm}{0cm}{0cm}{0cm}{0cm}
* Type faces :cool:
** *bold*
** _underline_
** /italic/
** +strike through+
** =code=
** ~verbatim~
** #comment
* Links
** \<\<internal\>\>
** \[\[find text\]\]
** \[\[[[*find headline\]\]
** \[\[ID\]\[description\]]
* Outline
- */**/***
- 1./2./3.
- +/-
* Description
- Titre1 :: description1
- Titre2 :: description2
* Tables
** https://orgmode.org/manual/Tables.html
** Creation: C-c |
** Inplace realign: C-c C-c
** Realign+move next col: TAB
** Realign+move next row: RET
** Blank the field at point: C-c SPC
** Move to start current field: M-a
** Move to end current field: M-e
** Move current row up: M-up
** Movecurrent row down: M-down
** Insert a horizontal line below+move below: C-c RET
** Sort the table lines in the region: C-c ^
** Sum the numbers in the current column/region: C-c + (C-y to insert it)
** Copy from above: S-RET
* Views
** Agenda (dates): C-c C-[ + M-x org-agenda / C-c C-o on a date / View d/w/vm / Filter:"/" / prev/nxt: f/b / Show holydays: H
** Sparse Tree (regex matches): C-c "/" d (DEADLINE) / C-c C-v (TODO) / C-u r <regex>
** Column View (properties): C-x C-x C-c / Quit: q / Edit: e
* Export (C-x C-e)
** ASCII: C-c C-e t u
** HTML: C-c C-e h h
** LaTeX: C-c C-e l l
** PDF: C-c C-e l p
* Including external elements (source code, quote, verbatim, LaTeX/HTML, etc.)
** =<s= + TAB
#+BEGIN_SRC <lang>
#+END_SRC
** =<e= + TAB
#+BEGIN_EXAMPLE
#+END_EXAMPLE
** =<q= + TAB
#+BEGIN_QUOTE
#+END_QUOTE
** =<V= + TAB
#+BEGIN_VERBATIM
#+END_VERBATIM
** =<l= + TAB
#+BEGIN_LaTeX
#+END_LaTeX
** =<h= + TAB
#+BEGIN_HTML
#+END_HTML
** =<i= + TAB
#+INDEX:
** =<I= + TAB
#+INCLUDE: "/path/to/filename/you/interactively/select"
- (2071)How to remove Title and TOC when exporting from org-mode
#+OPTIONS: title:0 ---> does not work => use 3 lines below
#+OPTIONS: author:nil date:nil
#+TITLE:
#+AUTHOR:
#+OPTIONS: toc:nil ---> you can set the TOC depth with toc:<nb>
- (2080)How to narrow/widen to/from a region in Emacs?
CTRL-x n n => narrow
CTRL-x n w => widen
- (2081)How to sort (selected) lines in Emacs?
C-u M-x sort-lines.
From: http://pragmaticemacs.com/emacs/sort-lines-in-a-region/
- (2099)How to disable the "smart" underscore in Emacs?
M-x ess-disable-smart-underscore
or
---- ~/.emacs
(ess-toggle-underscore nil)
From: https://www.emacswiki.org/emacs/ess-smart-underscore.el
- (2148)How to easily insert a unicode (by its name) symbol in Emacs?
1. Switch to TeX input method pressing C-\
2. Type latex expression like \Bbb{R} or \Leftrightarrow
From: https://emacs.stackexchange.com/questions/20472/fast-unicode-symbol-insertion
- (2168)How to colorize/indent source code (e.g. java code) in org-mode?
; in .emacs
'(org-src-fontify-natively t)
'(org-src-tab-acts-natively t)
; in org-mode in a #+BEGIN java block
M-x org-src-fontify-block
From: https://stackoverflow.com/questions/28079957/emacs-orgmode-with-java-syntax-highlithting
- (2170)How to execute and show result of (java) code in org-mode?
#+HEADERS: :classname HelloWorld :cmdline "-cp ."
#+begin_src java :results output :exports both
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World");
}
}
#+end_src
#+RESULTS:
: Hello, World
From: http://ehneilsen.net/notebook/orgExamples/org-examples.html#sec-19
- (2227)How to turn on colors/syntax highlighting in Emacs?
M-x font-lock-mode <RET>
From: https://www.gnu.org/software/emacs/manual/html_node/efaq/Turning-on-syntax-highlighting.html
- (2596)How to move Rows/Cols/Cells in org-mode?
- Rows & Cols can be moved with ESC-<arrows>
- Cells: there's no command, but using ESC-t often works to switch 2 cells (Beware to put the cursor on the correct side of the element to switch!)
From: https://lists.gnu.org/archive/html/emacs-orgmode/2010-09/msg01468.html
- (2613)How to auto insert a snippet/template of code in Emacs?
Here is a skeleton for a C++ file that you can try by EvaluatingExpressions or by adding to you InitFile.
(eval-after-load 'autoinsert
'(define-auto-insert
'("\\.\\(CC?\\|cc\\|cxx\\|cpp\\|c++\\)\\'" . "C++ skeleton")
'("Short description: "
"/*" \n
(file-name-nondirectory (buffer-file-name))
" -- " str \n
" */" > \n \n
"#include <iostream>" \n \n
"using namespace std;" \n \n
"main()" \n
"{" \n
> _ \n
"}" > \n)))
From: https://www.emacswiki.org/emacs/AutoInsertMode
- (2627)How to open the corresponding header file of a cpp source file in Emacs?
There's ff-find-other-file.
You can bind this to your own key using something like:
(global-set-key (kbd "C-x C-o") 'ff-find-other-file)
From: https://stackoverflow.com/questions/3509919/emacs-c-opening-corresponding-header-file
- (2641)How to update packages manually?
- M-x list-packages
- Hit U to mark available upgrades
- Hit x to execute the marekd actions
From: https://emacs.stackexchange.com/questions/31872/how-to-update-packages-installed-with-use-package#31874
- (2694)How to correct the indentation of \item(s)?
Add these 2 line in ~/.emacs:
(setq LaTeX-item-indent -2)
(setq LaTeX-indent-level 4)
From: https://emacs.stackexchange.com/questions/3083/how-to-indent-items-in-latex-auctex-itemize-environments/3100#3100
- (2716)How to reformat/align BibTeX entries in EmacS/AucTeX?
When the cursor is somewhere in the entry, run the command bibtex-fill-entry (bound to C-c C-q), which will align the fields. You may also want to set variable bibtex-align-at-equal-sign to a non nil value to change the details of alignment.
From: https://emacs.stackexchange.com/questions/34146/how-to-make-emacs-align-and-indent-a-bibtex-entry/34147#34147
- (2717)How to automagically insert references from GoogleScholar (et al.) in a BibTeX file opened with Emacs/AucTeX?
Use: https://github.com/cute-jumper/gscholar-bibtex
Pb: since it scraps the GoogleScholar pages with using an API key, using too much in short amount of time might results in being blocked (for some time)...
From: https://github.com/cute-jumper/gscholar-bibtex
- (2718)How to solve "Failed to verify signature archive-contents.sig" in Emacs 26+?
1) set package-check-signature to nil
2) download the package gnu-elpa-keyring-update and run the function with the same name.
3) reset package-check-signature to the default value 'allow-unsigned`
From: https://stackoverflow.com/questions/58202993/emacs-failed-to-verify-signature-archive-contents-sig
https://emacs.stackexchange.com/questions/233/how-to-proceed-on-package-el-signature-check-failure#53142
- (2732)How to auto-insert .tex/org-mode template at opening of a new file (and set default text buffer to be org-mode DOESNOTWORK)?
(auto-insert-mode) ;;; adds hook to find-files-hook
; LaTeX-mode
(setq-default latex-item-indent 0)
(define-auto-insert "\.tex" "~/Softs/Basic_LaTeX_Example_article.tex")
; org-mode
;(add-hook 'text-mode-hook 'org-mode) ; <- makes all texts (including tex-mode/etc.) become org-mode :{
;(setq initial-major-mode 'org-mode) ; <- does not work either :[
(define-auto-insert "\.org" "~/Softs/Basic_OrgMode_Example.org")
From: https://emacs.stackexchange.com/questions/46056/quick-startup-in-org-mode#46129
https://www.emacswiki.org/emacs/AutoInsertMode
- (2749)How to disable to running of Maven at each opening of a Java file?
Add:
(jdee-maven-disabled-p t)
to your custom-set-variables in .emacs
From: https://emacs.stackexchange.com/questions/32052/jdee-runs-maven-all-the-time/46618#46618
- (2753)How to create a separated theme for "emacs -nw" than "emacs"?
In .emacs:
(if (display-graphic-p)
(enable-theme 'solarized)
(enable-theme 'wheatgrass))
From: https://emacs.stackexchange.com/questions/13050/different-theme-for-nw-terminal
- (2768)How can I make emacs save all my files with spaces instead of tabs, without manually having to run untabify? [NOT TESTED]
In your .emacs:
;; no tabs by default. modes that really need tabs should enable
;; indent-tabs-mode explicitly. makefile-mode already does that, for
;; example.
(setq-default indent-tabs-mode nil)
;; if indent-tabs-mode is off, untabify before saving
(add-hook 'write-file-hooks
(lambda () (if (not indent-tabs-mode)
(untabify (point-min) (point-max)))))
- (2769)How to assign a function to C-TAB with global-set-key in Emacs?
(global-set-key [C-tab] 'my-func)
From: https://stackoverflow.com/questions/916797/emacs-global-set-key-to-c-tab/916918#916918
- (2772)How to manipulate tables in org-mode and (auto)save/load them in/from csv [e.g for using in python code]?
1. Create tables in separate files
2. Create a org-table to name theù (using #+NAME:)
#+NAME: tables
| Table | Key |
|---------------+---------------------|
| assets_w | Description |
| assets_s | Description |
| tax_rates | |
| disposition | Asset |
| probate_rates | Asset |
| basic | Client information |
| base_expenses | Category |
| general | General assumptions |
3. Use the code below to exports the tables to CSVs:
#+begin_src emacs-lisp :results silent :var tables=tables :tangle no
(defun my-tbl-export (row)
"Search for table named `NAME` and export."
(interactive "s")
(save-excursion
(goto-char (point-min))
(let ((case-fold-search t))
(when (search-forward-regexp (concat "#\\+NAME: +" (car row)) nil t)
(next-line)
(org-table-export (format "%s.csv" (car row)) "orgtbl-to-csv")))))
(mapc 'my-tbl-export tables)
#+end_src
4. Use them in your org/python files like that:
#+begin_src python :results silent :tangle no
in_org=1
#+end_src
#+begin_src python :results silent :exports code
import pandas as pd
import numpy as np
import orgbabelhelper as ob
def out(df, **kwargs):
if 'in_org' in globals():
print(ob.dataframe_to_orgtable(df, **kwargs))
else:
print(df)
return df
#+end_src
#+begin_src python :results silent :var tables=tables :colnames yes
for row in tables:
table = row[0]
index = row[1]
if row[1] == '':
index = None
globals()[table] = pd.read_csv(table + '.csv', index_col=index).apply(pd.to_numeric, errors='ignore')
# print(globals()[table])
#+end_src
From: https://sachachua.com/blog/2019/10/python-org-mode-and-writing-org-tables-to-csvs-so-that-i-can-read-them-back/
- (2798)How to create a comment in a MarkDown document?
If you want a comment that is strictly for yourself (readers of the converted document should not be able to see it, even with "view source") you could (ab)use the link labels (for use with reference style links) that are available in the core Markdown specification:
http://daringfireball.net/projects/markdown/syntax#link
That is:
[comment]: <> (This is a comment, it will not be included)
[comment]: <> (in the output file unless you use it in)
[comment]: <> (a reference style link.)
Or you could go further:
[//]: <> (This is also a comment.)
To improve platform compatibility (and to save one keystroke) it is also possible to use # (which is a legitimate hyperlink target) instead of <>:
[//]: # (This may be the most platform independent comment)
From: https://stackoverflow.com/questions/4823468/comments-in-markdown/20885980#20885980
- (2842)How to use global-set-key to call an interactive function with arguments?
SOLUTION: use a lambda
(global-set-key (kbd "M-<up>") (lambda () (interactive) (move-line -1)))
From: https://stackoverflow.com/questions/1030392/emacs-global-set-key-and-calling-interactive-function-with-argument
- (2843)How to automatically activate OrgMode's section numbering?
; Globally (in .emacs)
(org-startup-numeroted)
; Locally (in a given buffer)
#+STARTUP: num
; for OLD versions of OrgMode, in .emacs:
(add-hook 'org-mode-hook 'org-num-mode)
Thanks Bastien for implementing this!
From: https://code.orgmode.org/bzg/org-mode/commit/325962c003
- (2867)What is a good dark theme for Emacs (my taste!)?
https://github.com/mjwall/ample-zen
- (2868)How to search & insert bibtex formatted CS refs in any bib file when you just have the title/authors?
Install the Emacs package "gscholar-bibtex", it can search GoogleScholar and DBLP!
Usage:
- M-x gscholar-bibtex
- Select source, e.g. "Google Scholar" (hitting G<tab> works!)
- Type your query, e.g. title <space> main_author
- Select the entry that corresponds to the paper you want to cite
- Hit 'c' to get & copy (in the clipboard) the correspondong bibref
- Hit 'q' to quit the search buffer
- Hit 'CTRL-y' to insert the bibref in any buffer (e.g. .bib file)
From: https://github.com/cute-jumper/gscholar-bibtex
- (2876)How to convert Org files into pretty (static) HTML files in a few minutes?
Use org-html-themes!!!
From: https://github.com/fniessen/org-html-themes
- (2914)How to change Encoding of a buffer (a.k.a. Local Variables in Emacs)?
SOLUTION1:
Add the following line at the beginning of the file
---
;;; Emacs is unable to open this file properly: -*- coding: UTF-8 -*-
---
From: https://www.emacswiki.org/emacs/LocalVariables
https://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables
SOLUTION2:
+ 'C-x RET c C-x C-f' forces Emacs to read a file in a specific encoding
+ 'C-x C-m c <encoding> RET C-x C-w RET' forces the encoding in an opened buffer
'M-x revert-buffer-with-coding-system' can be used if you opened a file and Emacs determined the encoding incorrectly
+ Saving with 'C-x C-m f' allows to change the encoding
NOTE: You can list all available encodings with 'M-x list-coding-systems'
From: https://www.emacswiki.org/emacs/ChangingEncodings
- (2915)My .emacs @TSE2020 (Org Mode litterate programming config)
#+STARTUP: overview indent
# overview/showall
#+TODO: TODO(t) LATER(l) | DONE(o)
#+OPTIONS: num:t toc:1
#+TITLE: emacs config file as literate programming
#+DATE: May 01 2021
#+DESCRIPTION: my emacs config file as an OrgMode file!
#+AUTHOR: gmuller
* TODO
** DONE *Configure TeX to use PDF Tools*
** DONE *Make C/C++ auto-insert work again*
** DONE Switch to =use-package=
** TODO extract "Requires" into org outline, not emacs-lisp code
** Better structure
** Defer even more packages loadings at start to speedup boot time
* use-package NOTE
** Docs
+ https://ianyepan.github.io/posts/setting-up-use-package/
+ https://github.com/jwiegley/use-package
+ https://jwiegley.github.io/use-package/keywords/
+ :ensure :: t
+ :hook :: (<mode without "mode"> . <hook func>)
+ :config :: after package [progn for multiple lines]
- https://www.reddit.com/r/emacs/comments/j2xezg/usepackage_best_practices/
+ :init :: before package [progn for multiple lines]
+ :custom :: for vars
+ :commands :: autoloads but defer package until use
+ :bind :: keys
+ :after :: delay loading of current package after loading of other package
+ :mode :: ("\\.<ext>$" . <the>-mode)
+ :magic :: ("%<file type>" . <the>-mode)
* How to load it from =~/.emacs=
+ https://cestlaz.github.io/posts/using-emacs-10-org-init/
#+BEGIN_COMMENT
;; Ensuring latest/MELPA org-mode is loaded instead of older builtin version
(add-to-list 'load-path "~/.emacs.d/elpa/org-latest")
(require 'org-loaddefs)
;; Loading the Emacs config written in org-mode
(org-babel-load-file
(expand-file-name
"config.org"
user-emacs-directory))
#+END_COMMENT
* Packages
** Where to get the packages: GNU + MELPA + ORG
#+BEGIN_SRC emacs-lisp
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
;;(require 'package)
(package-initialize) ;; Load all packages auto-load.el
(add-to-list 'package-archives
'("gnu" . "http://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/"))
;;(add-to-list 'package-archives
;; '("org" . "http://orgmode.org/elpa/"))
#+END_SRC
** Get fresh list at start
#+BEGIN_SRC emacs-lisp
;;(when (not package-archive-contents)
;;(package-refresh-contents))
#+END_SRC
* Hack for Speed
# Uses a package ⇒ must be after packages updates...
#+BEGIN_SRC emacs-lisp
;; Hack for Speed - Start with high memory-occupancy value before GC
;; (setq gc-cons-threshold (* 50 1000 1000))
;; hacks the GC to increase available memory when doing large tasks
(use-package gcmh
:ensure t
:config (gcmh-mode 1)
:hook
;; Displays startup time in modeline at startup
(emacs-startup .
(lambda ()
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time
(time-subtract after-init-time before-init-time)))
gcs-done)))
)
#+END_SRC
* User Info
#+BEGIN_SRC emacs-lisp
(setq user-full-name "Guillaume MULLER")
(setq user-mail-address "Guillaume.MULLER@univ-st-etienne.fr")
#+END_SRC
* GUI configuration
** Customize GUI appearance
#+BEGIN_SRC emacs-lisp
;; Prevents opening of the "About" buffer at startup
(setq inhibit-startup-screen t)
;; Remove the toolbar at the top
(tool-bar-mode -1)
;; Puts the scrollbars on the right
(setq set-scroll-bar-mode 'right)
;; Shows only the last opened file, not the list of opened files
(setq inhibit-startup-buffer-menu t)
#+END_SRC
** Show modes
#+BEGIN_SRC emacs-lisp
;; Show parenthesis matches
(show-paren-mode t)
;; Show line-number in the mode line
(line-number-mode 1)
;; Show column-number in the mode line
(column-number-mode 1)
;;(column-number-mode t)
;; ===== From: http://homepages.inf.ed.ac.uk/s0243221/emacs/
;; HighLight current line
(setq global-hl-line-mode 1)
#+END_SRC
** User help
+ https://cestlaz.github.io/posts/using-emacs-1-setup/
+ Displays possibilities when you start a keybinding
#+BEGIN_SRC emacs-lisp
(use-package which-key
:after lsp
:ensure t
:config
(which-key-mode)
:hook (lsp-mode . lsp-enable-which-key-integration))
#+END_SRC
** Theming
*** Theme & font colors
+ https://cestlaz.github.io/posts/using-emacs-9-themes/
#+BEGIN_SRC emacs-lisp
(setq ansi-color-names-vector ["#3f3f3f" "#ea3838" "#7fb07f" "#fe8b04" "#62b6ea" "#e353b9" "#1fb3b3" "#d5d2be"])
(use-package ample-zen-theme
:ensure t
:config
(progn
(setq custom-enabled-themes (quote (ample-zen)))
(load-theme 'ample-zen t)))
(setq diary-entry-marker (quote font-lock-variable-name-face))
(setq fci-rule-color "#222222")
;;(setq gnus-logo-colors ((quote ("#2fdbde" "#c0c0c0")) t))
(setq hl-paren-colors
(quote
("#B9F" "#B8D" "#B7B" "#B69" "#B57" "#B45" "#B33" "#B11"))
)
;; (set-face minibuffer-prompt ((t (:inverse-video t))))
;; (set-face mode-line
;; ((t
;; (:background "yellow" :foreground "black" :box
;; (:line-width -1 :style released-button)))))
;; (set-face mode-line-highlight
;; ((t
;; (:box
;; (:line-width 2 :color "grey90" :style released-button)))))
;; (set-face show-paren-match ((t (:background "yellow"))))
;; (vc-annotate-background "#222222")
;; (vc-annotate-color-map
;; (quote
;; ((20 . "#db4334")
;; (40 . "#ea3838")
;; (60 . "#abab3a")
;; (80 . "#e5c900")
;; (100 . "#fe8b04")
;; (120 . "#e8e815")
;; (140 . "#3cb370")
;; (160 . "#099709")
;; (180 . "#7fb07f")
;; (200 . "#32cd32")
;; (220 . "#8ce096")
;; (240 . "#528d8d")
;; (260 . "#1fb3b3")
;; (280 . "#0c8782")
;; (300 . "#30a5f5")
;; (320 . "#62b6ea")
;; (340 . "#94bff3")
;; (360 . "#e353b9"))))
;; (setq vc-annotate-very-old-color "#e353b9")
#+END_SRC
*** Using Nerd/Fontawesome font
+ Get nice icons (e.g. lsd/exa working in shell-mode)
#+BEGIN_SRC emacs-lisp
;; Use a fixed font with a size little larger than system font
;; (set-face-attribute 'default nil :font "monospace" :height 121)
;; Using Ubuntu Mono [Nerd font] to get nice icons (e.g. lsd/exa working in shell-mode)
(set-face-attribute 'default nil :family "UbuntuMono Nerd Font Mono" :height 113)
#+END_SRC
*** Using incons everywhere
#+BEGIN_SRC emacs-lisp
;;(add-to-list load-path (expand-file-name "~/.emacs.d/elpa/mode-icons-20200920.2031/"))
(use-package mode-icons
:ensure t
:config
(mode-icons-mode) ;; Requires Emacs::mode-icons
)
;;(add-to-list 'load-path (expand-file-name"~/.emacs.d/elpa/all-the-icons-20210208.0/"))
(use-package all-the-icons
:ensure t ;; Requires Emacs::all-the-icons + initialization with M-x all-the-icons-install-fonts
)
#+END_SRC
** Tabs
+ https://cestlaz.github.io/posts/using-emacs-4-buffers/
#+BEGIN_SRC emacs-lisp
;; (use-package tabbar
;; :ensure t
;; :config (tabbar-mode 1)
;; )
;; (use-package tabbar-ruler
;; :ensure t
;; :config (tabbar-ruler-style 'firefox)
;; )
;; ;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/awesome-tab/")) ; required as installed manually from https://github.com/manateelazycat/awesome-tab.git
;;(require 'awesome-tab) ; Requires cd .emacs.d/ && git clone https://github.com/manateelazycat/awesome-tab.git
;;(setq awesome-tab-dark-unselected-background-color "black")
;;(setq awesome-tab-dark-unselected-foreground-color "dark gray")
;;(setq awesome-tab-dark-selected-background-color "black")
;;;(setq awesome-tab-dark-selected-foreground-color "light gray")
;;(setq awesome-tab-show-tab-index t)
;;(awesome-tab-mode t)
#+END_SRC
** Others
#+BEGIN_SRC emacs-lisp
(setq
initial-scratch-message nil ; empty scratch buffer
echo-keystrokes 0.1 ; show keystrokes right away, don't show the message in the scratch buffer
)
(setq-default c-basic-offset 4) ; WORKAROUND FOR BUG
#+END_SRC
** Management of errors
#+BEGIN_SRC emacs-lisp
;; (setq visible-bell 1) ; visual
(setq ring-bell-function 'ignore) ; nothing (no sound, no visual)
#+END_SRC
* Encoding
#+BEGIN_SRC emacs-lisp
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
(modify-coding-system-alist 'file "\.tex" 'utf-8) ; I don't kno why TeX file were opened as iso-latin-1
#+END_SRC
* White spaces
** Config
#+BEGIN_SRC emacs-lisp
;; use spaces instead of tabs (tab=4 spaces)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
;; show whitespace chars
(use-package whitespace
:ensure t
:config
(setq-default whitespace-style '(face tabs newline empty trailing space-after-tab::space indentation::space)) ; add "lines" to visualize lines that are too long
(global-whitespace-mode 1)
)
#+END_SRC
** Utility function
#+BEGIN_SRC emacs-lisp
;; My own tab/whitespace cleanup
(defun my-whitespace-cleanup ()
"replaces tabs by spaces + cleans heading/trailing spaces/tabs + removes ^M"
(interactive)
(whitespace-cleanup)
(untabify 0 (point-max))
(replace-string "" "")
)
#+END_SRC
** White Spaces Key bindings :KEYS:
#+BEGIN_SRC emacs-lisp
;;(global-set-key [f10] (quote whitespace-cleanup))
(global-set-key [f10] (quote my-whitespace-cleanup))
#+END_SRC
* Add a few recent files
#+BEGIN_SRC emacs-lisp
(setq
;; recentf-auto-cleanup 'never
recentf-max-menu-items 2
recentf-max-saved-items 5
;; recentf-filename-handlers '(file-truename abbreviate-file-name)
)
(recentf-mode 1)
#+END_SRC
* Change backup behaviour
#+BEGIN_SRC emacs-lisp
;; Enable backup files.
(setq make-backup-files t)
;; Enable versioning with default values (keep five last versions, I think!)
(setq version-control t)
;; Auto Save every 50 new chars
(setq auto-save-interval 50) ; no less than 20!
;; Save all backup file in this directory.
(setq backup-directory-alist (quote ((".*" . "~/.emacs_backups/"))))
;; From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Backup-Deletion.html
;; deletes excess backup files silently
(setq delete-old-versions t)
;; number of oldest-backups to keep
(setq kept-old-versions 2)
;; number of newest-backups to keep
(setq kept-new-versions 8)
#+END_SRC
* Emacs' default behaviours I don't like
#+BEGIN_SRC emacs-lisp
;; Do not ask if I want to reload a file when it has changed on disk
;; It is supposed not the loose new things that would have been typed in the buffer as it syncs files&buffer live
(global-auto-revert-mode t)
;; Do not ask confirmation when quitting Emacs if there are running processes
(setq confirm-kill-processes nil) ; not the correct one
;; From: https://emacs.stackexchange.com/a/46087
(setq kill-buffer-query-functions nil) ; the correct one
#+END_SRC
* Utilities
#+BEGIN_SRC emacs-lisp
;; To unable increment number at point
;; (add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/shift-number-20170301.1459/"))
;; From: https://github.com/waymondo/hemacs/blob/97ffe0a45263c2533f73d94ba8ef84ee1bd57778/init.el#L470
(use-package shift-number
:ensure t
:bind
("C-c +" . shift-number-up)
("C-c -" . shift-number-down)
)
#+END_SRC
* Macros
#+BEGIN_SRC emacs-lisp
;; Insert UTF-8 right arrow
(fset 'rg-ar
[?\C-x ?8 return ?R ?I ?G ?H ?T ?\S- ?A ?R ?R tab return]
)
;; Insert UTF-8 double right arrow ("implies")
(fset 'dbl-ar
[?\C-x ?8 return ?R ?I ?G ?H ?T ?\S- ?D ?O ?U ?B ?\S- ?A ?R ?R tab return]
)
;; Insert UTF-8 ellipsis
(fset 'ell
[?\C-x ?8 return ?H ?O ?R ?I ?Z ?\S- ?E ?L ?L ?I tab return]
)
;; Insert UTF-8 danger
(fset 'warn
[?\C-x ?8 return ?W ?A ?R ?N ?I tab return]
)
#+END_SRC
* Ediff mode
#+BEGIN_SRC emacs-lisp
(use-package ediff
:ensure t
:custom
(ediff-merge-split-window-function (quote split-window-vertically))
(ediff-split-window-function (quote split-window-horizontally))
)
#+END_SRC
* Shebang mode
#+BEGIN_SRC emacs-lisp
;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/insert-shebang-20201203.1648/"))
(use-package insert-shebang
:ensure t
:custom (insert-shebang-ignore-extensions (quote ("txt" "org" "text")))
)
#+END_SRC
* VC mode
#+BEGIN_SRC emacs-lisp
;;(require 'vc-mode??)
(setq vc-follow-symlinks t)
#+END_SRC
* PostGreSQL mode
#+BEGIN_SRC emacs-lisp
(use-package sql
:ensure t
:mode ("\\.psql$" . sql-mode)
)
#+END_SRC
* Default mode
** No indentation
#+BEGIN_SRC emacs-lisp
(when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
#+END_SRC
* Dired mode
#+BEGIN_SRC emacs-lisp
;; Make dired list files like ls -ahl would do
(setq dired-listing-switches "-ahl")
;; Make dabbrev be case sensitive
;;(setq dabbrev-case-fold-search "case-fold-search")
;;(setq dabbrev-case-replace nil)
#+END_SRC
* aspell
** Basics
#+BEGIN_SRC emacs-lisp
(setq-default ispell-program-name "aspell")
#+END_SRC
** Utility functions
#+BEGIN_SRC emacs-lisp
(setq current-language 1)
(ispell-change-dictionary "british")
(defun set-language-english ()
;; Set english as ispell language
(setq current-language 1)
(ispell-change-dictionary "british")
(force-mode-line-update)
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space t)
)
(defun set-language-french ()
;; Set french as ispell language
(setq current-language 0);
(ispell-change-dictionary "francais")
(force-mode-line-update);
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space nil)
)
(defun set-language-portuguese ()
;; Set pt-br as ispell language
(setq current-language 2);
(ispell-change-dictionary "pt_BR")
(force-mode-line-update);
(setq sentence-end "[.?!][]\"')}]*\\($\\| $\\|\t\\| \\)[ \t\n]*")
(setq sentence-end-double-space nil)
)
(defun toggle-language ()
"Toggle language between french/english/pt_BR"
(interactive)
(cond ((eq current-language 1)
(set-language-french))
((eq current-language 0)
(set-language-portuguese))
((eq current-language 2)
(set-language-english))
(t (set-language-french))
)
)
#+END_SRC
** Language Key bindings :KEYS:
#+BEGIN_SRC emacs-lisp
(global-set-key [f4] (quote toggle-language))
(global-set-key [f5] (quote ispell-buffer))
(global-set-key [f6] (quote ispell-continue))
#+END_SRC
* Cursor Movements
#+BEGIN_SRC emacs-lisp
;; A macro to move quickly within a page
(defun moveup ()
"move 5 lines up"
(interactive)
(previous-line)
(previous-line)
(previous-line)
(previous-line)
(previous-line)
)
;; A macro to move quickly within a page
(defun movedown ()
"move 5 lines down"
(interactive)
(next-line)
(next-line)
(next-line)
(next-line)
(next-line)
)
;; A macro to imitate CTL-ALT-up of Xemacs
(defun moveupc ()
"move 5 lines up and recenter"
(interactive)
(moveup)
(recenter)
)
;; A macro to imitate CTL-ALT-down of Xemacs
(defun movedownc ()
"move 5 lines down and recenter"
(interactive)
(movedown)
(recenter)
)
;; M-Del delete word, does not go to next parenthesis!
(global-unset-key "\C-\M-d")
(global-set-key "\C-d" 'delete-char)
(global-set-key "\C-\M-d" 'kill-word)
(global-set-key (kbd "<escape> <deletechar>") 'kill-word)
(global-set-key (kbd "<escape> DEL") 'backward-kill-word)
(global-set-key [C-tab] 'other-window)
(global-set-key (kbd "C-M-<up>") (quote moveupc))
(global-set-key (kbd "C-M-<down>") (quote movedownc))
(global-set-key (kbd "C-<up>") (quote moveup))
(global-set-key (kbd "C-<down>") (quote movedown))
;; keybidings for ssh console mode!!!
(global-set-key (kbd "M-[ 1 ; 5 A") (quote moveup))
(global-set-key (kbd "M-[ 1 ; 5 B") (quote movedown))
(global-set-key (kbd "M-[ 1 ; 5 C") (quote forward-word))
(global-set-key (kbd "M-[ 1 ; 5 D") (quote backward-word))
#+END_SRC
* Unfinished
#+BEGIN_SRC emacs-lisp
;; Requires configuration of .Xdefaults/.Xresources
;;*vt100.modifyOtherKeys: 1
;;*vt100.formatOtherKeys: 1
(global-set-key (kbd "[37;6u") 'query-replace-regexp)
;; Emacs 24 now differenciates ESC- and M-!!!
(global-set-key (kbd "<escape> u") 'upcase-word)
(global-set-key (kbd "<escape> l") 'downcase-word)
(global-set-key (kbd "<escape> c") 'capitalize-word)
(global-set-key (kbd "<escape> t") 'transpose-words)
(global-set-key (kbd "<escape> q") 'fill-paragraph)
(global-set-key (kbd "<escape> %") 'query-replace)
(global-set-key (kbd "<escape> #") 'query-replace-regexp)
(global-set-key (kbd "M-#") 'query-replace-regexp)
(global-set-key (kbd "<escape> C-%") 'query-replace-regexp)
(global-set-key (kbd "<escape> x") 'execute-extended-command)
(global-set-key (kbd "<escape> $") 'ispell-word)
(global-set-key (kbd "<escape> g g") 'goto-line)
(global-set-key (kbd "<escape> <deletechar>") (quote kill-word))
(global-set-key [f9] (quote dabbrev-expand))
(global-set-key [C-f10] (quote menu-bar-open))
(global-set-key [f11] (quote comment-or-uncomment-region))
(global-set-key [f12] (quote comment-or-uncomment-region))
;; Problems with copy/paste/yank from/to other applications
;; From: http://www.emacswiki.org/emacs/CopyAndPaste
(setq select-active-regions t) ; active region sets primary X11 selection
(global-set-key [mouse-2] 'mouse-yank-primary) ; make mouse middle-click only paste from primary X11 selection, not clipboard and kill ring.
(global-set-key "\C-w" 'clipboard-kill-region)
(global-set-key "\M-w" 'clipboard-kill-ring-save)
(global-set-key "\C-y" 'clipboard-yank)
;;(global-set-key [(shift delete)] 'clipboard-kill-region)
;;(global-set-key [(control insert)] 'clipboard-kill-ring-save)
;;(global-set-key [(shift insert)] 'clipboard-yank)
(put 'downcase-region 'disabled nil)
#+END_SRC
* Auto Insert mode
#+BEGIN_SRC emacs-lisp
;; From: https://quinoa42.github.io/en/dot-emacs/#auto-insert
(use-package autoinsert
:init
;; Don't want to be prompted before insertion:
;;(setq auto-insert-query nil)
;;(setq auto-insert-directory (locate-user-emacs-file "templates"))
:config
(define-auto-insert "\\.tex$" "~/Softs/BasicLaTeX_article.tex")
(define-auto-insert "\\.org$" "~/Softs/BasicOrgMode_autoinsert.org")
(auto-insert-mode 1) ;; Adds hook to find-files-hook
;; Template for minimal C file
(define-auto-insert '("\\.c$" . "C skeleton")
'(
"Short description: "
"/**\n * "
(file-name-nondirectory (buffer-file-name))
" -- " str \n
" *" \n
" * Written on " (format-time-string "%A, %e %B %Y.") \n
" */" > \n \n
"#include <stdio.h>" \n
"#include \""
(file-name-sans-extension
(file-name-nondirectory (buffer-file-name)))
".h\"" \n \n
"int main(int arc, char *argv[])" \n
"{" > \n
> _ \n
"}" > \n))
;; Template for minimal C++ file
(define-auto-insert '("\\.\\(CC?\\|cc\\|cxx\\|cpp\\|c++\\)$" . "C++ skeleton")
'("Short description: "
"/*" \n
(file-name-nondirectory (buffer-file-name))
" -- " str \n
" */" > \n \n
"#include <iostream>" \n \n
"using namespace std;" \n \n
"int main(int argc, char *argv[])" \n
"{" \n
> _ \n
"}" > \n))
;;
)
#+END_SRC
* PDFView
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools
:magic ("%PDF" . pdf-view-mode)
:config
(progn
(pdf-tools-install :no-query)
)
)
#+END_SRC
* <<LSP>>
+ Requires export PATH=$PATH:$HOME/.emacs.d/.cache/lsp/
# From: https://emacs-lsp.github.io/lsp-mode/page/installation/#vanilla-emacs
#+BEGIN_SRC emacs-lisp
;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/lsp-mode-20210208.1555/"))
;;(add-to-list 'load-path (expand-file-name "~/.emacs.d/elpa/company-20210122.2314/"))
(use-package lsp-mode
:ensure t)
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode) ; From: https://www.mattduck.com/lsp-python-getting-started.html
(use-package lsp-treemacs
:after treemacs
:ensure t)
(use-package company
:ensure t)
;;(require 'flycheck)
;; See in packages inserted from "Use Emacs" YT! Channel
(use-package helm-lsp
:ensure t)
(use-package lsp-ivy
:ensure t)
(use-package dap-mode
:ensure t)
(use-package lsp-sonarlint
:ensure t)
;; ML-base completion for all languages
(use-package company-tabnine
:ensure t
:config
(add-to-list 'company-backends #'company-tabnine)
)
#+END_SRC
* Shell/Bash
#+BEGIN_SRC emacs-lisp
(use-package shell
:ensure t
:hook (shell-mode . lsp)
)
;; Kill shell buffer on exit
;; From: https://www.eigenbahn.com/2020/05/13/emacs-comint-buffer-auto-close
;; (defvar my-kill-on-exit-comint-hook-has-run nil
;; "Whether or not `kill-on-exit-comint-hook' has run or not.
;; We need this buffer-local var to prevent the hook from running
;; several times, as can happen for example when calling `shell'.")
;; (defun my-async-funcall (function &optional buffer args delay)
;; "Run FUNCTION with ARGS in the buffer after a short DELAY."
;; (run-at-time (or delay 0.2) nil
;; `(lambda ()
;; (with-current-buffer ,buffer ,(cons function args)))))
;; (defun kill-on-exit-comint-hook ()
;; (unless my-kill-on-exit-comint-hook-has-run
;; (setq-local my-kill-on-exit-comint-hook-has-run t)
;; (my-async-funcall #'add-my-kill-on-exit-sentinel (current-buffer))))
;; (add-hook 'comint-mode-hook #'kill-on-exit-comint-hook)
#+END_SRC
* LaTeX / AUCTeX
#+BEGIN_SRC emacs-lisp
;; For getting .bib entries automatically
(use-package gscholar-bibtex
:ensure t
:config
(setq gscholar-bibtex-default-source "Google Scholar") ;; Setting default source for BiTeX references search
)
;; From: https://github.com/jwiegley/use-package/issues/379#issuecomment-244812580
(use-package auctex ; requires Emacs::AUCTeX to be installed
:ensure t
:mode
("\\.tex$" . LaTeX-mode) ; switch to LaTeX rather than plain old TeX : https://stackoverflow.com/questions/60995270/using-c-c-c-f-c-x-in-auctex-randomly-inserts-font-commands-in-old-tex-style
;;("\\.tikz$" . LaTeX-mode)
:hook (
;; For LaTeX
(TeX-mode . lsp)
(LaTeX-mode . lsp)
;; For BibTeX
(bibtex-mode . lsp)
(bibtex-mode . (lambda () (setq fill-column 100))) ; Allow longer lines in .bib files
)
:custom
(output-pdf "PDF Tools")
;; :init
;; ;; Older, more complex, version from old .emacs
;; ;; From: https://emacs.stackexchange.com/questions/19472/how-to-let-auctex-open-pdf-with-pdf-tools
;; (progn
;; ;; Use pdf-tools to open PDF files
;; (setq TeX-view-program-selection '((output-pdf "PDF Tools"))
;; TeX-source-correlate-start-server t)
;; ;; Update PDF buffers after successful LaTeX runs
;; (add-hook 'TeX-after-compilation-finished-functions
;; #'TeX-revert-document-buffer)
;; )
;; )
)
(use-package lsp-latex ; requires Emacs::lsp-latex to be installed + requires OS:TeXLab/digest to be installed + export PATH=$PATH::$HOME/Softs/TeXLab
:ensure t
:after (auctex)
:hook (LaTeX-mode . lsp-latex) ; requires Emacs::lsp-latex to be installed + requires OS:TeXLab/digest to be installed
:custom (lsp-clients-texlab-executable "~/Softs/TeXLab/texlab")
;; :hook (LaTeX-mode . lsp) ;;;; TODO Emacs<->texlab freezes too often => unusable
:custom
(LaTeX-item-indent 0)
(bibtex-align-at-equal-sign t) ;; aligns bibtex entries on = sign when using C-c C-q
:config (add-to-list 'LaTeX-font-list (quote (15 "\\textcolor{}{" "}"))) ; (Does not work) C-c C-f C-o' inserts "\textcolor{}{}" (cursor in the first pair of brackets). But no completion for the colors.
)
#+END_SRC
* R/ESS mode (<<Eglot>>)
#+BEGIN_SRC emacs-lisp
;; From: https://emacs.stackexchange.com/questions/44980/properly-install-ess-using-use-package
(use-package ess ; Requires Emacs::ESS to be installed
:ensure t
:init (require 'ess-site)
:mode (("\\.[rR]\\'" . R-mode)
("\\.Rnw\\'" . Rnw-mode))
:hook (ess-r-mode . lsp)
)
;; (use-package eglot ; Requires Emacs::eglot to be installed
;; :ensure t
;; :hook (ess-r-mode . eglot-ensure) ; Requires installation of R::install.packages(c("lintr","languageserver"))
;; )
#+END_SRC
* Python
#+BEGIN_SRC emacs-lisp
(use-package pylint
:ensure t)
(use-package blacken
:ensure t)
;; From: https://www.mattduck.com/lsp-python-getting-started.html
(use-package python
:after blacken
:after pylint
:ensure t
:mode ("\\.py\\'" . python-mode)
:hook
;; THERE'S A BUG in the fact that both python.el (builtin Emacs) and python-mode.el both define python-mode
;; - if .py file is opened from command line, python.el is loaded
;; - if .py opened from Emacs directly, python-mode.el is loaded
;; => LSP is loaded only is python-mode.el is loaded i.e. is .py opened from Emacs
;; // if using emacs-client, this occurs only if .py file is opened at first ;)
(python-mode . lsp) ; Requires Python::pip3 install python-lsp-server pylint pandas (+ start Emacs inside venv)
(python-mode . blacken-mode) ; Requires Python::pip3 install black pyls-black ; For indentation
:config
;;TODO ( (add-to-list 'lsp-disabled-clients 'pyls)
;;TODO (add-to-list 'lsp-enabled-clients 'jedi) )
;; Assign C-Return to eval-region , like in R/ESS
(define-key python-mode-map (kbd "<C-return>") #'python-shell-send-region)
(python-mode)
(lsp)
)
;;(use-package elpy
;; :ensure t
;; :config (elpy-enable) ; Requires Emacs::elpy
;; )
;; Completion requires Emacs::flyC + Emacs::jedi + Emacs::company-jedi
;; (use-package lsp-jedi
;; :after python
;; :ensure t
;; :custom
;; (progn
;; (lsp-pyls-plugins-jedi-completion-enabled t)
;; (lsp-register-custom-settings
;; '(("pyls.plugins.pyls_black.enabled" t t)
;; ("pyls.plugins.flake8.enabled" t t)
;; ))
;; )
;; )
(use-package ein
:ensure t
;; 2 following lines do not work to automatically run ein:notebook-open when opening a .ipynb file...
:mode ("\\.ipynb$" . 'ein)
;;:hook (ein . ein:notebook-open) ; for IPython Notebooks , requires Emacs::EIN / C-c C-o on a .ipynb file / ein:run launches jupyter
)
#+END_SRC
* C/C++
#+BEGIN_SRC emacs-lisp
(use-package cc-mode
:ensure t
:hook (c-mode . lsp) ; Requires installation os OS::clangd
:hook (c++-mode . lsp) ; Requires installation os OS::clangd
)
#+END_SRC
* JavaScript
#+BEGIN_SRC emacs-lisp
(use-package js3-mode
:ensure t
:hook (js3-mode . lsp) ; Requires initialization with C-u M-x lsp-install-server metals
)
;; (use-package lsp-sonarlint-javascript
;; :ensure t
;; :custom (lsp-sonarlint-javascript-enabled t)
;; )
#+END_SRC
* Scala mode
#+BEGIN_SRC emacs-lisp
(use-package scala-mode
:ensure t)
(use-package lsp-metals
:ensure t ; Requires Emacs::lsp-metals to be installed
:hook (scala-mode . lsp) ; Requires initialization with C-u M-x lsp-install-server metals + export PATH=$PATH:$HOME/.local/share/coursier/bin # Emacs
)
#+END_SRC
* Java / JDEE mode
#+BEGIN_SRC emacs-lisp
(use-package jdee
:ensure t
:hook (jdee-mode . lsp) ; Requires initialization with C-u M-x lsp-install-server jdtls
:mode ("\\.java$" . jdee-mode)
:custom
(jdee-maven-disabled-p t)
(jdee-gen-println (quote ("\"System.out.println(\" ~ \");\"")))
(jdee-server-dir "/home/gmuller/.emacs.d/jdee-server-compiled/")
(browse-url-browser-function (quote browse-url-firefox))
(jdee-jdk-doc-url "https://docs.oracle.com/javase/8/docs/api/")
(jdee-jdk (quote ("10.0")))
(jdee-jdk-registry (quote (("10.0" . "/usr/lib/jvm/java-11-openjdk-amd64"))))
(jdee-key-bindings
(quote
(("[? ? ?]" . jdee-run-menu-run-applet)
("[? ? ?]" . jdee-build)
("[? ? ?]" . jdee-compile)
("[? ? ?]" . jdee-debug)
("[? ? ?]" . jdee-find)
("[? ? ?]" . jdee-open-class-at-point)
("[? ? ?]" . jdee-bsh-run)
("[? ? ?]" . jdee-help-browse-jdk-doc)
("[? ? ?]" . jdee-save-project)
("[? ? ?]" . jdee-wiz-update-class-list)
("[? ? ?]" . jdee-run)
("[? ? ?]" . speedbar-frame-mode)
("[? ? ?]" . jdee-jdb-menu-debug-applet)
("[? ? ?]" . jdee-help-symbol)
("[? ? ?]" . jdee-show-superclass-source)
("[? ? ?]" . jdee-open-class-at-point)
("[? ? ?a]" . jdee-wiz-implement-interface)
("[? ? ?c]" . jdee-gen-class)
("[? ? ?d]" . jdee-gen-switch)
("[? ? ?e]" . jdee-wiz-extend-abstract-class)
("[? ? ?f]" . jdee-gen-try-finally-wrapper)
("[? ? ?g]" . jdee-wiz-get-set-methods)
("[? ? ?i]" . jdee-import-find-and-import)
("[? ? ?j]" . jdee-javadoc-autodoc-at-line)
("[? ? ?l]" . jdee-gen-println)
("[? ? ?m]" . jdee-gen-main)
("[? ? ?o]" . jdee-wiz-override-method)
("[? ? ?s]" . sr-speedbar-toggle)
("[? ? ?t]" . jdee-gen-tostring-method)
("[? ? ?u]" . jdee-gen-if-else-wrapper)
("[? ? ?y]" . jdee-gen-try-catch-wrapper)
("[? ? ?z]" . jdee-import-all)
("[? ? ?]" . jdee-run-etrace-prev)
("[? ? ?]" . jdee-run-etrace-next)
("[(control c) (control v) (control ?.)]" . jdee-complete-in-line)
("[(control c) (control v) ? ]" . jdee-complete))))
)
;; (use-package java
;; :ensure t
;; :hook (java-mode . lsp) ; Requires initialization with C-u M-x lsp-install-server jdtls
;; :mode ("\\.java$" . java-mode)
;; )
(use-package lsp-java ; Requires Emacs::lsp-java to be installed
;;(with-eval-after-load "lsp"
;; (add-to-list 'lsp-language-id-configuration '(java-mode . "java"))
;; (add-to-list 'lsp-language-id-configuration '(jdee-mode . "java")))
)
;; (use-pacakge lsp-sonarlint-java
;; :ensure t
;; :custom (lsp-sonarlint-java-enabled t)
;; )
#+END_SRC
* Dart/Flutter
** Dart
+ Requires OS::install flutter in ~/Softs/ https://flutter.dev/docs/get-started/install/linux#install-flutter-manually
+ export PATH=$PATH:~/Softs/flutter/bin in .bashrc
#+BEGIN_SRC emacs-lisp
;; https://github.com/amake/flutter.el#example
(use-package dart-mode
:ensure t
:mode ("\\.dart$" . dart-mode)
:hook (dart-mode . lsp)
:custom (lsp-dart-sdk-dir "/usr/lib/dart")
;; Optional
:hook (dart-mode . flutter-test-mode)
)
#+END_SRC
** Flutter
+ Requires OS::install flutter in ~/Softs/ https://flutter.dev/docs/get-started/install/linux#install-flutter-manually
+ export PATH=$PATH:~/Softs/flutter/bin in .bashrc
#+BEGIN_SRC emacs-lisp
;; From: https://github.com/amake/flutter.el#example
(use-package flutter
:ensure t
:after dart-mode
:bind (:map dart-mode-map
("C-M-x" . #'flutter-run-or-hot-reload))
:custom
(flutter-sdk-path "~/Softs/flutter/")
)
#+END_SRC
* Rust
#+BEGIN_SRC emacs-lisp
(use-package rustic
:ensure t
:mode ("\\.rust$" . rustic-mode)
:bind (:map rustic-mode-map
("M-j" . lsp-ui-imenu)
("M-?" . lsp-find-references)
("C-c C-c l" . flycheck-list-errors)
("C-c C-c a" . lsp-execute-code-action)
("C-c C-c r" . lsp-rename)
("C-c C-c q" . lsp-workspace-restart)
("C-c C-c Q" . lsp-workspace-shutdown)
("C-c C-c s" . lsp-rust-analyzer-status))
:config
;; uncomment for less flashiness
;; (setq lsp-eldoc-hook nil)
;; (setq lsp-enable-symbol-highlighting nil)
;; (setq lsp-signature-auto-activate nil)
;; comment to disable rustfmt on save
(setq rustic-format-on-save t)
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
(defun rk/rustic-mode-hook ()
;; so that run C-c C-c C-r works without having to confirm, but don't try to
;; save rust buffers that are not file visiting. Once
;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
;; no longer be necessary.
(when buffer-file-name
(setq-local buffer-save-without-query t)))
#+END_SRC
* Org mode
** org-bullets
+ https://cestlaz.github.io/posts/using-emacs-2-org/
+ Prettifies display of bullets
#+BEGIN_SRC emacs-lisp
;; From: https://emacs.stackexchange.com/a/44653
(use-package org-bullets
:ensure t
:hook (org-mode . org-bullets-mode)
)
#+END_SRC
** remaining
#+BEGIN_SRC emacs-lisp
;; org-mode
(use-package org
:ensure t)
;; To enable references in org/org-beamer/org-latex
(use-package org-ref
:ensure t)
;;(add-hook 'text-mode-hook 'org-mode) ; <- makes all texts (including tex-mode/etc.) become OrgMode
;;(setq initial-major-mode 'org-mode) ; <- does not work either :[
;; OrgMode
(setq org-default-notes-file "~/.emacs.d/notes.org")
(global-set-key "\C-cc" 'org-capture)
;; Activate numbering of section by default
;;(add-hook 'org-mode-hook 'org-num-mode) ;; TODO: removed?
;; Allow to toggle numbering of section with C-C n
(global-set-key "\C-cn" (lambda () (interactive) (org-num-mode 'toggle)))
;; Wrap lines
(add-hook 'org-mode-hook (lambda () (setq truncate-lines nil)))
(add-hook 'org-mode-hook (lambda () (visual-line-mode 0)))
;; Generates MindMaps from org-mode outlines
;;(require 'ox-org)
;;(require 'org-mind-map)
;; Do not ask for confirmation before executing source code
(setq org-confirm-babel-evaluate 'nil)
;; using listings packages in org-mode beamer instead of verbatim
(setq org-latex-listings t)
(add-to-list 'org-latex-default-packages-alist '("" "listings" nil nil))
;; parsing/generating the bilbiography when using org-*-export-to-pdf (e.g. org-beamer / org-ref)
(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
;; Using small fixed size for inline image (or #+ATTR_ORG: :width xxx px)
;; (setq org-image-actual-width (quote (100)))
(setq org-image-actual-width (/ (display-pixel-width) 5))
;; enable narrowing
(put 'narrow-to-region 'disabled nil)
;; ASCII Drawings in org-mode!
(setq org-ditaa-jar-path "/usr/share/ditaa/ditaa.jar")
(org-babel-do-load-languages
'org-babel-load-languages
'((ditaa . t))) ; this line activates ditaa
;; UML diagrams in org-mode!
(setq org-plantuml-jar-path (expand-file-name "/usr/share/plantuml/plantuml.jar"))
(add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
;; dot diagrams in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((dot . t))) ; this line activates dot
;; Python code in org-mode!
(setq org-babel-python-command "python3")
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t))) ; this line activates Python
;; ipython notebooks in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((ein . t))) ; this line activates EIN (Emacs INoteBook)
;; C/C++ code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((C . t))) ; this line activates C
;; Java code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((java . t))) ; this line activates Java
;; R code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t))) ; this line activates R
;; sh code in org-mode!
(setq org-babel-sh-command "bash")
(org-babel-do-load-languages
'org-babel-load-languages
'((shell . t))) ; this line activates Bash
;; LaTeX code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((latex . t))) ; this line activates LaTeX
;; gnuplot code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((gnuplot . t))) ; this line activates Gnuplot
;; sqlite code in org-mode!
(org-babel-do-load-languages
'org-babel-load-languages
'((sqlite . t))) ; this line activates sqlite
(setq org-trello-current-prefix-keybinding "C-c o")
;; to send captures
(setq send-mail-function (quote mailclient-send-it))
;;(org-reload)
#+END_SRC
* Treemacs
+ From: https://github.com/Alexander-Miller/treemacs#installation
#+BEGIN_SRC emacs-lisp
(use-package treemacs ; Needs to configure a default project with "M-x treemacs-edit-workspaces" (e.g. pointing to ~/)
:ensure t
:defer t
:custom
(treemacs-use-follow-mode t)
(treemacs-use-filewatch-mode t)
(treemacs-file-watch-threshold 100)
(treemacs-use-collapsed-directories 3)
(treemacs-is-never-other-window t)
(treemacs-show-hidden-files nil)
(projectile-require-project-root nil) ; do not ask for project-root when opening non-project file
:config (save-selected-window (treemacs-select-window))
)
#+END_SRC
* YAML
#+BEGIN_SRC emacs-lisp
(use-package yaml ; Requires Emacs::yaml-mode to be installed
:ensure t
:mode ("\\.yml$" . yaml-mode)
)
#+END_SRC
* Php
#+BEGIN_SRC emacs-lisp
(use-package php-mode
:ensure t
:hook (php-mode . lsp) ; Requires initialization with C-u M-x lsp-install-server ???intelephense??? (proprio)
)
;; (use-package lsp-sonarlint-php
;; :ensure t
;; :custom (lsp-sonarlint-php-enabled t)
;; )
#+END_SRC
* Web
#+BEGIN_SRC emacs-lisp
(use-package w3m ; Requires OS::w3m + Emacs::w3m-mode to be installed
:ensure t
)
;;(use-package lsp-sonarlint-html
;; :ensure t
;; :custom (lsp-sonarlint-html-enabled t)
;; )
#+END_SRC
* Client / Server mode
** Better to alias emac with "emacsclient -a '' -c"
#+BEGIN_SRC emacs-lisp
;; TODO: problem: all the buffers appear in all frames :{
;; (unless (boundp 'server-process)
;; (server-start))
#+END_SRC
* Emojis
#+BEGIN_SRC emacs-lisp
;; (el-get 'sync 'emojify)
;; (use-package emojify
;; :ensure t
;; :hook (org-mode . emojify-mode)
;; :hook (markdown-mode . emojify-mode)
;; :hook (git-commit-mode . emojify-mode)
;; )
#+END_SRC
# * Hack for Speed - End
# #+BEGIN_SRC emacs-lisp
# (setq gc-cons-threshold (* 2 1000 1000))
# #+END_SRC
* From YT! Chan "Using Emacs"
+ https://cestlaz.github.io/stories/emacs/
** Use-package
+ http://cestlaz.github.io/posts/using-emacs-1-setup
+ Faciliates writing of init.el code.
+ auto loads (installs?) pkg
+ initializes it
+ configures it
+ groups all info together
#+BEGIN_SRC emacs-lisp
;; Bootstrap "use-package"
(unless (package-installed-p 'use-package)
;; (package-refresh-contents) ;; TODO: activate on first Emacs use / Otherwise disable as it will make Emacs startup very slow
(package-install 'use-package))
#+END_SRC
** Try
+ http://cestlaz.github.io/posts/using-emacs-1-setup
+ Let's you try packages without installing them.
#+BEGIN_SRC emacs-lisp
(use-package try
:ensure t)
#+END_SRC
** IDO
+ https://cestlaz.github.io/posts/using-emacs-4-buffers/
+ Better completion
+ Using Counsel/Help/etc. is more advanced
+ See Swiper/Counsel below [[Swiper]]
#+BEGIN_SRC emacs-lisp
;;(setq ido-enable-flex-matching t)
;;(setq ido-everywhere t)
;;(ido-mode 1)
;; Better buffer to switch between frames: using keys like in list-packages:
;; 'm' = mark / 'd' = delete / 'u' = unmark / 'x' = execute
;; (defalias 'list-buffers 'ibuffer) ; make ibuffer default
(defalias 'list-buffers 'ibuffer-other-window) ; make ibuffer default
#+END_SRC
** LATER windmove + ace-windows + winner
+ Moving between buffer/frames/windows
+ https://cestlaz.github.io/posts/using-emacs-5-windows/
#+BEGIN_SRC emacs-lisp
;; move between windows by holding the shift key and with the arrows.
;; (windmove-default-keybindings)
;; move between windows with C-x o+<number> (that is printed on screen)
(use-package ace-window
:ensure t
:init
(progn
(global-set-key [remap other-window] 'ace-window)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0)))))
))
;; use C-c ↠or → to move through past window configurations
;; (winner-mode 1)
#+END_SRC
** Swiper <<Swiper>>
+ https://cestlaz.github.io/posts/using-emacs-6-swiper/
+ Better search/completion
#+BEGIN_SRC emacs-lisp
(use-package counsel
:ensure t
)
(use-package swiper
:ensure try
:config
(progn
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(global-set-key "\C-s" 'swiper)
;; (global-set-key (kbd "C-c C-r") 'ivy-resume)
;; (global-set-key (kbd "<f6>") 'ivy-resume)
;; (global-set-key (kbd "M-x") 'counsel-M-x)
(global-set-key (kbd "C-x C-f") 'counsel-find-file)
;; (global-set-key (kbd "<f1> f") 'counsel-describe-function)
;; (global-set-key (kbd "<f1> v") 'counsel-describe-variable)
;; (global-set-key (kbd "<f1> l") 'counsel-load-library)
;; (global-set-key (kbd "<f2> i") 'counsel-info-lookup-symbol)
;; (global-set-key (kbd "<f2> u") 'counsel-unicode-char)
;; (global-set-key (kbd "C-c g") 'counsel-git)
;; (global-set-key (kbd "C-c j") 'counsel-git-grep)
;; (global-set-key (kbd "C-c k") 'counsel-ag)
;; (global-set-key (kbd "C-x l") 'counsel-locate)
;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
))
#+END_SRC
** Avy/Searching
+ https://cestlaz.github.io/posts/using-emacs-7-avy/
+ 2 character search
#+BEGIN_SRC emacs-lisp
;; (use-package avy
;; :ensure t
;; :bind ("M-s" . avy-goto-char))
;; (use-package avy
;; :ensure t
;; :config
;; (avy-setup-default))
#+END_SRC
** Auto-completion
+ https://cestlaz.github.io/posts/using-emacs-8-autocomplete/
+ Better auto completion
#+BEGIN_SRC emacs-lisp
(use-package auto-complete
:ensure t
:init
(progn
(ac-config-default)
(global-auto-complete-mode t)))
#+END_SRC
** Présentations with org-reveal
+ https://cestlaz.github.io/posts/using-emacs-11-reveal/
+ Pretty & Simple Dynamic HTML/CSS Presentations from org-mode files
#+BEGIN_SRC emacs-lisp
;; (use-package ox-reveal
;; :ensure ox-reveal)
;; (setq org-reveal-root "http://cdn.jsdelivr.net/reveal.js/3.0.0/")
;; (setq org-reveal-mathjax t)
;; (use-package htmlize
;; :ensure t)
#+END_SRC
** Flycheck
+ https://cestlaz.github.io/posts/using-emacs-12-python/
+ On the fly syntax checking for many languages
+ Requires
+ =pip install pylint=
#+BEGIN_SRC emacs-lisp
(use-package flycheck
:after jdee
:ensure t
:init
(global-flycheck-mode t))
#+END_SRC
** Jedi
+ https://cestlaz.github.io/posts/using-emacs-12-python/
+ Provides more extensive completion for flycheck (particularly Python)
+ Requires =M-x jedi:install-server=, which requires:
+ =pip install virtualenv=
+ =pip install epc=
#+BEGIN_SRC emacs-lisp
(use-package jedi
:ensure t
:init
(add-hook 'python-mode-hook 'jedi:setup)
(add-hook 'python-mode-hook 'jedi:ac-setup))
#+END_SRC
** elpy
+ https://cestlaz.github.io/posts/using-emacs-13-yasnippet/
+ IDE features for python: completion, refactoring, project...
+ Requires
+ =pip install rope=
+ =pip install jedi=
+ =pip install flake8=
+ =pip install importmagic=
+ =pip install autopep8=
+ =pip install yapf=
+ See [[LSP]]/[[Eglot]]
#+BEGIN_SRC emacs-lisp
;; (use-package elpy
;; :ensure t
;; :config
;; (elpy-enable))
#+END_SRC
** Yasnippet
+ https://cestlaz.github.io/posts/using-emacs-13-yasnippet/
+ Snippets of code
+ Many pre-defined snippets + customizable (to put in =~/.emacs.d/snippets/xxx-mode/=)
+ Use <shortcut>+TAB to insert the snippet [see menus for snippet names]
+ Use Tab to navigate the fillable areas
#+BEGIN_SRC emacs-lisp
(use-package yasnippet
:ensure t
:init
(yas-global-mode 1))
#+END_SRC
- (2916)How to remove ^M from Windows text files?
At the bottom (status bar?), '(DOS)' is displayed if Emacs recognized the file as a Windows text file.
Click on it multiple times until you reach the configuration you want. It toggles between '(DOS)', '(Mac)' and nothing (=Linux).
- (3029)How to draw diagrams (freehand/language based)/graphs/UML in Emacs?
To freehand draw ASCII-art forms (lines, circles, rectangles...) in a buffer, as you would do in any paint app, you can run M-x artist-mode.
If you want more advanced/precise diagrams, org-mode can use external tools (diagrams: ditaa, UML: plantuml, graphs: dot). You simply insert their language-based code between #+BEGIN_SRC ... #+END_SRC.
Example:
----------------- BasicOrgMode_diagrams.org
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
* artist-mode Cheat Sheet
** artist-mode doc
*** https://www.emacswiki.org/emacs/ArtistMode
** Middle Click or "Artist" menu provides list of drawable shapes
** Copy/Cut => draws a rectangle which contents will be copied/cut
** "<" & ">" add arrow at end of line
** Right mouse erases
* Example ditaa drawing
** Ditaa doc
*** https://github.com/stathissideris/ditaa
** Emacs + Dita doc:
*** https://www.orgmode.org/worg/org-contrib/babel/languages/ob-doc-ditaa.html
*** https://emacs.stackexchange.com/questions/20731/setting-up-ditaa-in-org-mode/54090#54090
** C-c ' to edit / C-x C-s to save/update / C-c C-k to quit
** C-c C-c to compile result
#+BEGIN_SRC ditaa :file ./test_ditaa.png
+----------+
+---------------+ +-=------\ | | +-------------+ +---------+
|cRED | |c3AF | | {io}| |cBLU | | |
| | | | +----------+ | | | |
| | \--------+ | {o}| | {tr}|
| {d}| ------------- +-------------+ +---------+
+--+---+--------+ +---------+ ---/ \---
: | | {s}| -/ \- +-----------+
| | +---------+ / \ | |
| +---------------------------->( ) | {mo} |
| \ / +-----------+
+---------------------------------->-\ /-
---\ /--- +---------+
------------- | |
| {c}|
+---------+
#+END_SRC
#+RESULTS:
[[file:./test_ditaa.png]]
* Example PlantUML diagram
** PlantUML doc
*** https://plantuml.com/
*** https://crashedmind.github.io/PlantUMLHitchhikersGuide/
** PlantUML + Emacs doc
*** https://plantuml.com/emacs
** C-c ' to edit / C-x C-s to save/update / C-c C-k to quit
** C-c C-c to compile result
#+BEGIN_SRC plantuml :file ./test_plantuml_usecase.png
@startuml
'skinparam handwritten true
left to right direction
actor "Food Critic" as fc
rectangle Restaurant {
usecase "Eat Food" as UC1
usecase "Pay for Food" as UC2
usecase "Drink" as UC3
}
fc --> UC1
fc --> UC2
fc --> UC3
UC1 <|-- UC2
UC3 .> UC1 : extends
note right of (UC3)
A note can also
be on several lines
end note
@enduml
#+END_SRC
#+RESULTS:
[[file:./test_plantuml_usecase.png]]
#+BEGIN_SRC plantuml :file ./test_plantuml_seq.png
title Authentication Sequence
Alice->Bob: Authentication Request
note right of Bob: Bob thinks about it
Bob->Alice: Authentication Response
#+END_SRC
#+RESULTS:
[[file:./test_plantuml.png]]
#+BEGIN_SRC plantuml :file ./test_plantuml_class.png
@startuml
' Comments
class BaseClass {
'skinparam classAttributeIconSize 0 ' to replace icons by actual char
- private
# protected
~ pkg private
+ public
{static} static
~ method1()
{abstract} abstract()
}
namespace net.dummy #DDDDDD {
.BaseClass <|-- Person
Meeting o-- Person
.BaseClass <|- Meeting
}
namespace net.foo {
net.dummy.Person <|- Person
.BaseClass <|-- Person
net.dummy.Meeting o-- Person
}
BaseClass <|-- net.unused.Person
Class01 <|-- Class02
Class03 *-- Class04
Class05 o-- Class06
Class07 .. Class08 : direction >
Class09 -- Class10
class Class06b
class Class11
(Class06b, Class11) . Class12
'Class13 extends Class14
'Class13 implements Class15
bar ()- Class01
@enduml
#+END_SRC
#+RESULTS:
[[file:./test_plantuml_class.png]]
* Example Dot graphs
** dot doc:
*** https://en.wikipedia.org/wiki/DOT_(graph_description_language)
*** https://www.graphviz.org/documentation/
** dot + Emacs doc:
*** https://www.orgmode.org/worg/org-contrib/babel/languages/ob-doc-dot.html
** C-c ' to edit / C-x C-s to save/update / C-c C-k to quit
** C-c C-c to compile result
#+BEGIN_SRC dot :file ./test_dot_directed.png
digraph graphname { // DIrected graph
a -> b -> c;
b -> d;
}
#+END_SRC
#+RESULTS:
[[file:./test_dot_directed.png]]
#+BEGIN_SRC dot :file ./test_dot_undirected.png
graph test { // UNdirected graph
// This attribute applies to the graph itself
size="3,3";
// The label attribute can be used to change the label of a node
a [label="Foo"];
// Here, the node shape is changed.
b [shape=box];
// These edges both have different line properties
a -- b -- c [color=blue];
b -- d [style=dotted];
// [style=invis] hides a node.
}
#+END_SRC
#+RESULTS:
[[file:./test_dot_undirected.png]]
-------------------- BasicOrgMode_diagrams.org
- (3052)How to get rid of timeout error "(void-function org-time-add)" when using config.org as a litterate .emacs config file?
Add a (org-reload) call at the end of your org mode config.
From: https://emacs.stackexchange.com/questions/54005/problem-with-org-startup-indented/54008#54008
- (3053)How to quickly create (an inline) code block in Org Mode?
Use:
src_lang{code} or with header args: src_lang[args]{code},
Example:
src_python[:session]{10*x}
It is the same as
#+BEGIN_SRC python :session
10*x
#+END_SRC
From: https://orgmode.org/worg/org-contrib/babel/intro.html#org7776cd0
- (3054)How to go to a particular char position in a buffer?
M-x goto-char
From: https://stackoverflow.com/questions/14372226/how-to-locate-buffer-position-in-emacs
- (3064)How to make Org Mode use Python3 (or any python interpreter other than the default)?
(setq org-babel-python-command "/path/to/python3")
From: https://emacs.stackexchange.com/questions/42575/interpreter-discrepancy-in-org-babel-python-and-python-mode
- (3065)How to load bash (rather than sh) in org babel to enable #+BEGIN_SRC bash?
SOLUTION1: use
#+BEGIN_SRC shell
You'll nee to enable it:
(org-babel-do-load-languages 'org-babel-load-languages '( (shell . t) ) )
SOLUTION2: set variable:
org-babel-sh-command
From: https://stackoverflow.com/questions/29163164/how-can-i-load-bash-as-opposed-to-sh-in-org-babel-to-enable-begin-src-bash
- (3066)How to enable execution/interpretation of various langagues within #+BEGIN_SRC ... #+END_SRC block in Org Mode (a.k.a. What are the available languages in source blocks in Org Mode)?
M-x customize-variable org-babel-load-languages
or add the following line in your ~/.emacs
(org-babel-do-load-languages
'org-babel-load-languages
'( (python . t)
(xxx . t)
...
)
)
List of supported Babel languages: https://orgmode.org/worg/org-contrib/babel/languages.html
From: https://stackoverflow.com/questions/29163164/how-can-i-load-bash-as-opposed-to-sh-in-org-babel-to-enable-begin-src-bash
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html
- (3067)How to type & execute code blocks in Org Mode?
General format:
#+BEGIN_SRC python :results output
print "Hello, world!"
#+END_SRC
#+RESULTS:
: Hello, world!
I] Common Header Arguments
:session [name]: default is no session.
:var data=data-table: Variables can be passed into python from org-mode tables as scalars or lists. See the org-mode manual for more details.
:exports {code, results, both, none}: Standard babel option for what to export.
II] Python arguments
:results {output, value}: Value mode is the default (as with other languages). In value mode you can use the following subtypes:
raw: value is inserted directly
pp: value is pretty-printed by python using pprint.pformat(%s), then inserted
file: value is interpreted as a filename to be interpolated when exporting; commonly used for graphics output.
:preamble: Preamble code, inserted before the body (not commonly used). Default is none.
:return: Value to return (only when result-type is value, and not in session mode; not commonly used). Default is None; in non-session mode use return() to return a value.
:python: Name of the command for executing Python code.
III] R
There are some tricks to get the results in an external file. See:
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html
IV] Other languages
See https://orgmode.org/worg/org-contrib/babel/languages.html
From: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-python.html
https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html
https://orgmode.org/worg/org-contrib/babel/languages.html
- (3072)How to use bash (as opposed to sh) in org babel BEGIN_SRC?
SOLUTION1: might require (load-file "~/org-git/org-mode/lisp/ob-shell.el")
#+BEGIN_SRC shell
...
#END_SRC
SOLUTION2:
#+BEGIN_SRC sh :shebang "#!/bin/bash"
...
#END_SRC
SOLUTION3: Set the value of org-babel-sh-command (which defaults to "sh").
From: https://stackoverflow.com/questions/29163164/how-can-i-load-bash-as-opposed-to-sh-in-org-babel-to-enable-begin-src-bash
- (3073)How to write non-Beamer presentations in org-mode?
1. Epresent
- Download https://raw.githubusercontent.com/eschulte/epresent/master/epresent.el
- M-x load-file epresent.el
- open the example present.org file located in the repository
- call M-x epresent-run
- press "t" to view the top level of the presentation
- navigate the presentation with "n", "p", "t" and quit with "q"
2. S5
- Download https://github.com/eschulte/org-S5/blob/master/org-export-as-s5.el
- M-x load-file org-export-as-s5.el
- M-x org-export-as-s5
- Examples: https://eschulte.github.io/org-S5/
3. org-tree-slide
- Download https://raw.github.com/takaxp/org-tree-slide/master/org-tree-slide.el
- M-x org-tree-slide-mode
- Just type C-> and C-< to move between slides.
- To show CONTENT, type C-x s c
4. org-reveal
- Download https://github.com/yjwen/org-reveal/ (or install via MELPA) & https://github.com/hakimel/reveal.js/
- (setq org-reveal-root "file:///home/user/.emacs.d/reveal.js")
- M-x load-library ox-reveal
- Typing “C-c C-e R R” to export current Org buffer
- Open the generated "Readme.html" in your browser.
From: https://orgmode.org/worg/org-tutorials/non-beamer-presentations.html
- (3074)How to write Beamer presentations in org-mode?
I] Define an export template
#+TITLE: Writing Beamer presentations in org-mode
#+AUTHOR: Eric S Fraga
#+EMAIL: e.fraga@ucl.ac.uk
#+DATE: 2010-03-30 Tue
#+DESCRIPTION:
#+KEYWORDS:
#+LANGUAGE: en
#+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t
#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
#+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:https://orgmode.org/org-info.js
#+EXPORT_SELECT_TAGS: export
#+EXPORT_EXCLUDE_TAGS: noexport
#+LINK_UP:
#+LINK_HOME:
II] Beamer specific settings
#+startup: beamer
#+LaTeX_CLASS: beamer
#+LaTeX_CLASS_OPTIONS: [bigger]
III] Outline levels for frames
#+BEAMER_FRAME_LEVEL: 2
IV] A simple slide
------
* Introduction
** A simple slide
This slide consists of some text with a number of bullet points:
- the first, very @important@, point!
- the previous point shows the use of the special markup which
translates to the Beamer specific /alert/ command for highlighting
text.
The above list could be numbered or any other type of list and may
include sub-lists.
-------
V] Customization
#+latex_header: \mode<beamer>{\usetheme{Madrid}}
From: https://orgmode.org/worg/exporters/beamer/tutorial.html
- (3075)How to write your Emacs config file as an org-mode file?
1. Write & Structure your config file as an org-mode file
* <Name of section>
#+BEGIN_SRC emacs-lisp
<code for section>
#+END_SRC
2. Load it by replacing the (whole) content of your .emacs with:
(org-babel-load-file
(expand-file-name
"config.org"
user-emacs-directory))
From: https://blog.thomasheartman.com/posts/configuring-emacs-with-org-mode-and-literate-programming
https://github.com/akaWolf/emacs.d
- (3076)How to in-/de-crease number at current cursor position?
1. Install shift-number from MELPA
2. Use M-x shift-number-up or M-x shift-number-down
From: https://github.com/alezost/shift-number.el
- (3077)How to make org-mode babel gnuplot working?
1. Install Emacs & Gnuplot
2. Install gnuplot-mode (if not builtin Emacs)
3. Be sure all your "export PATH=..." are in .profile and not in .bashrc (if you're not running Emacs from bash)
From: https://www.reddit.com/r/emacs/comments/c8m0zl/org_gnuplot_not_working/
- (3081)How to edit org-mode files when you do not have access to an Emacs client (e.g. Windows, Android, etc.)?
Use "organice"
Problem: it's an online app :{
From: https://github.com/200ok-ch/organice
- (3082)How to get back "<s", "<q" shortcuts in recent org-mode?
Enable it by customizing org-modules or add (require 'org-tempo) to your Emacs init file
From: https://www.reddit.com/r/emacs/comments/aq9tf4/get_back_s_shortcut_in_orgmode/
https://www.reddit.com/r/emacs/comments/ad68zk/get_easytemplates_back_in_orgmode_92/
- (3083)How to quickly in-/de-crease font sizes in Emacs?
C-x C-+ or C-x C--
From: https://stackoverflow.com/questions/14010895/bind-key-to-increase-decrease-font-size-in-emacs#14012138
- (3084)How to switch to numbered/unnumbered lists in org-mode?
Switch the first element of the list and hit C-c C-c.
Example:
- a 1. a 1. a
- b => - b = C-c C-c on 1rst line => 2. b
- c - c 3. c
From: https://emacs.stackexchange.com/questions/26203/convert-between-numbered-and-unordered-lists-in-org-mode/26207#26207
- (3085)How to record a timestamp and a note when changing a TODO state in org-mode?
To record a timestamp and a note when changing a TODO state, call the command org-todo with a prefix argument.
C-u C-c C-t (org-todo)
From: https://orgmode.org/manual/Progress-Logging.html
- (3088)How to align TAGs to the right margin in org-mode?
C-u C-c C-q works for me
From: https://lists.gnu.org/archive/html/emacs-orgmode/2010-12/msg00410.html
- (3089)How to define a hierarchy of tags in org-mode?
If you write:
#+TAGS: [ GTD : Control Persp ]
#+TAGS: [ Control : Context Task ]
#+TAGS: [ Persp : Vision Goal AOF Project ]
It is equivalent to the following hierarchy:
- ‘GTD’
+ ‘Persp’
- ‘Vision’
- ‘Goal’
- ‘AOF’
- ‘Project’
+ ‘Control’
- ‘Context’
- ‘Task’
You can also use the :startgrouptag, :grouptags and :endgrouptag keyword directly when setting org-tag-alist:
(setq org-tag-alist '((:startgrouptag)
("GTD")
(:grouptags)
("Control")
("Persp")
(:endgrouptag)
(:startgrouptag)
("Control")
(:grouptags)
("Context")
("Task")
(:endgrouptag)))
From: https://orgmode.org/manual/Tag-Hierarchy.html#Tag-Hierarchy
- (3090)Important key bindings for playing with list in org-mode
C-c - Toogle bullets style (‘-’, ‘+’, ‘*’, ‘1.’, ‘1)’)
C-c * Turn a plain list item into a headline
C-c C-* Turn the whole plain list into a subtree of the current heading.
C-c ^ Sort the plain list.
M-LEFT/RIGHT Decrease/increase the indentation of an item, leaving children alone.
M-S-LEFT/RIGHT Decrease/increase the indentation of the item, including subitems.
M-RET Insert new item at current level
M-UP/DOWN Move the item including subitems up/down
C-c C-c Toggle the state of the checkbox
TAB Fold/unfold
From: https://orgmode.org/manual/Plain-Lists.html
- (3091)How to get multiple keyword sets in the same org-mode buffer?
(setq org-todo-keywords
'((sequence "TODO" "|" "DONE")
(sequence "REPORT" "BUG" "KNOWNCAUSE" "|" "FIXED")
(sequence "|" "CANCELED")))
The keywords should all be different,
C-S-RIGHT/LEFT Cycle from one TODO sub-sequence to the next. [NOTE: conflicts with Shift Selection]
S-RIGHT/LEFT Cycle through all keywords from all sub-sequences.
From: https://orgmode.org/manual/Multiple-sets-in-one-file.html#Multiple-sets-in-one-file
- (3092)How to add cell background colors to org-mode table in pdf export?
#+LATEX_HEADER: \usepackage[table]{xcolor}
* table test
| hi | there |
|------+------------------------------------|
| this | @@latex:\cellcolor{blue!25}@@ that |
| one | two |
From: https://emacs.stackexchange.com/questions/30304/add-cell-background-colors-to-org-mode-table-in-pdf-export
- (3093)How to display images inline in org-mode?
C-c C-x C-v (org-toggle-inline-images)
NOTE: An image is a link to an image file that does not have a description part.
#+CAPTION: This is the caption for the next figure link (or table)
#+NAME: fig:SED-HR4049
[[./img/a.jpg]]
From: https://orgmode.org/manual/Images.html
- (3096)How to solve "You need to run "make" or "make autoloads" from Org lisp directory"?
SOLUTION1: This is often due to the the org installation being newer than the emacs version which is running.
A simple solution is remove the org package or, if it is marked as "builtin" in the package-list-packages view, remove the entire ~/.emacs.d/elpa/org-20xxxxxx directory.
SOLUTION2: add following line in your .emacs
(require 'org-loaddefs)
From: https://emacs.stackexchange.com/questions/28474/how-can-i-fix-my-org-loaddefs-el/36670#36670
- (3119)How to reload Emacs configuration, when it is written in litterate org mode?
M-x org-babel-load-file "~/.emacs.d/config.org"
or add the following code in your .emacs:
(defun config-reload ()
"Reloads the configuration file"
(interactive)
(org-babel-load-file (concat user-emacs-directory "config.org"))
)
(global-set-key (kbd "C-c r") 'config-reload)
From: https://github.com/TediCreations/.emacs.d#reloading-the-configuration
- (3134)How to configure JDEE with OpenJDK 11?
Problem 1: version is not supported => hack the entry to make Emacs think it is another version
Problem 2: the version number is badly parsed => replace 1.8 with 8 (or the converse?)
1. Add a JDK entry in JDEE config
- M-x customize-variable
- jde-jdk-registry
- Copy the JDK 11 config to a new entry
- Change the "Version" field to 8,9 or 10 instead of 1.xxx (or converse)
- Save for future sessions
2. Select this JDK as the default
- M-x customize-variable
- jde-jdk
- Select the new entry
- Save for future sessions
From: https://github.com/jdee-emacs/jdee/issues/170
http://jdee.sourceforge.net/jdedoc/html/jde-ug/jde-ug-content.html#RegisterSelectJDK
- (3143)How to prevent generation of TOC when exporting to LaTeX/PDF in org mode?
#+OPTIONS: toc:nil
toc
Toggle inclusion of the table of contents, or set the level limit (org-export-with-toc).
From: https://stackoverflow.com/questions/35405702/how-do-i-extend-the-level-at-which-section-numbering-stops/53306369#53306369
https://orgmode.org/manual/Export-Settings.html
- (3144)How to prevent generation of number lists instead of sections when exporting to LaTeX/PDF in org mode?
#+OPTIONS: H:1 num:nil
H
Set the number of headline levels for export (org-export-headline-levels). Below that level, headlines are treated differently. In most back-ends, they become list items.
num
Toggle section-numbers (org-export-with-section-numbers). When set to number N, Org numbers only those headlines at level N or above. Set ‘UNNUMBERED’ property to non-nil to disable numbering of heading and subheadings entirely. Moreover, when the value is ‘notoc’ the headline, and all its children, do not appear in the table of contents either (see Table of Contents).
From: https://stackoverflow.com/questions/35405702/how-do-i-extend-the-level-at-which-section-numbering-stops/53306369#53306369
https://orgmode.org/manual/Export-Settings.html
- (3180)How to insert a UTF-8 char by name in Emacs?
M-x insert-char <name>
or, equivalent:
C-x 8 Return <name> Return
For example, try insert ->. Its name is “RIGHTWARDS ARROW”.
WHAT'S MAGIC: you can use the Tab to auto-complete the names!!!
From: http://ergoemacs.org/emacs/emacs_n_unicode.html#Insert%20a%20Unicode%20character%20by%20name
https://www.emacswiki.org/emacs/UnicodeEncoding
- (3181)How to get the characteristics/(UTF-8)name/representation/... of any char in Emacs?
Place the cursor on the char, then:
M-x describe-char
From: http://ergoemacs.org/emacs/elisp_unicode_representation_in_string.html
- (3184)How to insert numbers (1., 2., 3.) or letters (A., B., C.) at the beginning of each lines of a region?
I] To enter numbers
- select a region
- M-x rectangle-number-lines
II] To enter letters
- select a region
- C-u M-x rectangle-number-lines
- select 65 as first number
- select %c as format
From: http://ergoemacs.org/emacs/emacs_insert-alphabets.html
- (3203)How to make Emacs UI more modern?
Install packages:
- awesome-tab (tabs à la Firefox for opened buffers)
https://github.com/manateelazycat/awesome-tab
- all-the-icons (icons for each tabs according to buffer content)
(and run M-x all-the-icons-install-fonts)
https://github.com/domtronn/all-the-icons.el
- icons-mode (icons in the mini-buffer/bottom bar)
https://github.com/ryuslash/mode-icons
- (3204)How to use Emacs like a spreadsheet?
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
* Simple formulas (Set with = & @Line$Col / C-c C-c to evaluate)
| Student | Maths | Physics | Mean |
|----------+-------+---------+------|
| Bertrand | 13 | 09 | 11 |
| Henri | 15 | 14 | 14.5 |
| Arnold | 17 | 13 | 15 |
|----------+-------+---------+------|
| Means | 15 | 12 | 13.5 |
#+TBLFM: $4=vmean($2..$3)::@5$2=vmean(@2$2..@4$2)::@5$3=vmean(@2$3..@4$3)
* Maths expression computations (Calc)
https://www.gnu.org/software/emacs/manual/html_node/calc/Calculus.html#Calculus
|-------------+---+-----+--------------------------------------|
| Func | n | x | Result |
|-------------+---+-----+--------------------------------------|
| exp(x) | 1 | x | 1 + x |
| exp(x) | 2 | x | 1 + x + x^2 / 2 |
| exp(x) | 3 | x | 1 + x + x^2 / 2 + x^3 / 6 |
| x^2+sqrt(x) | 2 | x=0 | x*(0.5 / 0) + x^2 (2 - 0.25 / 0) / 2 |
| x^2+sqrt(x) | 2 | x=1 | 2 + 2.5 x - 2.5 + 0.875 (x - 1)^2 |
| tan(x) | 3 | x | x pi / 180 + 5.72e-8 x^3 pi^3 |
|-------------+---+-----+--------------------------------------|
#+TBLFM: $4=taylor($1,$3,$2);n3
|-------------+---+---------------------+-------------------------|
| Func | x | Deriv | Integr |
|-------------+---+---------------------+-------------------------|
| x | x | 1 | x^2 / 2 |
| exp(y) | y | exp(y) | exp(y) |
| log(x) | x | 1 / x | x ln(x) - x |
| sin(z) | z | cos(z) pi / 180 | -180 cos(z) / pi |
| x^2+sqrt(x) | x | 2 x + 0.5 / sqrt(x) | x^3 / 3 + 2:3 sqrt(x^3) |
| tan(x) | x | sec(x)^2 pi / 180 | 180 ln(sec(x)) / pi |
|-------------+---+---------------------+-------------------------|
#+TBLFM: $3=deriv($1,$2);n3::$4=integ($1,$2);n3
* Plot (ASCII: M-x orgtbl-ascii-plot / GUI: M-x org-plot/gnuplot)
#+PLOT: title:"Citas" ind:1 deps:(3) type:2d with:histograms set:"yrange [0:]"
| Sede | Max cites | H-index | |
|-----------+-----------+---------+--------------|
| Chile | 257.72 | 21.39 | WWWWWWWWWWWW |
| Leeds | 165.77 | 19.68 | WWWWWWWWWH |
| Sao Paolo | 71.00 | 11.50 | |
| Stockholm | 134.19 | 14.33 | WWWc |
| Morelia | 257.56 | 17.67 | WWWWWWW! |
#+TBLFM: $4='(orgtbl-ascii-draw $3 11.5 21.39 12)
From: https://orgmode.org/org.html#Advanced-features
- (3223)How to manage BibTeX entries with org-mode?
----- .emacs
;; manage citations
(require 'org-bibtex)
;; export citations
(require 'ox-bibtex)
(setq org-bibtex-file "papers.org")
---- papers.org
* The Org Mode 7 Reference Manual-Organize your life with GNU Emacs
:PROPERTIES:
:TITLE: The Org Mode 7 Reference Manual-Organize your life with GNU Emacs :manual:
:BTYPE: book
:CUSTOM_ID: dominik2010org
:AUTHOR: Dominik, Carsten
:YEAR: 2010
:PUBLISHER: Network Theory Ltd.
:END:
This line is my annotation for the entry of Org Mode 7 Reference Manual.
* A multi-language computing environment for literate programming and reproducible research :babel:
:PROPERTIES:
:BTYPE: article
:AUTHOR: Eric Schulte and Dan Davidson and Tom Dye and Carsten Dominik
:JOURNAL: Journal of Statistical Software
:VOLUME: 46
:NUMBER: 3
:YEAR: 2012
:MONTH: January
:CUSTOM_ID: schulte2012babel
:END:
Some annotation about babel.
From: https://gewhere.github.io/org-bibtex
- (3224)How to work with BibTeX files and entries when exporting-to-latex from org-mode?
#+BIBLIOGRAPHY: refs plain
- refs is the name of the BibTeX file (.bib extension omitted)
- plain is the bibliographystyle
You can then call org-reftex-citation (bound to C-c C-x [ by default) to insert references.
Requires:
---- .emacs
(require 'org)
(require 'ox-bibtex)
You can redefine the insert-citation keys with:
(define-key org-mode-map (kbd "C-c [") 'org-reftex-citation)
From: https://emacs.stackexchange.com/questions/3375/loading-bibtex-file-in-org-mode-file/3381#3381
- (3229)How to clean unused packages in Emacs (a.k.a. What is the equivalent of apt autoremove for Emacs packages)?
M-x package-autoremove
emacs -q -batch -l ~/.emacs.d/config.el -f package-autoremove -kill
From: https://github.com/purcell/emacs.d/issues/33#issuecomment-481571681
https://github.com/purcell/emacs.d/issues/33#issuecomment-481250991
- (3269)How to use Magit (Git inside Emacs)?
- Getting started with Magit is really easy:
- M-x magit-status to see git status, and in the status buffer:
- s to stage files
- c c to commit (type the message then C-c C-c to actually commit)
- b b to switch to another branch
- Other handy keys:
- P u to do a git push
- F u to do a git pull
- Try to press TAB
You might also want to read the official Getting-started guide: https://magit.vc/manual/magit/Getting-Started.html
From: https://www.emacswiki.org/emacs/Magit#toc1
- (3284)How to configure python-mode like ESS-mode, i.e. send/evaluate region with C-Ret?
What you want is to change what H-x does when in python-mode so that instead of running eval-region (which only works on elisp) it calls python-shell-send-region. You can use define-key to do this:
(with-eval-after-load 'python
(define-key python-mode-map (kbd "H-x") #'python-shell-send-region))
From: https://emacs.stackexchange.com/questions/17415/are-keybindings-mode-dependent-how-can-i-customize-this/17416#17416
- (3288)How to get items appear sequentially rather than all at once with org-beamer?
SOLUTION1: for the whole presentation
#+BEAMER: \beamerdefaultoverlayspecification{<+->}
SOLUTION2: for a specific itemize
- <+-> appear from start (could be <1->, but <+-> is better in case we change item order)
- <2> only showed in the second "page of the slide"
- <3-4> showed in pages 3 and 4
- <4-> showed from slide 4
- always showed
- <5-> showed from slide 5
SOLUTION3: general solution
- @@latex: <1->@@ item1
- @@latex: <2->@@ item2
From: https://emacs-orgmode.gnu.narkive.com/dFCVzTqN/org-beamer-how-to-get-items-appear-sequentially-rather-than-all-at-once
- (3289)How to export org-comments as latex-comments in org-latex?
SOLUTION1: in the text file
#+LaTeX: comment
or
#+BEGIN_LaTeX
\begin{comment}
comment
\end{comment}
#+END_LaTeX
SOLUTION2: by hacking the exporter code "org-latex.el"
replace :comments nil with :comments "%% %s"
From: https://stackoverflow.com/questions/9873365/export-comments-as-comments
- (3292)How to auto-scale images to fit into a slide in org-beamer?
SOLUTION1: With org-beamer's tools
#+ATTR_LATEX: :width 1.06\textwidth
[[file:curves.jpg]]
This is described here: https://orgmode.org/manual/Images-in-LaTeX-export.html
For specifying image ‘:width’, ‘:height’, and other ‘:options’, use this syntax:
#+ATTR_LATEX: :width 5cm :options angle=90
[[./img/sed-hr4049.pdf]]
SOLUTION2: Directly in LaTeX
#+LaTeX:\includegraphics[width = 1.06\textwidth]{curves.jpg}
From: https://emacs.stackexchange.com/questions/47649/how-to-auto-scale-images-to-fit-into-a-slide-in-org-mode-export-to-beamer/52476#52476
- (3294)How to change font size for example environment in org-beamer?
#+LaTeX: {\footnotesize
org stuff here
#+LaTeX: }
From: https://lists.gnu.org/archive/html/emacs-orgmode/2014-10/msg00387.html
- (3295)How to change font/shrink size of a full slide in org-beamer?
* The frame title
:PROPERTIES:
:BEAMER_opt: shrink=10
:END:
From: https://lists.gnu.org/archive/html/emacs-orgmode/2014-10/msg00501.html
- (3299)How to edit a Jupyter/IPython Notebook in Emacs?
Emacs IPython Notebook (EIN) lets you run Jupyter (formerly IPython) notebooks within Emacs. It channels all the power of Emacs without the idiosyncrasies of in-browser editing.
No require statements, e.g. (require 'ein), are necessary, contrary to the prevailing documentation_, which should be disregarded.
Org_ users please find ob-ein, a jupyter Babel backend.
From: https://awesomeopensource.com/project/millejoh/emacs-ipython-notebook
- (3306)How to get filename auto-completion when creating a link in org-mode?
C-u C-c C-l directly inserts a link /to a file/, thus with completion
C-c C-l inserts a link. If you type a prefix (e.g. "file:") + Hit Ret, completion for this type of prefix occurs
Unfortunately it does not when editing an existing link :{
From: https://orgmode.org/manual/Handling-Links.html#index-C_002dc-C_002dl
- (3324)How to use dired?
- "+" creates a directory
- "e" edits file
- "d" flags a file for deletion (places a D on the left margin)
- "D" deletes file immediately
- "#" flags auto-save files (whose names start&end with #) for deletion
- "~" flags all the backup files (whose names end with ~) for deletion.
- "u" unflags for deletion the file ("u"ndelete) (then move down one line)
- "Del" unflags, but in the other direction (unflags previous file in the list and then moves up one line)
- "<x>C" copies a file (prefix with number to select following files too)
- "R" moves ("R"enames) a file
- "<x>m" mark files
+ %l for renaming to lowercase
+ %u for renaming to uppercase
+ put the cursor on another file + "=" => diff files
- "t" toggles the marks
- "* *" marks executable files
- "* /" marks directories
- "* @" marks symbolic links.
- "%m" marks files whose filenames match a regular expression
- "!" executes shell command on file (use "*" to replace the name of the file in the command)
- "g" refreshes display
- "x" executes marked actions
- "C-x d" Open Directory
- "A" Search Files
- "Q" Query Replace in Files
- "^" Move to parent directory
From: https://dinasis.com/oliver/Learning_GNU_Emacs/gnu3-CHP-5-SECT-2.html
- (3328)How to add [fragile] to a LaTeX Beamer slide in org-beamer?
:PROPERTIES:
:BEAMER_OPT: fragile
:END:
or
#+PROPERTY: BEAMER_OPT fragile
From: https://lists.gnu.org/archive/html/emacs-orgmode/2016-07/msg00116.html
- (3331)How to quote/insert LaTeX code in org-mode?
GOAL: when exporting .org file to .tex, insert some LaTeX code as-is in the exported TeX file.
The LaTeX export back-end can insert any arbitrary LaTeX code, see Embedded LaTeX. There are three ways to embed such code in the Org file and they all use different quoting syntax.
SOLUTION1:
Inserting in-line quoted with @ symbols:
Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
SOLUTION2:
Inserting as one or more keyword lines in the Org file:
#+LATEX: any arbitrary LaTeX code
SOLUTION3:
Inserting as an export block in the Org file, where the back-end exports any code between begin and end markers:
#+BEGIN_EXPORT latex
any arbitrary LaTeX code
#+END_EXPORT
From: https://orgmode.org/manual/Quoting-LaTeX-code.html
- (3335)How to get completion/refactoring/... for LaTeX code in Emacs?
1. Install OS::texlab (https://github.com/latex-lsp/texlab/releases) or digestif (https://github.com/astoff/digestif)
2. Install Emacs::lsp-mode and Emacs::lsp-latex (https://github.com/ROCKTAKEY/lsp-latex)
3. Configure Emacs::lsp-latex-texlab-executable variable
4. Setup LSP to handle .tex & .bib files in Emacs::config.org
;;; For LaTeX
(with-eval-after-load "tex-mode"
(add-hook 'tex-mode-hook 'lsp)
(add-hook 'latex-mode-hook 'lsp))
;; For BibTeX
(with-eval-after-load "bibtex"
(add-hook 'bibtex-mode-hook 'lsp))
From: https://github.com/ROCKTAKEY/lsp-latex
- (3336)How to escape the * in org-mode to prevent bold fontification (a.k.a. How to disable org-mode special chars)?
PROBLEM: let's say you want to write *shrug* in a text without having it printed in bold.
SOLUTION1: If you just want the bold only not to appear in exported files
You can just use =*shrug*=
SOLUTION2: If you want the org-char not to be interpreted even in the org file the you can use the ZERO WIDTH SPACE unicode char (working, but not recommended hack)
Adding a zero-width space char before the first asterisk or after the second asterisk.
EXAMPLE:
This is some *bold* test and this is ​[ZWS]*not bold*.
This is some *bold* test and this is *not bold*​[ZWS].
([ZWS] indicates the ZERO WIDTH SPACE unicode char in the snippets above)
You can enter the ZERO WIDTH SPACE (unicode name) by doing C-x 8 RET ZERO WIDTH SPACE RET or C-x 8 RET 200b RET.
SOLUTION3: If you want the org-char not to be interpreted even in the org file (clean solution)
This answer is inspired after collective suggestions on the emacs-org-mode GNU list to use the org-entity ( C-h i g (org) Special symbols ) \ast{} instead of zero width space characters (which I suggested in my other answer here).
Below is a generic solution where the user does not need to remember the org entities for various symbols. It inserts the org entity (if available) when user does C-u SYMBOL; works for C-u *, C-u /, C-u =, etc.
(defun modi/org-entity-get-name (char)
"Return the entity name for CHAR. For example, return \"ast\" for *."
(let ((ll (append org-entities-user
org-entities))
e name utf8)
(catch 'break
(while ll
(setq e (pop ll))
(when (not (stringp e))
(setq utf8 (nth 6 e))
(when (string= char utf8)
(setq name (car e))
(throw 'break name)))))))
(defun modi/org-insert-org-entity-maybe (&rest args)
"When the universal prefix C-u is used before entering any character,
insert the character's `org-entity' name if available.
If C-u prefix is not used and if `org-entity' name is not available, the
returned value `entity-name' will be nil."
;; It would be fine to use just (this-command-keys) instead of
;; (substring (this-command-keys) -1) below in emacs 25+.
;; But if the user pressed "C-u *", then
;; - in emacs 24.5, (this-command-keys) would return "^U*", and
;; - in emacs 25.x, (this-command-keys) would return "*".
;; But in both versions, (substring (this-command-keys) -1) will return
;; "*", which is what we want.
;; http://thread.gmane.org/gmane.emacs.orgmode/106974/focus=106996
(let ((pressed-key (substring (this-command-keys) -1))
entity-name)
(when (and (listp args) (eq 4 (car args)))
(setq entity-name (modi/org-entity-get-name pressed-key))
(when entity-name
(setq entity-name (concat "\\" entity-name "{}"))
(insert entity-name)
(message (concat "Inserted `org-entity' "
(propertize entity-name
'face 'font-lock-function-name-face)
" for the symbol "
(propertize pressed-key
'face 'font-lock-function-name-face)
"."))))
entity-name))
;; Run `org-self-insert-command' only if `modi/org-insert-org-entity-maybe'
;; returns nil.
(advice-add 'org-self-insert-command :before-until #'modi/org-insert-org-entity-maybe)
So when the user types C-u *, \ast{} is inserted and the below message is displayed in the echo area,
Inserted ‘org-entity’ \ast{} for the symbol *.
If org-pretty-entities is set to t above, the inserted \ast{} will be displayed as *.
If an org-entity does not exist for a character X and if the user does C-u X, X is simply inserted 4 times (as C-u would usually do).
From: https://emacs.stackexchange.com/questions/16688/how-can-i-escape-the-in-org-mode-to-prevent-bold-fontification#answer-16689
- (3337)How to know who edited a particular cell on a Google Sheet?
SOLUTION1: recent feature
- Right clic on cell
- Select "Show Edit History"
or
- File > See revision history
SOLUTION2: previous version
1. Go to the spreadsheet.
2. Tools - Script Editor
3. Paste in this:
function checkEdits() {
var thisSS = SpreadsheetApp.getActiveSpreadsheet();
var sheet1 = thisSS.getSheetByName('Sheet1');
// Change this cell to whichever one you want to watch.
var specialCell = sheet1.getRange("A1");
if (thisSS.getActiveCell().getA1Notation() == specialCell.getA1Notation()) {
var htmlEmail = "Cell " + specialCell.getA1Notation() +
" edited by " + Session.getActiveUser().getEmail();
GmailApp.sendEmail("YOUR EMAIL HERE", "Spreadsheet Update " + new Date(), "", {htmlBody:htmlEmail} );
}
}
4. Save (the disk icon).
5. Open triggers (the timer/clock icon). Choose "checkEdits - From spreadsheet - On edit".
And that's it. With your email in here, you'll get an email every time someone changes A1. You can change A1 to whichever cell you want.
From: https://www.quora.com/Is-there-a-way-to-know-who-edited-a-particular-cell-on-a-Google-Sheet?share=1
- (3357)What are the package to add to benefit from all the features of LSP-mode?
- company-mode for completion popups.
- dap-mode if your language is supported by the debugger.
- flycheck if you prefer the more popular flycheck over renewed flymake. lsp-mode will automatically pick it up.
- helm-lsp provides on type completion alternative of xref-apropos using helm.
- lsp-ui for fancy sideline, popup documentation, VScode-like peek UI, etc.
- lsp-treemacs for various tree based UI controls (symbols, errors overview, call hierarchy, etc.)
- lsp-ivy provides on type completion alternative of xref-apropos using ivy.
- lsp-treemacs displays everything as a tree (Project structure, Symbols in file, Call stack, Errors list)
== For Python
- Rope for Completions and renaming
- Pyflakes linter to detect various errors
- McCabe linter for complexity checking
- pycodestyle linter for style checking
- pydocstyle linter for docstring style checking (disabled by default)
- autopep8 for code formatting
- YAPF for code formatting (preferred over autopep8)
- pip::pyls-mypy Mypy type checking for Python 3
- pip::pyls-isort Isort import sort code formatting
- pip::pyls-black for code formatting using Black
From: https://emacs-lsp.github.io/lsp-mode/page/installation/#vanilla-emacs
https://emacs-lsp.github.io/lsp-mode/#overview
https://github.com/emacs-lsp/lsp-treemacs#synchronization
https://github.com/palantir/python-language-server#installation
- (3361)How to debug the statup (time) of Emacs?
First verify that the raw Emacs (no config, no package, etc.) is working correctly/smoothly:
emacs -Q
SOLUTION1:
emacs --debug-init
SOLUTION2:
- Install Emacs::ESUP package
https://github.com/jschaf/esup
- M-x esup
SOLUTION3:
- Install Emacs::profile-dot-emacs
https://raw.githubusercontent.com/abo-abo/profile-dotemacs/master/profile-dotemacs.el
- Run it
emacs -Q -l <PATH>/profile-dotemacs.el -f profile-dotemacs
SOLUTION4: Not really for the startup, but interesting
- Invoke M-x profiler-start RET RET (the second RET is to confirm cpu);
- Do some typing, preferably an entire paragraph or more;
- Invoke M-x profiler-report.
From: https://emacs.stackexchange.com/questions/5359/how-can-i-troubleshoot-a-very-slow-emacs#5438
https://www.gnu.org/software/emacs/manual/html_node/elisp/Profiling.html
- (3365)What are the name of the various components of the Emacs GUI?
See https://www.emacswiki.org/pics/static/DrewsEmacsWindowCallouts.jpg
- Buffer: An opened file
- Menu Bar: the top menu line
- Windows: the various buffers displayed
- Frame: the whole window
- Mode Line: the status bar at the bottom of each buffer/windows with information about the opened file
From: https://www.emacswiki.org/emacs/ModeLine
- (3383)How to render LaTeX-math formulae inline in org-mode?
Hit "C-c C-x C-l" in a LaTeX part
- This requires "texlive-full" to be installed + "dvipng" or "imagemagick"
- You might need to take a look at "org-preview-latex-default-process"
From: https://emacs.stackexchange.com/questions/33603/why-wont-my-latex-render-in-org-mode
- (3395)How to display the error when a line is signaled as "bad" in LSP?
It's probably flycheck / flymake that generates/displays the error, thus following commands should work:
M-x flymake-show-diagnostics-buffer
M-x flycheck-list-errors
Also the lsp-treemacs+lsp-ui Emacs package can help:
M-x lsp-treemacs-errors-list
From: https://www.reddit.com/r/emacs/comments/ezxtc5/lspmode_show_errors/
- (3400)How to install latest version of org mode?
PROBLEM: org-mode is builtin Emacs, so if you install a newer version you\'ll very probably get errors due to loading of incompatible parts of both versions.
SOLUTION:
1. Install the newest version
For instance from ELPA in ~/.emacs.d/elpa/
2. Create a link to this specific version
ln -s ~/.emacs.d/elpa/org-mode-2021xxxx ~/.emacs.d/elpa/org-mode-latest
3. Add the following lines in *~/.emacs*, BEFORE any loading of org-mode, i.e. before loading the .org config file!
(add-to-list \'load-path \&quot;~/.emacs.d/elpa/org-mode-latest/lisp\&quot;)
(require \'org-loaddefs)
From: https://emacs.stackexchange.com/a/55415
https://orgmode.org/manual/Installation.html#Installation
- (3403)How to import code to be prettified from external file in org-beamer?
#+INCLUDE: ./path/to/file.java src java
From: https://orgmode.org/manual/Include-Files.html
- (3404)How to import text from another org-beamer file?
#+INCLUDE: \&quot;/path/to/file.org\&quot; :minlevel 1
minlevel indicates at which level the file is inserted (its outline levels be shifted so that its level one becomes level 2 in main file!)
You can also import only some sections
#+INCLUDE: \&quot;./paper.org::*conclusion\&quot;
#+INCLUDE: \&quot;./paper.org::#theory\&quot;
Or only some specific lines
#+INCLUDE: \&quot;./paper.org\&quot; :lines 1-20
From: https://orgmode.org/manual/Include-Files.html
- (3405)How to create a \\item that starts with \'&lt;[0-9]\' in org-beamer (a.k.a. How to prevent org-beamer to interpret &lt;[0-9] as the overlay specifier)?
Inserting the \&quot;&lt;\&quot; in Maths mode works but you need a space between \'$\' and the number
---- file.org
- $&lt;$ 7ms
----
From: https://emacs.stackexchange.com/questions/27586/org-beamer-export-vs-symbol
- (3407)How to set a LaTeX attribute (e.g. image size) for a code-generated (BEGIN_SRC) image?
Put
#+ATTR_LATEX: :height xxx :width yyy
right before the #+RESULTS: line
From: https://stackoverflow.com/questions/47796307/org-mode-set-latex-attribute-in-code-generated-image#47799379
- (3409)How to change font size in code listings in org-beamer?
SOLUTION1:
@@latex: \\lstset{basicstyle=\\ttfamily\\scriptsize}@@
SOLUTION2:
#+ATTR_LATEX: :options basicstyle=\\ttfamily\\scriptsize
#+begin_src C
some code
#+end_src
From: https://emacs.stackexchange.com/questions/23871/how-to-change-font-size-in-code-listings-in-org-mode-beamer
- (3410)Howto include external files in org-mode (e.g. other org-mode files or source files)?
SOLUTION1: for source files
#+INCLUDE: \"~/.emacs\" src emacs-lisp
Also see Tip#3403
SOLUTION2: for org-mode files
#+INCLUDE: \"~/my-book/chapter2.org\" :minlevel 1
Also see Tip~3404
From: https://orgmode.org/manual/Include-Files.html
https://emacs.stackexchange.com/questions/9853/exporting-org-mode-includes-as-latex-lstinputlisting-or-equivalent/9864#9864
- (3415)How to define (the size of) the default font from Emacs .org config file?
(set-face-attribute \'default nil :font myfont :height 144)
From: https://github.com/yanivdll/.emacs.d/blob/master/config.org#settings
- (3416)How to find the default/current font in use by Emacs?
Move the cursor on a character with the font type you want to get information about, then
M-x describe-font
From: https://superuser.com/questions/422968/how-to-find-out-current-font-used-in-my-emacs
- (3423)How to add [fragile] to an org-beamer slide?
* The slide
:PROPERTIES:
:BEAMER_OPT: fragile
:END:
or
* The slide
#+PROPERTY: BEAMER_OPT fragile
From: https://lists.gnu.org/archive/html/emacs-orgmode/2016-07/msg00116.html
- (3425)How to create an "empty" slide, with only a large picture on it in org-beamer?
SOLUTION: the trick is to use the [plain] slide type
* The slide
:PROPERTIES:
:BEAMER_OPT: plain
:END:
@@latex: \hspace*{-1cm}%@@
#+ATTR_LATEX: :center nil :width 1.2\textwidth
[[file:/path/to/image.ext]]
NOTE: use \paperwidth instead of 1.2\textwidth?
From: https://tex.stackexchange.com/questions/3915/image-on-full-slide-in-beamer-package
- (3426)How to write your notes in an org-beamer presentation?
To keep your presentation notes (reminders about what to say), add a heading below the frame, and select the note environment with C-c C-b.
#+LATEX_HEADER: \setbeameroption{show notes}
* Frame title
** Some note
:PROPERTIES:
:BEAMER_env: note
:END:
This is a note.
- Stress this first.
- Then this.
** First actual presentation block
From: https://github.com/fniessen/refcard-org-beamer#note
- (3427)How to have some slides inserted in the middle of a slide?
PROBLEM:
- You start presenting a few points in a slide
- Then, you want to "pause" the slide to present some other slides as a parenthesis
- Then, you want to "continue" the slide that you previously started
SOLUTION: (NOT TRIED) use "againframe". You'll need to provide:
- BEAMER_ref property to refer, using link syntax, to (the label of) the frame being resumed, and
- BEAMER_act property to set the overlay specification.
From: https://github.com/fniessen/refcard-org-beamer#againframe
- (3428)How to terminate a block in org-beamer (a.k.a. How to stop a multicolumn env)?
PROBLEM: LaTeX uses braces to identify the code blocks. org-beamer does not mark end of blocks. So for example, when you want to write something like:
* Slide
@@latex: { \small @@
** Block1
** Block2
- item1
- item2
@@latex: } @@
** Block3
org-beamer does not know if the final LaTeX '}' should end up inside the itemize, between the end of itemize and Block2 or after Block2.
SOLUTION: You can force the ending of a block
* Frame
** Block1
** Block2
** End of block
:PROPERTIES:
:BEAMER_env: ignoreheading
:END:
NOTE: This can be used to stop a multi-column environment
From: https://github.com/fniessen/refcard-org-beamer#ignoreheading
https://stackoverflow.com/questions/48129974/org-mode-beamer-stop-a-2-column-block-and-display-following-text-throughout-pag
- (3429)How to make overlays work with "ignoreheading" in org-beamer?
PROBLEM: Using ":BEAMER_env: ignoreheading" and ":BEAMER_act: xxx" on the same slide does not work well.
SOLUTION1: use
#+BEAMER: \pause[\thebeamerpauses]
SOLUTION2: Manually inserting \pause is more reliable than :BEAMER_act: xxx
From: https://emacs.stackexchange.com/questions/46106/ignoreheading-beamer-environment-doesnt-work-with-beamer-act-overlay/46138#46138
- (3437)How to dis/enable wrapping of lines?
General command is:
"M-x toggle-truncate-lines"
SOLUTION1: for a single file, add this line in the header:
# -*- truncate-lines: nil -*-
SOLUTION2: by defining a key binding
(global-set-key (kbd "C-x p") 'toggle-truncate-lines)
From: https://emacs.stackexchange.com/questions/30171/how-do-i-toggle-soft-wrapped-lines-in-org-mode/61268#61268
- (3444)How to upgrade packages via script?
---- upgrade_Emacs_packages.sh
#!/usr/bin/emacs -script
(setq package-archives
(quote
(("gnu" . "http://elpa.gnu.org/packages/";)
("melpa" . "http://melpa.org/packages/";)
("marmalade" . "https://marmalade-repo.org/packages/";)
("org" . "http://orgmode.org/elpa/";)))
package-menu-async nil)
(list-packages)
(package-menu-mark-upgrades)
(package-menu-execute t)
----
- (3447)How to open treemacs with any files, without erlated projects, like classical IDE?
---- emacs.org
#+BEGIN_SRC emacs-lisp
(setq treemacs-use-follow-mode t)
(setq treemacs-use-filewatch-mode t)
(setq treemacs-use-collapsed-directories 3)
(setq treemacs-is-never-other-window t)
(setq treemacs-show-hidden-files nil)
(setq projectile-require-project-root nil) ; do not ask for project-root when opening non-project file
(save-selected-window (treemacs-select-window)) ; prevents opening of *scratch* buffer
#+END_SRC
----
From: https://www.reddit.com/r/emacs/comments/kobq4x/open_treemacs_programmatically_not_working/
https://github.com/Alexander-Miller/treemacs/issues/258
- (3448)How to improve Emasc speed?
Install Emacs "Garbage Collector Magic Hack" package. It enforces a sneaky Garbage Collection strategy to minimize GC interference with user activity.
From: https://github.com/emacsmirror/gcmh
- (3450)How to automatically accept re-opening of a file that has changed on disk?
Add this line in your .emacs:
(global-auto-revert-mode t)
From: https://stackoverflow.com/questions/1480572/how-to-have-emacs-auto-refresh-all-buffers-when-files-have-changed-on-disk
- (3452)How to make Emacs stop asking "Active processes exist; kill them and exit anyway"?
Add following line in your .emacs
(setq confirm-kill-processes nil)
From: https://stackoverflow.com/questions/2706527/make-emacs-stop-asking-active-processes-exist-kill-them-and-exit-anyway/39806660#39806660
- (3454)How to have Emacs automatically reload a (all) buffer(s) when files have changed on disk?
Add the following line in your .emacs:
(global-auto-revert-mode t)
From: https://stackoverflow.com/questions/1480572/how-to-have-emacs-auto-refresh-all-buffers-when-files-have-changed-on-disk/1481706#1481706
- (3465)How to manage a (bibtex) bibliography with org-mode?
1. Use org-ref : add following line to your config file
(require 'org-ref) ; To enable references in org/org-beamer/org-latex
2. In a .bib file, you can use
- "Packages" (now included in org-ref ?)
- doi-utils to insert a bibtex entry from a DOI
- org-ref-url-utils to drag-n-drop urls to create bibtex entries
- org-ref-arxiv to add bibtex entries from arxiv.org
- org-ref-pubmed to add bibtex entries from PMID
- Commands
- org-ref-bibtex-* to open the corresponding site on a query based on the selected text
- org-ref-{pubmed,wos,google-scholar...} to search
3. In a .org file, you can use
- C-c ] to open a GUI to insert a ref with easy filtering by pattern
or (if you enter a title in "pattern" field to search on various repo for the entry)
- org-ref-browser to view all the entries
From: https://github.com/jkitchin/org-ref#some-other-useful-libraries-in-org-ref
- (3467)How to manipulate (select text, annotate, etc.) PDFs directly inside Emacs?
Use pdf-tools::PDFView mode rather than the default DocView mode
To install it, use the system distribution "apt install elpa-pdf-tools" (It's curiously not in MELPA, contrarily to what the github README says).
To activate it, I add the following line in my .emacs config (not sure it's the correct line, though)
(add-to-list 'auto-mode-alist '("\\.pdf$" . pdf-tools-install))
From: https://emacs.stackexchange.com/questions/19686/how-to-use-pdf-tools-pdf-view-mode-in-emacs
- (3469)How to prevent a section from being inserted in the TOC in org-LaTeX/Beamer?
* Federated Learning @LabHC
:PROPERTIES:
:UNNUMBERED: t
:END:
From: https://emacs.stackexchange.com/questions/32926/unnumbered-section-among-numbered-ones-in-org-mode
https://tex.stackexchange.com/questions/52460/how-can-numbering-of-specific-headings-be-disabled-in-org-modes-latex-export/127287#127287
https://orgmode.org/manual/Drawers.html
- (3484)How to get the Current Value of a Variable?
M-x describe-variable <-> C-h v
From: https://www.gnu.org/software/emacs/manual/html_node/eintr/See-variable-current-value.html
- (3485)How to save multiple cut/paste elements in Emacs?
Use "registers"
C-x r s <r> -> "s"ave to register <r>
C-x r i <r> -> "i"nserts register <r>
From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Registers.html
- (3488)How to open a file which name is cited in another file (e.g. the header of a C file or a .tex \include)?
Use the find-file-at-point
From: https://www.emacswiki.org/emacs/FindFileAtPoint
- (3502)How to debug C/C++ code in Emacs?
- Install realgud from MELPA
- Use M-x load-library RET realgud RET to load RealGUD
- Use M-x realgud:pdb to start the debugger
- Useful keys:
n, F10 Next (aka “step overâ€, “step throughâ€)
s, SPC, F11 Step (aka “step intoâ€)
f, S-F11 Finish (aka “step outâ€, “returnâ€)
c, F5 Continue (run to next break point)
b, F9 Set breakpoint mouse2
D Clear breakpoint mouse2 (by number)
mouse middle Inspect variable under cursor (in tooltip)
q, S-F5 Quit
From: https://github.com/realgud/realgud
- (3514)How to work with Checkboxes in org-mode?
C-u C-c C-c on the first item of a list with no checkbox adds checkboxes to the rest of the list.
C-c C-c C-b (org-toggle-checkbox)
C-c C-x C-r (org-toggle-radio-button)
From: https://orgmode.org/manual/Checkboxes.html#index-ORDERED_002c-property-1
- (3520)How to automatically install Emacs packages by specifying a list of package names?
; list the packages you want
(setq package-list '(package1 package2))
; list the repositories containing them
(setq package-archives '(("elpa" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")))
; activate all the packages (in particular autoloads)
(package-initialize)
; fetch the list of packages available
(unless package-archive-contents
(package-refresh-contents))
; install the missing packages
(dolist (package package-list)
(unless (package-installed-p package)
(package-install package)))
From: https://stackoverflow.com/questions/10092322/how-to-automatically-install-emacs-packages-by-specifying-a-list-of-package-name/10093312#10093312
- (3526)How to make simple presentations in org-mode?
There are multiple possibilities:
- org-present [simplest]
- org-tree-slide [simple]
- org-Reveal
- epresent
- org-beamer [Richer but might require many raw LaTeX insertions]
From: https://geeksocket.in/posts/presentations-org-emacs/
https://alpha2phi.medium.com/using-emacs-for-presentation-6e1df7ff63fc
https://github.com/hexmode/ox-reveal
- (3528)How to solve error "ein:content-query-contents--error REQUEST-STATUS timeout DATA interrupt" when opening .ipynb in Emacs-EIN?
Seems to be related to preventing random javascript embedded in cell outputs from executing upon notebook-open.
Removing outputs cures the problem:
jupyter nbconvert --clear-output --inplace foo.ipynb
From: https://github.com/millejoh/emacs-ipython-notebook/issues/779
- (3537)What are the packages to install to benefit as much as possible from LSP-Python in Emacs?
NOTE: The palantir python-language-server (a.k.a. pyls/python-language-server) is deprecated, prefer using python-lsp-server (cf. links below)
pip install python-lsp-server
Then you can add companion packages:
- Rope for Completions and renaming
- Pyflakes linter to detect various errors
- McCabe linter for complexity checking
- pycodestyle linter for style checking
- pydocstyle linter for docstring style checking (disabled by default)
- autopep8 for code formatting
- YAPF for code formatting (preferred over autopep8)
Additional packages:
- pyls-flake8: Error checking using flake8.
- pylsp-mypy: MyPy type checking for Python >=3.6.
- pyls-isort: code formatting using isort (automatic import sorting).
- python-lsp-black: code formatting using Black.
- pyls-memestra: detecting the use of deprecated APIs.
- pylsp-rope: Extended refactoring capabilities using Rope.
From: https://github.com/python-lsp/python-lsp-server
https://github.com/palantir/python-language-server/issues/935
https://github.com/palantir/python-language-server
- (3547)How to make PDFTools::PDFView be the default PDF Viewer in AucTex?
- apt install elpa-pdf-tools
- Add these lines to .emacs:
(add-to-list 'auto-mode-alist '("\\.pdf$" . pdf-tools-install))
;; to use pdfview with auctex
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t) ;; not sure if last line is neccessary
;; to have the buffer refresh after compilation
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
From: https://emacs.stackexchange.com/questions/21755/use-pdfview-as-default-auctex-pdf-viewer
- (3551)How to change the way Emacs signals an error (a.k.a. How to switch off the sound Emacs makes when an error occurs)?
- To make the bell visual (flash screen on error)
(setq visible-bell 1) ; visual
- To disable the bell totally
(setq ring-bell-function 'ignore) ; nothing (no sound, no visual)
From: http://pragmaticemacs.com/emacs/using-a-visible-bell-in-emacs/
https://www.emacswiki.org/emacs/AlarmBell
- (3561)What are the other editors that can open Org-mode files?
- Vim : orgmode.nvim, vim-orgmode, and org.vim
- Atom : org-mode
- VS Code : vscode-org-mode
- Sublime : OrgExtended
- (3566)How to navigate history of entered values in Swiper?
PROBLEM: swiper uses arrows to nagivate the possibilities that match the (partial) expression you type. Using Up/Down without entering an entry does not do anything.
SOLUTION:
When you invoke swiper press:
- M-p to search for previously searched thing.
- M-n will let you search for the word under cursor.
- C-s will search for the next occurence.
From: https://emacs.stackexchange.com/questions/40556/swiper-get-last-search-term/40558#40558
- (3572)How to make Emacs a collaborative editing environment? (a.k.a. How to transfrom Emacs in an Etherpad-like system?)
https://www.emacswiki.org/emacs/Rudel
- (3573)Howto make Emacs kill buffer without asking first? (a.k.a. How to disable Emacs' prompt when killing buffers)
(setq kill-buffer-query-functions nil)
From: https://emacs.stackexchange.com/questions/14509/kill-process-buffer-without-confirmation/46087#46087
- (3574)How to make Emacs' org mode always display inline images at startup?
I] Definitively
In emacs config file:
(setq org-startup-with-inline-images t)
II] For a specific buffer
In the org buffer
#+STARTUP: inlineimages
#+STARTUP: noinlineimages
From: https://emacs.stackexchange.com/questions/14758/in-org-mode-how-to-always-display-inline-images-at-emacs-startup/14776#14776
- (3575)How to make Emacs' org mode always display LaTeX fragments at startup?
I] Definitively
In emacs config file:
(org-latex-preview)
(setq org-startup-with-inline-images t)
II] For a specific buffer
In the org buffer:
#+STARTUP: latexpreview
#+STARTUP: nolatexpreview
From: https://orgmode.org/manual/Previewing-LaTeX-fragments.html
https://www.reddit.com/r/orgmode/comments/fmqims/how_to_render_latex_inline_with_org_mode/
- (3581)Very small text-mode Emacs (-nw) alternatives
mg
JOE - Joe's Own Editor (jmacs)
JOVE - Jonathan’s Own Version of Emacs
EmACT by Eligis - a tiny, portable editor with Emacs UI
notGNU - tiny freeware (proprietary?) editor with Emacs UI
JED - S-Lang extensible editor (in Emacs emulation mode)
Rust Emacs
GNU Zile - ZILE Is Lossy Emacs
QEmacs - Quick Emacs
uEmacs MicroEmacs
From: https://github.com/emacs-containers
https://technomonastery.com/help/lightweight-emacs-editors/
https://linux.die.net/man/1/jmacs
https://github.com/troglobit/mg
- (3582)How to get "shortcuts"/snippets to write long Java sequences easily in Emacs?
Install YaSnippet & YaSnippet-java Emacs packages.
Then you can use:
p[Tab] : System.out.println()
cla[Tab] : The whole class snippet with name from filename!
mai[Tab] : The whole main method
...
Other abbrev (and their bindings) can be found in the 'YaSnippet' menu.
From: https://github.com/nekop/yasnippet-java-mode
- (3588)How to get Intelligent completion (~GitHub's Copilot) in Emacs?
https://melpa.org/#/company-tabnine // https://github.com/TommyX12/company-tabnine
https://melpa.org/#/tabnine
---- My Config
(straight-use-package 'tabnine)
(use-package! tabnine
:hook
(prog-mode . tabnine-mode)
(kill-emacs . tabnine-kill-process)
:bind
(:map tabnine-completion-map
("<tab>" . #'tabnine-accept-completion)
("TAB" . #'tabnine-accept-completion)
("M-f" . #'tabnine-accept-completion-by-word)
("M-<return>" . #'tabnine-accept-completion-by-line)
("C-g" . #'tabnine-clear-overlay)
("M-[" . #'tabnine-previous-completion)
("M-]" . #'tabnine-next-completion)
)
:config
(add-to-list 'completion-at-point-functions #'tabnine-completion-at-point)
(tabnine-start-process)
)
(after! company-tabnine
(add-to-list 'company-backends #'company-tabnine)
(company-tabnine t)
)
---
Also see Tip#3973
From: https://www.tabnine.com/install/emacs
- (3590)How to (partially) resolve the conflict between python.el mode and python-mode.el mode?
PROBLEM:
Emacs comes with a builtin package for Python files: python.el
If you install the better python-mode.el mode, when you open a .py file, depending if the package has been loaded or not (typically if you call "emacs toto.py" vs. open Emacs, then open the .py file from menus), then either one or the other package gets called :{
SOLUTION: In your .emacs, force the loading of the bad package first, then override it with the correct one:
(require 'python)
(require 'python-mode)
From: https://superuser.com/questions/108233/how-can-i-prevent-the-python-el-that-ships-with-emacs-23-from-ever-loading/999608#999608
https://stackoverflow.com/questions/33530054/loading-python-mode-el-with-use-package-still-get-python-el
- (3604)How to prevent lsp-java from watching *all files* in user's home (thus making Emacs lag at opening)?
PROBLEM: You have accidentally added the Home folder to the list of workspaces.
SOLUTION1:
- Use lsp-workspace-folders-remove and the next time you see the import project dialogue make sure you pick the project root.
SOLUTION2:
- Delete lsp-sessions-file, lsp-java-workspace-dir and restart emacs.
From: https://github.com/emacs-lsp/lsp-java/issues/225
- (3605)How to manage builtin modes with use-packes (a.k.a. How to make use-package load a package without trying to download it first)?
(use-package xxx-mode
:ensure nil ; <-- Trick is here!
:config ...)
From: https://www.reddit.com/r/emacs/comments/54pvg4/usepackage_with_builtin_modes/
- (3607)How to code in Java with Emacs (a.k.a. How to transform Emacs into a Java IDE)?
- Use Meghanada mode
https://github.com/mopemope/meghanada-emacs
- and LSP-java
https://github.com/emacs-lsp/lsp-java
- (3616)How to re-open *scratch* buffer in Emacs?
Just re-create the buffer by switching to it:
C-x b *scratch* RET
From: https://emacs.stackexchange.com/questions/20/re-open-scratch-buffer
- (3619)How to make TabNine (FLOSS ML-based autocompletion) enable semantic completion on JavaScript?
There's a message in the mini-buffer saying that you have to type "TabNine::sem" to enable semantic completion.
The problem is where to type that (minibuffer ? option file ? ...) ?
The solution is quite simple even if counter intuitive: literally type that text inside the JS code buffer, then delete it!!!
From: https://github.com/TommyX12/company-tabnine/issues/54
- (3632)How to get help to find good sentences for writing academic papers?
(use-package academic-phrases
:ensure t
)
https://github.com/nashamri/academic-phrases
- (3635)How do you list the active minor modes in emacs?
To show all the active minor modes (and major mode) and a brief description of each:
C-h m
M-x describe-mode
From: https://stackoverflow.com/questions/1511737/how-do-you-list-the-active-minor-modes-in-emacs
- (3647)How to "jump to definition" in Emacs?
PROBLEMs:
1- The definition of a function is language-dependent
2- Sometimes the definition is in another file, thus it requires a notion of project
2 packages offer such a possibility:
- xref
https://www.gnu.org/software/emacs/manual/html_node/emacs/Xref.html
- Dumb Jump
https://melpa.org/#/dumb-jump
From: https://melpa.org/#/dumb-jump
https://github.com/emacs-lsp/lsp-java/issues/350
https://emacs.stackexchange.com/questions/10125/can-emacs-support-go-to-declaration-of-function-in-an-entire-project
- (3648)How LSP interacts with older packages in Emacs to offer IDE-like features?
A good article to understand how LSP interacts with older packages in Emacs to offer IDE-like features:
https://taingram.org/blog/emacs-lsp-ide.html
- (3650)How to insert time in org-mode?
Use a builtin macro:
"This document was last exported on: {{{time(%Y-%m-%d %a %H:%M)}}}"
More macros: https://github.com/fniessen/org-macros
From: https://stackoverflow.com/questions/21615500/in-org-mode-how-to-insert-current-date-for-html-export-only/21623147#21623147
- (3652)How to solve "Missing/Wrong GPG signatures" when installing a LSP package?
PROBLEM: trying to install some LSP servers, like metals (particularly coursier), you can get an error as it was signed with expired GPG keys.
SOLUTION: disable checking of signatures (dangerous!)
(setq lsp-verify-signature nil)
From: https://github.com/coursier/coursier/issues/2346
- (3660)How to always enable some backends for company-mode (completion)?
(use-package company
:ensure t
:config
(add-to-list 'company-backends #'company-keywords) ; to complete with keywords
(add-to-list 'company-backends #'company-files) ; to complete file pathes
(add-to-list 'company-backends #'company-semantic) ; to complete with semantic.el
(add-to-list 'company-backends #'company-capf) ; to complete with CompletionAtPoint entries
(add-to-list 'company-backends #'company-yasnippet) ; to complete with YASnippets
(add-to-list 'company-backends #'company-lsp) ; to complete with LSP
;;; BAD (add-to-list 'company-backends #'company-dabbrev) ; to complete with dabbrev completions
)
From: https://github.com/company-mode/company-mode/issues/407
- (3669)How to Hide/Show function/blocks of code in Emacs?
Use "hs-minor-mode"
C-c @ C-h
Hide the current block (hs-hide-block).
C-c @ C-s
Show the current block (hs-show-block).
From: https://www.gnu.org/software/emacs/manual/html_node/emacs/Hideshow.html
- (3670)How to make Emacs consider the sub-words in a function name when moving cursor?
Problem: In computer languages, you can use snake_case/CamelCase to give meaningful names to your variables. These names often are composed by multiple words. Following the instructions in the current mode, moving instructions in Emacs sometimes move over the whole variable name, other time over single "sub-words".
E.g.:
- ^thisIsANameWithMultipleWords = 1; // ^ indicates cursor
- Hit CTRL-Right
- thisIsANameWithMultipleWords^ = 1; // ^ indicates cursor
You might want this:
- this^IsANameWithMultipleWords = 1; // ^ indicates cursor
This can be controlled by "subword-mode"
From: https://www.gnu.org/software/emacs/manual/html_node/ccmode/Subword-Movement.html
- (3681)How to open a (html) file/buffer in a web browser (e.g Firefox) from within Emacs?
browse-url-of-file . It is bound to <menu-bar> <HTML> <Load this Buffer in Browser>, C-c C-z v.
From: https://stackoverflow.com/questions/2035678/how-to-open-files-in-web-browsers-e-g-firefox-within-editors-like-vim-or-emacs/2036632#2036632
- (3684)How to open links in Firefox (or any other browser) from Emacs?
(setq browse-url-generic-program (executable-find "firefox")
browse-url-browser-function 'browse-url-generic)
or
(setq browse-url-browser-function 'browse-url-firefox
browse-url-new-window-flag t
browse-url-firefox-new-window-is-tab t)
or
(setq browse-url-browser-function (quote browse-url-firefox))
From: https://www.emacswiki.org/emacs/BrowseUrl#h5o-7
- (3690)How to specify the LaTeX format for a table in org-latex?
You can give the format to the table for LaTeX with #+attr_latex:, say:
#+attr_latex: align=|c|c|c|
|------+-----+-----|
| A | B | C |
|------+-----+-----|
| 2.34 | 2.7 | 8.9 |
| 3.67 | 4.5 | 8.9 |
|------+-----+-----|
From: https://stackoverflow.com/questions/8532762/exporting-vertical-lines-in-org-mode-table-to-latex/8538461#8538461
- (3691)How to prevent Emacs (with TabNine) to get laggier the longer it is used?
;;;; GC issue
(add-hook 'after-init-hook (lambda () (setq gc-cons-threshold 100000000)))
(add-hook 'focus-out-hook 'garbage-collect)
From: https://github.com/TommyX12/company-tabnine/issues/45#issuecomment-778560945-permalink
- (3693)How to prevent figures to always be centered in org-LaTeX?
I] Globally
#+BIND: org-latex-images-centered nil
II] For a single figure
#+ATTR_LATEX: :center nil
From: https://emacs.stackexchange.com/questions/29697/org-mode-figures-always-centered/71169#71169
- (3698)How to solve "Jupyter server failed to start, cancelling operation." in Emacs::EIN?
The problem most probably comes from an already existing installation.
EIN and Spyder do not seem to like each others' jupyter installations.
From: https://github.com/millejoh/emacs-ipython-notebook/issues/248
- (3706)How to make integrate PlantUML and Emacs (a.k.a. How to make Emacs call local PlantUML jar instead of website)?
(setq plantuml-default-exec-mode 'jar) ; Use local jar instead of website
(setq plantuml-jar-path "/usr/share/plantuml/plantuml.jar") ; path of jar file (here, when installed from apt-get)
From: https://medium.com/@shibucite/emacs-and-plantuml-for-uml-diagrams-academic-tools-6c34bc07fd2#d658
- (3707)How to handle custom variables changed by setq in DoomEmacs (a.k.a. How to prevent my variable to get overridden by its default value)?
Use the 'after!'
;; in ~/.doom.d/config.el
(after! >xxx-mode>
(setq <xxx-mode-var> '(<value>)))
From: https://github.com/hlissner/doom-emacs/issues/2059
- (3714)How to write a LaTeX letter from org-mode (a.k.a How to solve "Unknown latex class 'letter'" when exporting org file to a LaTeX letter)?
Org is only "aware" of (i.e., can only handle/export) the LaTeX classes defined in the variable org-latex-classes. If you want Org to handle more classes than the default setting, you have to add manually the support for those classes, by customizing the value of this lisp variable. For example, you can add the following lines in your init.el (or .emacs) file:
(add-to-list 'org-latex-classes
'("letter"
"\\documentclass{letter}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")))
The first link posted by Robert explains how to better customize (if needed) the support of section headers for this class:
See https://orgmode.org/manual/LaTeX-header-and-sectioning.html#LaTeX-header-and-sectioning You can customize org-latex-classes like https://superuser.com/questions/896741/how-do-i-configure-org-latex-classes-in-emacs
From: https://emacs.stackexchange.com/questions/53331/emacs-org-mode-letter-class-unknown-latex-class-letter/53352#53352
- (3717)How to enter special symbols (e.g. LaTeX's unbreakable space) in OrgMaode?
https://orgmode.org/manual/Special-Symbols.html#Special-Symbols page lists "special symbols" that can be used in OrgMode
Writing:
\nbsp{}example # in OrgMode
is translated to:
e.g.~example % in LaTeX
From: https://stackoverflow.com/questions/9311538/how-to-make-non-breaking-spaces-ties-in-org-mode-that-exports-properly-to-late/16176740#16176740
- (3718)How to customize the export of "special symbols" from OrgMode?
org-entities is a mechanism to do more generic export customisations, as well as support multiple backends.
Set org-entities to something like this:
(setq org-entities-user
'(("space" "~" nil " " " " " " " ")))
The following Org source:
E.g.\space{}a, b, c
exports to LaTeX as:
E.g.~a, b, c
and exports to HTML as:
<p>
E.g. a, b, c</p>
From: https://stackoverflow.com/questions/9311538/how-to-make-non-breaking-spaces-ties-in-org-mode-that-exports-properly-to-late/30690064#30690064
- (3719)How to make non-breaking spaces in Org-mode that exports properly to LaTeX?
Org
e.g.\nbsp{}example
LaTeX export
e.g.~example
Also see Tip#3717
From: https://stackoverflow.com/questions/9311538/how-to-make-non-breaking-spaces-ties-in-org-mode-that-exports-properly-to-late/21936300#21936300
- (3720)Good short intro to Emacs
https://www.reddit.com/r/emacs/comments/uioib2/wrote_some_basic_emacs_notes_for_myself_as_i_kept/
- (3727)How to make "keycast package" work with DoomEmacs?
(after! keycast
(define-minor-mode keycast-mode
"Show current command and its key binding in the mode line."
:global t
(if keycast-mode
(add-hook 'pre-command-hook 'keycast--update t)
(remove-hook 'pre-command-hook 'keycast--update))))
(add-to-list 'global-mode-string '("" mode-line-keycast))
(keycast-mode) ;; or run keycast-mode by demand
From: https://github.com/tarsius/keycast/issues/7#issuecomment-627604064
- (3728)How to disable Smartparens / parenthesis completion in DoomEmacs?
(after! smartparens
(smartparens-global-mode -1))
From: https://discourse.doomemacs.org/t/disable-smartparens-or-parenthesis-completion/134
- (3732)Useful Emacs packages that combine well with OrgMode
- calc
- constants
- cdlatex
- imenu
- speedbar
- table
From: https://orgmode.org/manual/Cooperation.html#Cooperation
- (3733)How to manage complex tables (multirow/cols, etc.) in Emacs OrgMode?
C-c ~ (org-table-create-with-table.el)
From: https://orgmode.org/manual/Cooperation.html#Cooperation
https://emacs.stackexchange.com/questions/7299/multicolumn-cells-in-org-mode-tables
- (3734)How to make DoomEmacs paste (middle mouse button) on the current cursor position vs. on where the click occurs?
(setq mouse-yank-at-point t)
(setq mouse-yank-at-point nil)
From: https://superuser.com/questions/330849/can-i-tell-emacs-to-paste-middle-mouse-button-on-the-cursor-position
- (3735)How to solve error 'unambigious name for "main"' when upgrading DoomEmacs?
PROBLEM: This happens because a repo has moved to a new branch or repo, upstream. Renaming master to main, for instance, has become common lately
SOLUTION:
- rm -rf ~/.emacs.d/.local/straight/repos/<problematic package>
- doom sync
- Restart Emacs
If you get this prompt multiple times, consider deleting ~/.emacs.d/.local/straight entirely before you doom sync, to start fresh.
From: https://github.com/doomemacs/doomemacs/issues/4984#issuecomment-832842879
- (3750)How to disable a builtin package in DoomEmacs?
If you'd like to disable a package included with Doom, for whatever reason, you can do so here with the :disable property:
(package! builtin-package :disable t)
From: https://tecosaur.github.io/emacs-config/config.html#disabling-built-packages
- (3751)How to change the installed version of a package in DoomEmacs?
If you'd like to install a specific version of a package included with Doom, you can override the recipe of a built in package without having to specify all the properties for :recipe. These will inherit the rest of its recipe from Doom or MELPA/ELPA/Emacsmirror:
(package! builtin-package :recipe (:nonrecursive t))
(package! builtin-package-2 :recipe (:repo "myfork/package"))
Specify a :branch to install a package from a particular branch or tag.
(package! builtin-package :recipe (:branch "develop"))
From: https://tecosaur.github.io/emacs-config/config.html#disabling-built-packages
- (3752)How to create a transition slide (Single C) in Beamer from OrgMode?
* @@l:@@
:PROPERTIES:
:BEAMER_ENV: frame
:BEAMER_OPT: c
:END:
\centering \LARGE Single Text
From: https://orgmode.org/manual/Frames-and-Blocks-in-Beamer.html
https://tex.stackexchange.com/questions/208633/latex-beamer-how-to-horizontally-vertically-center-text-ignoring-other-content
- (3753)How to organize blocks in Beamer form OrgMode?
You have to play with:
- BEAMER_COL property to set width of blocks/columns
- Blocks & sub-blocks to organise blocks, with "anonymous" blocks that structure sub-blocks vertically/horizontally
- BEAMER_ENV ignoreheading to close blocks/columns
------ Example.org -----
#+STARTUP: showall indent latexpreview inlineimage
# --- Use C-c C-c to reload this ---
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+OPTIONS: toc:nil ## remove Table Of Content
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [aspectratio=169]
#+LATEX_HEADER: \usetheme{Warsaw}
#+LATEX_HEADER:\usecolortheme{seagull}
* 1 block on top of 2 bottom blocks
** Block 1 - Top # Full width block
:PROPERTIES:
:BEAMER_ACT: <1->
:END:
Lorem Ipsum
** Block 2 - Bottom1 # Half width block
:PROPERTIES:
:BEAMER_ACT: <2->
:BEAMER_COL: .5
:BEAMER_ENV: block
:END:
Lorem Ipsum
** Block 3 - Bottom2 # Half width block
:PROPERTIES:
:BEAMER_ACT: <3->
:BEAMER_COL: .5
:BEAMER_ENV: block
:END:
Lorem Ipsum
* 2 blocks on top of 1 bottom block
** Block 1 - Top1 # Half width block
:PROPERTIES:
:BEAMER_ACT: <1->
:BEAMER_COL: .5
:BEAMER_ENV: block
:END:
Lorem Ipsum
** Block 2 - Top2 # Half width block
:PROPERTIES:
:BEAMER_ACT: <2->
:BEAMER_COL: .5
:BEAMER_ENV: block
:END:
Lorem Ipsum
** @@l:@@ # Closes the suite of blocks with col settings
:PROPERTIES:
:BEAMER_ENV: ignoreheading
:END:
** Block 3 - Bottom # Full width block
:PROPERTIES:
:BEAMER_ACT: <3->
:BEAMER_ENV: block
:END:
Lorem Ipsum
* 4 blocks - horizontal
** Block 1 - Top1 # Half width block
:PROPERTIES:
:BEAMER_COL: .5
:BEAMER_ACT: <1->
:BEAMER_ENV: block
:END:
Lorem Ipsum
** Block 2 - Top2 # Half width block
:PROPERTIES:
:BEAMER_COL: .5
:BEAMER_ACT: <2->
:BEAMER_ENV: block
:END:
Lorem Ipsum
** @@l:@@ # Closes the first suite of blocks with col settings
:PROPERTIES:
:BEAMER_ENV: ignoreheading
:END:
** Block 3 - Bottom1 # Half width block
:PROPERTIES:
:BEAMER_COL: .5
:BEAMER_ACT: <3->
:BEAMER_ENV: block
:END:
Lorem Ipsum
** Block 4 - Bottom # Half width block
:PROPERTIES:
:BEAMER_COL: .5
:BEAMER_ACT: <4->
:BEAMER_ENV: block
:END:
Lorem Ipsum
* 4 blocks - vertical
** @@l:@@ # artificial grouping of below sub-blocks
:PROPERTIES:
:BEAMER_COL: .5
:END:
*** Block 1 - Top1 # Half width block
:PROPERTIES:
:BEAMER_ACT: <1->
:BEAMER_ENV: block
:END:
Lorem Ipsum
*** Block 2 - Bottom1 # Half width block
:PROPERTIES:
:BEAMER_ACT: <2->
:BEAMER_ENV: block
:END:
Lorem Ipsum
** @@l:@@ # artificial grouping of below sub-blocks
:PROPERTIES:
:BEAMER_COL: .5
:END:
*** Block 3 - Top2 # Half width block
:PROPERTIES:
:BEAMER_ACT: <3->
:BEAMER_ENV: block
:END:
Lorem Ipsum
*** Block 4 - Bottom2 # Half width block
:PROPERTIES:
:BEAMER_ACT: <4->
:BEAMER_ENV: block
:END:
Lorem Ipsum
------------------------
From: https://orgmode.org/manual/Frames-and-Blocks-in-Beamer.html
- (3760)How to solve strange errors (like "unexpected runtime error" "Symbol's function definition is void") when upgrading DoomEmacs?
PROBLEM: trying to upgrade DoomEmacs results in very strange errors, like "unexpected runtime error" "Symbol's function definition is void" "(always)":
$ doom upgrade
> Preparing to upgrade Doom Emacs and its packages...
✓ Doom is already up-to-date!
Doom is up-to-date!
> Compiling your literate config...
x There was an unexpected runtime error
Message: Symbol's function definition is void
Details: (always)
Backtrace:
(always (doom-print (doom-print--format "Restarting...") :format nil))
(and (not (getenv "__NOTANGLE")) (+literate-tangle +literate-config-file (concat doom-module-config-file ".el") doom-private-...
(+literate-tangle--sync)
(if noninteractive (+literate-tangle--sync) (+literate-tangle--async))
(+literate-tangle-h)
(run-hooks doom-before-sync-hook)
(let ((noenvvar\? (cdr (assq 'noenvvar\? alist))) (noelc\? (cdr (assq 'noelc\? alist))) (update\? (cdr (assq 'update\? alist)...
((closure (t) (cli alist) (let ((noenvvar\? (cdr (assq 'noenvvar\? alist))) (noelc\? (cdr (assq 'noelc\? alist))) (update\? (...
(funcall (closure (t) (cli alist) (let ((noenvvar\? (cdr (assq 'noenvvar\? alist))) (noelc\? (cdr (assq 'noelc\? alist))) (up...
(doom-cli-execute #s(doom-cli ("doom" "sync") nil (("SUMMARY" . "Synchronize your config with Doom Emacs.") ("MAIN" . "This i...
(let ((bindings x5) (cli x4)) (doom-cli-execute cli bindings))
(let* ((x4 (car x3)) (x5 (cdr x3))) (let ((bindings x5) (cli x4)) (doom-cli-execute cli bindings)))
! Wrote extended backtrace to ~/.emacs.doom.d/.local/logs/cli.doom.220704101212.725787.error
✓ Finished in 1.52441s
SOLUTION:
cd ~/.emacs.d
git pull --rebase
doom sync -u
From: https://github.com/doomemacs/doomemacs/issues/6532#issuecomment-1174000104
- (3780)Where to find the docs about the myriad of addons/packages included in DoomEmacs?
https://github.com/doomemacs/doomemacs/blob/master/docs/modules.org
- (3781)How to do rectangular selection/copy/paste in DoomEmacs/EvilMode?
- ESC v -> visual mode
- Ctrl-v -> toggle rectangular selection
- d -> cut / p -> paste
From: https://stackoverflow.com/questions/25065328/how-select-a-rectangle-in-emacs
- (3783)How to add a custom word list to company (completion framework of DoomEmacs)?
1. Create a file with you completion (1 word per line)
2. Configure company-ispell backend as follows:
(setq company-ispell-available t)
(setq company-ispell-dictionary "/path/to/your/wordlist/file")
(add-to-list 'company-backends 'company-ispell)
Also see Tips#4004 for indicating how to ignore specific chars in the file before completing with the custom dict (e.g. to ignore the starting '\' for commands)
From: https://emacs.stackexchange.com/questions/46648/adding-custom-word-list-to-company/61066#61066
- (3784)How to create a directory from within Emacs?
- to create the directory dir/to/create, type:
M-x make-directory RET dir/to/create RET
- to create directories dir/parent1/node and dir/parent2/node, type:
M-! mkdir -p dir/parent{1,2}/node RET
- in a Dired mode
+
From: https://stackoverflow.com/a/155510
- (3785)How to run an Emacs script in DoomEmacs (a.k.a. How to ensure DoomEmacs's config is loaded before calling commands from its packages)?
- Don't use the vanilla "emacs --batch" method.
- Doom commit e5b7edc introduced bin/doomscript for this purpose
Example script from exporting org files into PDFs:
1. Make sure ~/.emacs.d/bin is in your $PATH.
2. Make sure ~/.doom.d/bin is in your $PATH.
3. Put this in ~/.doom.d/bin/export-notes:
#!/usr/bin/env doomscript
(defcli! export-notes (&args files)
(require 'doom-start) ; load your user config
(dolist (file files) ; supports multiple files, if you want
(find-file file) ; open an org file
(org-latex-export-to-pdf))) ; and export it
(run! "export-notes" (cdr (member "--" argv)))
4. Make this script executable: chmod +x export-notes
5. Now you have a Doom script:
./export-notes notes.org
TODO: How to call "async" methods like '(lsp-update-servers)'?
https://github.com/doomemacs/doomemacs/issues/6899
From: https://github.com/doomemacs/doomemacs/issues/6494#issuecomment-1164718987
- (3792)How to use pdf-tools (pdf-view-mode) in Emacs?
== For org-mode:
You need to configure the "org-file-apps" variable:
(eval-after-load 'org '(require 'org-pdfview))
(add-to-list 'org-file-apps
'("\\.pdf\\'" . (lambda (file link)
(org-pdfview-open link))))
== For AucTeX
You need to configure the "TeX-view-program-selection" variable
== Other tools
They generally use the system tools, that you can configure with "xdg-open"
See Tip#3506 , Tip#3322 and Tip#569
From: https://emacs.stackexchange.com/a/24502
- (3793)How to set/change the (external) applications used by org-mode to open files/links?
You need to configure the 'org-file-apps variable
From: https://emacs.stackexchange.com/a/24502
- (3800)How to clear recent files list in DoomEmacs?
PROBLEM:
(recentf-cleanup) "intelligently" removes recent files, thus it dos not remove ALL files
SOLUTION:
M-x recentf-edit-list and manually select all the files to remove ("a la" dired)
From: https://emacs.stackexchange.com/questions/37191/how-to-clear-recent-files-list/37203#37203
- (3802)What is the equivalent of \today in org-mode?
Have a look at the time macro:
https://orgmode.org/manual/Macro-Replacement.html
For example:
* Date test
This is the export time: {{{time(%Y-%m-%d)}}}.
From: https://tex.stackexchange.com/questions/402441/equivalent-of-today-in-org-mode
https://www.gnu.org/software/emacs/manual/html_node/elisp/Time-Parsing.html
- (3803)How to enable/disable visual/truncate-line (line wrapping) inside Markdown cells in EIN/Emacs?
In you DoomEmacs config:
(use-package! ein
:hook
; From: https://github.com/millejoh/emacs-ipython-notebook/issues/134#issuecomment-260159965
;;(ein:notebook-mode . global-visual-line-mode)
(ein:notebook-mode . toggle-truncate-lines)
)
From: https://github.com/millejoh/emacs-ipython-notebook/issues/134#issuecomment-260159965
https://stackoverflow.com/questions/3281581/how-can-i-enable-line-wrap-on-word-boundaries-only-in-emacs#3282132
- (3817)How to make AucTeX open a file chooser when inserting a href command?
(eval-after-load "hyperref"
'(TeX-add-symbols
'("href" [ (TeX-arg-key-val LaTeX-hyperref-href-options) ]
(TeX-arg-file "URL") "Text" ignore)))
From: https://emacs.stackexchange.com/questions/16502/auctex-make-it-open-a-file-chooser-when-inserting-a-href-command
- (3818)How to point to a specific part of an external org-mode file?
- Add a (custom) id to this part:
* Headline 2
:PROPERTIES:
:CUSTOM_ID: my-headline-2
:END:
This is heading number two
- You can now refer to it with '::#<id>':
#+INCLUDE: "/home/user/.../the_external_file.org::#my-headline-2" :minlevel 1
From: https://writequit.org/articles/emacs-org-mode-generate-ids.html#the-solution
- (3829)How to get numbered Plain Lists in org-mode?
You can also get ‘a.’, ‘A.’, ‘a)’ and ‘A)’ by configuring org-list-allow-alphabetical. To minimize confusion with normal text, those are limited to one character only. Beyond that limit, bullets automatically become numbers.
From: https://orgmode.org/manual/Plain-Lists.html#FOOT11
- (3830)How to sort Plain Lists in org-mode?
C-c ^
Sort the plain list. Prompt for the sorting method: numerically, alphabetically, by time, or by custom function.
From: https://orgmode.org/manual/Plain-Lists.html#index-C_002dc-_005e-1
- (3831)How to regenerate DoomEmacs' environment variables (a.k.a. How to solve errors related to programs not being found whereas they are in path)?
- doom env:
(Re)generates an “envvar file”, which is a snapshot of your shell environment that Doom loads at startup. If your app launcher or OS launches Emacs in the wrong environment you will need this. This is required for GUI Emacs users on MacOS.
- (3892)How to reopen EIN's list of available Notebooks when you closed its buffer?
M-x ein:notebooklist-open
From: https://millejoh.github.io/emacs-ipython-notebook/#notebook-list
- (3901)How to make Footnotes appear correctly in overlays of an org-mode Beamer presentation?
SOLUTION: put the <x-y> overlay specification directly on the \footnote{} command
#+TITLE: My Great Title
#+STARTUP: beamer
#+LATEX_CLASS: beamer
* This is a test
+ <4-> Level1.3@@beamer:\footnote<4->{@@Footnote@@beamer:}@@
Thanks Eric Fraga!
From: https://list.orgmode.org/87cz7r7f48.fsf@ucl.ac.uk/T/#t
- (3903)BasicOrgMode_autoinsert.org
#+STARTUP: showall indent latexpreview inlineimage
# --- Use C-c C-c to reload this ---
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: OB(o) FlB(f) VC(v) AZ(a) MLF(l) LGN(g) PhJ(p) XS(x) MJ(m) Yous(y) TM(t) | GM(g)
#+TITLE: My Great Title
#+AUTHOR: Guillaume MULLER
#+EMAIL: guillaume.muller@emse.fr
#+DATE: {{{time(%Y-%m-%d %a %H:%M)}}}
#+DESCRIPTION: My Great Description
#+KEYWORDS: My Key Words
#+LANGUAGE: en
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:1 ## With H:1, *=slides || with H:2, *=sections
# #+OPTIONS: num:nil ## use itemize vs. enumerate
#+OPTIONS: comments yes
* Type faces :cool:
** *bold*
** _underline_
** /italic/
** +strike through+
** =code=
** ~verbatim~
** #comment
** LaTeX fragments \[ \int_{x=1}^{\infty} sin(x) dx \] rendered inline with C-c C-x C-l
- (3904)BasicOrgMode_LaTeX.org
# *- org-image-actual-width: 100px
#+STARTUP: showall indent latexpreview inlineimage
# To reload config: C-c C-c
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: | CANCELED(c)
#+TITLE:
#+AUTHOR:
#+EMAIL: guillaume.muller@emse.fr
#+DATE: \today
# #+OPTIONS: title:0
# #+OPTIONS: author:nil date:nil
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:1 ## number of header levels to consider (level below are list items)
#+OPTIONS: num:nil ## use itemize vs. enumerate
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper]
# #+LATEX_HEADER: \usepackage[margin=0.5in]{geometry}
#+LATEX_HEADER: \usepackage{vmargin}\setmarginsrb{2cm}{1cm}{2cm}{1cm}{0cm}{0cm}{0cm}{0cm}
# #+LATEX: \pagestyle{empty}
#+LATEX_HEADER: \usepackage[utf8]{inputenc}
#+LATEX_HEADER: \usepackage[T1]{fontenc}
#+LATEX_HEADER: \usepackage{graphicx} % To insert images
#+LATEX_HEADER: \graphicspath{{./images/}} % Default path for images
#+LATEX_HEADER: \usepackage[normalem]{ulem} % For underline/strike
# #+LATEX_HEADER: \usepackage{amsmath,bm} % For mathcal? + \bm (bold)
#+LATEX_HEADER: \usepackage{fontawesome5} % For pretty UTF-8 emojis \faExclamationTriangle
# #+LATEX_HEADER: \usepackage[usenames,dvipsnames]{xcolor} % To call colors by name # Already included (by Beamer/TikZ? which rather uses "red!60" for colors)
#+LATEX_HEADER: \usepackage{tikz} % For drawings
#+LATEX_HEADER: \usetikzlibrary{positioning} % For using "above=of", etc
#+LATEX_HEADER: \usetikzlibrary{arrows.meta} % For arrow heads
#+LATEX_HEADER: \usepackage{tikzsymbols} % For Sticky man
# #+LATEX_HEADER: \usepackage{hyperref} % For pdf meta info + links?
# #+LATEX_HEADER: \hypersetup{
# #+LATEX_HEADER: pdfauthor={...},
# #+LATEX_HEADER: pdftitle={...},
# #+LATEX_HEADER: pdfkeywords={...},
# #+LATEX_HEADER: pdfsubject={...},
# #+LATEX_HEADER: pdfcreator={...},
# #+LATEX_HEADER: pdflang={English}
# # Force Hyperref to color URLs
# #+LATEX_HEADER: colorlinks=true,%
# #+LATEX_HEADER: urlcolor=blue,%
# #+LATEX_HEADER: linkcolor=blue%
# #+LATEX_HEADER: }
# #+LATEX_HEADER: \usepackage[dvipsnames,svgnames,x11names]{xcolor}
# #+LATEX_HEADER: \lstset{frame=none,
# #+LATEX_HEADER: showstringspaces=false,
# #+LATEX_HEADER: columns=flexible,
# #+LATEX_HEADER: basicstyle={\ttfamily},
# #+LATEX_HEADER: keywordstyle=\color{blue},
# #+LATEX_HEADER: commentstyle=\color{DarkGreen},
# #+LATEX_HEADER: stringstyle=\color{DarkMagenta},
# #+LATEX_HEADER: breaklines=true,
# #+LATEX_HEADER: breakatwhitespace=true,
# #+LATEX_HEADER: tabsize=2
# #+LATEX_HEADER: }
# #+LATEX_HEADER: \usepackage[
# #+LATEX_HEADER: backend=bibtex, % Tool used to compile biblio files (can also be "biber")
# #+LATEX_HEADER: style=alphabetic, % style equiv to alpha.bst / style=authoryear
# #+LATEX_HEADER: natbib=true % allows creating citations but not having a section with the biblio references
# #+LATEX_HEADER: ]{biblatex} %
# #+LATEX_HEADER: \addbibresource{mypapers.bib}
#+BIBLIOGRAPHY: ./references.bib
#+CITE_EXPORT: biblatex alphabetic
* Type faces :cool:
** *bold*
** _underline_
** /italic/
** +strike through+
** =code=
** ~verbatim~
** #comment
* TODOs
** TODO test
** LATER test
** INPROGRESS test
** CANCELLED test
** DELEGATED test
** DONE test
* TAGs
** TAG1 :TAG:
** TAG-2 :TAG-2:
** TAG_3 :TAG_3:
* Links
** \<\<internal\>\>
** \[\[find text\]\]
** \[\[[[*find headline\]\]
** \[\[ID\]\[description\]]
* Outline
- */**/***
- 1./2./3.
- +/-
- C-c -: to switch basic text to basic items
- C-c C-*: to switch items to outline
* Description
- Titre1 :: description1
- Titre2 :: description2
* Tables
** https://orgmode.org/manual/Tables.html
** Select some text, e.g. separated by column (csv file), then M-x org-table-convert-region
** Creation: C-c |
** Inplace realign: C-c C-c
** Realign+move next col: TAB
** Realign+move next row: RET
** Blank the field at point: C-c SPC
** Move to start current field: M-a
** Move to end current field: M-e
** Move current row up: M-up
** Movecurrent row down: M-down
** Insert a horizontal line below+move below: C-c RET
** Sort the table lines in the region: C-c ^
** Sum the numbers in the current column/region: C-c + (C-y to insert it)
** Copy from above: S-RET
* LaTeX fragments
** \[ \int_{x=1}^{\infty} sin(x) dx \]
** Render inline with C-c C-x C-l
* Timers
** C-c C-x 0 : start timer
** C-c C-x . : echo timer value in the buffer
* Scheduling
** C-c C-s : schedule a task
* Views
** Agenda (dates): C-c C-[ + M-x org-agenda / C-c C-o on a date / View d/w/vm / Filter:"/" / prev/nxt: f/b / Show holydays: H
** Sparse Tree (regex matches): C-c "/" d (DEADLINE) / C-c C-v (TODO) / C-u r <regex>
** Column View (properties): C-x C-x C-c / Quit: q / Edit: e
* Export (C-x C-e)
** ASCII: C-c C-e t u
** HTML: C-c C-e h h
** LaTeX: C-c C-e l l
** PDF: C-c C-e l p
* Including external elements (source code, quote, verbatim, LaTeX/HTML, etc.)
** =<s= + TAB
#+BEGIN_SRC <lang>
#+END_SRC
** =<e= + TAB
#+BEGIN_EXAMPLE
#+END_EXAMPLE
** =<q= + TAB
#+BEGIN_QUOTE
#+END_QUOTE
** =<V= + TAB
#+BEGIN_VERBATIM
#+END_VERBATIM
** =<l= + TAB
#+BEGIN_LaTeX
#+END_LaTeX
** =<h= + TAB
#+BEGIN_HTML
#+END_HTML
** =<i= + TAB
#+INDEX:
** =<I= + TAB
#+INCLUDE: "/path/to/filename/you/interactively/select"
* References
+ This is a citation [cite:@Author2022Title]!
* Bibliography
# #+BEGIN_EXPORT latex
# \begin{refsection}
# %%% To create the items yourself:
# \cite{Blibli}~\fullcite{Blibli} % [xxx] <full text of the ref>
# %%% or, to generate the "References" section automatically:
# \cite{Blabla} % just the [xxx]
# \printbibliography{}
# \end{refsection}
# #+END_EXPORT
#+PRINT_BIBLIOGRAPHY:
- (3905)BasicOrgMode_Beamer.org
#+STARTUP: showall indent latexpreview inlineimage
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: | CANCELED(c)
#+TITLE: My Great Title
#+AUTHOR: Guillaume MULLER
#+EMAIL: guillaume.muller@emse.fr
#+DATE: \today
#+DESCRIPTION: My Great Description
#+KEYWORDS: My Key Words
#+LANGUAGE: en
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:2 ## With H:1, *=slides || with H:2, *=sections
# #+OPTIONS: num:nil ## use itemize vs. enumerate
#+OPTIONS: comments yes
#+STARTUP: beamer
#+LATEX_CLASS: beamer
#+LATEX_CLASS_OPTIONS: [aspectratio=169]
# %%% Conflicts with the theme's color redefinition below :{
# #+BEAMER_THEME: Warsaw
# #+BEAMER_COLOR_THEME: seagull
#+LATEX_HEADER: \usetheme{Warsaw}
#+LATEX_HEADER:\usecolortheme{seagull} % Full grey theme
# % Other themes: AnnArbor,Antibes,Bergen,Berkeley,Berlin,Boadilla,CambridgeUS,Copenhagen,Darmstadt,Dresden,Frankfurt,Goettingen,Hannover,Ilmenau,JuanLesPins,Luebeck,Madrid,Malmoe,Marburg,Montpellier,PaloAlto,Pittsburgh,Rochester,Seagull,Singapore,Szeged,Warsaw,boxes,default
# % See: https://latex-beamer.com/tutorials/beamer-themes/ or https://deic.uab.cat/~iblanes/beamer_gallery/index_by_theme.html
# % Already loaded by org-mode
# #+LATEX_HEADER: \usepackage[utf8]{inputenc}
# #+LATEX_HEADER: \usepackage[T1]{fontenc}
# #+LATEX_HEADER: \usepackage{graphicx} % To insert images
# #+LATEX_HEADER: \graphicspath{{./images/}}
# #+LATEX_HEADER: \usepackage[normalem]{ulem} % For underline/strike
# #+LATEX_HEADER: \usepackage{amsmath,bm} % For mathcal? + \bm (bold)
# #+LATEX_HEADER: \usepackage{amssymb} % For math symbols?
# #+LATEX_HEADER: \usepackage{hyperref} % For pdf meta info + links?
# #+LATEX_HEADER: \hypersetup{
# #+LATEX_HEADER: pdfauthor={...},
# #+LATEX_HEADER: pdftitle={...},
# #+LATEX_HEADER: pdfkeywords={...},
# #+LATEX_HEADER: pdfsubject={...},
# #+LATEX_HEADER: pdfcreator={Emacs (Org mode)},
# #+LATEX_HEADER: pdflang={English}
# #+LATEX_HEADER: }
# % Force Hyperref to color URLs
#+LATEX_HEADER: \hypersetup{
#+LATEX_HEADER: colorlinks=true,%
#+LATEX_HEADER: urlcolor=blue,%
#+LATEX_HEADER: linkcolor=blue%
#+LATEX_HEADER: }
#+LATEX_HEADER: \usepackage{menukeys} % For Apple's keys ⌘⌥ and listing menu entries
#+LATEX_HEADER: \usepackage[gen]{eurosym} % For € symbol
#+LATEX_HEADER: \usepackage{wasysym} % For smileys
#+LATEX_HEADER: \usepackage{bclogo} % For danger & bccrayon signs
#+LATEX_HEADER: \usepackage{fontawesome5} % For pretty UTF-8 emojis \faExclamationTriangle
#+LATEX_HEADER: \usepackage{tikz} % For drawings
#+LATEX_HEADER: \usetikzlibrary{arrows.meta} % For arrow heads
#+LATEX_HEADER: \usetikzlibrary{positioning} % For using "above=of", etc
#+LATEX_HEADER: \usepackage{tikzsymbols} % For Sticky man
#+LATEX_HEADER: \usepackage{listings} % To insert Java code listing
# #+LATEX_HEADER: \usepackage{xcolor} % TikZ already calls xcolor and uses "red!60" style
#+LATEX_HEADER: \definecolor{dkgreen}{rgb}{0,0.6,0} %% Colors for the Java listings
#+LATEX_HEADER: \definecolor{gray}{rgb}{0.5,0.5,0.5}
#+LATEX_HEADER: \definecolor{mauve}{rgb}{0.58,0,0.82}
#+LATEX_HEADER: \lstset{frame=none, % For Java listings
#+LATEX_HEADER: language=Java,
#+LATEX_HEADER: aboveskip=1mm,
#+LATEX_HEADER: belowskip=1mm,
#+LATEX_HEADER: showstringspaces=false,
#+LATEX_HEADER: columns=flexible,
#+LATEX_HEADER: basicstyle={\scriptsize \ttfamily},
#+LATEX_HEADER: numbers=left,
#+LATEX_HEADER: numberstyle=\scriptsize\color{gray},
#+LATEX_HEADER: keywordstyle=\color{blue},
#+LATEX_HEADER: commentstyle=\color{dkgreen},
#+LATEX_HEADER: stringstyle=\color{mauve},
#+LATEX_HEADER: breaklines=true,
#+LATEX_HEADER: breakatwhitespace=true,
#+LATEX_HEADER: tabsize=2
#+LATEX_HEADER: }
# % Dark theme based on Warsaw
#+LATEX_HEADER: \setbeamercolor{normal text}{fg=white,bg=black!90}
#+LATEX_HEADER: \setbeamercolor{structure}{fg=white}
#+LATEX_HEADER: \setbeamercolor{alerted text}{fg=red!85!black}
#+LATEX_HEADER: \setbeamercolor{item projected}{use=item,fg=black,bg=item.fg!35}
#+LATEX_HEADER: \setbeamercolor*{palette primary}{use=structure,fg=structure.fg}
#+LATEX_HEADER: \setbeamercolor*{palette secondary}{use=structure,fg=structure.fg!95!black}
#+LATEX_HEADER: \setbeamercolor*{palette tertiary}{use=structure,fg=structure.fg!90!black}
#+LATEX_HEADER: \setbeamercolor*{palette quaternary}{use=structure,fg=structure.fg!95!black,bg=black!80}
#+LATEX_HEADER: \setbeamercolor*{framesubtitle}{fg=white}
#+LATEX_HEADER: \setbeamercolor*{block title}{parent=structure,bg=black!60}
#+LATEX_HEADER: \setbeamercolor*{block body}{fg=black,bg=black!10}
#+LATEX_HEADER: \setbeamercolor*{block title alerted}{parent=alerted text,bg=black!15}
#+LATEX_HEADER: \setbeamercolor*{block title example}{parent=example text,bg=black!15}
# % What is the "headline" level that is transformed to a frame?
#+LATEX_HEADER_FRAME_LEVEL: 1
# % Disable NavigationBar…
# #+BEAMER_HEADER: \beamertemplatenavigationsymbolsempty
# % …or hack it!
# Remove top line: outline
#+BEAMER_HEADER: \setbeamertemplate{headline}{}
# Remove bottom line: clickable navigation icons
#+BEAMER_HEADER: \setbeamertemplate{navigation symbols}{}
# Add slide numbers
#+BEAMER_HEADER: \addtobeamertemplate{navigation symbols}{}{%
#+BEAMER_HEADER: \usebeamerfont{footline}%
#+BEAMER_HEADER: \usebeamercolor[fg]{footline}%
#+BEAMER_HEADER: \hspace{1em}%
#+BEAMER_HEADER: \insertframenumber{}/\inserttotalframenumber{}
#+BEAMER_HEADER: }
# % Hack the frame number to skip BackUp slides / appendices
#+BEAMER_HEADER: \newcommand{\backupbegin}{
#+BEAMER_HEADER: \newcounter{finalframe}
#+BEAMER_HEADER: \setcounter{finalframe}{\value{framenumber}}
#+BEAMER_HEADER: }
#+BEAMER_HEADER: \newcommand{\backupend}{
#+BEAMER_HEADER: \setcounter{framenumber}{\value{finalframe}}
#+BEAMER_HEADER: }
# % Put a slide with presentation outline before every new section
#+BEAMER_HEADER: \AtBeginSection[]
#+BEAMER_HEADER: {
#+BEAMER_HEADER: \begin{frame}<beamer>
#+BEAMER_HEADER: %\frametitle{Outline for section \thesection}
#+BEAMER_HEADER: \tableofcontents[currentsection]
#+BEAMER_HEADER: \end{frame}
#+BEAMER_HEADER: }
# % Make items appear one after the other
# #+BEAMER: \beamerdefaultoverlayspecification{<+->}
# % One can include other org files with:
# #+INCLUDE: "/path/to/chapter2.org" :minlevel 1
* Not in Toc
:PROPERTIES:
:UNNUMBERED: t
:END:
* Links
** Must be on their own line
- https://mega.nz/
* Level 1 title = Frame
# org comments
** Level 2 title = Block
+ items
* Images
#+CAPTION: UEdit Nag-screen
#+ATTR_LATEX: :width 1.2\textwidth
#+NAME: fig:FigName
[[./images/fig_name.png]]
* Scaling
:PROPERTIES:
:BEAMER_opt: shrink=15
:END:
# Whole slide scaling: dirty but works
some text
# fontsize change: does not always work :{
#+LATEX: { \footnotesize
+ small item1
+ small @@latex:{\tiny item2}@@
#+LATEX: }
- (3906)BasicOrgMode_Reveal.org [Works only with local install of Reveal]
#+STARTUP: showall indent latexpreview inlineimage
# --- Use C-c C-c to reload this ---
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: | CANCELED(c)
#+TITLE: My Presentation Title
#+AUTHOR: Guillaume MULLER
#+EMAIL: guillaume.muller@emse.fr
#+DATE: {{{time(%Y-%m-%d %a %H:%M)}}}
#+OPTIONS: toc:nil
#+REVEAL_TRANS: None
# None/Fade/Slide/Convex/Concave/Zoom
#+REVEAL_THEME: black
# black/white/league/sky/beige/simple/serif/blood/night/moon/solarized
#+REVEAL_ROOT: ./reveal.js/
# https://cdn.jsdelivr.net/npm/reveal.js@3.5.0/
#+REVEAL_INIT_OPTIONS: slideNumber: "h/v"
# true - "h.v" - "h/v" - "c" - "c/t"
#+OPTIONS: org-reveal-center:f org-reveal-progress:t
# org-reveal-history:nil org-reveal-control:t
# org-reveal-rolling-links:nil org-reveal-keyboard:nil org-reveal-overview:nil
* Horizontal Slide1
:PROPERTIES:
:reveal_background: images/name-of-image
:reveal_background_size: width-of-image
:reveal_background_trans: slide
:END:
** Vertical Slide 1.1
#+BEGIN_NOTES
Your notes must be at the end of the slide!!!
#+END_NOTES
** Vertical Slide 1.2
** Vertical Slide 1.3
* Horizontal Slide 2
** Vertical Slide 2.1
#+BEGIN_NOTES
Your note
#+END_NOTES
** Vertical Slide 2.2
** Vertical Slide 2.3
** Vertical Slide 2.4
* Horizontal Slide 3
** Vertical Slide 3.1
** Vertical Slide 3.2
#+BEGIN_NOTES
Your note
#+END_NOTES
- (3923)How to solve "global-git-commit-mode" "def-var" error in DoomEmacs?
PROBLEM: some deps of magit are assuming Emacs29, whereas Emacs28 is stil the norm for most people.
SOLUTION:
1. Add the following lines to ~/.doom.d/packges.el:
(package! transient
:pin "c2bdf7e12c530eb85476d3aef317eb2941ab9440"
:recipe (:host github :repo "magit/transient"))
(package! with-editor
:pin "bbc60f68ac190f02da8a100b6fb67cf1c27c53ab"
:recipe (:host github :repo "magit/with-editor"))
2. Run ~/.emacs.d/bin/doom sync -u
From: https://github.com/doomemacs/doomemacs/issues/6425
- (3939)How to solve DoomEmacs upgrade error "abort: In repository xxx, failed to get status..."
- Delete the guilty package
rm -rf ~/.emacs.d/.local/straight/repos/<xxx>
- Re-run upgrade
doom upgrade
From: https://github.com/doomemacs/doomemacs/issues/6230#issuecomment-1085832546
- (3946)How to create files using the file-templates module in DoomEmacs?
Package YaTemplates simplifies writing templates: just create files in the configured directory (here .doom.d/templates) with names that corresponds to a regex on the created file in which the template should be inserted (e.g. .doom.d/templates/00:.*.c content will be inserted in any file named "xxx.c")
;; Simplified version of writing templates
(use-package! yatemplate
:init
(setq yatemplate-dir "~/.doom.d/templates/")
:config
(yatemplate-fill-alist)
)
;; + Specific to override org mode file templates
(after! org
:init
(setq +file-templates-dir "~/.doom.d/templates/")
)
From: https://www.reddit.com/r/emacs/comments/adde88/comment/edjm4am/?context=3
https://github.com/doomemacs/doomemacs/issues/2134
- (3966)How to make some LaTeX commands work inside a code block environment?
You can add the following command right before the environment:
#+LATEX: \lstset{escapeinside={(*@}{@*)}
And all the code between '(*@' and '@*)' will be rendered as LaTeX.
From: https://emacs.stackexchange.com/a/12408
- (3969)How to get multicolumn cells in org-mode tables?
You can use table.el by Takaaki Ota. There is some built-in support for this in org-mode (see manual). Your example can be easily translated to table.el syntax by replacing some | with +:
+------------+-----------+----------+----------+-------------+
| | Singular | Plural |
| +-----------+----------+----------+-------------+
| | Masculine | Neuter | Feminine | All genders |
+------------+-----------+----------+----------+-------------+
| Nominative | *der* | *das* | *die* | *die* |
| Accusative | *den* | *das* | *die* | *die* |
| Dative | *dem* | *dem* | *der* | *denen* |
| Genitive | *dessen* | *dessen* | *deren* | *deren* |
+------------+-----------+----------+----------+-------------+
NOTE1: The table can be edited using C-c ' and it exports fine with the HTML and LaTeX backends, except that org-mode syntax (such as using asterisks for bold) inside the cells is not recognised.
NOTE2: Conversion between 'standard' org tables and table.el can be done with org-table-create-with-table.el, bound in Org Mode to ‘C-c ~’
From: https://emacs.stackexchange.com/questions/7299/multicolumn-cells-in-org-mode-tables
- (3971)How to solve error "Project XXX at YYY cannot be read"?
Just remove "~/.emacs.d/.local/cache/treemacs-persist" and restart emacs
From: https://github.com/Alexander-Miller/treemacs/issues/586#issuecomment-892726329
- (3972)How to make (company) completions works in org-mode?
Add:
(setq org-self-insert-command t)
in your Emacs config
From: https://github.com/company-mode/company-mode/issues/50#issuecomment-33333899
- (3973)How to get a FLOSS(?) equivalent of GitHub/MS-Copilot in Emacs?
- Create an account at https://huggingface.co/bigcode/starcoder
- Get a token for this project
- Add:
(use-package! starhugger
:config
(setq starhugger-api-token "<token>")
)
to your config.org
Also see Tip#3588
From: https://gitlab.com/daanturo/starhugger.el
- (3974)How to add new word to dictionary in Emacs flyspell-mode?
Using "C-c $" (flyspell-correct-word-before-point) on the incorrect word, it gives an option to save the word.
From: https://stackoverflow.com/questions/22107182/in-emacs-flyspell-mode-how-to-add-new-word-to-dictionary
- (3977)How to create a backtrace in DoomEmacs
FROM bin/doom
- a limited backtrace will already be displayed
- the full backtrace is written to ~/.emacs.d/.local/doom.error.log
FROM NON frozen Emacs
- Set the debug-on-error variable to a non-nil value
- Go ahead and reproduce an error, and a new window will appear to display a backtrace
FROM frozen Emacs
- Send a USR2 signal to the Emacs process:
pkill -USR2 emacs
- Turn on debug-on-quit, mash C-g, and hope for the best.
From: https://discourse.doomemacs.org/t/what-is-a-backtrace-how-to-produce-them/85#from-frozen-emacs-5
- (3981)How to make <Multi_key> work in Emacs?
ibus/XModifiers is broken. Run:
XMODIFIERS="" emacs
From: https://emacs-devel.gnu.narkive.com/ZeUmbu0l/multi-key-is-undefined
- (3983)How to do TTS (Text2Speech/Text to Speech) in Emacs?
- Install Emacs::ReadAloud
- Install OS::speechdispatcher
# apt install speech-dispatcher
$ mkdir ~/.config/speech-dispatcher
$ cp /etc/speech-dispatcher/speechd.conf !$
$ $EDITOR !$
$ cat ~/.config/speech-dispatcher/speechd.conf
LogLevel 3
LogDir "default"
DefaultRate 40
DefaultVolume 100
AudioOutputMethod "alsa"
DefaultModule flite
NOTE: to get better voice, configure spd to use pico2wave
----
(use-package read-aloud
:bind
(:map global-map
("C-S-p" . #'read-aloud-this)
)
:config
(setq read-aloud-engine "speech-dispatcher")
)
----
From: https://github.com/gromnitsky/read-aloud.el
- (3984)How to get STT (Speech2Text/VoiceTyping) in Emacs?
- Install Emacs::Whisper.el
https://github.com/natrys/whisper.el
- Install OS::Whisper.cpp (or is it installed automagically?)
https://github.com/ggerganov/whisper.cpp
https://github.com/openai/whisper
---- MyConfig
(defun toggle-language-whisper ()
"Toggle language between french/english for Speech2Text (whisper)"
(interactive)
(cond ((string= whisper-language "en") (setq whisper-language "fr"))
((string= whisper-language "fr") (setq whisper-language "en"))
(t (seq whisper-language "en"))
)
(message (concat "Speech2Text language changed to " whisper-language))
)
(setq whisper-language "en")
(use-package! whisper
:load-path
"~/.doom.d/packages/whisper.el"
:bind
("C-S-r" . #'whisper-run)
("C-S-t" . #'toggle-language-whisper)
:config
(setq
whisper-install-directory "~/.doom.d/packages/"
; whisper-model "tiny-q5_0"
; whisper-model "tiny"
whisper-model "base-q5_0"
; whisper-model "base"
; whisper-model "small-q5_0"
; whisper-model "small"
whisper-translate nil
whisper--ffmpeg-input-format "pulse"
whisper--ffmpeg-input-device "default" ; -ar 16000 -ac 1 -c:a pcm_s16le
)
(setq whisper-language "en") ; (setq whisper-language "fr")
;; (setq whisper--ffmpeg-input-device ":0")
)
----
- (3987)How to get Dynamic Tiling Windows in Emacs (à la dwm/awesome: "master/stack" layout)?
Use Edwina
https://github.com/ajgrf/edwina
----
(use-package! edwina
:bind
(:map edwina-mode-map
("C-x C-f" . #'find-file-other-window)
)
:config
(setq display-buffer-base-action '(display-buffer-below-selected))
;; (edwina-setup-dwm-keys)
(edwina-mode 1)
)
----
From: https://www.youtube.com/watch?v=_qXZNfRcNnw
- (3988)How to access ChatGPT/BingAI from Emacs?
- Use emacs-AIChat
- Extract your Bing.com cookie from the browser and put it in "~/.doom.d/packages/cookie.json"
https://github.com/xhcoding/emacs-aichat#option-two
(use-package! aichat
;; :load-path "~/.doom.d/packages/emacs-aichat/" ;; see packages.el
:bind
(:map global-map
("C-S-a" . #'aichat-bingai-assistant)
("C-S-c" . #'aichat-bingai-chat)
)
)
(after! aichat
;; (require 'aichat)
;; (require 'aichat-bingai)
;; (setq aichat-browser-name 'firefox)
(setq aichat-bingai-cookies-file "~/.doom.d/packages/cookie.json")
(require 'aichat-bingai)
)
From: https://github.com/xhcoding/emacs-aichat
- (3990)How to solve 'sqlite' problem in Emacs (org-roam: "No such file or directory" "sqlite")?
The simple but slow way:
$ doom build (rebuilds all packages),
The faster way:
# assuming Doom was cloned to ~/.config/emacs
$ rm -rf ~/.config/emacs/.local/straight/{repos,build-*}/emacsql*
$ doom sync
Other solution:
Deleted the ~/.doom.d/.local/cache/org-roam.db.
From: https://github.com/doomemacs/doomemacs/issues/7099
https://www.reddit.com/r/DoomEmacs/comments/11pg8oa/comment/jcu6d9c/?rdt=59298
- (3998)How to set (company) backends for completion in DoomEmacs?
- In general
---- my cconfig.org
(after! company
(setq company-backends nil)
;; (setq-local company-backends nil)
(add-to-list 'company-backends
#'(company-capf
company-files
company-yasnippet
company-clang
company-dabbrev
company-dabbrev-code
company-ispell
company-keywords
company-semantic
company-shell
company-tabnine
company-cmake
company-gtags
company-etags))
----
- For a specific mode
(after! latex
(setq company-backends '(<list-of-my-desired-backends>))
(after! latex
(set-company-backend! 'LaTeX-mode '(<list-of-my-desired-backends>)))
From: https://www.reddit.com/r/DoomEmacs/comments/xoatpr/comment/jcgk4tl/
- (4004)How to use special chars in aspell custom dictionary (a.k.a. How to allow '\' commands to be completed by company-ispell)?
At the end of the file add the following line:
special ' -*-
special is the keyword that tells aspell that following characters are to be treated as special characters. The format for adding special characters is:
special <char_to_be_considered_special/ignored> <begin><middle><end>
<char_to_be_considered_special/ignored> is the non-letter character in question.
<begin>, <middle<, <end> are either a ‘-‘ or a ‘*‘.
A star any of these positions means that the character can appear at this position in a word, a ‘-‘ means it can’t.
Full article: http://www.webspeaks.in/2015/01/adding-special-characters-in-aspell-dictionary-for-php.html
Also see Tip#3783 for setting company-ispell to complete custom commands.
E.g. to complete the fontawesome5 LaTeX commands with company-ispell in Emacs, I have extracted a list of the commnds in a cuustom ispell dictionary file that ends with:
----
...
faYoutube
faYoutubeSquare
faZhihu
special \\ *--
----
From: https://stackoverflow.com/questions/1676132/how-to-use-special-chars-on-aspell-custom-dictionary/28038520#28038520
- (4011)How can I insert current date and time into a file using Emacs?
C-u M-! date
From: https://stackoverflow.com/questions/251908/how-can-i-insert-current-date-and-time-into-a-file-using-emacs#275849
- (4015)How to make Alt-RET split an outline line into 2 lines at current cursor position, one with start of line other with rest of line?
Header splitting can only occur if you set "org-insert-heading-respect-content" to nil.
From: https://github.com/doomemacs/doomemacs/issues/6544
- (4020)How to copy a region without killing it (a.k.a. How to copy a region in a read-only buffer)?
SOLUTION1:
- Mark the region (C-space at one end of the range, and move to the other end)
Or select it with the mouse
- Use M-w (kill-ring-save)
SOLUTION2:
- Mark the region (C-space at one end of the range, and move to the other end)
Or select it with the mouse
- When the buffer is read-only, you can use the kill-* routines (C-w and C-k) to copy the region/line to the kill ring.
(Emacs will beep at you, but it's a documented feature)
From: https://stackoverflow.com/questions/3158484/emacs-copying-text-without-killing-it/3158508#3158508
https://stackoverflow.com/questions/3158484/emacs-copying-text-without-killing-it/3159592#3159592
- (4022)How to get Copilot in Emacs?
Install & Use: https://github.com/zerolfx/copilot.el
---- MyConfig
** Copilot
*** Usage
- Ensure your Emacs version is at least 27, and the dependency package editorconfig (melpa) is also installed.
- Install Node.js v16+. (You can specify the path to node executable by setting copilot-node-executable.)
- Setup copilot.el as described in the next section.
- Login to Copilot by M-x copilot-login. You can also check the status by M-x copilot-diagnose (NotAuthorized means you don't have a valid subscription).
*** Config
#+BEGIN_SRC emacs-lisp
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook
(prog-mode . copilot-mode)
:bind
(:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)
)
)
#+END_SRC
----
From: https://docs.github.com/en/copilot/quickstart#signing-up-for-github-copilot-for-your-personal-account
- (4056)How to show API doc in DoomEmacs?
+lookup/documentation ↔ C-c c k
Thanks Khaïs
- (4060)How to open multiple files in DoomEmacs?
DoomEmacs uses Ranger as an improvement of Dired.
- Open a directory
- Select files with 't' (toggle)
- Type the command you want to execute on these files:
ws exit ranger and open selected file in horizontal split
wv exit ranger and open selected file in vertical split
wf exit ranger and open selected file in new frame
From: https://github.com/punassuming/ranger.el#selected-file-actions
- (4062)How to gracefully shutdown emacs daemon?
From Emacs:
M-x save-buffers-kill-emacs
From outside (shell):
emacsclient -e '(save-buffers-kill-emacs)'
From: https://stackoverflow.com/questions/1167484/how-to-gracefully-shutdown-emacs-daemon/1220074#1220074
- (4064)How to use Copilot in DoomEmacs?
Add package definition to ~/.doom.d/packages.el:
(package! copilot
:recipe (:host github :repo "zerolfx/copilot.el" :files ("*.el" "dist")))
Configure copilot in ~/.doom.d/config.el:
;; accept completion from copilot and fallback to company
(use-package! copilot
:hook (prog-mode . copilot-mode)
:bind (:map copilot-completion-map
("<tab>" . 'copilot-accept-completion)
("TAB" . 'copilot-accept-completion)
("C-TAB" . 'copilot-accept-completion-by-word)
("C-<tab>" . 'copilot-accept-completion-by-word)))
Strongly recommend to enable childframe option in company module ((company +childframe)) to prevent overlay conflict.
From: https://github.com/zerolfx/copilot.el
- (4070)How to prevent/solve "Error (use-package): Failed to parse package <pkname>: use-package: Keyword handler not defined: use-package-handler/:bind?
PREVENT: Most of the time it comes from the use of "doom build" (together )
SOLVE: Unfortunately, one need to reconstruct/build the all the installed packages, which takes a lot of time:
$ cd doom-emacs/.local/straight
$ rm -rf build-28.1 build-28.1-cache.el
$ doom sync
From: https://github.com/doomemacs/doomemacs/issues/7321
- (4071)How to create links that contain [ in org-mode?
SOLUTION1: for URL only, use URL encoding:
- Left Square Bracket ("["):5B
- Right Square Bracket ("]") 5D
[http://www.example.com/Array%5Bi%5D][Your description]
SOLUTION2: for description, use macro
# Square Bracket Open [
#+MACRO: BO @@latex:\char91@@ @@html:[@@
# Square Bracket Close ]
#+MACRO: BC @@latex:\char93@@ @@html:]@@
[[http://emacs.stackexchange.com][{{{BO}}}Emacs SE{{{BC}}}]]
From: https://emacs.stackexchange.com/questions/7792/can-i-make-links-in-org-mode-that-contain-brackets-or
- (4073)How to override a org-configuration-variable directly in .org file (a.k.a. How to force org-latex/beamer-export-... to use 'lstlistings' TeX package for code)?
You can override a org-configuration-variable with:
#+BIND: <variable> <value>
NOTE: ⚠ This is very dangerous so you have to allow it in your config file with:
(setq org-export-allow-bind-keywords 1)
Example (to force org-latex/beamer-export-... to use 'lstlistings'):
#+BIND: org-latex-src-block-backend 'listings
From: https://orgmode.org/manual/Export-Settings.html
https://orgmode.org/manual/Literal-Examples.html#FOOT113
- (4075)How to make (Centaur) Tabs work when running emacs-client?
Add these lines in your "config.org"
(after! centaur-tabs
(setq centaur-tabs-set-bar 'right))
From: https://github.com/doomemacs/doomemacs/issues/6647
- (4076)How to make icons work again in the doom-modeline?
PROBLEM: DoomEmacs has switched from using "all-the-icons" to "nerd-icons" to display icons in the modeline/dashboard/etc.
SOLUTION:
- You need to install the "nerd-icons" package and run "M-x nerd-icons-install-fonts" to install the necessary fonts.
- You can remove the "all-the-icons" fonts
\rm -fr ~/.local/share/fonts/all-the-icons.ttf
\rm -fr ~/.emacs.d/.local/straight/repos/all-the-icons.el/
From: https://www.youtube.com/watch?v=_wgeEvKkgGQ
https://github.com/doomemacs/doomemacs/issues/7455
- (4078)How to insert a checkbox in an org-file?
- If point is in a checklist item C-c C-c will toggle its state
- If point is in a simple line just C-u C-c C-c would do
From: https://stackoverflow.com/questions/34038688/emacs-org-mode-insert-checkbox#34043142
https://orgmode.org/manual/Checkboxes.html
- (4080)How to automatically open "notebook mode" when opening .ipynb files in DoomEmacs?
Add following line to your "config.org":
(add-hook! 'ein:ipynb-mode-hook
;; By adding it to this hook, we can be sure that the server
;; won't be started until the buffer is visible (prevents a
;; cascade of new processes when opening multiple *.ipynb files
;; all at once.
(add-hook 'doom-switch-buffer-hook #'ein:process-open-notebook nil 'local)
)
From: https://github.com/doomemacs/doomemacs/issues/7257#issuecomment-1648522478
- (4093)How to change the appearance of the bullet of a list item when exporting a org-file into LaTeX?
I've learned here that there are two ways to modify an \item:
- [@123] will set the counter of enumerations (or "ordered lists") to 123.
- [$Rightarrow$] :: bla will generate a "description".
Both do not really yield the flexibility that I was hoping for in my question, but it seems that this is as far as one can get.
EDIT:
I've stumbled over a not so obvious way to gain full flexiblity:
- @@latex:[$\Rightarrow$]@@ will be exported as \item[$\Rightarrow$]
Notice that @@beamer:[$\Rightarrow$]@@ does not effect this.
From: https://emacs.stackexchange.com/questions/35976/how-to-change-the-appearance-of-list-bullets-in-latex-beamer-exports/35985#35985
- (4094)How to automatically insert a date (e.g. current) in DoomEmacs?
C-c . (org-timestamp) displays a calendar. Just hiting Return give today's date.
- (4095)What are the commands (#+...) for creating the Title page of a Beamer presentation generated from an org-file (included adding the author's email)?
Title page commands:
The very first slide (called frame in a Beamer presentation) is the title page. By default, it will automatically be displayed with the following elements:
- the document title
#+TITLE: Document title
(if none specified - file name - could be removed in the future)
- the author(s)’s name
#+AUTHOR: John Doe
(Emacs Lisp variable user-full-name, if none specified)
The insertion of \author can be turned off with:
#+OPTIONS: author:nil
- a date
#+DATE: 2017-01-01
(LaTeX macro \today, if none specified)
- The author’s email can be included with:
#+AUTHOR: \href{mailto:email@example.com}{John Doe}
#+AUTHOR: \texorpdfstring{John Doe\newline\url{email@example.com}}{John Doe} % DOES NOT WORK XXX -> BEAMER_HEADER???
#+BEAMER_HEADER: \author{\texorpdfstring{John Doe\newline\url{email@example.com}}{John Doe}} % BAD ORDER XXX
- Logo
#+BEAMER_HEADER: \logo{\includegraphics[height=.9cm]{InstLogo}}
- Image on the title slide
#+BEAMER_HEADER:
\titlegraphic{
\includegraphics[width=\textwidth,height=.5\textheight]{someimage}
}
Insert an image in the title slide that fills the whole width of the slide but limits to half height.
- Other:
#+BEAMER_HEADER: \subtitle{Document subtitle}
#+BEAMER_HEADER: \institute[INST]{Institute\\\url{http://www.institute.edu}}
#+BEAMER_HEADER: \titlegraphic{\includegraphics[height=1.5cm]{InstLogo}}
From: https://github.com/fniessen/refcard-org-beamer#creating-a-title-page
- (4099)How to fill a column with the row number (a.k.a How to number rows) in a org-table?
SOLUTION1: Using @# to get the row number. Similarly, $# returns the column number.
| row | data |
|-----+------|
| 2 | 0303 |
| 3 | 5123 |
| 4 | 41 |
| 5 | 4234 |
#+TBLFM: $1=@#
SOLUTION2: Using the count of #lines since the first horizontal lines
This means calculate the length of the row range from the first hline @I (the second would be @II, ...) to the current (0) row.
|bla|blabla|
|---+------|
|1 | bla |
|2 | bla |
#+TBLFM: $1=vlen(@I..0)
From: https://stackoverflow.com/questions/9267050/how-to-achieve-a-row-index-column-in-emacs-org-mode-using-a-calc-column-rule
- (4100)How to properly upgrade DoomEmacs when Emacs itself has been upgraded?
PROBLEM:
apt dist-upgrade # -> Emacs major version is changed / ~/.emacs.d/.local is outdated
EXPLANATION:
To quote the “Up/Downgrading Emacs” section of our manual (https://github.com/doomemacs/doomemacs/blob/488ad07cc548469e5356b7cfcca0e3747edff44a/docs/getting_started.org#updowngrading-emacs):
You may encounter errors after up/downgrading Emacs. Run $ doom sync on the command line after changing the installed version of Emacs. If you’ve changed the major version (e.g. 27 → 28 or vice versa) run $ doom build too.
$ doom sync # will re-index any built-in/site loaddef files. This is especially necessary if paths to built-in libraries have changed.
$ doom build # will recompile all your installed packages, which is necessary because Emacs bytecode not generally forward compatible across major releases (e.g. 27 → 28). Alternatively, reinstall all your packages by deleting ~/.emacs.d/.local , then run $ doom sync .
SOLUTION:
$ doom build && doom sync
From: https://discourse.doomemacs.org/t/how-to-upgrade-emacs-properly/2559/2
- (57)Convert file from/to encoding (utf8, iso8859-1...)
iconv -f utf8 -t iso8859-1 # (-f = from, -t = to)
If there are special characters that do not translate directly to the asked "-t" format, then use the TRANSLIT option as follows:
iconv -f utf-8 -t ascii//TRANSLIT
- (22)The RAID levels
2.4 The RAID levels
Here's a short description of what is supported in the Linux RAID
patches. Some of this information is absolutely basic RAID info, but
I've added a few notices about what's special in the Linux
implementation of the levels. Just skip this section if you know RAID.
The current RAID patches for Linux supports the following levels:
* Linear mode
o Two or more disks are combined into one physical
device. The disks are ``appended'' to each other, so writing
linearly to the RAID device will fill up disk 0 first, then
disk 1 and so on. The disks does not have to be of the same
size. In fact, size doesn't matter at all here :)
o There is no redundancy in this level. If one disk crashes
you will most probably lose all your data. You can however
be lucky to recover some data, since the filesystem will
just be missing one large consecutive chunk of data.
o The read and write performance will not increase for
single reads/writes. But if several users use the device,
you may be lucky that one user effectively is using the
first disk, and the other user is accessing files which
happen to reside on the second disk. If that happens, you
will see a performance gain.
* RAID-0
o Also called ``stripe'' mode. The devices should (but need
not) have the same size. Operations on the array will be
split on the devices; for example, a large write could be
split up as 4 kB to disk 0, 4 kB to disk 1, 4 kB to disk 2,
then 4 kB to disk 0 again, and so on. If one device is much
larger than the other devices, that extra space is still
utilized in the RAID device, but you will be accessing this
larger disk alone, during writes in the high end of your
RAID device. This of course hurts performance.
o Like linear, there is no redundancy in this level
either. Unlike linear mode, you will not be able to rescue
any data if a drive fails. If you remove a drive from a
RAID-0 set, the RAID device will not just miss one
consecutive block of data, it will be filled with small
holes all over the device. e2fsck or other filesystem
recovery tools will probably not be able to recover much
from such a device.
o The read and write performance will increase, because
reads and writes are done in parallel on the devices. This
is usually the main reason for running RAID-0. If the busses
to the disks are fast enough, you can get very close to N*P
MB/sec.
* RAID-1
o This is the first mode which actually has
redundancy. RAID-1 can be used on two or more disks with
zero or more spare-disks. This mode maintains an exact
mirror of the information on one disk on the other
disk(s). Of Course, the disks must be of equal size. If one
disk is larger than another, your RAID device will be the
size of the smallest disk.
o If up to N-1 disks are removed (or crashes), all data are
still intact. If there are spare disks available, and if the
system (eg. SCSI drivers or IDE chipset etc.) survived the
crash, reconstruction of the mirror will immediately begin
on one of the spare disks, after detection of the drive
fault.
o Write performance is often worse than on a single device,
because identical copies of the data written must be sent to
every disk in the array. With large RAID-1 arrays this can
be a real problem, as you may saturate the PCI bus with
these extra copies. This is in fact one of the very few
places where Hardware RAID solutions can have an edge over
Software solutions - if you use a hardware RAID card, the
extra write copies of the data will not have to go over the
PCI bus, since it is the RAID controller that will generate
the extra copy. Read performance is good, especially if you
have multiple readers or seek-intensive workloads. The RAID
code employs a rather good read-balancing algorithm, that
will simply let the disk whose heads are closest to the
wanted disk position perform the read operation. Since seek
operations are relatively expensive on modern disks (a seek
time of 6 ms equals a read of 123 kB at 20 MB/sec), picking
the disk that will have the shortest seek time does actually
give a noticeable performance improvement.
* RAID-4
o This RAID level is not used very often. It can be used on
three or more disks. Instead of completely mirroring the
information, it keeps parity information on one drive, and
writes data to the other disks in a RAID-0 like way. Because
one disk is reserved for parity information, the size of the
array will be (N-1)*S, where S is the size of the smallest
drive in the array. As in RAID-1, the disks should either be
of equal size, or you will just have to accept that the S in
the (N-1)*S formula above will be the size of the smallest
drive in the array.
o If one drive fails, the parity information can be used to
reconstruct all data. If two drives fail, all data is lost.
o The reason this level is not more frequently used, is
because the parity information is kept on one drive. This
information must be updated every time one of the other
disks are written to. Thus, the parity disk will become a
bottleneck, if it is not a lot faster than the other
disks. However, if you just happen to have a lot of slow
disks and a very fast one, this RAID level can be very
useful.
* RAID-5
o This is perhaps the most useful RAID mode when one wishes
to combine a larger number of physical disks, and still
maintain some redundancy. RAID-5 can be used on three or
more disks, with zero or more spare-disks. The resulting
RAID-5 device size will be (N-1)*S, just like RAID-4. The
big difference between RAID-5 and -4 is, that the parity
information is distributed evenly among the participating
drives, avoiding the bottleneck problem in RAID-4.
o If one of the disks fail, all data are still intact,
thanks to the parity information. If spare disks are
available, reconstruction will begin immediately after the
device failure. If two disks fail simultaneously, all data
are lost. RAID-5 can survive one disk failure, but not two
or more.
o Both read and write performance usually increase, but can
be hard to predict how much. Reads are similar to RAID-0
reads, writes can be either rather expensive (requiring
read-in prior to write, in order to be able to calculate the
correct parity information), or similar to RAID-1
writes. The write efficiency depends heavily on the amount
of memory in the machine, and the usage pattern of the
array. Heavily scattered writes are bound to be more
expensive.
- (30)Kill defunct processes
Defunct process also known as "zombie" process are the ones that for
some reason lose the handle to the parent, or the parent loses the
handle to the child process, so the last step of clean up does not
occur when the process finishes.
Here is the favorite technical quote of Zombie processes: "When a
process dies, it becomes a zombie process. Normally, the parent
performs a wait() and cleans up the PID. Sometimes, the parent
receives too many SIGCHLD signals at once, but can only handle one at
a time. It is possible to resend the signal on behalf of the child via
kill -18 PPID. Killing the parent or rebooting will also clean up
zombies. The correct answer is to fix the buggy parent code that
failed to perform the wait() properly."
Usually keeping the OS and the application up to par with regards to
patches should take care of the problem, however, once in a while
you'll have this. It is not terribly important to clean these up, as
they are inactive and generally harmless.
- (31)Firewalling / iptables / Setting /proc Values
Currently, linux uses files in /proc to store certain
settings. Placing a "1" in a file called /proc/sys/net/ipv4/ip_forward
for example, will turn on ip forwarding, which you will need to create
your gateway. For both 2.2 and 2.4 series kernels, here is a small
script that will set all the appropriate values in /proc (partially
taken from page 3 of the IP Masquerade HOWTO).
#!/bin/sh
#
# rc.firewall_proc_config - Sets various /proc values needed
# to create a firewall/gateway.
#CRITICAL: Enable IP forwarding since it is disabled by default since
#
# Redhat Users: you may try changing the options in
# /etc/sysconfig/network from:
#
# FORWARD_IPV4=false
# to
# FORWARD_IPV4=true
#
echo "1" > /proc/sys/net/ipv4/ip_forward
#CRITICAL: Enable automatic IP defragmenting since it is disabled by default
# in 2.2.x kernels. This used to be a compile-time option but the
# behavior was changed in 2.2.12
#
echo "1" > /proc/sys/net/ipv4/ip_always_defrag
# Dynamic IP users:
#
# If you get your IP address dynamically from SLIP, PPP, or DHCP, enable this
# following option. This enables dynamic-ip address hacking in IP MASQ,
# making the life with Diald and similar programs much easier.
#
#echo "1" > /proc/sys/net/ipv4/ip_dynaddr
#SECURITY-CRITICAL:
#
# Use "SYN Cookies" cryptographic challenge to help prevent
# SYN-Flood DOS Attacks
#
echo 1 >/proc/sys/net/ipv4/tcp_syncookies # Helps Prevent SYN-Flood DOS Attacks
#SECURITY-CRITICAL:
#
# Enable Route Verification on all interfaces to help prevent IP Spoofing.
# Route verification is where a packet which comes from an unexpected
# interface is dropped. If you have Asymmetric Routing, you will instead
# want to disable this filtering on those interfaces.
#
for f in /proc/sys/net/ipv4/conf/*/rp_filter; do
echo 1 > $f
done
- (32)My first helpfile under linux :)
---- aide / tutorials ----
man -k/-K : apropos/recherche dans les pages man
man awk : Aide sur les Expressions régulières
man -t <cmde>: sort le .ps sur stdout du man de la commande
---- commandes diverses ----
ulimit -c 0 : pas de core dump
nice : priorités
time : diverse mesures de temps d'exécution d'un programme
nohup : arrière plan
strace : trace l'execution d'un prog => affiche les libs qui merdent
xargs : echo "coucou" | xargs cat => passe "coucou" comme argument à cat
script : enregistre stdin stderr stdout dans un fichier, finir avec exit.
---- réseau ----
last : dernières personnes logguées
netstat : connexions courrantes
chroot : déplace le /
hdparm : régler les paramètres UDMA du disque
lpstat : liste des imprimantes
---- X ----
xdpyinfo : pour avoir toutes les infos sur la config de X
xev : keycode clavier et souris
xrdb : reload config X (utiliser -load ou -all)
XvGetPortAttribute(dpy, port, attribute, p_value) : pour choisir la luminosité et le contraste
xvinfo : toutes les infos sur l'extension Xv de Xfree
---- programmation ----
hexdump <file> : affiche un file en hexa
make kernel : make clean ; make xconfig ; make dep ; make ; make modules ; make install ; make modules_install
depmod : recrée la liste des dépendances de modules du kernel actuel
java -Xms<val>M : une pile de <valeur> Méga AU DEPART au lieu de 32 M
java -Xmx<val>M : une pile de <valeur> Méga MAX au lieu de 32 M
basename : pour virer une extention à un nom de fichier
---- Xterm ----
--config--
stty : -a pour voir toutes les option, voir man pour les réglages
xterm -sl num -fn <font> : pour régler la taille de fontes de xterm
xterm bloqué : reset / tput reset / tput init / C-j reset C-j / stty sane / C-v C-o ret
--fontes--
kbd : charge la police console
xmodmap -pke : affiche la table d'association touche/action actuelle
--locale--
zoneinfo : charge les parametre locaux pour l'horloge
--calculs--
echo "scale=5; 13.0/24.0" | bc
---- Progs ----
xemacs : CTL-x ESC-ESC? : rappel de la dernière commande (utile après un combi de touches !)
: Pour mettre les modes en route modifier /usr/local/lib/xemacs-21.1.14/lisp/auto-autoloads.el
en retirant (<=>; devant) les lignes contenant "Already Loaded" puis recompiler en .elc par xemacs
xfig : pour avoir les caractères spéciaux (alpha ...) il faut changer de Fonte (Symbol)
--------------------------
PROTOCOLES DE TRANSFERT :
kermit recevoir et transmettre: protocol kermit kermit -h
sb transmettre: protocol y-modem sz -h
sx transmettre: protocol x-modem sz -h
sz transmettre: protocol z-modem sz -h
rb recevoir: protocol y-modem rz -h
rx recevoir: protocol x-modem rz -h
rz recevoir: protocol z-modem rz -h
--------------------------
FICHIERS :
/etc/hosts : config du nom de machine
/etc/resolv.conf : DNS
/etc/ppp/pap-secret et
/etc/ppp/peers/adsl : config des login/mdp pour ADSL
/etc/fstab : pour les droits users : user,gid=XX,uid=YY
/etc/inittab : config des niveaux de boot
/etc/printcap : config imprimante
/etc/services : liste des port associé
/etc/inetd.conf : limitations des services
/etc/host : nom de machine
/etc/hosts.XXX : limitation imprimante
/home/<xxx>/.xsession : pour lancer des trucs à chq démarrage de session X
--------------------------
Comment mettre un LinuX sur un réseau :
0. charger les iptables pour la sécurité
1. régler les services dans /etc/inetd.conf et /etc/services
2. régler les DNS dans /etc/resolv.conf
3. changer le nom de machine : /etc/host ou hostname <nom de machine>
4. lancer l'interface : ifconfig eth0 up 192.168.1.<xxx> netmask 255.255.255.0
3. route par défaut : route del default ; route add -host 192.168.1.<yyy> dev eth0 gw 192.168.1.<yyy>
--------------------------
Comment mettre un DD SCSI sous LinuX :
1. Vérifier le SCSI ID sur le DD avec le Jumper
2. Vérifier au boot que le kernel voit le DD (dmesg) et quel /dev lui est lié
3. Partitionner le DD (fdisk /dev/sd<x> où <x> à remplacer par la lettre donnée en 2)
Mettre le partitions en ext2fs = 83
4. Formatter les partitions (mke2fs /dev/sd<x><y> <x> est une lettre, <y> un chiffre)
5. Créer le répertoire où monter le disque (mkdir /mnt/disk<y>)
6. Ajouter une ligne dans /etc/fstab du type : /dev/sd<x><y> /mnt/disk<y> ext2 defaults 0 0
- (36)Raising skinny elephants is utterly boring (SysReq Keys, thanks to Infernal Quack, Aurélien Bompard and Pierre Tramo)
Si vous bidouillez un peu trop votre Linux et qu'à un moment il
"freeze" et que même CTRL-ALT-SUPPR ne le ranime pas, n'appuyez
surtout pas le bouton reset de votre ordi car ça implique un fsck au
prochain démarrage. Essayer d'abord les contrôles systèmes dans
l'ordre suivant : Alt-SysRq-S (met le swap sur disque) Alt-SysRq-U
(remonte tout en readonly) Alt-SysRq-B (reboot) Et adieu le check
forced :)
Plus d'infos dans /usr/src/linux/Documentation/sysrq.txt
http://linuxfr.org/tips/23.html
-----------------
En fait, la serie est un peu plus longue. C'est :
R S E I U B
R passe ton clavier en mode RAW, après tu peux réessayer C-A-Del ou
mieux C-A-BackSpace (tue X).
E je sais plus ;)
I non plus ;)
U remonte des systèmes de fichier en mode Read-only
Il y a une phrase (à la con) pour se souvenir de tout :
Raising Skinny Elephants Is Utterly Boring.
J'avais aussi trouvé quelquepart :
"Remembering the Sequence Entirely Is Useful, Buddy"
mais je préfère l'autre. ;)
---------------------
d'après sysrq.txt:
* What are the 'command' keys?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'r' - Turns off keyboard raw mode and sets it to XLATE.
'k' - Secure Access Key (SAK) Kills all programs on the current
virtual console. NOTE: See important comments below in SAK
section.
'b' - Will immediately reboot the system without syncing or
unmounting your disks.
'o' - Will shut your system off (if configured and supported).
's' - Will attempt to sync all mounted filesystems.
'u' - Will attempt to remount all mounted filesystems read-only.
'p' - Will dump the current registers and flags to your console.
't' - Will dump a list of current tasks and their information to your
console.
'm' - Will dump current memory info to your console.
'0'-'9' - Sets the console log level, controlling which kernel
messages will be printed to your console. ('0', for example
would make it so that only emergency messages like PANICs or
OOPSes would make it to your console.)
'e' - Send a SIGTERM to all processes, except for init.
'i' - Send a SIGKILL to all processes, except for init.
'l' - Send a SIGKILL to all processes, INCLUDING init. (Your
system will be non-functional after this.)
'h' - Will display help ( actually any other key than those
listed above will display help. but 'h' is easy to remember :-)
pour pouvoir utiliser ces combinaisons, il faut les avoir
compilés leurs support dans le noyau (kernel hacking/Magic Sysrq
key) il est possible de les désactiver grâce à un simple:
echo "0" > /proc/sys/kernel/sysrq
mais la meilleure des choses reste de lire la doc du noyau pour
en savoir plus.
------
Other typical sentences to remember the sequence:
"Raising Elephants Is So Utterly Boring"
"Raising Skinny Elephants Is Utterly Boring"
"Reboot Even If System Utterly Broken"
"BUSIER" read backward
"Red Stripe Ends In Unique Blends"
"Rebooting So Easy In Ubuntu Breezy"
"Remembering the Sequence Entirely Is Useful, Buddy"
- (68)Undelete files
-> Umount the filesystem
-> Use mc (Midnight Commander): "Commands" -> "Undelete Files"
- (88)A simple "Trash Can" script to replace rm by a mv to a Trash dir to prevent f*ck*ng "rm -fr /*"-like mistakes
------------------------------- /bin/myrm
#!/bin/bash
# to use this script to prevent fucking "rm -fr /*"-like mistakes:
# 1. call this script "myrm", put it in /bin and make it executable
# 2. create an alias for each user that wants to use it: alias rm='/bin/myrm' >> ~<user>/.bash_profile
# 3. Don't forget to empty the trash for time to time (or make a script that does it)
Red="\001\033[0;31m\002"
Blue="\001\033[0;34m\002"
ColorOff="\001\033[0m\002"
trashLocation="$HOME/tmp/Trash" # MUST be an ABOSLUTE path
if [[ ! -d ${trashLocation} ]]
then
mkdir ${trashLocation} >/dev/null 2>&1
fi
for i in "$@"
do
#ls "${trashLocation}/"
/bin/mv "$i" "${trashLocation}/"
if [[ $? -eq 0 ]]
then
echo -e "Moving \"$i\" to the trash: ${Blue}OK${ColorOff}"
else
echo -e "Moving \"$i\" to the trash: ${Red}ERROR${ColorOff}"
fi
done
- (115)Copy a whole directory from linux to linux through FAT32 file system without loosing ownership and case
It's simple: build a tar/targz archive ;)
- (121)Preserve permissions and owners when moving files on FAT filesystem
Simply build a tar/targz archive
- (147)When multiple booting the clock does not show the same time under all the OSes
Set the Hardware Clock to UTC
By default, OpenBSD assumes your hardware clock set to UTC (Universal Coordinated Time) rather than local time, assumed by some other operating systems, which can cause problems when multi-booting.
Many other operating systems, can be configured to do the same, which avoids this problem altogether.
If having the hardware clock set to UTC is a problem, you can change the default behavior of OpenBSD using config(8). For example, to configure OpenBSD to use a hardware clock set to US/Eastern (5 hours behind UTC, so 300 minutes):
# config -ef /bsd
OpenBSD 4.6 (GENERIC.MP) #89: Thu Jul 9 21:32:39 MDT 2009
deraadt@i386.openbsd.org:/usr/src/sys/arch/i386/compile/GENERIC.MP
Enter 'help' for information
ukc> timezone 300
timezone = 300, dst = 0
ukc> quit
Saving modified kernel.
See options(4) and search for option "TIMEZONE=value" for more information.
Normally, the time zone is set during install. If you have need to change the time zone, you can create a new symbolic link to the appropriate time zone file in /usr/share/zoneinfo. For example, to set the machine to use EST5EDT as the new local time zone:
# ln -fs /usr/share/zoneinfo/EST5EDT /etc/localtime
From:
http://www.openbsd.org/faq/faq8.html
http://ubuntuforums.org/archive/index.php/t-43810.html
- (170)How to get the UUID of a drive
ls -l /dev/disk/by-uuid/
blkid /dev/sda1
sudo vol_id /dev/sda1
UUID=4020BFEC20BFE6D6 /media/Windows ntfs defaults 0 0
- (180)How to make an archive (e.g. tar) whithout forgetting '.*' files and without "going up" in the directory structure (because of following ../)
find . | xargs tar cvf <name>.tar
find . > /tmp/list
tar cvf <name>.tar -T /tmp/list
- (186)How to switch off the bell
$ setterm -blength 0
$ xset b off
$ xset b on
- (229)Install Word 2003 in wine in TinyCore 2.10
To install :
- Set gdiplus + riched20 + riched32 to native
After installation :
- Word will say that something is not installed correctly
=> rm .wine/drive_c/windows/Installer/*
- Word still says that something has to be repaired
=> ???
- (247)List of sites to find FOSS alternatives
http://www.alternative.to/
http://www.alternativeto.net/
http://www.osalt.com/
- (250)How to recover from icons problems in evolution or any other Gtk -based application?
$ chmod -R 0775 /usr/share/icons
$ echo gtk-icon-theme-name=\"gnome\" >> ~/.gtkrc-2.0
- (334)What is the meaning of the section numbers for the manual pages?
MANUAL SECTIONS
The standard sections of the manual include:
1 User Commands
2 System Calls
3 C Library Functions
4 Devices and Special Files
5 File Formats and Conventions
6 Games et. Al.
7 Miscellanea
8 System Administration tools and Deamons
Distributions customize the manual section to their specifics,
which often include additional sections.
NOTE: In cases like that you can pass the section number to man before the page name to choose which one you want, or use man -a to show every matching page in a row:
$ man 3 printf
$ man -a printf
From: http://unix.stackexchange.com/questions/3586/what-do-the-numbers-in-a-man-page-mean
- (341)How to force a user to change her password at next login?
Il te suffit d'effectuer la commande:
#passwd -e username
en remplacant username par le nom d'utilisateur.
Cordialement.
Le 26 mars 2011 00:08, Jrmmmme Desquilbet <jerome@desquilbet.org> a crit :
> > Bonsoir,
> > Je pose la question aprs avoir cherché en vain dans les pages man...
> > Comment fait-on pour obliger un utilisateur à changer son mot de passe à son
> > prochain login
- (355)How to limit a process (e.g. these f*ck*ng memory-leaking FF4&FF5) memory consumption?
ulimit -d 524288 # (512Mo)
- (356)How to change a user's default shell without beeing root and editing /etc/password?
chsh -s /path/to/shell {user-name}
chsh changes the user login shell. This determines the name of the user's initial login command. A normal user may only change the login shell for her own account, the super user may change the login shell for any account.
http://www.cyberciti.biz/faq/howto-set-bash-as-your-default-shell/
- (358)How to make/use an encrypted filesystem under linux with cryptsetup, using a crypted file as partition?
# create file for cryptedFS
head -c <size> /dev/<zero or random> > luksfile # create empty file
losetup /dev/loop0 luksfile # map luksfile to /dev/loop0
cryptsetup luksFormat /dev/<loop device> -c aes -s 256 -h sha256 # create LUKS on loop device
cryptsetup luksOpen /dev/<loopdevice> <name> # map the loop device to a /dev/maaper device
mke2fs -j /dev/mapper/<name> -L <description string> # initialize a file system
# mount cryptedFS
losetup /dev/loop0 luksfile # map luksfile to /dev/loop0
cryptsetup luksOpen /dev/<loopdevice> <name> # map the loop device to a /dev/maaper device
mount /dev/mapper/<name> /mnt/<mountpoint> # mounts the encrypted file
# umount everything
umount /mnt/<mountpoint>
cryptsetup luksClose /dev/<loopdevice>
losetup -d /dev/<loopdevice>
- (359)How to make an encrypted filesystem under linux with cryptsetup, using directly a partition?
# create file for cryptedFS
cryptsetup luksFormat /dev/<partition> -c aes -s 256 -h sha256 # create LUKS on loop device
cryptsetup luksOpen /dev/<partition> <name> # map the loop device to a /dev/maaper device
mke2fs -j /dev/mapper/<name> -L <description string> # initialize a file system
# mount cryptedFS
cryptsetup luksOpen /dev/<partition> <name> # map the loop device to a /dev/maaper device
mount /dev/mapper/<name> /mnt/<mountpoint> # mounts the encrypted file
# umount everything
umount /mnt/<mountpoint>
cryptsetup luksClose /dev/<partition>
- (368)Where does nautilus mount the samba/cifs shares?
in ~.gvfs/
(note: the f**king latest versions of "mount -t cifs/smbfs" does allow only root to mount such shares. However, at boot, when the computer runs is root, there is no access to the network, since it is WICD as a user that makes it work and when I have access to the network, I am logged in as a single user... therefore I cannot use a simple script at boot to mount the shares...)
- (380)Linux Mint 11 configurations
E:Malformed line 1 in source list /etc/apt/sources.list.d/local-repository.list (dist parse)
> slash ( / ) is what is the solution. just add ( katya/ ) instead of ( katya ) in /etc/apt/sources.list.d/local-repository.list file
__________________________________________________
error "request_module: runaway loop modprobe binfmt-464c"
Short answer: If you are getting this error right after linux kernel initialization, you are likely booting a 32-bit kernel with a 64-bit OS
http://saalwaechter-notes.blogspot.com/2008/10/requestmodule-runaway-loop-modprobe.html
_________________________________________________
W:Failed to fetch http://archive.canonical.com/ubuntu/dists/katya/partner/binary-amd64/Packages 404 Not Found
refresh servers lists
_________________________________________________
Set the clock to UTC (so that it does not conflicts with OpenBSD)
gksu gedit /etc/default/rcS => UTC="yes"
- (384)What to do if errors saying that dbus is not running occur?
When getting a DBus error or when launching a software that does nothing but should talk with devices.other programs
use:
$ dbus-launch <name of software>
- (387)Useful flags for pgrep
-f The pattern is normally only matched against the process name. When -f is set, the full command line is used.
-u euid,...
Only match processes whose effective user ID is listed. Either the numerical or symbolical value may be used.
-x Only match processes whose name (or command line if -f is specified) exactly match the pattern.
- (392)Script to umount a luksFS encrypted file
umount /dev/mapper/airpx # unmounts the encrypted file
cryptsetup luksClose /dev/mapper/airpx # unmap the loop device to a /dev/maaper device
losetup -d /dev/loop0 # detaches the crypted file
- (393)How to take a screenshot in commandline mode (a.k.a import/scrot)?
- With ImageMagick
import MyScreenshot.png
To capture the entire screen after a delay (so you can open some menus or whatever):
sleep 10; import MyScreenshot2.png
To capture the whole screen
import -window root MyScreenshot2.png
You can also manipulate the screenshot with ImageMagick as you take it. For example, the following line will take a screenshot and resize the image to a width of 500 pixels:
import -window root -resize 500 AnotherScreenshot.png
- With scrot
sudo aptitude install scrot
scrot MyScreenshot.png
To get a screenshot and immediately open it in the GIMP, type:
scrot -q 85 -d 5 screenshot.png && gimp screenshot.png &
The -q option sets the quality.
The -d sets the delay.
- With gnome-[panel-]screenshot
gnome-panel-screenshot
You can also add a delay:
gnome-panel-screenshot --delay 5
From: http://tips.webdesign10.com/how-to-take-a-screenshot-on-ubuntu-linux
- (2115)How to use multiple calendar files with BSD's "calendar" tool?
SOLUTION: simply call "calendar" multiple times
-- Typical example from my .bashrc
( calendar -A 3 -B 1 -f ~/.dates_naissances ; \
calendar -A 1 -B 1 -f /usr/share/calendar/fr_FR/calendar.fetes ; \
calendar -A 7 -B 0 -f /usr/share/calendar/fr_FR/calendar.jferies) | sed '/^$/d' | sort -k1,1 -k2,2
From: Personnal experience
- (409)How to remove fortunes in LinuxMint11?
in gconf-editor set this entry
/desktop/linuxmint/terminal/show_fortunes
to false
(there is also an entry in gnome-control-center under "window manager"/"terminal" or something like that...)
- (470)How to detect which linux distro is running?
"uname -r" for kernel.
"cat /etc/issue" for distro (on any distro)
--
Novell SUSE /etc/SUSE-release
Red Hat /etc/redhat-release, /etc/redhat_version
Fedora /etc/fedora-release
Slackware /etc/slackware-release, /etc/slackware-version
Debian /etc/debian_release, /etc/debian_version, /etc/os-release (wheezy)
Mandrake /etc/mandrake-release
Yellow dog /etc/yellowdog-release
Sun JDS /etc/sun-release
Solaris/Sparc /etc/release
Gentoo /etc/gentoo-release
UnitedLinux /etc/UnitedLinux-release
ubuntu /etc/lsb-release
$ cat /proc/version
$ cat /proc/sys/kernel/{ostype,osrelease,version}
$ cat /etc/*release
$ lsb_release -a
From: http://www.novell.com/coolsolutions/feature/11251.html
https://www.cyberciti.biz/faq/command-to-show-linux-version/
- (490)A simple script to take snapshots of pre-defined webpages
#!/bin/sh
# From: http://stackoverflow.com/questions/125951/command-line-program-to-create-website-screenshots-on-linux
# start a server with a specific DISPLAY
vncserver :11 -geometry 1024x768
# start firefox in this vnc session
firefox -display :11
# read URLs from a data file in a loop
count=1
while read url
do
# send URL to the firefox session
firefox -display :11 $url
# take a picture after waiting a bit for the load to finish
sleep 5
import -window root image$count.jpg
done < url_list.txt
# clean up when done
vncserver -kill :11
- (491)How to clear/reset any terminal?
tput [-Ttype] capname [parms ... ]
tput [-Ttype] init
tput [-Ttype] reset
tput [-Ttype] longname
tput -S <<
tput -V
tput clear
Echo the clear-screen sequence for the current terminal.
- (538)How to back-up files while preserving permissions?
DO NOT USE the 7-zip format for backup purpose on Linux/Unix because :
- 7-zip does not store the owner/group of the file.
On Linux/Unix, in order to backup directories you must use tar :
- to backup a directory : tar cf - directory | 7za a -si directory.tar.7z
- to restore your backup : 7za x -so directory.tar.7z | tar xf -
- (554)Bitlbee: How to create a room to speak to one buddy in particular?
Use:
/query <nickname>
Instead of:
/msg <nickname> <message>
<nickname>: <message>
- (565)How to make a user a sudoer on Ubuntu?
# usermod -a -G admin $USER
- (567)How to prevent overwriting of existing files?
Use the 'k' option:
tar xkvzf file.tgz
Useful when mistaking x for c... => does not overwrite existing files!
- (569)How to set default browser (or any alternative software) in Mint/Ubuntu?
check the output of the following commands and how they could be changed
- exo-open http://<somesite>
- xdg-open http://<somesite>
- gnome-open http://<somesite>
- kde-open http://<somesite>
- (pcmanfm http://<somesite>)
$ update-alternatives --list x-www-browser
/usr/bin/arora
/usr/bin/firefox
/usr/bin/konqueror
/usr/bin/midori
# update-alternatives --set x-www-browser /usr/bin/firefox
- (570)How to store alsa mixer configuration?
1. set mixer levels using (as user or root?):
$ alsamixer
2. save configuration (as root) using:
# alsactl store
- (571)How to see the progress of a command (e.g. the growth of resulting file)?
watch -n <refresh delay in secs> "<command>"
e.g.,
$ watch -n 1 "ls -al outfile.text"
NOTE: if you use * in the command, you HAVE TO use single quotes (') instead of double quotes (") around the command, otherwise the list of files will be extended during the call of watch, thus fixed once and for all in the list of arguments passed to the command, and watch will refresh display for these files only. Newly created files will never appear in the results!
Thx Karim
- (574)How to do show progress of a command (e.g. cp, netcat) with a progressbar?
You can use pv or rsync --progress
cat $1 | pv -s -L $size -p -e -r > $2
cat $1 | pv -s 1m -p -e -r > $2
rsync --stats --progress
From: http://www.mjmwired.net/linux/2008/09/26/copy-with-a-progress-bar/
cat backup.iso | pv -b | nc -l 3333
From: http://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/
#@source
tar -cf - /path/to/dir | pv | nc -l -p 6666 -q 5
#@target
nc 192.168.1.100 6666 | pv | tar -xf -
From: http://www.commandlinefu.com/commands/view/15289/network-folder-copy-with-monitoring-tar-nc-pv-
- (576)How to know which distribution of Linux you are running?
$ cat /etc/issue
$ cat /etc/issue.net
$ lsb_release -a
$ cat /etc/*-release
$ cat /etc/*-version
$ cat /etc/*release
$ cat /etc/*_release
$ cat /etc/*version
- (579)My .Xsession
#!/bin/bash
# A function that runs a process only if it is not already running
function run_only_once()
{
IFS=" " read -a splitted <<< $1
progName=`basename ${splitted[0]}`
if [[ "$progName" =~ "sudo" ]]
then
progName="$(basename "${splitted[1]}")"
fi
# echo "PROG_NAME: $progName"
# out=$(pgrep -f "$progName(\\s+|$)")
# echo -e "PGREP: $out ($?)"
mesg=$(pgrep -f "$progName(\\s+|$)" || eval "${splitted[*]}" 2>&1)
echo -e "${progName}:\n ${mesg}" >> /tmp/mesg_${progName}
}
# Swap CTL and CapsLock keys
# Set correct FR keymap (i.e. with numpad)
(sleep 0 ; source ~/Softs/set_keyboard) &
# Run screensaver deamon
(sleep 1 ; run_only_once "/usr/bin/xscreensaver -no-splash" ) &
# Run davmail, the proxy to get LDAP+MAIL+CALENDAR from the Outlook/Exchange server
(sleep 1 ; run_only_once "/usr/bin/davmail" ) &
# Set sound level
(sleep 1 ; /usr/bin/amixer sset 'Master' 98% ; /usr/bin/amixer sset 'Headphone' 98% ; /usr/bin/amixer sset 'Speaker' 98% ; /usr/bin/amixer sset 'PCM' 98%) & # /usr/bin/amixer sset 'Beep' disable
# Run MintUpdate
(sleep 1 ; run_only_once "/usr/lib/linuxmint/mintUpdate/mintUpdate.py" ) &
# Run network applet
(sleep 1 ; run_only_once "/usr/bin/nm-applet" ) &
# Run ACPI applet
(sleep 1 ; run_only_once "/usr/bin/gnome-power-manager" ) &
# Set correct resolution on both screens (particularly the right one)
(sleep 2 ; source ~/Softs/set_resolution) &
# Set bg image
(sleep 3 ; source ~/Softs/set_background) &
# Set the ssh-agent so that the passphrase is to be entered only one in this X session
(/usr/bin/ssh-agent /usr/bin/awesome & /usr/bin/ssh-add) &
- (597)How to kill a zombie?
Tuesday, May 13, 2008
Killing Zombie Processes In Linux And Unix
Greetings,
Today's post is going to deal with "zombie" processes. These are processes to which the definition of a process only loosely applies.
A zombie process is most often generated when a parent process loses track of its child process and that child process becomes detached. The parent process, generally running some sort of a "wait()" call to receive notification that the child process has exited, loses track of the child process and never receives that information. The child process exits normally, but the parent thinks it's still running, and thus is a zombie process born :)
There are a number of steps to take, from simplest to most obscure, to get rid of zombie processes. And then there's what to do if none of that seems to work. Here we go :)
1. First, identify the fact that you have zombie processes running on your system (you may not notice, and there's a good reason why, which we'll address near the end of this post). You can do this on most major brands of Unix and Linux by running:
host # ps -el|grep Z <--- The -l flag to ps will include the "state" column. The zombie state is represented by a capital Z.
On Solaris 9:
host # ps -el|grep Z
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 Z 0 3038 1 0 0 - - 0 - ? 0:00
0 Z 0 19769 2966 0 0 - - 0 - ? 0:00
On SUSE Linux 9:
/home/ymdg001# ps -el|grep Z
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 Z 0 476 9874 0 0 - - 0 - ? 0:00
2. Now that you know you have zombie processes running, the first, and easiest, thing you can do to kill them is to try and "assassinate" the actual defunct (zombie) process. For the process in the SUSE example above, you can always try:
host # kill -9 476
It probably won't work, but it's worth a shot. Sometimes it does and your troubles are over just like that :)
3. Next, you should try to kill the parent process. This may or may not be possible for you. For instance, the parent process may be a process that you "need" to have running. It may also be a process that the Operating System "needs" to have running (like "init" - process 1, shown in the Solaris example above, under the PPID column).
Killing the parent process (if possible) will almost always work to get rid of a zombie process.
Please "never" try to kill init (process 1). If you're successful, your machine will go down hard and fast!
4. Assuming none of the above worked, some common wisdom says you should just give up (and for good reason, which we'll get to very soon ;). However you can try killing both the zombie process (and/or the parent process) using signals other than SIGKILL (or -9). I've seen it happen more than a few times. Different programs trap, and/or handle, different signals different ways. If your zombie doesn't go away when you execute a "kill -9" against it, try a simple "kill" (Which is, technically "kill -15" or SIGTERM). You can try to kill the process with any signal you want. I generally try signals 1 - 15 and then SIGUSR1 and SIGUSR2, just in case they're defined differently for that particular program on that particular system. You'd be surprised how many zombies you can whack with a SIGHUP or SIGINT. Sending a kill SIGCHLD or SIGCLD (Which is the same as SIGCHLD on System V) is a good one to try, as well. Sometimes your chosen method won't make "textbook sense" but it will work from time to time :)
You can find a handy list of signals to try in our old post on translating signal names to numbers and vice versa.
5. And the point I've been alluding to throughout this entire post.
What to do if your zombie process just won't die, you can't kill the parent and/or you're otherwise stuck?
The answer is: nothing.
Here's a brief explanation why: Even though zombie processes alarm most casual users of Unix and/or Linux, and they can make the process table look ugly with all those "defunct" messages scattered in between everything else, a zombie process lives up to its name in more ways than the sense defined above. It literally is like the somewhat-living dead. Although the proc table (and filesystem) have space reserved to record it, the process has already exited and is not consuming any of your system resources. It takes up none of your kernel or system space and is only a minor nuisance since "times" keeps track of its time (If you're a fly, you'll notice the 0:00 slow-down ;)
6. But WAIT!
There's more... (I'm starting to sound like a pitch man ;). Here's one last thing you can do if that ps entry for your zombie process is really bugging you: Once the zombie has totally disconnected from its parent process, you can just use the "wait" command to make it go away. For example:
host # ps -el|grep Z
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 Z 0 3038 1 0 0 - - 0 - ? 0:00
host # id
uid=0(root) gid=0(root)
host # wait 3038
...and when that returns (I'd recommend that you run this with "&" to background it - e.g. "wait 3038 &")
host # ps -el|grep Z
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
It's gone :)
In any event, hopefully, after reading this, you'll no longer worry about zombies :)
Cheers,
Mike
From: http://linuxshellaccount.blogspot.fr/2008/05/killing-zombie-processes-in-linux-and.html
- (601)How to resize images with ImageMagick?
$ convert rose.jpg -resize 50% rose.png
- (609)How to change the name of output files in Grip?
Figure 7.4: Configuring grip is straightforward. This setup uses cdparanoia to read the Audio CD data and lame to convert the resulting WAV files to mp3. Note also that a track number (%t) has been added to the file name.
From: http://www.togaware.com/linux/survivor/Grip.html
- (617)What graphical tools exist for visualizing "diff"s between two files?
xxdiff
(x)emacs ediff mode
vim -d file1 file2
meld
kompare
kdiff3
Diffuse
Guiffy
vimdiff
gvimdiff
tkdiff
colordiff
- (625)How to draw the tree of running processes?
ps auxf
- (694)Basic scripts to run Word/Excel/Powerpoint from wine
wine ~/.wine/drive_c/Program\ Files/Microsoft\ Office/Office12/EXCEL.EXE "$*"
wine ~/.wine/drive_c/Program\ Files/Microsoft\ Office/Office12/POWERPNT.EXE "$*"
wine ~/.wine/drive_c/Program\ Files/Microsoft\ Office/Office12/WINWORD.EXE "$*"
- (696)How to transpose a matrix (i.e. exchange lines/columns)?
if [[ $# != 2 ]]
then
echo "USAGE: $0 <filename> <separator>"
else
file=$1
sep=$2
awk '
{
for (i=1; i<=NF; i++)
{
a[NR,i] = $i
}
}
NF>p { p = NF }
END
{
for(j=1; j<=p; j++)
{
str="a[1,j]"
for(i=2; i<=NR; i++)
{
str=str" "a[i,j];
}
print str
}
}' $file
fi
- (698)How to mount/umount a LUKS encrypted file?
###### MOUNT
losetup /dev/loop0 /home/$USER/Work/AirPX/luksfile.JSUN0\!
cryptsetup luksOpen /dev/loop0 airpx # map the loop device to a /dev/maaper device
mount /dev/mapper/airpx # mounts the encrypted file
###### UMOUNT
umount /dev/mapper/airpx # unmounts the encrypted file
cryptsetup luksClose /dev/mapper/airpx # unmap the loop device to a /dev/maaper device
losetup -d /dev/loop0 # detaches the crypted file
- (699)Scripts to quickly check for spelling
echo "$1" | aspell -a -d french
echo "$1" | aspell -a -d english
- (705)Script to uncompress file in batch
#TODO : test error return and/or "Everything is OK" and remove $i
for i in *.[Zz][Ii][Pp] *.[Rr][Aa][Rr] ; do 7z x $i ; done
- (719)How to get the week number?
For today:
$ date +%W
17
For any date in the past/future:
$ date -d"04/15/2012" +%W
- (733)Which is the quicker between "sed" and "tr" to strip a string?
Answer: "tr" !
$ time seq 1 5000000 | tr '\n' ',' | sed -e 's/[,;]//g' > /dev/null
real 0m4.096s
user 0m4.140s
sys 0m0.170s
$ time seq 1 5000000 | tr '\n' ',' | tr -d ',' | tr -d ';' > /dev/null
real 0m3.122s
user 0m3.230s
sys 0m0.100s
- (735)How to beautifully convert a PDF to a PNG?
convert -density 600x600 -resize '2048x!' -quality 90 toto.pdf toto.png
- (737)How to get the list of all installed packages in Ubuntu-based distros?
dpkg --get-selections
- (738)How to cleanly reinstall a package in Ubuntu-based distros?
apt-get install --reinstall -y <pkgname>
- (739)How to force the install a package in Ubuntu-based distros?
apt-get install -f <pkgname>
- (740)How to remove all files when removing a package in Ubuntu-based distros?
apt-get remove --purge <pkgname> # the purge applies to all "remove" cmds even for dependencies
or
apt-get purge <pkgname> # purges only the named packages
- (755)How to know which video driver is currently in use on my system?
$ jockey-text -l
or:
$ lshw -c video
look for the line with "configuration". The loaded driver is prefixed with "driver:"
or:
$ lspci -nnk | grep -i vga -A3 | grep -C 10 'in use'
Then you can get more info about the running driver with:
$ modinfo i915
From: http://askubuntu.com/questions/23238/how-can-i-find-what-video-driver-is-in-use-on-my-system
- (756)How to prevent a Linux kernel module from auto loading (a.k.a how to prevent nouveau from crashing regularly your machine)?
If you are using CentOS/Redhat/RHEL/Fedora Linux...
Just open your /etc/modprobe.conf file and turn of auto loading using following syntax:
alias driver-name off
If you are using Debian / Ubuntu Linux...
open /etc/modprobe.d/blacklist file and add drivername using following syntax:
blacklist driver-name
From: http://www.cyberciti.biz/tips/avoid-linux-kernel-module-driver-autoloading.html
- (765)How to Auto Mount Drives at System Startup in Linux Mint 13
- Go to Menu > Software Manager, type pysdm into the Search box and press "Enter".
- Select "pysdm" and click "Install" if it has not been installed.
- Go to Menu > Applications > Administration > Storage Device Manager.
- Extend the list of sda and select the sda you want to auto mount, click 'OK' to configure.
- Click the "Assistant" button.
- Uncheck "Mount file system in read only mode" and keep "The file system is mounted at boot time" checked.
- Click the "Mount", "Apply" then "Close" button, and restart the system.
From: http://www.techsupportalert.com/content/tips-and-tricks-ubuntu-after-installation-ubuntu-1204.htm
- (773)How to install/update packages AND THEIR DEPS on a machine with no internet access?
Use Keyrix: http://www.le-libriste.fr/2010/01/keyrix-gestionnaire-de-package-apt-offline/
- (783)How to list M$ machines on an SMB network?
$ smbtree -N
- (787)How to solve error: "WARNING: The following packages cannot be authenticated!" in Ubuntu/Debian?
- Update the ftp server key with sudo apt-key update command.
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com votre_n°_de_cle
From: http://doc.ubuntu-fr.org/apt-key
- Run the sudo apt-get update command to update the source list.
From: https://answers.launchpad.net/ubuntu/+source/update-manager/+question/88266
- (791)How to manage services in ubuntu/debian?
- Starting a Service
# Traditional:
/etc/init.d/myservice start
# Upstart
service myservice start
- Stopping a Service
# Traditional:
/etc/init.d/myservice stop
# Upstart
service myservice stop
- Getting a list of Services
# Traditional:
ls /etc/init.d
# Upstart:
service --status-all
- Adding a Service to Default runlevels
update-rc.d apache2 defaults
- Removing a Service from Default runlevels
rm /etc/rc*/*myscript
- Interesting files:
/etc/init is where the upstart init configs live. While they are not scripts themselves, they essentially execute whatever is required to replace sysvinit scripts.
/etc/init.d is where all the traditional sysvinit scripts and the backward compatible scripts for upstart live. The backward compatible scripts basically run service myservice start instead of doing anything themselves. Some just show a notice to use the "service" command.
/etc/init/rc-sysinit.conf controls execution of traditional scripts added manually or with update-rc.d to traditional runlevels in /etc/rc*
/etc/default has configuration files allowing you to control the behaviour of both traditional sysvinit scripts and new upstart configs.
From: https://help.ubuntu.com/community/UbuntuBootupHowto
- (792)How to correct error "<some-package>: Depends: <other-package> (= version) but this-version is to be installed" in apt-get?
- make sure that the "restricted" and "universe" repositories are enabled
- sudo apt-get clean ; sudo apt-get autoclean
- sudo apt-get -f install ; sudo dpkg --configure -a ; sudo apt-get -f install
- sudo apt-get -u dist-upgrade ; sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
- Disable/Remove/Purge PPAs (e.g. in synaptic), then:
sudo apt-get install ppa-purge
sudo ppa-purge ppa:someppa/ppa
- sudo apt-get autoremove --purge package-name
sudo add-apt-repository --remove ppa:someppa/ppa
sudo apt-get autoclean
From: http://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies
- (793)How to prevent messages from other users to be printed to the console?
write/talk/ytalk, etc. allow to send message to other users on the machine.
to prevent these message to appear on your console/terminal, use:
mesg n # To be done for each tty you are logged in!
- (794)How to set/unset the proxy in CLI in ubuntu? [a.k.a how to set a gnome property w/o using gnome?]
-- Unset
unset no_proxy
unset http_proxy
unset https_proxy
unset ftp_proxy
unset socks_proxy
gsettings set org.gnome.system.proxy mode 'none'
gsettings set org.gnome.system.proxy.http enabled false
# Could be ignored?
gsettings set org.gnome.system.proxy.http host ''
gsettings set org.gnome.system.proxy.http port 0
gsettings set org.gnome.system.proxy.http use-authentication false
gsettings set org.gnome.system.proxy.https host ''
gsettings set org.gnome.system.proxy.https port 0
gsettings set org.gnome.system.proxy.ftp host ''
gsettings set org.gnome.system.proxy.ftp port 0
gsettings set org.gnome.system.proxy.socks host ''
gsettings set org.gnome.system.proxy.socks port 0
gsettings set org.gnome.system.proxy use-same-proxy false
gsettings set org.gnome.system.proxy ignore-hosts "[ 'localhost', '127.0.0.0/8' ]"
-- Set
export no_proxy=localhost,127.0.0.1,*.example.com
export http_proxy=http://cache.polytechnique.fr:8080/
export https_proxy=https://cache.polytechnique.fr:8080/
export ftp_proxy=ftp://cache.polytechnique.fr:8080/
# export socks_proxy=socks://cache.polytechnique.fr:8080/
# Configuration
gsettings set org.gnome.system.proxy.http host 'cache.polytechnique.fr'
gsettings set org.gnome.system.proxy.http port 8080
gsettings set org.gnome.system.proxy.http use-authentication false
gsettings set org.gnome.system.proxy use-same-proxy false
gsettings set org.gnome.system.proxy.https host 'cache.polytechnique.fr'
gsettings set org.gnome.system.proxy.https port 8080
gsettings set org.gnome.system.proxy.ftp host 'cache.polytechnique.fr'
gsettings set org.gnome.system.proxy.ftp port 8080
gsettings set org.gnome.system.proxy.socks host ''
gsettings set org.gnome.system.proxy.socks port 0
# Enabling
gsettings set org.gnome.system.proxy mode 'manual'
gsettings set org.gnome.system.proxy.http enabled true
gsettings set org.gnome.system.proxy ignore-hosts "[ 'localhost', '127.0.0.0/8' ]"
- (797)How to change the base directory of UbuntuOne?
In ~/.config/ubuntuone/syncdaemon.conf add:
[__main__]
root_dir = ~/new/folder
From: http://ubuntuforums.org/showthread.php?t=1291425
- (801)How to create the root user in Ubuntu?
$ sudo passwd root
From: http://en.kioskea.net/faq/12775-ubuntu-create-a-root-password
- (809)How to know the used/free/total RAM available in Linux?
cat /proc/meminfo
From: http://www.cyberciti.biz/faq/linux-check-memory-usage/
cat /sys/devices/system/node/node0/meminfo
From: http://stackoverflow.com/questions/4724259/relation-between-linux-proc-meminfo-and-sys-devices-system-node-nodex-meminfo
- (810)How to know the used/free CPU usage in Linux?
cat /proc/stat
From: http://askubuntu.com/questions/68741/finding-cpu-usage-from-top-command
From: http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html
TODO: and with /sys ????
From: ???
- (811)How to know the used/remaining battery usage in Linux?
cat /proc/acpi/battery/BAT0/state
From: http://www.tldp.org/HOWTO/ACPI-HOWTO/usingacpi.html
cat /sys/class/power_supply/BAT0/charge_*
From: https://bbs.archlinux.org/viewtopic.php?id=128453
- (812)How to move back to alsa instead of pulseaudio?
1. Remove pulseaudio
apt-get autoremove pulse??
2. If your username don't belong also in the audio group, you should
add your user as a member of it, like
sudo usermod -a -G audio <your_login_name>
From: http://cmc.site11.com/2011/01/ubuntu-10-04-alsamixer-cannot-open-mixer-no-such-file-or-directory-solved/
- (814)How to swap Ctrl-Caps in console in Linux?
$ sudo dumpkeys > /usr/share/keymaps/Caps2Ctrl.map
Then add the following lines to that file:
keycode 58 = Control #This makes Caps act as Ctrl
keycode 29 = Caps_Lock #This makes Ctrl act as Caps
# alt_is_meta #This fixes the Alt key
Then run loadkeys on that file:
$ sudo loadkeys /usr/share/keymaps/Caps2Ctrl.map
Also see Tip#707 & Tip#1163
From: http://emacswiki.org/emacs/MovingTheCtrlKey#toc7
- (815)How to access Google Drive for Ubuntu?
- Install google-drive-ocamlfuse [https://github.com/astrada/google-drive-ocamlfuse]
sudo add-apt-repository ppa:alessandro-strada/ppa
sudo apt update && sudo apt install google-drive-ocamlfuse
- Commandline usage
- google-drive-ocamlfuse
The first time you do this the utility will create all the
relevant config files and folders it needs to mount your Google
Drive account. It will also launch your default web browser so
that you sign in and authorize access to your Google Drive files.
- mkdir ~/googledrive
- Once created go ahead and mount it there by running this command:
google-drive-ocamlfuse ~/googledrive
Pop open Nautilus (or whichever modern file manager you use) and
you will see your Google Drive mount listed in the sidebar as a
device.
- When you’re finished editing, adding or copying files you can
unmount the fuse filesystem with this command:
fusermount -u ~/google-drive
From: http://www.omgubuntu.co.uk/2017/04/mount-google-drive-ocamlfuse-linux
---
- sudo apt install gnome-control-center gnome-online-accounts
- After you do, open the Dash and search for “GNOME Control
Center”. Launch the “Settings” application that appears.
- Click the “Online Accounts” option in the GNOME Control Center
window.
- Click the “Add Account” button, select “Google”, and sign into your
Google account. Give the GNOME desktop access to your account when
prompted. Ensure that the “Files” option is enabled here.
- Open the File Manager and you’ll see your Google account’s email
address as an option under “Computer” in the sidebar. Click it to
view your Google Drive files.
From: https://www.howtogeek.com/196635/an-official-google-drive-for-linux-is-here-sort-of-maybe-this-is-all-well-ever-get/
- (819)How to build an alarm clock or sleeping schedule with Audacious?
Enable the "Alarm" plugin that comes with Audacious and that solves the wake-up part. Then I start playing a song and type in a terminal "sleep 30m; audacious -s" where you can change 30m (30 minutes) to 1h (1 hour) or whatever duration you wish it should play before stopping.
From: http://ubuntuforums.org/showthread.php?t=903962
- (821)How to change the hostname in Ubuntu?
http://www.tech-recipes.com/rx/2732/ubuntu_how_to_change_computer_name/
http://ubuntuforums.org/showthread.php?t=799896
*Re: sudo: unable to resolve host*
------------------------------------------------------------------------
Yup. If you change the hostname in /etc/hostname, you must also fix up /etc/hosts so the new name resolves to 127.0.0.1. The safest way is to edit hosts and add the new name, then edit hostname, then go back to hosts to remove the old hstname.
- (822)How to use gnome-open to open pdf files? [a.k.a how to change file association for Ubuntu/Gnome]
Fourth Approach
I could reproduce your problem by deleting this file /usr/share/applications/evince.desktop, so make sure you have this file.
Third Approach
xdg-open appears to use the configuration of /etc/mailcap. So edit it to associate pdf with evince.
gksu gedit /etc/mailcap
Look for the lines that begin with application/pdf; application/x-pdf; application/x-bzpdf; application/x-gzpdf. They should look like this to associate pdf with evince:
application/pdf; evince '%s'; test=test -n "$DISPLAY"; nametemplate=%s.pdf
application/x-pdf; evince '%s'; test=test -n "$DISPLAY"; nametemplate=%s.pdf
application/x-bzpdf; evince '%s'; test=test -n "$DISPLAY"; nametemplate=%s.pdf.bz2
application/x-gzpdf; evince '%s'; test=test -n "$DISPLAY"; nametemplate=%s.pdf.gz
Second Approach
What is the output of
xdg-mime query filetype foo.pdf
If the output isn't what we should expect, then:
xdg-mime default evince.desktop application/pdf
First Approach
There are other places that the file associations are set.
You may change the files associations at:
/usr/share/applications/defaults.list
/usr/share/applications/mimeinfo.cache
~/.local/share/applications/
~/.gnome/share/apps/
Look for "pdf" and for "Nautilus" inside theses files.
From: http://askubuntu.com/questions/35602/using-gnome-open-to-open-pdf-files
- (824)How to install a specific version of grails in Ubuntu?
sudo add-apt-repository ppa:groovy-dev/grails
sudo apt-get update
sudo apt-get install grails-ppa
#to add grails 2.0.x
sudo apt-get install grails 2.0.x
#to add grails 1.3.9
sudo apt-get install grails-1.3.9
#to add grails 1.2.5
sudo apt-get install grails-1.2.5
#switch between versions
sudo update-alternatives --config grails
From: http://grails.org/download/ubuntu
- (825)How to create Application launcher and add icon to Unity in Ubuntu 12.10?
sudo gnome-desktop-item-edit /usr/share/applications/ --create-new
From: http://www.howopensource.com/2012/10/create-application-launcher-add-icon-to-unity-ubuntu-12-10/
- (826)How to disable guest account in ubuntu 12.04?
$ gksudo gedit /etc/lightdm/lightdm.conf
Add the following line:
allow-guest=false
From: http://www.ubuntugeek.com/ubuntu-tiphow-to-disable-guest-account-in-ubuntu-12-04precise.html
- (827)How to disable the overlay scrollbars in Ubuntu?
sudo apt-get remove overlay-scrollbar liboverlay-scrollbar-0.1-0
sudo su
echo "export LIBOVERLAY_SCROLLBAR=0" > /etc/X11/Xsession.d/80overlayscrollbars
- (828)How can I move the window buttons to the top right of the window in Ubuntu?
Press Alt+F2 to open the Run Application window.
Type gconf-editor into the text box and click Run to start the Configuration Editor.
Open /apps/metacity/general using the side pane and double-click the button_layout item.
Change the value to say
:minimize,maximize,close
(the position of the colon determines which side of the window the buttons appear on).
Click OK and the location of the windows buttons will change immediately.
From: https://help.ubuntu.com/10.04/config-desktop/C/window-button-order.html
- (836)How to set proxy for apt-get?
- Temporary proxy session
This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy.
Enter this line in the terminal prior to using apt-get (substitute your details for yourproxyaddress and proxyport).
$ export http_proxy=http://yourproxyaddress:proxyport
If you normally use sudo to run apt-get you will need to login as root first for this to work unless you also add some explicit environment settings to /etc/sudoers, e.g.
Defaults env_keep = "http_proxy https_proxy ftp_proxy"
- APT configuration file method
This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you only want apt-get (and not other applications) to use a http-proxy permanently.
On some installations there will be no apt-conf file set up. This procedure will either edit an existing apt-conf file or create a new apt-conf file.
$ gksudo gedit /etc/apt/apt.conf
Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
Acquire::http::Proxy "http://yourproxyaddress:proxyport";
Save the apt.conf file.
- BASH rc method
This method adds a two lines to your .bashrc file in your $HOME directory. This method is useful if you would like apt-get and other applications for instance wget, to use a http-proxy.
gedit ~/.bashrc
Add these lines to the bottom of your ~/.bashrc file (substitute your details for yourproxyaddress and proxyport)
http_proxy=http://yourproxyaddress:proxyport
export http_proxy
Save the file. Close your terminal window and then open another terminal window or source the ~/.bashrc file:
$ source ~/.bashrc
Test your proxy with sudo apt-get update and whatever networking tool you desire. You can use firestarter or conky to see active connections.
If you make a mistake and go back to edit the file again, you can close the terminal and reopen it or you can source ~/.bashrc as shown above.
$ source ~/.bashrc
- How to login a proxy user
If you need to login to the Proxy server this can be achieved in most cases by using the following layout in specifying the proxy address in http-proxy. (substitute your details for username, password, yourproxyaddress and proxyport)
http_proxy=http://username:password@yourproxyaddress:proxyport
From: https://help.ubuntu.com/community/AptGet/Howto#Setting_up_apt-get_to_use_a_http-proxy
- (838)How to work with UbuntuOne in CLI?
u1sdtool --start &
u1sdtool --status &
u1sdtool --current-transfers &
u1sdtool --quit
u1sdtool --connect
u1sdtool --refresh-shares
- (841)How to solve error "No protocol specified" or "Gtk-WARNING **: cannot open display: :0" when running sudo in Ubuntu/LinuxMint?
$ su $USER -c 'xhost local:$USER; <command>'
Or simply add "xhost local:root" in the Xorg's user's .bashrc
From: http://ubuntuforums.org/showthread.php?t=759389
Pour info, je ne sais pas si tu te rappelles, j'avais un problème avec VirtualBox que toi tu n'avais pas : quand je lançais avec sudo, Ubuntu me faisait une erreur "No protocol specified" ou "Gtk-WARNING **: cannot open display: :0". J'ai le même problème de nouveau à mon nouveau taff.
Je viens de trouver le problème et la solution : j'avais créé un "vrai" utilisateur root. Du coup, le squelette de .bashrc avait été copié dans /root. Or, ce dernier ne définit pas les infos Xorg. En ajoutant "xhost local:root" dans le .bashrc, ça remarche :) (si j'ai bien compris, ça dit en tant que quel utilisateur les affichages doivent être fait)
- (848)How to make UbuntuOne work again after an upgrade?
Error: Failure: ubuntuone.platform.tools.linux.IPCError: org.freedesktop.DBus.Error.NoReply
I have solved the issue here. First login into https://login.ubuntu.com/, click the Applications tab and remove the devices. Then:
/bin/rm -fr ~/.config/ubuntuone
/bin/rm -fr ~/.cache/ubuntuone/
/bin/rm -fr ~/.local/share/ubuntuone/
From: https://bugs.launchpad.net/ubuntuone-control-panel/+bug/966731
- (854)How to convert music (flac/wma/...) or movies (mp4/avi/flv...) to mp3?
---- For flac (specific to flac)
1. install "flac" and "lame"
2. run:
for file in *.flac; do flac -cd "$file" | lame -h - "${file%.flac}.mp3"; done
From: http://pinehead.tv/linux/solution-converting-flac-to-mp3/
---- For wma (more generic, can be used for any format supported by mplayer)
(sudo mkfifo /dev/mypipe ; sudo chmod a+rwx /dev/mypipe)
for i in *.wma ; do mplayer -ao pcm:file=/dev/mypipe "$i" | lame -h /dev/mypipe "$i.mp3" ; done
(sudo /bin/rm /dev/mypipe)
From: http://lists.freebsd.org/pipermail/freebsd-multimedia/2004-April/001049.html
---- For movies
(sudo mkfifo /dev/mypipe2 ; sudo chmod a+rwx /dev/mypipe2)
for i in *.mp4 *.flv *.avi ; do mplayer -vo null -vc null -ao pcm:fast:file=/dev/mypipe "$i" | lame -h /dev/mypipe "$i.mp3" ; done
(sudo /bin/rm /dev/mypipe2)
From: http://savvyadmin.com/extract-audio-from-video-files-to-wav-using-mplayer/
---- For any media file type in current dir
find . -type f -exec ffmpeg -i "{}" "{}".mp3 \;
From: http://www.commandlinefu.com/commands/view/13791/convert-all-files-media-to-mp3
- (855)How to prevent annoying auto-mount of non-existing floppy/fd0 in LinuxMint14?
echo "blacklist floppy" | sudo tee /etc/modprobe.d/blacklist-floppy.conf && sudo rmmod floppy && sudo update-initramfs -u
From: http://forum.linuxmint.com/viewtopic.php?f=200&t=77720
- (856)How to install pattented software to view DVD (Ubuntu)?
Ubuntu 10.04 (i386, amd64), 10.10, 11.04, 11.10, 12.04, and 12.10 (i386, amd64)
Works for old releases that are no longer supported if you have repositories on Cd/Dvd or somewhere. So, anything from 9.04 onwards. The last LTS, 10.04, worked this way. The current LTS, 12.04 and the recent 12.10 also work this way.
Install the libdvdread4 package (no need to add third party repositories) via Synaptic or command line: (note: if you have installed *ubuntu-restricted-extras this has already been installed automatically for you)
sudo apt-get install libdvdread4
Then open a terminal window and execute:
sudo /usr/share/doc/libdvdread4/install-css.sh
From: https://help.ubuntu.com/community/RestrictedFormats/PlayingDVDs
- (870)How to make Skype use the correct default browser?
Pb: Setting FF as the system default browser (from FF itself) is not sufficient.
sudo update-alternatives --config x-www-browser
From: http://crunchbang.org/forums/viewtopic.php?id=16411
- (879)How to make Alps touchpad work on Ubuntu 12.10? DOES NOT WORK
0) Get: http://www.dahetral.com/public-download/psmouse-alps-dst-1.0.tbz/at_download/file
1) Extract psmouse-alps-dst-1.0.tbz in /usr/src/ sudo rights. Extracting it on the Downloads folder (right click the file -> Extract here) and moving it with the following command in the terminal also works:
sudo mv psmouse-alps-dst-1.0 /usr/src
ps: Note that the folder you need to move is inside 'usr/src/' folder that you extracted.
2) Go to /usr/src/ and then just give those commands in the terminal:
sudo dkms build psmouse/alps-dst-1.0
sudo dkms install psmouse/alps-dst-1.0
sudo rmmod psmouse && sudo modprobe -v psmouse
From: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/606238/comments/227
http://en.community.dell.com/support-forums/software-os/f/3525/t/19455247.aspx?PageIndex=1
- (886)How to correctly tar a huge number of files ????
This does not loose the names of the files
find . -name 'xxx*' | xargs tar cvzf plop.tgz ???
- (898)How to make wifi work (on kernel 3.5) on Dell Latitude E5530 (presans)?
- install linux-image k3.5
- install linux-header k3.5
- install linux-image-extra k3.5
=> will install tg3.ko so that wired connection still works :)
- REMOVE linux-backports k3.5
=> will prevent installation of bad version of lib80211
- install bcwl-kernel-source
=> will compile and create wl.ko kernel module
(- install b43-*)
(- install firmware-b43*)
- (900)Why is my new line in /etc/sudoers ignored (a.k.a. NOPASSWD option not working?)?
You should put that line after the line with the rule for the admin group, because, as the sudoers man page states:
When multiple entries match for a user, they are applied in order.
Where there are multiple matches, the last match is used (which is not
necessarily the most specific match).
Also see Tip#2259
From: http://askubuntu.com/questions/100051/why-is-sudoers-nopasswd-option-not-working
- (901)How to grant rights to users/groups (a.k.a. syntax of the /etc/sudoers file)?
%admin ALL=(ALL)NOPASSWD:/usr/bin/apt-get
To break it down:
%admin - All users of the admin group
ALL= - from any Host/IP
(ALL) - can run as any user
NOPASSWD - with no password required
:/usr/bin/apt-get - the list of comma, separated, applications.
Also see Tip#2259
From: http://ubuntuforums.org/showthread.php?t=1132821
- (904)How to recover the normal text-based verbose boot of an Ubuntu?
- In /etc/default/grub:
-> change GRUB_CMDLINE_LINUX_DEFAULT: delete 'quiet splash'. Add 'text'. On 12.04 servers without a serial console, we leave this blank.
-> uncomment the 'GRUB_TERMINAL=console' line. Without this change the console stays blank for a while and only the later boot messages show.
- In /etc/init/tty1.conf: By default the virtual console logins clear the screen when they start; on tty1, this has the effect of erasing the last screen's worth of boot-time messages. To tell getty not to do this, we add --noclear to the exec line:
exec /sbin/getty --noclear -8 38400 tty1
Also See Tip#1931
From: http://utcc.utoronto.ca/~cks/space/blog/linux/Ubuntu1204VerboseBoot
http://askubuntu.com/questions/174312/how-can-i-set-my-ubuntu-12-04-lts-to-boot-to-console-without-gui
- (905)How to select the kernel to boot at next reboot?
grub-reboot
From: http://linuxfr.org/news/gruik-fait-sa-tete-de-lard
- (906)How to get a gnome Drag&Drop sudo?
Create a launcher with the following command:
gksudo "gnome-open %u"
When you drag and drop any file on this launcher (it's useful to put it on the desktop or on a panel), it will be opened as Root with its own associated application. This is helpful especially when you're editing config files owned by Root, since they will be opened as read only by default with gedit, etc.
From: https://help.ubuntu.com/community/RootSudo#Graphical_sudo
- (907)How to change the max number of files opened files in Linux?
cat /proc/sys/fs/file-max
65536
cat /etc/sysctl.conf
fs.file-max = 200000
ulimit -n
1024
cat /etc/security/limits.conf
* soft nofile 2048
* hard nofile 2048
From: http://lj4newbies.blogspot.fr/2007/04/too-many-open-files.html
- (919)How to compose a large image based on small tiles?
1. Rename the files, so that they can be listed in line/col order by bash's completion
2. Montage <myImages>*
NOTE1: to prevent ImageMagick from adding a frame arround the images:
montage -geometry '<width of myImages>x<height of myImages>+0+0'
From: http://www.imagemagick.org/script/montage.php
convert -append in-*.jpg out.jpg
montage -mode concatenate -tile 1x in-*.jpg out.jpg
From: http://superuser.com/questions/290656/combine-multiple-images-using-imagemagick
NOTE2: convert -append can probably also be used
From: https://www.linuxquestions.org/questions/linux-software-2/compose-two-smaller-images-into-one-larger-image-711414
Note, that if the number of tiles exceeds the default number of 20 (5 per row, 4 per column), more than one composite image is created. To ensure a single image is produced, use -tile [GM: "#cols x #rows", before -geometry!] to increase the number of tiles to meet or exceed the number of input images.
To join several PNG images together without any extraneous graphics (e.g. no label, no shadowing, no surrounding tile frame), use:
montage +frame +shadow +label -tile 5x1 -geometry 50x50+0+0 *.png joined.png
- (920)How to decompose a large image into small tiles?
$ convert -crop $WIDTHx$HEIGHT@ huge_file.png tile_%d.png
From: http://michael.otacoo.com/linux-2/split-an-image-file-into-tiles/
- (938)How to make the ALPS touchpad work on latitude E5530 on Ubuntu 12.10?
Add the PPA source:
http://ppa.launchpad.net/cernekee/ppa/ubuntu
Then add the package:
psmouse-3.5.0-1
- (948)How to exclude packages from apt-get/dpkg upgrade/install?
sudo apt-mark hold <package>
echo <package> hold | sudo dpkg --set-selections
NOTE: To show packages on hold:
apt-mark showhold
From: http://askubuntu.com/questions/99774/exclude-packages-from-apt-get-upgrade
- (950)How to execute commands on special/system events/interrupts/signals?
trap [-lp] [[arg] sigspec ...]
The command arg is to be read and executed when the shell receives signal(s) sigspec. If arg is
absent (and there is a single sigspec) or -, each specified signal is reset to its original dis?
position (the value it had upon entrance to the shell). If arg is the null string the signal
specified by each sigspec is ignored by the shell and by the commands it invokes. If arg is not
present and -p has been supplied, then the trap commands associated with each sigspec are dis?
played. If no arguments are supplied or if only -p is given, trap prints the list of commands
associated with each signal. The -l option causes the shell to print a list of signal names and
their corresponding numbers. Each sigspec is either a signal name defined in <signal.h>, or a
signal number. Signal names are case insensitive and the SIG prefix is optional.
If a sigspec is EXIT (0) the command arg is executed on exit from the shell. If a sigspec is
DEBUG, the command arg is executed before every simple command, for command, case command,
select command, every arithmetic for command, and before the first command executes in a shell
function (see SHELL GRAMMAR above). Refer to the description of the extdebug option to the
shopt builtin for details of its effect on the DEBUG trap. If a sigspec is RETURN, the command
arg is executed each time a shell function or a script executed with the . or source builtins
finishes executing.
If a sigspec is ERR, the command arg is executed whenever a simple command has a non-zero exit
status, subject to the following conditions. The ERR trap is not executed if the failed command
is part of the command list immediately following a while or until keyword, part of the test in
an if statement, part of a command executed in a && or || list, or if the command's return value
is being inverted via !. These are the same conditions obeyed by the errexit option.
Signals ignored upon entry to the shell cannot be trapped or reset. Trapped signals that are
not being ignored are reset to their original values in a subshell or subshell environment when
one is created. The return status is false if any sigspec is invalid; otherwise trap returns
true.
- (952)How to find files that where accessed/changed(status)/modified(data) X time ago?
find . -type f -[a|c|m]time -2
# - is for expressing "ago"
# 2 is the multiple of 24h when the file was accessed/created/...
From: http://www.dba-oracle.com/t_find_recent_files_directory_command.htm
- (953)How to find all the man pages with a given name?
$ whatis <command name>
From: http://www.cyberciti.biz/faq/linux-unix-view-man-pages-from-sections/
- (956)Equivalent of /etc/login.conf (OpenBSD) in Linux?
/etc/security/limits.conf
From: http://linux.die.net/man/5/limits.conf
- (1338)How to use the mouse in console in Linux?
1) install gpm & start it
2) configure /etc/conf.d/gpm
From: https://wiki.gentoo.org/wiki/GPM
- (965)How to find the parent of a (failing) process?
ps -A --forest
From: http://askubuntu.com/questions/230553/how-to-prevent-so-many-instances-of-apt-check-running
- (966)How to create a blank image with ImageMagick?
convert -size 100x100 xc:white canvas.jpg
From: http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=11747
- (974)How to make BCM4313 work (with free driver) on Ubuntu 12.10 (kernel 3.8.0-23)?
1. remove all BCM proprietary packages (b43, b43-legacy, broadcom-sta...)
2. install package kernel 3.8++
3. install package linux-firmware
#modprobe cfg80211
modprobe brcmsmac
# rfkill list all => find if/which device is rf-kill'ed
rfkill unblock 1 #= phy0
# ifconfig wlan0 up
# wpa_supplicant ...
# dhclient wlan0
To know the correct module to load (brcmsmac/brcmfmac), see:
https://wiki.frugalware.org/index.php/Broadcom_wireless_%28Fran%C3%A7ais%29#brcmsmac.2Fbrcmfmac
From: http://askubuntu.com/questions/94021/how-do-i-get-the-broadcom-bcm4313-wireless-working-on-an-asus-1015px [THIS PAGE IS ERRONEOUS: IT'S NOT modeprobe brcm80211, but modprobe brcmsmac]
rfkill unblock all
OPT1: apt-get install bcmwl-kernel-source
OPT2: [a.k.a. bcm43xx] apt-get install firmware-b43-installer b43-fwcutter
OPT3: b43 and ssb
Also see how to blacklist auto-loading of these modules in /etc/modules and /etc/modprobe.d/blacklist.conf and /etc/modprobe.d/blacklist-*.conf
- (975)How to re-activate a device that has been rf-kill'ed?
PROBLEM:
$ sudo ifconfig wlan0 up
SIOCSIFFLAGS: Operation not possible due to RF-kill
SOLUTION:
$ sudo rfkill list all
# find the # of the device in question
$ sudo rfkill unblock <device#>
- (980)Funy thing with apt-get
apt-get moo
- (982)How to get low level hardware info (like available RAM slots/bank)?
$ lshw
or
#dmidecode --type {KEYWORD / Number }
dmidecode --type memory
dmidecode -t 17
# Type Short Description
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
From: http://adityo.blog.binusian.org/?p=96
- (991)How to hibernate/suspend from command line?
Hibernate:
echo platform > /sys/power/disk
echo disk > /sys/power/state
or
echo shutdown > /sys/power/disk
echo disk > /sys/power/state
Suspend:
echo mem > /sys/power/state
From: https://help.ubuntu.com/community/PowerManagement/Hibernate
- (992)How to enable Hibernate/swap? [a.k.a. gnome-control-settings -> Power shows Hibernate as greyed out ; a.k.a. resolve "bash: echo: write error: Cannot allocate memory" when attempting to hibernate from commandline]
[See also Tip#991]
# swapon -s
Filename Type Size Used Priority
# fdisk -l /dev/sda
...
/dev/sda5 616753152 625141759 4194304 82 Linux swap / Solaris
...
# mkswap /dev/sda5
Setting up swapspace version 1, size = 4194300 KiB
no label, UUID=xxx
# vi /etc/fstab # add UUID=xxx none swap sw 0 0
# swapon -a
# swapon -s
Filename Type Size Used Priority
/dev/sda5 partition 4194300 0 -1
- (995)How to list the available man pages with same names?
$ whatis printf:
printf (1) - format and print data
printf (1p) - write formatted output
printf (3) - formatted output conversion
printf (3p) - print formatted output
printf [builtins] (1) - bash built-in commands, see bash(1)
Meaning of the man pages sections [SEPARATE? MERGE?]
Section #1 : User Commands
Section #2 : System Calls
Section #3 : C Library Functions
Section #4 : Devices and Special Files
Section #5 : File Formats and Conventions
Section #6 : Games et. Al.
Section #7 : Miscellanea
Section #8 : System Administration tools and Deamons
From: http://www.cyberciti.biz/faq/linux-unix-view-man-pages-from-sections/
- (1379)How to know which tty I'm using?
$ tty
From: http://www.cyberciti.biz/faq/linux-unix-appleosx-bsd-what-tty-command/
- (1368)How to take every Xth line from a file?
awk '!(NR % <X>)' file
From: https://twitter.com/UnixToolTip/status/522789268243369984
- (1369)How to make a OR / AND / NOT in grep?
* OR
grep '(word1\|word2\|...)' file
grep -E '(word1|word2|...)' file
egrep '(word1|word2|...)' file
grep -e word1 -e word2 file
* AND
grep -E 'word1' file | grep -E 'word2'
grep -E 'word1.*word2|word2.*word1' file
* NOT
grep -v 'word' file
From: http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
- (1370)How to use wildcards with tar? (aka how to position --wildcards?)
tar tvz --wildcards -f "/tmp/svm_light_linux64.tar.gz" "svm*"
From: https://dev.openwrt.org/attachment/ticket/628/ipkg-utils-1.7-ipkg_new_tar.patch
- (1356)How to repair a GUID Partition Table (GPT) disk?
Use gdisk's option 'r':
recovery/transformation command (? for help): ?
b use backup GPT header (rebuilding main)
c load backup partition table from disk (rebuilding main)
d use main GPT header (rebuilding backup)
e load main partition table from disk (rebuilding backup)
f load MBR and build fresh GPT from it
g convert GPT into MBR and exit
h make hybrid MBR
i show detailed information on a partition
l load partition data from a backup file
m return to main menu
o print protective MBR data
p print the partition table
q quit without saving changes
t transform BSD disklabel partition
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
From: http://rodsbooks.com/gdisk/repairing.html
- (1357)How to manage GUID Partition Table disks (GPT)?
use gdisk instead of fdisk!
From: http://rodsbooks.com/gdisk/repairing.html
- (1341)My basic .bashrc
export TERM=xterm-color # wsvt26
#export TERM=xterm-xfree86 # xterm-color, wsvt25
if [[ $0 == "-bash" ]]
then
setterm -blength 0
fi
ulimit -c 0 -d 2097152 -m 2097152 # -u 20000 does not work in k3.16 bsh4.3.30 # -v 2097152
umask u=rwx,g=,o= ##umask 0077
if `tty -s`
then
mesg n
xhost local:root + > /dev/null
calendar -A 3 -B 1 -f .dates_naissances
fi
#unset TERM
export IGNOREEOF=0 # directly exists when CTL-d is hit
export HISTFILE=~/.bash_history # file name to save commands history
export HISTFILESIZE=150 # size of in-file list of last commands
export HISTSIZE=300 # size of in-memory list of last commands
export HISTCONTROL=ignoredups # do not save multiple executions of same command in history
shopt -s cmdhist # saves multiple lines command
shopt -s autocd # if a directory is given with no command => cd to this dir
##shopt -s cdspell # corrects typos in dir names during cd
shopt -s dirspell # corrects typos in dir names during completion
shopt -s histappend # appends in-memory commands history to in-file history, thus allowing merging histories from multiple XTerms
#shopt -s histreedit # allows reedition of failed substitution
#shopt -s histverify # allows to test substitution before sending command
#shopt -s hostcomplete # allows completion of hostname (after "@")
#shopt -s huponexit # kills child processes
#shopt -s lithist # Keeps newline chars into save commands instead of replacing by ;
#shopt -s no_empty_cmd_completion # do not complete empty lines!
#shopt -s nocaseglob # do not consider case in completion
PROMPT_COMMAND="history -a" # save each command right after it has been executed
export SVN_SSH="ssh -p 22"
export SVN_EDITOR="emacs"
export GIT_EDITOR="emacs"
export PRINTER=
export PATH=$PATH:/usr/X11R6/bin/:/sbin:/usr/local/bin:/home/guillaume/Softs/
whereisjavac=`ls -l /etc/alternatives/javac | awk '{ print $11 }'`
export JDK_HOME=$(dirname $(dirname $whereisjavac))
export JAVA_HOME=${JDK_HOME}
export JAVA_OPTS="-Xmx1G -server" # -XX:MaxPermSize=64M removed in J8
# -XX:+UseSerialGC
# -XX:+CMSClassUnloadingEnabled (replaces -XX:+CMSPermGenSweepingEnabled)
# -XX:+UseParallelGC or -XX:+UseSerialGC
# -XX:+UseConcMarkSweepGC or -XX:+UseParNewGC
# -XX:+PrintGCDetails
# -XX:+UseAdaptiveSizePolicy # used by default with the -XX:+UseParallelGC
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.6/:.
# NOTE: the // indicates to LaTeX to get recursively into the subdirs.
#for i in . ~/.TeX/installedPkgs/*
#do
# export TEXINPUTS=${i}//:$TEXINPUTS
# export BIBINPUTS=${i}//:$BIBINPUTS
# export BSTINPUTS=${i}//:$BSTINPUTS
#done
alias ls='ls -hl --color'
alias mv='mv -i'
alias rm='rm -i'
alias cp='cp -i'
alias mplayer='mplayer -softvol-max 1000 -softvol -vo xv -heartbeat-cmd "xscreensaver-command -deactivate" -stop-xscreensaver -ao pulse -zoom'
alias startx='~/.mystartx'
alias xemacs='emacs'
alias vi='vim'
alias rm='/bin/myrm'
alias clear='clear -T vt220'
alias qemu='qemu-system-x86_64 -m 1024m -soundhw sb16 -net nic,model=rtl8139 -net user'
alias grepp='grep -A6 -B6 -i'
alias cat8='iconv -t utf-8 -f iso-8859-1'
alias unlink='cd `pwd -P`'
alias nolimit='ulimit -d $((3*`ulimit -d`))'
alias bc='bc -l'
alias xpdf='xpdf -z page'
alias java='java $JAVA_OPTS'
alias nautilus='nautilus --no-desktop'
alias R='R --no-save --no-restore-data --quiet --no-save'
alias pdf2imgportrait='convert -quality 98 -resize 1240x1753 -extent 1240x1753 -gravity center -units PixelsPerInch -density 150x150 '
alias pdf2imglandscape='convert -quality 98 -resize 1753x1240 -extent 1753x1240 -gravity center -units PixelsPerInch -density 150x150 '
alias img2pdfportrait='convert -quality 98 -resize 1240x1753 -extent 1240x1753 -gravity center -units PixelsPerInch -density 150x150 '
alias img2pdflandscape='convert -quality 98 -resize 1753x1240 -extent 1753x1240 -gravity center -units PixelsPerInch -density 150x150 '
##-ANSI-COLOR-CODES-##
ColorOff="\001\033[0m\002"
###-Regular-###
Red="\001\033[0;31m\002"
Green="\001\033[0;32m\002"
Blue="\001\033[0;34m\002"
Purple="\001\033[0;35\002"
####-Bold-####
BRed="\001\033[1;31m\002"
BGreen="\001\033[1;32m\002"
BBlue="\001\033[1;34m\002"
BPurple="\001\033[1;35m\002"
# Status of last command (for prompt)
function __stat() {
if [[ $? -eq 0 ]]
then
echo -en "${Green}[\u2714]${ColorOff}"
else
echo -en "${Red}[\u2718]${ColorOff}"
fi
}
PS1=""
if [[ "$TERM" != "xterm" && "$TERM" != "xterm-color" && "$TERM" != "linux" && "$TERM" != "vt220" && "$TERM" != "wsvt25" && "$TERM" != "xterm-xfree86" ]]
then
PS1+="\u@\h:\W$ "
else
PS1+='$(__stat) '"${BBlue}\u${ColorOff}@\h:\W$ "
fi
export PS1
# mostly for Xemacs+utf8
export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_COLLATE="C"
export LC_TIME="C"
export LC_NUMERIC="C"
export LC_MONETARY="C"
export LC_MESSAGES="en_US.UTF-8"
export LC_ALL=""
- (1333)How to clone the permissions and/or ownership from one file to another?
chmod --reference=/home/user/copyfromfile /tmp/targetfile
chown --reference=/home/user/copyfromfile /tmp/targetfile
From: http://www.commandlinefu.com/commands/view/13666/clone-perms-and-owner-group-from-one-file-to-another
- (1307)How to manually "unzip"/uncompress an initramfs image?
cd `mktemp -d` && gzip -dc /boot/initrd.img-`uname -r` | cpio -ivd
From: https://wiki.ubuntu.com/Initramfs
- (1303)How to find dead symbolic links?
find -L /path/ -type l
-L tells find to follow symbolic links, so -type l will only return links it can't follow (i.e., those that are broken).
find -type l -xtype l
From: http://www.commandlinefu.com/commands/view/13586/find-dead-symbolic-links
- (1012)How to create a patch?
diff -crB Tb01 Tb02 > Tb02.patch
To test it:
patch --dry-run -p1 -i Tb02.patch
To apply it:
patch -p1 -i Tb02.patch
From: http://linux.byexamples.com/archives/163/how-to-create-patch-file-using-patch-and-diff/
- (1019)How to do an equivalent of basename in awk?
echo "/path/to/my/file" | awk { n=split($1,a,"/"); print a[n] }
From: http://www.unix.com/shell-programming-scripting/128862-extracting-basename-awk-nawk.html
- (1037)How to recover corrupted tar files content?
"HORRAY! I found out, thanks to Aaron M. Renn (creator of The gzip Recovery Toolkit: http://www.urbanophile.com/arenn/coding/gzrt/gzrt.html), that a useful utlility cpio can do the trick quite easily! Here is what I did:
$ cpio -ivd -H tar < new-try/new-try.tar
cpio: invalid header: checksum error
cpio: warning: skipped 23065728 bytes of junk
... EXTRACTED FILES DISPLAYED ...
From: https://www.linuxquestions.org/questions/linux-software-2/recovering-files-from-corrupt-tar-archive-326716/
Also there's a tool call "magicrescue", that acts like photorec/testdisk (i.e. extracts files based on magic numbers to get the type), but works on simple files instead of partitions/disks.
- (1038)How to install TrueType fonts on Debian GNU/Linux?
This tutorial describes how to install TrueType fonts on Debian GNU/Linux 4.0 (etch). In other Linux distributions like Redhat/Fedora or SuSE it works in a similar way.
Before you begin you should verify that the programs "ttmkfdir" und "mkfontdir" are installed. An X-windows system is also necessary.
If not get them with "apt-get install ttmkfdir"
You will need fontconfig as well ("apt-get install fontconfig").
In Linux fonts are often stored in /usr/share/fonts or /usr/X11R6/lib/X11/fonts.
If /usr/share/fonts is your main font directory, the TrueType fonts for X would go into /usr/share/fonts/truetype.
It is possible, though not recommended, to store fonts anywhere in the system.
When you want to use Microsofts TrueType fonts on your Linux box, you can install the package "msttcorefonts". The non-free repository has to be enabled in /etc/apt/sources.list. Just enter "apt-get install msttcorefonts" to install and configure the fonts automatically.
Manual installation of fonts will be descibed below:
Unpack your TrueType fonts and copy them to /usr/local/fonts/ttf.
Then "cd" to /usr/local/fonts/ttf and create the fonts.scale and fonts.dir files with "ttmkfdir -o fonts.scale" and "mkfontdir".
Now you have to tell the program "fontconfig", that is used by many modern Linux applications, where to look for the newly installed fonts. Create a new file "/etc/fonts/local.conf" and append the following lines to it:
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir>/usr/local/fonts/ttf</dir>
</fontconfig>
Call "fc-list" to check if the new fonts were recognized by the system.
From: http://www.truetype-font.com/faq.html
- (1046)How to configure proxy system-wide on a debian box?
set http_proxy, https_proxy, and ftp_proxy (and no_proxy) in /etc/environment
- (1050)How to find files with different extensions with "find" (a.k.a. how to define a OR operator with find)?
find . -type f \( -name "*.cache" -o -name "*.xml" -o -name "*.html" \)
From: http://alvinalexander.com/blog/post/linux-unix/an-example-of-use-unix-linux-find-command-locate-files-with-dif
--
Another way is to use regexes :
# Be careful that, even if refering to a filename, arg is a REGEX now: conversely to -[i]name: "*" here mean repetition, "." means any char, etc.
find . -[i]regex 'arg'
The type of regex can be defined with:
-regextype [emacs|posix-awk|posix-basic|posix-egrep|posix-extended]
- (1238)How to convert a unix timestamp into a date?
If timestamp is in secs:
date --date="@<timestamp>" +"%D %R"
If timestamp is in millisecs:
date --date="@`echo 1378996606488/1000 | bc -l`" +"%D %R"
From: man date
- (1251)How to add alarm/notification/ringtone sounds to android 1.6 (galaxos)?
[1. download an file management app that allows root & system administration, like ES File Explorer]
[2. Configure ES File Explorer to be super user & to mount "system drive"]
3. Put your files, in ogg format, in the following directory:
/system/media/audio/notifications
From: http://androidforums.com/samsung-galaxy-s/467284-adding-notification-sounds.html
- (1259)How to circumvent the apt-mark "hold" / dpkg --set-selections on some packages in debian-based distributions to force the upgrade of a package?
apt-get install <package name> # the "install" keyword will force the upgrade
NOTE: To show packages on hold:
apt-mark showhold
From: http://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it
- (1260)How to send mail in command line?
1. sudo apt-get install ssmtp
2. sSMTP can be configured from one text file. Open /etc/ssmtp/ssmtp.conf in a text editor:
sudo gedit /etc/ssmtp/ssmtp.conf
--
root=myemailaddress@gmail.com
mailhub=smtp.gmail.com:587
AuthUser=mygmailusername
AuthPass=mypassword
UseSTARTTLS=YES
--
3. sSMTP will then wait for you to type your message, which needs to be formatted like this:
To: recipient_email@example.com
From: myemailaddress@gmail.com
Subject: test email
hello world!
You can now use that line in a script:
ssmtp myemailaddress@gmail.com < msg.txt
From: http://tombuntu.com/index.php/2008/10/21/sending-email-from-your-system-with-ssmtp/
- (1261)How to use nano?
- Ctrl-w is find. Ctrl-\ is replace
- Switch between multiple buffers: Esc-< and Esc->
- Open more file buffers: Ctrl-R (open) + Esc-F (turn on multiple buffers).
- Avoid wordwrap "accidents" in line-sensitive files: nano -w
From: http://chxo.com/be2/nano_find_replace.html
- (1288)What to do when ubuntu crashes each time too much memory is used?
Is the problem that the swap partition is shared with openbsd?
Is the problem that the kernel upgraded when the swap partition was encrypted?
# 1. Check if swap is in use. If not:
mkswap /dev/sda5
swapon /dev/sda5
# + eventually add corresponding line to /etc/fstab
# 2. Does adding this line in /etc/rc.local helps?
sysctl vm.vfs_cache_pressure=100000
- (1293)How to use nanosleep?
BEFARE OF THE UNDERLYING PLATFORM CLOCK SPEED!!!!
If your CPU runs at 240MHZ one CPU cycle is about 4.167ns so every system call etc is talking this time. Since you call nanosleep(1) every call is taking at least 4.167 times the time you requested.
if you look in the manpage from nanosleep (man 2 nanosleep). You would have read the following notes:
man 2 nanosleep
If the interval specified in req is not an exact multiple of the granuâlarity underlying clock (see time(7)), then the interval will be rounded up to the next multiple.
From: http://www.codeproject.com/Questions/79582/How-to-use-nanosleep
- (1388)What software to use as a simple image editor?
- Shotwell (simple manipulation : select, crop...)
- Pinta (more complex edition: add text, etc.)
- (1231)How to reset a samsung i7550 phone to a useable state (with Galaxo=android 1.6)?
- Do a HardReset : VolDown+CallOK+CallCancel + "Reset to Factory"
- Install Galaxo : VolDown+CallOK+CallCancel + "install any zip" + "Galaxo.zip"
- Install Google Apps : VolDown+CallOK+CallCancel + "install any zip" + "googleapps.zip"
- Install usefull applications:
-> Advanced Task Cleaner 2.0
-> EZ File Explorer
-> Sound Recorder
-> TinyPlayer
-> FBReader
-> EbookDroid
(-> Android PDF Viewer)
-> Shoot Bubble Double Deluxe
- (1228)How to know the day of the year?
date +'%j'
From: https://twitter.com/UnixToolTip
- (1218)How to write a message to a/all user on CLI in UNICES?
talk "user"
echo "hello world" | write "user"
echo "hello world" | wall
Thanks FC!
- (1219)How to draw a banner?
install "figlet"
$ figlet Welcome
__ __ _
\ \ / /__| | ___ ___ _ __ ___ ___
\ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \
\ V V / __/ | (_| (_) | | | | | | __/
\_/\_/ \___|_|\___\___/|_| |_| |_|\___|
From: http://www.binarytides.com/linux-fun-commands/
- (1220)How to find/remove broken symlinks?
- Find:
find . -type l | while read f ; do test -e "$f" || echo "$f" ; done
find /path/to/search -type l | (while read FN ; do /usr/bin/test -e "$FN" || echo "$FN"; done)
find /path/to/search -type l ! -exec /usr/bin/test -r {} \; -print
find -L /path/to/search -type l
- Remove:
find . -type l | while read f ; do test -e "$f" || /bin/rm "$f" ; done
find /path/to/search -type l | (while read FN ; do /usr/bin/test -e "$FN" || \rm -f "$FN"; done)
find -L /path/to/search -type l -exec \rm -f \{} \;
find -L /path/to/search -type l -delete
From: http://www.theunixtips.com/find-broken-symlink
- (1223)How to use apt-get/dpkg (a.k.a. apt-get cheatsheet)?
- apt-get: APT is acronym for Advanced Package Tool. It supports installing packages over internet using ftp or http protocols. You can also upgrade all packages in a single operations, which makes it even more attractive.
- dpkg: Debian packaging tool which can be use to install, query, uninstall packages.
Remember whenever I refer .deb file it signifies complete file name, and whenever I refer package name it must be first part of .deb file. For example, when I refer to a package sudo it means sudo only and not the .deb file i.e. sudo_1.6.7p5-2_i386.deb.
- You can find out debian package name with the following command:
# apt-cache search <package-name>
# apt-cache search apache
- Add a new package called samba. The syntax is:
# apt-get install <package-name>
# apt-get install samba
- Remove the package called samba but keep the configuration files
# apt-get remove <package-name>
# apt-get remove samba
- Remove (erase) package and configuration file
# apt-get --purge remove <package-name>
# apt-get --purge remove samba
- Update all packages to newest version
# apt-get upgrade
- Update individual packages to newest version
# apt-get install <package-name>
# apt-get install sudo
- Get package information such as description of package, version, etc.
# dpkg --info <full-package-name>
# dpkg --info sudo_1.6.7p5-2_i386.deb | less
- List all installed packages
# dpkg -l
- List individual packages
# dpkg -l <package-name>
# dpkg -l apache
- Verify if a package (e.g. sudo) is installed
# dpkg -l | grep -i 'sudo'
- List packages related to another (e.g. apache)
# dpkg -l '*apache*'
- List files provided (or owned) by an *installed* package
# dpkg -L <package-name>
# dpkg -L samba
# dpkg --contents <full-package-name>
# dpkg --contents sudo_1.6.7p5-2_i386.deb
- Find what package owns a particular file?
# dpkg -S </path/to/file>
# dpkg -S /bin/netstat
- Search for package or package description
# apt-cache search <text-to-search>
-> e.g., find out all the Debian package which can be used for Intrusion Detection
# apt-cache search "Intrusion Detection"
-> e.g., find out all sniffer packages, run:
# apt-cache search "sniffer"
- Find out if Debian package is installed or not (status)
# dpkg -s <package-name> | grep Status
# dpkg -s samba | grep Status
- List all the dependencies a package has:
# apt-cache depends <package-name>
# apt-cache depends lsof
# apt-cache depends mysql-server
- Get the (long) description of a package
# apt-cache show <pakage-name>
- List available versions of a package
apt-cache policy <pkg>
apt-cache madison <pkg>
- Find the package that contains a given file
apt-file search <file>
From: http://www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html
https://askubuntu.com/questions/49578/get-package-description-using-apt#49585
https://askubuntu.com/questions/447/how-can-i-see-all-versions-of-a-package-that-are-available-in-the-archive#2108
https://stackoverflow.com/questions/12670517/how-to-find-packages-containing-a-specific-file
- (1193)How to change/reset the title of an Xterm?
The general scheme is:
echo -ne "\033]0;<Your Text>\007"
e.g.:
echo -ne "\033]0;+++`hostname`+++\007"
From: http://www.tldp.org/HOWTO/Xterm-Title-4.html#ss4.3
- (1192)How to know the color codes for xterm-color/xterm-256color/screen-256color
In xterm-color, the scheme is the following:
color_user='\[\e[1m\e[1;<X>m\]'
Where:
- \[ \] protects the codes, so that readline does not count them in the # of chars of the line and therefore the remaining of the display stays correct
- \e[1m sets the font to "Bold"
- \e[1;<X> sets the foreground color to <X> (e.g. 31 or 33)
- m closes the command and sets everything back to normal
In xterm-256color, the scheme is the following:
color_user='\[\e[1m\e[38;5;21m\]'
Where:
- \[ \] protects the codes, so that readline does not count them in the # of chars of the line and therefore the remaining of the display stays correct
- \e[1m sets the font to "Bold"
- \e[38;5;<X> sets the foreground color to <X> (e.g. 31 or 33)
(\e[48;5;<X> sets the background color)
- m closes the command and sets everything back to normal
In Konsole, you can set the colors with:
\[\e[38;2;<r>;<g>;<b>m\] Select RGB foreground color
\[\e[48;2;<r>;<g>;<b>m\] Select RGB background color
For the color codes, see tips #1173 (emacs M-x list-colors-display, then use XXX of the listed color-XXX)
Also See Tip#1173
From: http://misc.flogisoft.com/bash/tip_colors_and_formatting
http://en.wikipedia.org/wiki/ANSI_escape_code#Colors
- (1186)How to do the equivalent of a screenshot in CLI mode (a.k.a how to save the typed commands and their results in a text file)?
"script" makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).
From: http://stackoverflow.com/questions/14208001/save-screen-program-output-to-a-file
- (1183)How to configure [java] alternatives in Ubuntu?
To configure the default for the Java interpreter:
update-alternatives --config java
To configure the default Java compiler:
update-alternatives --config javac
From: http://askubuntu.com/questions/315646/update-java-alternatives-vs-update-alternatives-config-java
- (1182)How to make find print absolute pathes of the files it finds?
If you give find an absolute path to start with, it will print absolute paths. For instance, to find all .htaccess files in the current directory:
find `pwd` -name .htaccess
find simply prepends the path it was given to a relative path to the file from that path.
Greg Hewgill also suggested using pwd -P if you want to resolve symlinks in your current directory.
From: http://stackoverflow.com/questions/246215/how-can-i-list-files-with-their-absolute-path-in-linux
- (1169)How to know the list/effects of the console codes (e.g. ^[[3~)?
man console_codes
- (1162)How to create a ramdisk?
# mkfs -q /dev/ram1 8192
# mkdir -p /ramcache
# mount /dev/ram1 /ramcache
# df -H | grep ramcache
From: http://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/
- (1161)How to set PulseAudio volumes commandline?
For the raise volume button:
sh -c "pactl set-sink-mute 0 false ; pactl set-sink-volume 0 +1%"
For the lower volume button:
sh -c "pactl set-sink-mute 0 false ; pactl -- set-sink-volume 0 -1%"
For the mute button:
pactl set-sink-mute 0 toggle
https://wiki.archlinux.org/index.php/Xfce#Configuring_xfce4-mixer
- (1051)How to indent an XML file inplace?
xmllint -o <file.xml> --format <file.xml>
From: http://www.mail-archive.com/xml@gnome.org/msg07666.html
- (1145)How to save the layout of your splits in screen?
- Hit:
Ctrl-a :
- Then enter: layout save default
From: http://superuser.com/questions/69816/how-to-keep-windows-split-after-detaching-reattaching-gnu-screen
- (1133)How to provide an option APT::xxx to apt-get?
Try this: apt-get -o=APT::Get::Show-User-Simulation-Note=no --simulate ...
From: http://stackoverflow.com/questions/20749925/apt-get-simulate-dist-upgrade-without-notice
- (1134)How to switch from a TTY/console to another in command-line?
In a virtual terminal, you should be able to use the chvt command, e.g. sudo chvt 7 to go back to your X session.
From: http://askubuntu.com/questions/54814/how-can-i-ctrl-alt-f-to-get-to-a-tty-in-a-qemu-session
- (1137)How to set the keyboard repeat rate?
xset r rate 770 30
From: man xset
- (1139)How to set Trebble/Bass system wide? (a.k.a. a system-wide equalizer for Ubuntu)
Ubuntu 13.04 and 13.10 users don't have to add the PPA - you can simply download qpaeq (the equalizer) and place it in you path, like /usr/local/bin for example, and make it executable. You can do this by running the commands below:
wget http://cgit.freedesktop.org/pulseaudio/pulseaudio/plain/src/utils/qpaeq -O /tmp/qpaeq
sudo install /tmp/qpaeq /usr/local/bin/
If you do this, skip step 1 below. But you can add the PPA below since it's safe and you'll get the equalizer automatically.
1. To add the PPA (available for Ubuntu 13.04, 12.10 and 12.04), use the following commands:
sudo add-apt-repository ppa:webupd8team/pulseaudio-eq
sudo apt-get update
Then, launch the Software Updater and upgrade the packages (or run "sudo apt-get dist-upgrade"). Make sure all Pulseaudio packages have been upgraded successfully!
2. To be able to use the equalizer, you'll need to install some extra dependencies:
sudo apt-get install python-dbus python-qt4 python-qt4-dbus pulseaudio-utils
3. Now, let's restart Pulseaudio. Open a terminal and copy/paste the following commands:
pulseaudio -k
pulseaudio &
4. Everything is ready now, but the equalizer needs two modules to be loaded to work, so open a terminal and copy/paste these two commands:
pactl load-module module-equalizer-sink
pactl load-module module-dbus-protocol
Now you can launch the equalizer. It doesn't come with a desktop file so either press ALT + F2 or open a terminal and type:
qpaeq
The equalizer should now start.
You can now play some music / video / etc. and try the equalizer. To see if it works, you can set the preamp (first slider on the left) to maximum or minimum. If the sound doesn't go up or down, open the sound settings and under Output, select "FFT based equalizer on Built-in...":
Some applications will only work with this while others will also work without changing this (I'm not yet sure exactly how this works, please leave a comment if you know more about this).
5. The modules we've loaded under step 4 aren't automatically loaded on system start. So if you want to be able to use the equalizer after a restart without having to run those two commands, you'll have to add those modules either to ~/.pulse/ for your user or /etc/pulse/default.pa for all users. Below, I'm going to add them to /etc/pulse/default.pa and for this, you'll need to open the file as root with a text editor:
gksu gedit /etc/pulse/default.pa
And at the bottom of the file, add this:
### Load the integrated pulseaudio equalizer and dbus modules
load-module module-equalizer-sink
load-module module-dbus-protocol
Then save the file and you're done.
From: http://www.webupd8.org/2013/03/install-pulseaudio-with-built-in-system.html
- (1086)How to change keyboard layout in console in linux (a.k.a. switch keyboard language, a.k.a switch keyboard to French)?
use: loadkeys <keymap> as root. E.g.:
# loadkeys fr
Also see Tip#497
From: https://wiki.archlinux.org/index.php/Keyboard_Configuration_in_Console#Temporary_configuration
- (1081)How to find file that belong to a given owner (user/group)?
find directory-location -group {group-name} -name {file-name}
or
find directory-location -user {username} -name {file-name}
From: http://www.cyberciti.biz/faq/how-do-i-find-all-the-files-owned-by-a-particular-user-or-group/
- (1080)How to remove a named-pipe?
rm pipe_name
Be careful to cleanly stop any process that might use it before, or you'll get:
"mkfifo: cannot create pipe_name: File exists"
next time you want to create a new pipe with the same name. "fuser" or "lsof" might be used for this purpose.
From: http://www.unix.com/showthread.php?t=79454
- (1078)How to restore the MBR/BootLoader manually by copying one from another disk?
- Boot to your favorite liux distro
- Copy the first sector of the hard disk into a file:
sudo dd if=/dev/sda of=/mnt/sdb1/bootloader.img bs=446 count=1
Note for doing the same, including the primary partition table, use just bs=512.
From: http://brozkeff.net/2012/06/03/backup-truecrypt-bootloader-in-mbr-using-dd
- (1071)How to exclude package from beeing treated by apt-get?
apt-mark hold <package>
NOTE: To show packages on hold:
apt-mark showhold
From: http://askubuntu.com/questions/99774/exclude-packages-from-apt-get-upgrade
- (1070)How to make dhclient work on Ubuntu 12.10? (a.k.a. How to solve error "Can't create addrlist socket")
$ sudo dhclient
...
Can't create addrlist socket
Problem: culprit is AppArmor that is configured too stricly for the 'dhclient' executable to run properly
Solution:
ln -s /etc/apparmor.d/sbin.dhclient3 /etc/apparmor.d/disable/
apparmor_parser -R /etc/apparmor.d/sbin.dhclient3
From: https://bugs.launchpad.net/ubuntu/+source/dhcp3/+bug/354471
- (1065)How to cat a bunch of files?
$ more * | cat
- (1055)How NOT to use find?
Warnings: Don't forget that the find command line is evaluated as an
expression, so putting -delete first will make find try to delete
everything below the starting points you specified.
Thanks FC
- (1390)How to get the peak amount of memory occupied by any process with "FOO" in its name?
grep VmHWM /proc/$(pgrep -d '/status /proc/' FOO)/status
Show the maximum amount of memory that was needed by a process at any time. My use case: Having a long-running computation job on $BIG_COMPUTER and judging whether it will also run on $SMALL_COMPUTER.
http://man7.org/linux/man-pages/man5/proc.5.html
VmHWM: Peak resident set size ("high water mark")
From: http://www.commandlinefu.com/commands/view/13810/peak-amount-of-memory-occupied-by-any-process-with-foo-in-its-name
- (1395)How to keep the compressed file after uncompressing?
gunzip -c x.txt.gz >x.txt
From: http://www.commandlinefu.com/commands/view/13776/keep-gz-file-after-uncompressing
- (1396)How to calculate size (in kilobyte) of files that are deleted but still in use?
lsof -ns | grep REG | grep deleted | awk '{s+=$7/1024} END {print s}'
From: http://www.commandlinefu.com/commands/view/13790/find-size-in-kilobyte-of-files-that-are-deleted-but-still-in-use-and-therefore-consumes-diskspace
- (1403)What is the meaning of the sticky bit on a directory?
The Sticky bit (t) will prevent users from altering or replacing any other user's files. Only the file owner and the superuser may remove files from that directory. All PUBLIC directories should be configured with sticky bit.
Unlike with file sticky bits, the sticky bit on directories remains there until the directory owner or superuser explicitly removes the directory or changes the permissions.
The sticky bit, together with the default umask of 077, solves a big problem for less secure systems. Together, both features prevent other users from altering or replacing any file you have in a public directory. The only information they can gain from the file is its name and attributes.
$ chmod u+t directory
From: http://ss64.com/bash/syntax-permissions.html
- (1411)How to display all zombie process IDs?
ps axo pid=,stat= | awk '$2~/^Z/ { print $1 }'
From: http://www.commandlinefu.com/commands/view/13872/display-all-zombie-process-ids
- (1415)How to list the name of packages APT is aware of [matching a prefix]?
$ apt-cache pkgnames linux-
In this case, linux- is the prefix; simply running
apt-cache pkgnames
would list every package APT knows about.
The default APT config assumes -g, --generate; to use the cache as/is, you could similarly run:
apt-cache --no-generate pkgnames [prefix]
Adding --all-names, like so:
apt-cache --no-generate --all-names pkgnames [prefix]
would print all the packages APT knows about, using the cache as/is, including virtual packages and missing dependencies.
From: http://www.commandlinefu.com/commands/browse
- (1416)How to get Ubuntu's crypto key's?
To list the available keys:
sudo apt-key adv --keyserver keyserver.ubuntu.com --list-keys
To install the master ones ("Ubuntu Archive Automatic Signing Key <ftpmaster@ubuntu.com>" and "Ubuntu Extras Archive Automatic Signing Key <ftpmaster@ubuntu.com>"):
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 437D05B5 3E5C1192
sudo apt-get update
From: http://askubuntu.com/questions/248685/cannot-update-install-apps-untrusted-packages
- (2822)How to redefine the IFS separator from read when using this command in a pipe?
#!/bin/bash
_input="foo.txt"
# set IFS (internal field separator) to |
# read file using while loop
while IFS='|' read -r domain ip4 ip6
do
echo "$domain has $ip4 IPv4 and $ip6 IPv6 address."
done < "$_input"
From: https://www.cyberciti.biz/faq/unix-linux-bash-while-read-function-define-ifs-delimiter/
- (1441)How to find commons lines between two (sorted) files?
$ man comm
"With no options, produce three-column output. Column one contains lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files."
$ comm -1 -2 <file1> <file2>
From: http://www.cyberciti.biz/faq/command-to-display-lines-common-in-files/
- (1448)How to get/set the runlevel/initlevel?
To get the current runlevel:
$ runlevel
To switch runlevels:
- now:
$ sudo init $runlevel
- at every boot:
$ sudo vim /etc/init/rc-sysinit.conf
Change this line to whichever runlevel you want
env DEFAULT_RUNLEVEL=2
Also See Tip#1931
From: http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level
- (1450)Sed patterns
/a/ means pattern a
a,b means from a to b
a~b means from a, every b
+a means from current to current+a lines
$ means last line
### DELETES
$ sed -n 'x~yd' filename
Delete lines starting from line number x and every yth line from there.
$ sed -n '0/1~2d' filename
Prints only odd/even lines
### MATCHES
$ sed -n ‘/PATTERN/,Np’ filename
Prints lines from the one which matches the pattern to the Nth line.
$ sed -n ‘N,/PATTERN/p’ filename
Prints from the Nth line to the line which matches the pattern. If the pattern doesnt match, it prints upto end of the input.
$ sed -n ‘/PATTERN/,$p’ filename
Prints from the line that matches the given pattern to end of file.
$ sed -n ‘/PATTERN/,+Np’ filename
Prints the lines which matches the pattern and next N lines following the matched line.
$ sed -n ‘/P1/,/P2/p’ filename
Prints the section of file between two regular expression (including the matched lines).
### REPLACEMENTS
Syntax:
$ sed 'ADDRESSs/REGEXP/REPLACEMENT/FLAGS' filename
$ sed 'PATTERNs/REGEXP/REPLACEMENT/FLAGS' filename
s is substitute command
/ is a delimiter
REGEXP is regular expression to match
REPLACEMENT is a value to replace
FLAGS can be any of the following
g Replace all the instance of REGEXP with REPLACEMENT
n Could be any number,replace nth instance of the REGEXP with REPLACEMENT.
p If substitution was made, then prints the new pattern space.
i match REGEXP in a case-insensitive manner.
w file If substitution was made, write out the result to the given file.
We can use different delimiters ( one of @ % ; : ) instead of /
$ sed 's/Linux/Linux-Unix/' thegeekstuff.txt
Substitute Word "Linux" to "Linux-Unix"
$ sed 's/Linux/Linux-Unix/g' thegeekstuff.txt
Substitute all Appearances of a Word
$ sed 's/Linux/Linux-Unix/2' thegeekstuff.txt
Substitute Only 2nd Occurrence of a Word
$ sed -n 's/Linux/Linux-Unix/gpw output' thegeekstuff.txt
Write Changes to a File and Print the Changes
$ sed '/\-/s/\-.*//g' thegeekstuff.txt
Substitute Only When the Line Matches with the Pattern
$ sed 's/...$//' thegeekstuff.txt
Delete Last X Number of Characters From Each Line
$ sed -e 's/#.*//' thegeekstuff.txt
Eliminate Comments
$ sed -e 's/#.*//;/^$/d' thegeekstuff.txt
Eliminate Comments and Empty Lines
$sed 's/.$//' filename
Convert DOS newlines (CR/LF) to Unix format
$ sed -e 's/<[^>]*>//g'
Eliminate HTML Tags from file
From:
http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/
http://www.thegeekstuff.com/2009/09/unix-sed-tutorial-printing-file-lines-using-address-and-patterns/
http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-how-to-write-to-a-file-using-sed/
http://www.thegeekstuff.com/2009/10/unix-sed-tutorial-advanced-sed-substitution-examples/
http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-append-insert-replace-and-count-file-lines/
http://www.thegeekstuff.com/2009/12/unix-sed-tutorial-7-examples-for-sed-hold-and-pattern-buffer-operations/
- (1459)How to slow down the CPU?
- To get info about the cores possibilities:
cpufreq-info -o
- To change the policy (to know the avalaible policies: cpufreq-info -g)
# echo "<governor>" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null
# cpufreq-set -g <governor>
where governor = [ondemand|performance|conservative|powersave|userspace|...]
- To slow down core <x> (to know the avaliable frequencies: cpufreq-info -l):
# cpufreq-set --min <freqMin> --max <freqMax> -c <x>
- To stop using core <x>:
# echo 0 > /sys/devices/system/cpu/cpu<x>/online
From: https://wiki.archlinux.org/index.php/CPU_frequency_scaling#CPU_frequency_driver
see also: cpufrequtils::man cpufreq-[info|set]
- (1470)How to print only the running (non-Idle) commands in top?
Hit key 'i'!
From: "online" help (accessed using '?' in top)
- (1471)How to get the full command line in top?
Hit key 'c'!
(discovered by chance)
- (1476)How to run a script on an ACPI event (e.g. re-set special keyboard maps when waking-up from suspend/LID-close)
1. Create file: /etc/acpi/events/lm_lid with this content:
event=button/lid.*
action=/etc/acpi/lid.sh
2. Create file: /etc/acpi/lid.sh with this content:
#!/bin/sh
grep -q open /proc/acpi/button/lid/*/state
if [ $? = 0 ]; then
<your task>
## Example to reset input devices: keyboard+mouse
## /etc/init.d/udev restart
fi
From: http://askubuntu.com/questions/541848/run-script-after-wake-up
- (1478)How to add entries in the "Places" panel of Thuner
gedit .gtk-bookmarks
For each entry, add a line like:
file:///home/guillaume/<MyDir>
Since this file is updated dynamically, it's best to chmod a-w after modification (or even to chattr +i!)
- (1479)How to fix the placement of the icons on the desktop in XFCE4?
gedit .config/xfce4/desktop/icons.screen0-<your resolution>.rc
Each [item:file|dir] is positionned on the grid with attributes "row=" and "col="
e.g.:
[/home/guillaume/Desktop/cheques.text]
row=10
col=2
- (1481)How to add a command at boot on modern SystemD GNU/Linux?
1. sudo vi /etc/rc.local
2. # add you line in this file
3. sudo chmod +x /etc/rc.local
4. # on some machines (using SystemD) you need to enable /etc/rc.local execution at boot:
systemctl enable rc-local.service
# You can check status with: systemctl status rc-local.service
From: https://ask.fedoraproject.org/en/question/26898/what-is-the-auto-start-file-like-rclocal/
- (1485)How to create an arbitrary big file full of zeroes in a second?
truncate --size 1G bigfile.txt
From: http://www.commandlinefu.com/commands/view/14068/create-arbitrary-big-file-full-of-zeroes-but-done-in-a-second
- (1491)How to compute a relative date in CLI?
date --date="6 days ago" "+%Y%m%d"`
Thanks VP
- (1497)How to get the creation date of a file on ext2-3-4 fs?
debugfs -R "stat <$(stat --printf=%i filename)>" /dev/sdaX | grep crtime
From: http://www.commandlinefu.com/commands/view/14156/get-creation-date-of-a-file-on-ext2-3-4-fs
- (1506)How to look for a printer on a network?
nmap -sP 172.16.0.0/24 # scan your IP range for active IP's
nmap -p T:515,631,9100 <an ip> # check common printing ports on a likely IP
From: http://ubuntuforums.org/showthread.php?t=1470030
- (1508)How to change the boot level with systemd?
systemd has the concept of targets which is a more flexible
replacement for runlevels in sysvinit.
Run level 3 is emulated by multi-user.target. Run level 5 is emulated
by graphical.target. runlevel3.target is a symbolic link to
multi-user.target and runlevel5.target is a symbolic link to
graphical.target.
You can switch to 'runlevel 3' by running
systemctl isolate multi-user.target
You can switch to 'runlevel 5' by running
systemctl isolate graphical.target
How do I change the default target?
systemctl set-default <name of target>.target
graphical.target is the default. You might want multi-user.target for
the equivalent of non graphical (runlevel 3) from sysv init. The full
list of targets can be accessed via systemctl list-units --type=target
systemd does not use /etc/inittab file.
To get the current target:
systemctl get-default
--- DON'T FORGET TO VERIFY GRUB'S OPTIONS!!!
vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
#GRUB_CMDLINE_LINUX_DEFAULT="text"
Also See Tip#1931 and Tip#2189
From : https://fedoraproject.org/wiki/Systemd#How_do_I_change_the_target_.28runlevel.29_.3
- (1510)How to switch between display managers (gdm/lightdm/mdm/...)?
sudo dpkg-reconfigure <one of the installed DMs>
From: http://www.webupd8.org/2011/07/how-to-switch-between-gdm-lightdm-or.html
- (1516)How to install a recent program (backported to) an old Debian?
# echo "deb http://ftp.debian.org/debian wheezy-backports main contrib non-free" >> /etc/apt/sources.list
# aptitude update
# aptitude -t wheezy-backports install <prog>
From: https://wiki.debian.org/Backports
- (1520)How to copy symbolic links?
Use the -d option:
cp -d files /var/copylinktohere/
From man cp:
-d same as --no-dereference --preserve=link
From: http://stackoverflow.com/questions/10330984/linux-copy-symbolic-link
- (1522)How to disable the CPU/HD-intensive process that rebuilds the xapian index?
sudo apt-get autoremove --purge apt-xapian-index
sudo apt-get autoremove --purge
From: http://ubuntuforums.org/showthread.php?t=1062688
- (1540)What are the available math functions in bc and how to compute the lacking ones?
The library consists entirely of elementary functions of one argument and the names of the functions spell out "scale":
S-ine
C-osine
A-rctangent
L-ogarithm (natural)
E-xponential
[In truth, there also exists j(n,x), that compute the nth Bessel function of x where n is an integer]
How to compute other functions:
tan(x) = s(x)/c(x)
arcsin(x) = arctan(x/sqrt(1–x^2))
arccos(x) = arctan(sqrt(1–x^2 )/ x)
arccot(x) = pi/2–arctan(x)
arcsec(x) = arctan(sqrt(x^2–1))
arccsc(x) = arctan(1/sqrt(x^2–1))
To compute x^y for a floating point value y, use: e(l(x)*y)
To find logarithms to other bases, use: logb(x) = log(x) / log(b)
From: http://www.johndcook.com/blog/2010/07/14/bc-math-library/
- (1544)How to search for file modified in the last X days?
find /path/to/search/for/ -mtime -<X>
From: man find
- (1552)How to configure Startup Apps on systemd-enabled distros?
Most of display managers sources /etc/xprofile, ~/.xprofile and /etc/X11/xinit/xinitrc.d/. For more details, see xprofile.
From: https://wiki.archlinux.org/index.php/Display_manager#Autostarting
- (1553)How to make rc.local work on systemd-enabled distros?
1. Edit "/etc/rc.local"
2. Add permissions
chmod +x /etc/rc.local
3. Create the service file "/usr/lib/systemd/system/rc-local.service"
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty1
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
4. Create a soft link
cd /etc/systemd/system/multi-user.target.wants
ln -s /usr/lib/systemd/system/rc-local.service rc-local.service
5. Enable the service:
systemctl enable rc-local.service
6. Start the service:
systemctl start rc-local.service
From: https://www.raspberrypi.org/forums/viewtopic.php?f=53&t=98722
- (1579)How to change the hostname of a machine?
The /etc/hosts file has nothing to do with your hostname. The /etc/hosts file list the different hosts on your network, even if it includes your own.
The hostname of your machine is set using the hostname command (for a dynamic/live change) and /etc/hostname for a sustainable change.
Also, for a sustainable change, you might need to change init scripts (e.g. /etc/sysconfig/network) on some distros
From: http://www.linuxquestions.org/questions/linux-networking-3/what-to-do-after-changing-etc-hosts-168008/
- (1596)How to delete all tickets from trac?
$ cd $TRACK_HOME/$PROJECT/db
$ sqlite3 trac.db
sqlite> select * from ticket;
sqlite> delete from ticket ;
sqlite> select * from ticket;
Beware that comments & attachments are not removed, you might need to also run:
delete from ticket_change where field="comment" and ...;
delete from attachment where ...;
- (1601)How to know whether two files differ, not how they differ?
diff -q (or --brief).
From: https://twitter.com/UnixToolTip/status/654336129198596096
- (1608)How to georeferentiate a map in qGIS?
* Plugins to install
** GeoReferencer to actually set geo points/refs on a map
** OpenLayers => allows to show many online maps in qGIS but at low resolution
** TileLayer Plugin => allows to show maps with high resolution. OpenStreetMap must be added manually:
+ https://gis.stackexchange.com/questions/142359/qgis-zoom-level-with-openstreetmap-data
* Georeferencing a map
** Load a base map (e.g., OSM has the borders of the buildings)
** Open a raster image (e.g., IGC map) *in GeoReferencer*
+ NOTE: OSM/Google/... use a PseudoMercator projection (3857)
** Find a reference point on the base map
** Clic on 'Add Point' icon (on top) GeoReferencer
In the popup, select 'From MapCanvas'
The base map (OSM) windows will come to front
Select the same point on the base map (OSM)
** Repeat previous steps 3 times
NOTE: do not add too much points, otherwise the raster will be rotated/... too much
** The clic on the wheel icon on the raster window to configure the transformations: "Transformation Settings"
*** Select "Thin Plate Spline"
*** Select "Nearest Neighbour"
*** Select "Output: [Geo]Tiff" (eventually use the "deflate" compression: no losses)
*** Select Options: Open in qGIS
*** Still in the raster window you can also save the points you have marked for later improvments "Save GCPoints"
** Finally clic the green arrow to apply the transformations/GeoReferencing
* Export to PDFMaps
** gdal_merge.py -o <output> *.["geo"]tiff -init 255 # unknown parts will be white
* Notes
** Once you have a referenced map, saved as a [geo]tiff, if you want to show it as an overlay of the base map (OSM), use the "Open Raster" on the left of the base map window.
Thanks Jaj!
- (1612)How to change DropBox Filemanager (a.k.a. how to add options to Nautilus when opened by DropBox)?
mimeopen -d ~/Desktop/
Please choose a default application for files of type inode/directory
1) ...
...
5) Other...
use application# 5
use command: /usr/bin/nautilus --no-desktop
From: http://askubuntu.com/questions/49531/how-can-i-integrate-dropbox-with-pcmanfm
- (1613)How to compute total space used by open but deleted files?
sudo lsof -nP | awk '/deleted/ { sum+=$8 } END { print sum }'
From: http://www.commandlinefu.com/commands/view/14696/total-space-used-by-open-but-deleted-files
- (1614)How to monitor memory fine-grained usage (e.g. firefox)?
watch "awk '/Rss/{sum += \$2; } END{print sum, \"kB\"}' < /proc/$(pidof firefox)/smaps"
From: http://www.commandlinefu.com/commands/view/14693/monitor-memory-fine-grained-usage-e.g.-firefox
- (1615)How to check which processes are waiting for IO interrupts?
while true; do date; ps auxf | awk '{if($8=="D") print $0;}'; sleep 1; done
From: http://www.commandlinefu.com/commands/view/14701/monitor-what-processes-are-waiting-for-io-interrupts
- (1628)How to transform your PC/RaspBerryPi/... into a true MediaCenter?
- Install Kodi (ex-XMBC)
- Install the repository "srp.nu"
* Navigate to "SYSTEM" and open "File Manager"
* Select "Add Source" on the left side of the screen.
* Click on the text box that says to open up the keyboard.
Type "http://srp.nu' (from SuperRePo) on the keyboard and then click the "Done" button
* Click the empty text box at the bottom under "Enter a name for this media Source"
* Type a name for the source (eg.:"SuperRepo"). Once done press the "Done" button again
* Click OK
* Return to the home screen and go to System->Addons->Install from zip
* Click at the source you just added
* Click the repository’s zip you want to install.
For example: Isengard/All/Repositories/[here-goes-the-name].zip
* The repository should now be visible when you go to System->Addons->Get Add-ons
From: https://superrepo.org/get-started/
- Install some plugins from this repository
(genesis, genesis-fr, 1Channel, IPTV, SITESdosPORTUGAS, ArmagedomFilmes, BrasilTvs, CCC-tv, Cinefilmes, docsPT, Docu-Hub, Films de France, HowStuffWorks.com, I wanna watch, Icefilms, KODI popcorn Time, p2p-streams, Popcornflix, primewire, SolarMovie.so, TED Talks, Tuga Filmes, OpenSubTitles (can auto load subs!) etc.)
- Configure Kodi to accept to be remote controlled
* System->Settings->Services->Webserver
enable the setting "Allow control of XBMC via HTTP"
* System->Settings->Services->Remote control
enable the settings "Allow programs on this system to control XBMC" and
"Allow programs on other systems to control XBMC"
* System->Settings->Services->Zeroconf
enable the setting "Announce these services to other systems via Zeronconf"
From: http://syncedsynapse.com/kore/kore-faq/
- Install "Kore" remote controller on your android phone
https://play.google.com/store/apps/details?id=org.xbmc.kore
- (1630)How to shuffle/randomize lines in bash?
$ shuf
or
$ sort -R # NOT: not perfect in case 2 lines are duplicates: they endup together
From: https://stackoverflow.com/questions/2153882/how-can-i-shuffle-the-lines-of-a-text-file-on-the-unix-command-line-or-in-a-shel
- (1653)How to read Linux man pages in color?
- Install "most"
- Set up your default PAGER to use most when calling man.
If you use bash, you can add it to your .bashrc file to make the changes permanent.
export PAGER="/usr/bin/most -s"
echo 'export PAGER="/usr/bin/most -s"' > ~/.bashrc
From: https://blog.terminal.com/10-unsorted-linux-tricks-volume-3/
- (1667)How to set the first day of the week?
In many countries the first day of the week is Monday. To adjust this, change or add the following lines:
/usr/share/i18n/locales/<chosen_locale>
LC_TIME
[...]
week 7;19971130;5
first_weekday 2
first_workday 2
From: https://wiki.archlinux.org/index.php/Locale#Setting_the_first_day_of_the_week
- (1669)How to make a (USB-stick) linux boot without Xorg blinking/scrambling on Intel internal video card?
PROBLEM: On booting a recent linux (USB-stick) on a computer with an Intel internal video card (and non-standard screen resolution?), Xorg/VM screen is visible, but scrambles a lot. On booting older linux image, the computer boots, but Xorg show alternatively red/green/blue/black/white screens.
SOLUTION: boot the kernel with "nomodeset" (before "--", that marks and of options). This reduces the possibilities in terms of resolution, but makes things work correctly.
From: http://ubuntuforums.org/showthread.php?t=361237&page=65
- (1686)How to get creation/access/change/modify time of a file?
You can use:
ls -U [time of creation]
NOTE1: Linux (more precisely extXfs) does not store creation/birth time?
ls -u [time of last access of contents (atime)]
ls -c [time of last modification of the inode (metadata, ctime)]
ls -t [time of last modification of contents (mtime)] <file>
Or, faster:
stat <file>
From: https://unix.stackexchange.com/questions/24441/get-file-created-creation-time
- (1694)How to execute a dd with a progress bar?
# pv -E -tpreb /dev/sd<a> | dd of=/dev/sd<b> bs=64M
# pv -E -tpreb /dev/sd<a> | dd of=/dev/sd<b> bs=4096 conv=notrunc,noerror
-E : skip errors, like dd conv=sync,noerror
-t : show timer
-p : show progress
-r : show rate
-e : show ETA (estimated remaining time)
-b : show byte counter
To show it in a dialog box:
(pv -n /dev/sda | dd of=/dev/sdb bs=128M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0
From: http://www.cyberciti.biz/faq/linux-unix-dd-command-show-progress-while-coping/
- (1701)How to fix “WARNING: The following packages cannot be authenticated!” in Kali Linux?
NOTE: DOES NOT WORK for me as http.kali.org seems to redirect to free.fr which seems to be the problem: it is a non-signed repository.
- First thing: make sure you have the correct Official Kali Linux repositories.
http://www.blackmoreops.com/2013/10/30/add-official-kali-linux-repositories/
- apt-key update
- apt-get install --reinstall kali-archive-keyring
# apt-get install --reinstall debian-archive-keyring
# apt-get install --reinstall ubuntu-archive-keyring
From: http://www.blackmoreops.com/2013/12/18/fix-warning-the-following-packages-cannot-be-authenticated-in-kali-linux/
- (1702)How to repair a broken EXT4 fs?
# fsck.ext4 -cDfty -C 0 /dev/sd**
-c – check for bad sectors
-D – optimize directories if possible
-f – force check, even if filesystem seems clean
-t – print timing stats (use -tt for more)
-y – assume answer “yes” to all questions (such as, “do you want to continue”)
-C 0 – print progress info to stdout
/dev/sd** – the partition to check, e.g. /dev/sda1 for first partition (1) on first hard disk (a), etc.
Also have a look at:
# fsck.ext4 -a /dev/sd**
From: https://justcheckingonall.wordpress.com/2010/07/18/howto-repair-broken-ext4-partitions/
http://blog.ricardoamaro.com/content/howto-check-and-mark-badblocks-ext4-partitions
- (1707)What do the "errors" means in fsck output?
e2fsck 1.42 (29-Nov-2011)
Checking for bad blocks (non-destructive read-write test)
Testing with random pattern: 92.64% done, 43:38:19 elapsed. (97/0/0 errors)
That means there was 97 read errors, 0 write errors and 0 corruption errors while testing your disk with random patterns.
- (1709)How to get full path of original file of a soft symbolic link?
readlink -f <link>
For instance for a command like javac:
readlink -f $(which command)
From: https://unix.stackexchange.com/questions/22128/how-to-get-full-path-of-original-file-of-a-soft-symbolic-link
- (1712)How to set the audio volume from commandline?
amixer -D pulse sset Master 5%+
pactl set-sink-volume 0 +10%
From: https://askubuntu.com/questions/97936/terminal-command-to-set-audio-volume
- (1714)How to disable Ubuntu's drum greeting sounds?
[DOESNOT WORK]
gsettings set com.canonical.unity-greeter play-ready-sound "false"
dconf-editor: com.canonical.unity-greeter > play-ready-sound > false
[WORKS]
Just mute the volume in the Greeter login screen
From: https://askubuntu.com/questions/701431/how-can-the-login-greeter-drums-be-turned-off-in-ubuntu-15-10/748457#748457
- (1715)How to correct “dconf: failed to commit changes to dconf: The connection is closed”?
Apparently this is caused by a corrupt config file
rm -fr ~/.config/dconf/
From: https://unix.stackexchange.com/questions/171697/failed-to-commit-changes-to-dconf-the-connection-is-closed
- (1718)How to check the RAM type and speed?
# dmidecode --type 17
From: http://www.cyberciti.biz/faq/check-ram-speed-linux/
- (1719)How to monitor disk IO stats (a.k.a. How to list processes that access the disk/HD)?
- # iotop -aoP
-a Will show accumulated output
-o Will only output
-P Will only show processes instead of threads
- dstat
-t for timestamps
-d for disk statistics
-D to specify the exact devices to report
60 to average over 60 seconds. The display is updated every second, but only once per 60 seconds a new line will be started.
not used in this example, but -c can report wait IO percentage, which in most cases is related to the CPU waiting for data from the disks.
- sar (from sysstat)
- iostat -x 1 /dev/sda (from sysstat)
- vmstat
- atop
- Munin
- Cacti
- Iozone (benchmark tool, not exactly observer tool)
- Centreon (build on Nagios)
- /sys/block/sda/stat (https://www.kernel.org/doc/Documentation/block/stat.txt)
- /proc/diskstats
From: https://unix.stackexchange.com/questions/55212/how-can-i-monitor-disk-io
https://superuser.com/questions/50091/how-do-i-find-out-what-processes-are-accessing-the-hard-disk-in-a-gnu-linux-base
- (1723)How to enable locate/updatedb using encrypted /home partition?
PROBLEM: /home is a virtual file system (ecryptfs). It is "mounted" as an accessible partition only when you log in. Therefore updatedb does not have access to its "unencrypted form" when it is run at boot time and you are not yet logged-in.
== DIRTY SOLUTION (renders all filenames accessible to anyone):
Check your /etc/updatedb.conf
a) remove ecryptfs from ignored file systems (PRUNEFS)
b) change to PRUNE_BIND_MOUNTS="no"
== CLEAN SOLUTION (creates a DB /inside/ the encrypted partition, thus readable only to the user):
- Make so that updatedb is run in background when you logged in (*) or regularly (**). Index
the files in a file in your own $HOME with:
updatedb -l 0 -o $HOME/var/mlocate.db -U $HOME
(*) adding the line in .login / .bash_login
(**) adding the line in a script "/path/to/run_updatedb_local" regularly run by this user's cron
$ crontab -e
# Update locate/updatedb indexes for user
*/30 * * * * /path/to/run_updatedb_local
- Tell locate where to find your own DB:
export LOCATE_PATH="$HOME/var/mlocate.db"
This way, you have a complete index of $HOME but the database isn't
visible unless $HOME is mounted and decrypted.
From: https://askubuntu.com/questions/20821/using-locate-on-an-encrypted-partition
--
IMPORTANT NOTE: There are different versions of locate/updatedb (GNU findutils
vs. mlocate) => you may not have "-U"/"-l"/"-o" options. In this case, just use
"--localpaths=" and "--output=" (there no "-l" equivalent...). Command thus becomes:
updatedb --output=$HOME/.mlocate.db --localpaths=$HOME
From: https://unix.stackexchange.com/questions/197080/updatedb-unrecognized-option-localpaths
- (1727)How to mute the sound under PulseAudio?
amixer -q -D pulse sset Master toggle
pactl set-sink-mute 0 1
From: https://askubuntu.com/questions/26068/how-do-you-mute-from-the-command-line
- (1733)How to keep only lines without a pattern?
grep -v "<pattern>" <file>
sed '/<pattern>/!' <file>
From: https://twitter.com/UnixToolTip/status/711955710058360832
- (1736)How to force "wrapping" of lines on commandline?
PROBLEM: some programs, like "ps aux" truncate the lines
SOLUTION: If you want to see/wrap them, pipe the command to "cat"
ps aux | cat
Thx FC
- (1738)How to reload a Linux user's group assignments without logging out?
PROBLEM: When you have added a user to a group she didn't belong before, for e.g. with:
usermod -G <grouplist> -a <user>
or by directly editing the /etc/group file
how do you reload the group assignments?
SOLUTION1:
su - $USER
SOLUTION2:
exec su -l $USER
SOLTION3: [horribly hacky]
$ id -g # gives you the current primary group ID
$ newgrp <new group name> # switches you to that group as the primary
$ newgrp <orig_group> # moves again to the original primary group
In the end you get a shell in which you can see the new group and the primary is the original one.
OTHER SOLUTIONS:
exec sg <new group name> newgrp `id -gn` # similar to SOLUTION3 but in 1-liner
gpasswd -a user groupname # for a single user
newgrp - # works only with usermod???
nscd -i group # requires installation of external software
From: https://superuser.com/questions/272061/reload-a-linux-users-group-assignments-without-logging-out
- (1739)How to run a command (e.g. shell) in a completely empty environment?
You can do this with env:
env -i <command>
This does completely clear out the environment, but it does not
prevent <command> setting new variables. In particular, running a
shell will cause the /etc/profile to run, and the shell may have some
built in settings also.
You can check this with:
env -i env
i.e. wipe the environment and then print it. The output will be blank.
From: https://unix.stackexchange.com/questions/48994/how-to-run-a-program-in-a-clean-environment-in-bash#48995
- (1741)How to enable mounting for users (of a group) in Ubuntu 14+ (under PolicyKit)? [DOES NOT WORK]
SOLUTION1: By giving privilege to a group
First create a group "mounter" by using this command:
sudo addgroup mounter
Then add the non-admin users to this group. For examle, I'm adding non-admin user normal to this group.
# adduser normal mounter
or
# usermod -G mounter -a normal
Then open the policy file with admin privilege.
# gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
At the top of the file there is a section like this:
[Mounting, checking, etc. of internal drives]
Identity=unix-group:admin;unix-group:sudo;
Action=org.freedesktop.udisks.filesystem-*;org.freedesktop.udisks.drive-ata-smart*
ResultActive=yes
Add "unix-group:mounter;" after "Identity=unix-group:admin;unix-group:sudo;" at the first line of the section.
From: http://askubuntu.com/questions/185718/allow-non-admin-users-to-mount-drives-via-nautilus
- (1749)How to prevent a dramatic end to running a badly configured shell script?
PROBLEM: If you have a line like "/bin/rm -fr /${a}/${b}" in a shell script and it happens that the vars stay undefined, the whole disk will be erased (included backups, if they are mounted at this time!)
SOLUTION: use "set -eu" in your bash scripts!!!
From: https://tech.korben.info/t/eviter-une-journee-de-merde-ca-passe-aussi-par-les-backups/3242
- (1755)How to run mplayer (or any graphical application) from cron?
Your script should look like that:
---
#!/usr/bin/env bash
export DISPLAY=:0.0
export XAUTHORITY=/home/<user>/.Xauthority
mplayer -ao pulse -vo null <file>
---
From: https://askubuntu.com/questions/64033/mplayer-cant-play-audio-from-cron-while-ncmpcpp-is-playing-simultaneously
- (1756)How to mount a block device as a user in Ubuntu 12+?
$ udisksctl mount -b /dev/sdc1
Mounted /dev/sdc1 at /media/user/1F00-1A26.
$ udisksctl unmount -b /dev/sdc1
From: http://manpages.ubuntu.com/manpages/trusty/man1/udisksctl.1.html
- (1759)Things to think of when writing cron script
- Do not use '%' inside /etc/crontab !!!!
- Script must be run by the correct user
- Script must be readable/executable by correct user
- Script must belong to correct user
- Script must contain shebang (#!/usr/bin/env bash)
- Script must contain absolute paths <=> There's no env, so no PATH is defined
- (1760)How to suspend/hibernate Ubuntu 14.10++?
/usr/sbin/pm-{suspend,hibernate}
From: http://manpages.ubuntu.com/manpages/wily/man8/pm-action.8.html
- (1761)How to set up an alarm every xx minutes with cron&mplayer (e.g. for timing tasks or warning about battery level)?
--- user$ crontab -e
0,30 * * * * /home/<user>/Softs/alarm.sh > /tmp/alarm.out 2>&1
*/1 * * * * /home/<user>/Softs/alarm_bat.sh > /tmp/alarm_bat.out 2>&1
--- script rights
-rwxr-xr-x 1 user user 613 Apr 26 21:17 /home/<user>/Softs/alarm.sh
-rwxr-xr-x 1 user user 613 Apr 26 21:17 /home/<user>/Softs/alarm_bat.sh
--- ~/Softs/alarm.sh <= E.g.: a beep every 30min to help time my tasks and focus on my work
#!/usr/bin/env bash
export DISPLAY=:0
export XAUTHORITY=/home/<user>/.Xauthority
export XDG_RUNTIME_DIR=/run/user/$(id -u)
export TERM=xterm
/usr/bin/mplayer -really-quiet `#--ao=pulse` -vo null -volume 90 ~/.sounds/alarm.ogg -loop 3
---
--- alarm_bat <= E.g.: check battery every minute and raise alarm+suspend when battery level is too low
#!/usr/bin/env bash
export DISPLAY=:0
export XAUTHORITY=/home/<user>/.Xauthority
export XDG_RUNTIME_DIR=/run/user/1000
export TERM=xterm
PLUGGED=$(cat /sys/class/power_supply/AC0/online)
CRITICAL_LEVEL=.05
WARNING_LEVEL=.1
REMINDER_LEVEL=.3
pc=$(. ~/Softs/getBATpercent)
if (( x"${PLUGGED}" == x"0" )) ## If the computer is plugged we don't care about the battery level!!
then
if (( $(bc -l <<< "$pc<${CRITICAL_LEVEL}") ))
then
sudo /usr/sbin/pm-suspend
else if (( $(bc -l <<< "$pc<${WARNING_LEVEL}") ))
then
\mplayer -loop 10 "~/.sounds/Droid 1 Alarms/Alarm_Beep_03.ogg" --volume=250
# Would loop printing a message every minute :{
# else if (( $(bc -l <<< "$pc<${REMINDER_LEVEL}") ))
# then
# /usr/bin/xmessage "BATTERIE IS ${pc}"
# fi
fi
fi
fi
From: https://trisquel.info/en/forum/sound-battery-chargeddecharged
https://stackoverflow.com/questions/42497130/audio-doesnt-play-with-crontab-on-raspberry-pi
https://wiki.archlinux.org/index.php/PulseAudio#Play_sound_from_a_non-interactive_shell_.28systemd_service.2C_cron.29
https://askubuntu.com/questions/64033/mplayer-cant-play-audio-from-cron-while-ncmpcpp-is-playing-simultaneously#answer-132266
- (1769)How to efficiently remove files which names are listed in a file?
NOTE: such commands might result in dramatic problems if badly used!!!
SOLUTION1 (does not work with patterns):
xargs rm < <file with list of filenames>
SOLUTION2 (works with patterns):
cat <file with list of filenames> | xargs echo rm | sh
SOLUTION3 (less efficient):
for f in $(cat <file with list of filenames>) ; do
rm "$f"
done
From: https://stackoverflow.com/questions/5142429/unix-how-to-delete-files-listed-in-a-file
- (1771)How to delete lines from one file which are listed in another file?
SOLUTION1 (faster):
sort file_a file_b | uniq -u
SOLUTION2 (fast):
sort f1 > f1.sorted; sort f2 > f2.sorted; comm -2 -3 f1.sorted f2.sorted
SOLUTION3 (slow):
grep -v -x -f f2 f1 should do the trick.
Explanation:
-v to select non-matching lines
-x to match whole lines only
-f f2 to get patterns from f2
One can instead use -F f2 to match fixed strings from f2 rather than patterns (in case you want remove the lines in a "what you see if what you get" manner rather than treating the lines in f2 as regex patterns).
From: https://stackoverflow.com/questions/4780203/deleting-lines-from-one-file-which-are-in-another-file
- (1772)How to keep "rm" command almost fully-automatic but still preventing against most mistakes?
There's an options to "rm" that is less intrusive than -i, while still
giving protection against most mistakes:
rm -I = prompts once before removing more than three files, or when
removing recursively
From: man rm
- (1776)How to make vboxdrv.ko to load in an environment where SecureBoot is enabled (a.k.a How to solve "modprobe: ERROR: could not insert 'vboxdrv': Required key not available")?
PROBLEM:
Since kernel version 4.4.0-20, it was enforced that unsigned kernel
modules will not be allowed to run with Secure Boot enabled. Because
you want to keep Secure Boot, then the next logical step is to sign
those modules.
- Create signing keys
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"
- Sign the module (vboxdrv for this example)
sudo /usr/src/linux-headers-$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
- Register the keys to Secure Boot
sudo mokutil --import MOK.der
- Supply a password for later use after reboot
- Reboot and follow instructions to Enroll MOK (Machine Owner Key). The system will reboot one more time.
From: https://askubuntu.com/questions/760671/could-not-load-vboxdrv-after-upgrade-to-ubuntu-16-04
- (1780)How to open tdb files in Ubuntu?
PulseAudio stores its configurations in ~/.config/pulse/ with .tdb extension.
These are small DBs, that can be opened with:
A] Shell
apt-get install tdb-tools
tdbdump <file>.tdb
tdbtool <file>.tdb (then dump or delete xxx, show xxx)
B] Python
apt-get install python-tdb.
import tdb
t = tdb.open('<file>.tdb')
print(list(t.iterkeys()))
From: https://www.daniweb.com/hardware-and-software/linux-and-unix/threads/483069/how-open-tdb-files
- (1781)How to stop alert sounds (resp. any sound from any application, like FF) in Ubuntu?
1. Launch
unity-control-center sound
2. Go to "Sound Effects" tab (resp. "Applications" tab)
3. Mute the corresponding volume
- (1782)How to pronounce your name backwards?
echo "$USER"| rev | espeak [-v fr] [-w recorded.wav]
From: http://www.commandlinefu.com/commands/view/17301/your-name-backwards
- (1790)How to count # threads currently in use by any user?
ps -u <username> -o nlwp= | awk '{ num_threads += $1 } END { print num_threads }'
From: http://www.commandlinefu.com/commands/view/17296/thrad-count-per-user
- (1793)How to disable and blacklist Linux modules?
- Find the name of the module
/lib/modules/<version>/kernel/drivers/
lsmod
- Gather information about the module and its depencies
modinfo <modulename>
- Configure modprobe to blacklist the module
echo 'blacklist <modulename>' >> /etc/modprobe.d/blacklist-<modulename>.conf
TIP: Instead of using "blacklist <modulename>" it can be better to use
"install <modulename> /bin/false" (it clearly shows in the
configuration that something is not allowed) or "alias <modulename>>
/dev/null".
- Verify the blacklisting status
modprobe --showconfig | egrep '^(blacklist|install|alias)'
- Reboot the machine
From:
http://linux-audit.com/kernel-hardening-disable-and-blacklist-linux-modules/
---
Another option, to disable a module at boot time, is to use the
following arguments on the kernel startup line of grub:
<modulename>.blacklist=yes
modprobe.blacklist=<modulename>
From: https://askubuntu.com/questions/110341/how-to-blacklist-kernel-modules/783922#783922
- (1801)How to change the scheduler in Linux?
##### For I/O
cat /sys/block/sda/queue/scheduler
n echo "noop" > /sys/block/sda/queue/scheduler
d echo "deadline" > /sys/block/sda/queue/scheduler
echo "cfq" > /sys/block/sda/queue/scheduler
cat /sys/block/sda/queue/scheduler
iostat -x 1 /dev/sda
##### For Tasks
[Seems to be possible only by recompiling kernel : see details in links]
From: https://doc.opensuse.org/documentation/html/openSUSE_121/opensuse-tuning/cha.tuning.taskscheduler.html
https://doc.opensuse.org/documentation/html/openSUSE_121/opensuse-tuning/cha.tuning.taskscheduler.html
- (1809)How to boot signed modules in UEFI (a.k.a. how to solve insmod::"Required key not avaible")?
----
If the (VBox) drivers are not signed, you first have to sign them:
1. Generate key & certificate
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Akrog/"
2. Sign module
sudo /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 ./MOK.priv ./MOK.der $(modinfo -n vboxdrv)
----
Then you have to configure UEFI
1. Verify which key was used to sign the module
modinfo <module.ko> | grep 'signer'
2. Verify if this key is enrolled in the UEFI's MOK (Machine Owner Keys)
mokutil --list-enrolled
3. If it is not present, import it ; a password is asked (**)
mokutil --import <file.cer>
4. Reboot
5. The "UEFI key management" menu should appear, select "Enroll MOK"
Continue Boot
_ Enroll MOK
Enroll key from disk
Enroll hash from disk
6. Select the key to enroll and enter the password(**)
Video tutorial:
https://drivers.suse.com/doc/media/IDF-demo-fade-sub-audio.ogv
From: https://drivers.suse.com/doc/Usage/Secure_Boot_Certificate.html
https://forums.virtualbox.org/viewtopic.php?f=7&t=77363&start=15#p361135
- (1811)How to know if the CPU is 64bits and supports virtualisation?
# Is CPU 64 bits?
egrep -wo 'lm' /proc/cpuinfo
## CPU supports virtualization?
egrep -wo 'vmx|ept|vpid|npt|tpr_shadow|flexpriority|vnmi|aes' /proc/cpuinfo | sort | uniq
lscpu | grep 'VT-x'
From: http://www.cyberciti.biz/faq/linux-xen-vmware-kvm-intel-vt-amd-v-support/
- (1815)How to optimize disk (so that there are no more cracks/freezes when playing sounds)?
(*) Done on ASUS 5200T/m laptop computer
## First, compute some performance statistics (*)
# hdparm -t /dev/sda # Perform device read timings
# hdparm -T /dev/sda # Perform cache read timings
## Second, force setting for max perf (*)
# hdparm -M 254 /dev/sda # Get/set acoustic management (0-254, 128: quiet, 254: fast)
## Third, regularly (cron /5 min) force disk cache flushes (*)
# hdparm -f /dev/sda # Flush buffer cache for device on exit
# hdparm -F /dev/sda # Flush drive write cache
## Finally, set long delay before auto-standby mode
# hdparm -S /dev/sda # Set standby (spindown) timeout
From: man hdparm
- (1821)How to manage (soft) RAID devices in Linux
* To check the status of a "virtual" device
# mdadm -D /dev/md4
From: https://serverfault.com/questions/178519/how-to-check-fsck-a-filesystem-on-a-md-device-linux-mdadm#178535
* To create a "virtual" device (="array"="RAID volume") from scratch (=from multiple clean/zeroed "physical" devices)
** Create
# mdadm --create /dev/md0 --level=1 --assume-clean --raid-devices=2 /dev/sdb1 /dev/sdc1
or
# mdadm --create /dev/md0 --level=5 --assume-clean --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
NOTE: You must "merge" partitions here, not disks!
** Then, we have to daemonise the RAID volume (= do so the system load the volume at boot)
# mdadm --daemonise /dev/md0
or
# mdadm --monitor --daemonise /dev/md0
* To re-assemble an existing "array"/"RAID volume"
** If you are sure the drive is clean and don't need resync... (if past array was /dev/md0, partitions inside saved super-minor=0, if you are creating a new array with different minor, e.g. /dev/md3, you need the --update=super-minor option)
# mdadm --assemble /dev/md0 --level=1 --assume-clean --update=super-minor --raid-devices=2 /dev/sdc /dev/sdd
** If sync is required (a disk crash & has been replaced ; or you have mounted/manipulated one of the "physical" partitions outside RAID)
# mdadm --assemble /dev/md0 --level=1 --update=resync --raid-devices=2 /dev/sdc /dev/sdd
* To get infos about our new RAID volume
# fdisk -l /dev/md0
# mdadm --detail /dev/md0
# cat /proc/mdstat
* To increase array size
# mdadm --manage /dev/md0 --add /dev/sdf1 # Add disk to array
# mdadm --grow /dev/md0 --raid-devices=5 # Extend array on these new partitions
# resize2fs /dev/md0 # Grow RAID partition over resized volume
* How to react in case of failure?
** Identify failing HD
*** Use gnome-disk-utility's SMART tool or
*** SMARTMonTools' smartctl
** Declare HD as failing
# mdadm --manage /dev/md0 --set-faulty /dev/sdb1
** Remove HD from RAID volume
# mdadm --manage /dev/md0 --remove /dev/sdb1
** Add replacement HD
# mdadm --manage /dev/md0 --add /dev/sdb1
* To monitor working
# mdadm --monitor --syslog --delay=1800 /dev/md0
* To stop an array/RAID volume
** To remove a drive/partition from the array
# mdadm --manage /dev/md0 --remove /dev/sdb1
** To stop the array/RAID volume
# mdadm --stop /dev/md0
NOTE: also have a look at Tip#1830& Tip#2013
From: https://doc.ubuntu-fr.org/raid_logiciel
- (1822)How to exclude files/dir from find results?
find . -type f -name 'foo*' \( \! -path 'foo-exclude-me/*' -and \! -path 'foo-exclude-me-also/*' \) -print
NOTE1: Do not forget the -print at the end
NOTE2: I'm not sure when to add (or not) "./" at the begining of the -path expressions
NOTE3: -type f might be useful if you pipe output to a recursive command (e.g. find ... | xargs tar), as this might re-include removed file (those inside directories included in find's results)
NOTE4: Beware that -name uses glob-style "regexes" whereas -path does not consider "/" & "." as special chars (i.e. meaning of '*' is different: -path "./sr*sc" will match ./src/misc'!)
From: https://unix.stackexchange.com/questions/67217/exclude-directory-in-find
- (1823)How to set the default boot entry in Grub2?
1. List all possible menu entries
# NOTE1: the numbering starts at 0!!!
# NOTE2: since this is configured at runtime, if you set a wrong number, GRUB2 will simply ignore it and boot with another one!
grep -P "submenu|menuentry" /boot/grub2/grub.cfg | nl -v 0
2. Set the desired default menu entry in the config file
/etc/default/GRUB # for definitive setting
/boot/GRUB/GRUB.cfg # for a setting until next run of update-grub
grub-set-default "<submenu title><menu entry title>" # or:
grub-set-default "<0-based entry index>"
3. Apply the change to grub.cfg by running:
grub-mkconfig -o /boot/grub2/grub.cfg # or:
/usr/sbin/update-grub2
From: https://fedoraproject.org/wiki/GRUB_2
- (1824)How to run / monitor a service in debian/ubuntu?
service <service name> start
ps aux | grep <service> ## Even with no error service might not have been started
service <service name> status -l ## Gives hints on what error might be
tail /var/log/<service>/<service>.log ### might provide more hints
NOTE: similar commands:
service <service name> start/status
start/status <service name>
systemctl start/status mongodb
From: https://dba.stackexchange.com/questions/47027/mongodb-user-for-ubuntu-ec2-instance
https://bbs.archlinux.org/viewtopic.php?id=160776
https://stackoverflow.com/questions/12232166/mongodb-on-ubuntu-wont-start-as-a-service-nothing-in-the-log
- (1827)How to enable Magic SysReq keys on 2.6++ kernels?
When system freezes, you are supposed to be able to prevent a very bad
crash by sending some "magic" commands to the kernel.
To enable this possibility:
- At compile time: CONFIG_MAGIC_SYSRQ
- Dynamically:
- sysctl kernel.sysrq=176
- echo "176" > /proc/sys/kernel/sysrq
176 = 128+32+16 (see below)
The meaning of the number:
/proc/sys/kernel/sysrq:
0 - disable sysrq completely
1 - enable all functions of sysrq
>1 - bitmask of allowed sysrq functions (see below for detailed function
description):
2 = 0x2 - enable control of console logging level
4 = 0x4 - enable control of keyboard (SAK, unraw)
8 = 0x8 - enable debugging dumps of processes etc.
* 16 = 0x10 - enable sync command
* 32 = 0x20 - enable remount read-only
64 = 0x40 - enable signalling of processes (term, kill, oom-kill)
* 128 = 0x80 - allow reboot/poweroff
256 = 0x100 - allow nicing of all RT tasks
The (most important) commands that can be sent to the kernel:
unRaw (take control of keyboard back from X),
tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
kIll (send SIGKILL to all processes, forcing them to terminate immediately),
Sync (flush data to disk),
Unmount (remount all filesystems read-only),
reBoot.
Mnemonics to remember the correct order to send them:
- "Raising Elephants Is So Utterly Boring"
- "Reboot Even If System Utterly Broken"
From: https://en.wikipedia.org/wiki/Magic_SysRq_key
https://www.kernel.org/doc/Documentation/sysrq.txt
- (1828)How to reassemble physical drives/partitions in a RAID array after crash (a.k.a. How to correct error "mdadm: missing has no superblock - assembly aborted"?)
PROBLEM: mdadm says, one way or another, that drives are not compatible anymore.
SOLUTION: create array with 1 drive, then add the other one and let reconstruction/sync solve the problem:
mdadm --assemble /dev/md0 /dev/sd1 /dev/sdb1 /dev/sdc1 /dev/sde1
mdadm --add /dev/md0 /dev/sdd1
More specifically, @presans, I did:
# mdadm --assemble /dev/md3 --update=resync /dev/sdc[5] /dev/sdd[5]
mdadm: missing has no superblock - assembly aborted
# mdadm --assemble /dev/md3 --update=resync /dev/sdc[5]
mdadm: /dev/md3 assembled from 1 drive - need all 2 to start it (use --run to insist).
(* Unsuccessfully tried solution from second link here...)
# mdadm --assemble /dev/md3 --update=resync /dev/sdc[5] --run
mdadm: /dev/md3 has been started with 1 drive (out of 2).
# mdadm --add /dev/md3 /dev/sdd[5]
(*)
# mdadm --assemble /dev/md3 --scan
mdadm: /dev/md3 not identified in config file.
Also see Tip#2013
From: http://superuser.com/questions/465616/mdadm-superblock-on-dev-sdd1-doesnt-match-others-assembly-aborted
http://globalblindspot.blogspot.fr/2011/06/how-to-replace-failed-disk-of-raid-5.html
- (1830)How to generate the ARRAY line for /etc/mdadm/mdadm.conf?
mdadm --detail --scan
Also see Tip#1821, Tip#1828, Tip#1830, Tip#2013
From: http://www.linuxdevcenter.com/pub/a/linux/2002/12/05/RAID.html
- (1831)How to use interactive commands in top?
1: show cores (CPU0, CPU*1*, CPU2...)
i: show only non-*I*dle tasks
c: show full *C*ommand-line
M: sort by *M*emory
P: sort by C*P*U consumption
V: organize as a tree
z,b: Highlight (*B*old) currently running process
x: Highlight sort field
W: Write configuration to ~/.toprc
u: show only current user processes
From: man top + top>h
- (1832)What is the format of /etc/crontab?
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
From: https://stackoverflow.com/questions/5398014/using-crontab-to-execute-script-every-minute-and-another-every-24-hours
- (1833)How to trick cron to run a script every x seconds?
# Will run the script every stright minute
* * * * * /foo/bar/your_script
# Will run the script every stright minute+15 sec
* * * * * sleep 15; /foo/bar/your_script
# Will run the script every stright minute+30 sec
* * * * * sleep 30; /foo/bar/your_script
# Will run the script every stright minute+45 sec
* * * * * sleep 45; /foo/bar/your_script
As a conclusion script will be run every 15 seconds!!!
From: https://stackoverflow.com/questions/1034243/how-to-get-a-unix-script-to-run-every-15-seconds/1034304#1034304
- (1877)How to solve a bug in UNetbootin where you only get a grey window?
sudo unetbootin &
(blank screen opens)
sudo QT_X11_NO_MITSHM=1 unetbootin
(new screen with correct display opens)
From: https://bbs.archlinux.org/viewtopic.php?id=187234
https://bugs.launchpad.net/unetbootin/+bug/1620628
- (1878)Script to purge old kernels
if [[ $# -lt 1 ]]; then
echo "USAGE $0 <list of kernel version# to be removed>"
else
for val in $*
do
apt-get purge linux-headers-${val} linux-image-${val} linux-image-extra-${val} linux-tools-${val} linux-cloud-tools-${val} linux-signed-image-${val}
done
fi
- (1882)How to switch to UTC in LinuxMint?
gksu gedit /etc/default/rcS
- (1883)How to set hostname in ArchLinux?
# sysctl kernel.hostname=<name>
# vi /etc/hostname
- (1884)How to rescue a damaged partition/disk/file?
- TestDisk (includes PhotoRec)
- http://www.linuxlinks.com/article/20100226123455346/ddrescue.html
- (1894)How to set keyboard in RasberryPi?
vi /etc/default/keyboard
- (1895)How to play video using the video acceleration in RasberryPi?
use omxplayer instead of vlc or mplayer.
- (1896)What to do if a program seems stuck/frozen for a very long time?
1. Use "iotop" to see if the program encounters I/O problems
2a. Determine the process ID of the program and its threads:
ps -efL|grep <Process Name>
2b. "strace" the code to see what method is blocking:
strace -p <comma separated list of processes/threads ids>
In a very sneaky case, I got:
[pid 2642] futex(0x66b5909459d0, FUTEX_WAIT, 2643, NULL <unfinished ...>
[pid 2636] wait4(-1,
and the was still completely stuck.
The problem was that I used CTRL-S to freeze the display to have a
look at my code's output, then forgot to use CTRL-Q to un-freeze the
display. What happens in this case is that, after some time, the
program has completely filled its output buffer and has to wait until
some memory is freed to be able to continue. It will thus continue
only if you hit CTRL-Q to un-freeze the display and free some space in
the output buffer!!!
From: https://meenakshi02.wordpress.com/2011/02/02/strace-hanging-at-futex/
- (1919)How to get rid of freeze during halt on Ubuntu 16.04 (freeze on "[OK] Stopped Thermal daemon/CTL-ALT-SUPPR/Started unattended upgrade shutdown")?
- To stop & disable problem source service:
sudo systemctl stop cups-browsed.service and sudo systemctl disable cups-browsed.service
-To verify:
sudo systemctl status cups-browsed or sudo systemctl is-enabled cups-browsed
From: http://askubuntu.com/questions/760952/slow-shutdown-on-ubuntu-16-04-lts-stopping-thermal-daemon-running-fit-make-remo#763803
---
systemctl status ntp.service ; systemctl stop ntp.service ; systemctl disable ntp.service
systemctl status unattended-upgrades.service ; systemctl stop unattended-upgrades.service ; systemctl disable unattended-upgrades
nmcli con show
- (1922)How to get rid of untimely unmount/disconnection of ecryptfs'd /home in Ubuntu 16.04?
SOLUTION for local disconnection:
Prevent auto-unmount by deleting ~/.ecryptfs/auto-umount (to add in .xsession?)
SOLUTION for remote connexion:
We'd still like to find a better fix for this, but tonight @eminence mentioned a half-decent workaround on #mosh: ssh localhost upon connecting to the remote host. mosh remote-host-name ssh localhostwill often work as well.
EXPLANATION:
Ah, eCryptfs. What actually happens is that pam_ecryptfs maintains a session counter (/dev/shm/ecryptfs-$USER-Private) that is incremented on PAM login and decremented on PAM logout. The temporary SSH session that mosh uses to launch the remote mosh-server causes a PAM login followed immediately by a PAM logout, so the counter reaches zero and the encrypted folder is unmounted immediately.
From: https://github.com/mobile-shell/mosh/issues/529
- (1925)How to install a previous version of a software (a.k.a. downgrade the package version)?
You can install a specific version of a package with apt-get in the
terminal. First, determine the available versions you can install with
the following command
apt-cache showpkg packagename
Next, run the apt-get install command and specify the package version
you want to install.
sudo apt-get install packagename=version
After it’s installed, run the following command to hold your installed
version, preventing the package manager from automatically updating it
in the future:
sudo echo “package hold” | sudo dpkg –set-selections
From: http://www.howtogeek.com/117929/how-to-downgrade-packages-on-ubuntu/
- (1926)How to open man pages as beautiful HTML page in browser?
alias bman='man --html=x-www-browser'
From: http://www.commandlinefu.com/commands/view/18212/open-a-manpage-in-the-default-graphical-web-browser
- (1927)How to compute the number of days between 2 dates?
-- ddiff.sh
day1sec=$(date '+%s' -d "$1")
day2sec=$(date '+%s' -d "$2")
echo "($day2sec-$day1sec)/(24*3600)" | bc
--
From: http://unix.stackexchange.com/questions/24626/quickly-calculate-date-differences
- (1928)How to solve "pdflatex ... Font ...[umvs] at ... not found"?
As a user, run:
updmap [--verbose]
From: http://tex.stackexchange.com/questions/310155/what-is-the-windows-miktex-equivalent-to-updating-pdftex-map-by-running-initexm#310167
- (1931)How to change boot back to graphical in Ubuntu 16+?
-- /etc/default/grub
##GM: for gfx boot
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
##GM: for text boot
##GRUB_CMDLINE_LINUX_DEFAULT="text"
-- SystemD (more recent linux)
##GM: for gfx boot
systemctl set-default multi-user.target
##GM: for text boot
systemctl set-default graphical.target
See Tip#1508
https://fedoraproject.org/wiki/Systemd#How_do_I_change_the_target_.28runlevel.29_.3
-- /etc/init/rc-sysinit.conf
##GM: for console start
##env DEFAULT_RUNLEVEL=2
##GM: for X/DM start
env DEFAULT_RUNLEVEL=5
See Tip#1448
Also See Tip#904 and Tip#2189
http://askubuntu.com/questions/86483/how-can-i-see-or-change-default-run-level
- (1933)How to execute commands at logout/bash exit?
-- .logout
##rm -rf ~/tmp/*
rm -rf ~/.cache/*
/usr/bin/clear
/usr/bin/clear_console
--
chmod u+x .logout
ln -s .logout .bash_logout
From: http://go2linux.garron.me/linux/2010/12/how-execute-commands-when-you-log-out-logout-file-865/
- (1935)How to get the version number of an installed package?
dpkg -l | grep '^ii' | grep <pkgname>
From: http://askubuntu.com/questions/347555/how-do-i-list-all-installed-packages-with-specific-version-numbers#347563
- (1937)Interesting linux distros
- Very small (in memory)
http://www.tinycorelinux.net/
http://www.slitaz.org/en/
http://www.damnsmalllinux.org/download.html
- Light linux
https://www.linuxliteos.com/
https://www.bunsenlabs.org/installation.html
- For Windows (7) users
http://zorinos.com/ (Free+$$$)
- For OS X / MacOS users
http://vectorlinux.com/downloads
https://elementary.io/ ($$$)
https://os.trenta.io/
- Very simple
http://handylinux.org/
http://www.geteasypeasy.com/
https://apricityos.com/ (Arch, GnomeShell)
https://antergos.com/ (Arch, GnomeShell)
http://www.backslashlinux.in/ (Indian, GnomeShell?)
https://www.deepin.org/en/download/ (Chinese, specific desktop: Deepin)
https://elementary.io/ (Ubuntu, specific desktop: Pantheon)
- People with visual disabilities
https://www.ulule.com/handydv-linux/
- Security/anonymity
-> Defensive Security/Anonymity
https://tails.boum.org/ (Tor)
http://www.ipredia.org/ (I2P - unmaintained 2013?)
https://www.stamus-networks.com/open-source/ (Suricata IntrusionDetectionSystem/IPS)
http://bugtraq-team.com
https://www.qubes-os.org/ (each app in a VM)
-> Offensive Security/PenTesting
https://www.kali.org/
https://www.parrotsec.org/
https://backbox.org/
http://www.pentoo.ch/download/
http://www.blackarch.org/
http://www.caine-live.net/
http://www.wifislax.com
https://sourceforge.net/projects/archassault/ (unmaintained - 2015?)
http://cyborg.ztrela.com/
- Wayland
https://github.com/n3rdopolis/rebeccablackos/releases/tag/2016-02-08
- Other Linuces
https://solus-project.com/download/
http://voyagerlive.org/ (xubuntu - French)
https://nixos.org/ (entirely declaratice package manager)
- ReactOS - Windows API
https://sourceforge.net/projects/reactos/
- Android for x86
http://www.jide.com/remixos
- ASM
http://www.menuetos.net/
http://kolibrios.org/fr/
From: http://sysadmin.lliseil.fr/linux/distribs/leger.php
- (1938)How to record all the output of a shell session into a file?
Run:
$ script <filename> # this will fork a new shell
$ ... # do your stuff
$ ^D # quit
The file <filename> will contain all the output you saw appear on your shell session
From: https://twitter.com/UnixToolTip/status/801118157800808448
- (1940)How to get infos about your CPU?
- cat /proc/cpuinfo
- lscpu
- hardinfo
- lshw -class processor
- nproc
- dmidecode -t 4
- cpuid
From: http://www.binarytides.com/linux-cpu-information/
- (1941)How to work with a password-less root system?
- use `sudo su` to become root and run the command
- put sudo in front of all the commands
- Alternatively you can set a password by entering
# sudo passwd
From: https://groups.google.com/forum/#!topic/qubes-users/aUExUHdIoqI
- (1960)How to draw arrows in UTF-8?
Car Dec Hex Entity Name
← 8592 2190 ← LEFTWARDS ARROW
↑ 8593 2191 ↑ UPWARDS ARROW
→ 8594 2192 → RIGHTWARDS ARROW
↓ 8595 2193 ↓ DOWNWARDS ARROW
↔ 8596 2194 ↔ LEFT RIGHT ARROW
↕ 8597 2195 UP DOWN ARROW
↖ 8598 2196 NORTH WEST ARROW
↗ 8599 2197 NORTH EAST ARROW
↘ 8600 2198 SOUTH EAST ARROW
↙ 8601 2199 SOUTH WEST ARROW
↚ 8602 219A LEFTWARDS ARROW WITH STROKE
↛ 8603 219B RIGHTWARDS ARROW WITH STROKE
↜ 8604 219C LEFTWARDS WAVE ARROW
↝ 8605 219D RIGHTWARDS WAVE ARROW
...
⇄ 8644 21C4 RIGHTWARDS ARROW OVER LEFTWARDS ARROW
⇅ 8645 21C5 UPWARDS ARROW LEFTWARDS OF DOWNWARDS ARROW
⇆ 8646 21C6 LEFTWARDS ARROW OVER RIGHTWARDS ARROW
⇇ 8647 21C7 LEFTWARDS PAIRED ARROWS
⇈ 8648 21C8 UPWARDS PAIRED ARROWS
⇉ 8649 21C9 RIGHTWARDS PAIRED ARROWS
⇊ 8650 21CA DOWNWARDS PAIRED ARROWS
⇋ 8651 21CB LEFTWARDS HARPOON OVER RIGHTWARDS HARPOON
⇌ 8652 21CC RIGHTWARDS HARPOON OVER LEFTWARDS HARPOON
...
⇍ 8653 21CD LEFTWARDS DOUBLE ARROW WITH STROKE
⇎ 8654 21CE LEFT RIGHT DOUBLE ARROW WITH STROKE
⇏ 8655 21CF RIGHTWARDS DOUBLE ARROW WITH STROKE
⇐ 8656 21D0 ⇐ LEFTWARDS DOUBLE ARROW
⇑ 8657 21D1 ⇑ UPWARDS DOUBLE ARROW
⇒ 8658 21D2 ⇒ RIGHTWARDS DOUBLE ARROW
⇓ 8659 21D3 ⇓ DOWNWARDS DOUBLE ARROW
⇔ 8660 21D4 ⇔ LEFT RIGHT DOUBLE ARROW
⇕ 8661 21D5 UP DOWN DOUBLE ARROW
⇖ 8662 21D6 NORTH WEST DOUBLE ARROW
⇗ 8663 21D7 NORTH EAST DOUBLE ARROW
⇘ 8664 21D8 SOUTH EAST DOUBLE ARROW
⇙ 8665 21D9 SOUTH WEST DOUBLE ARROW
See Tip#1785 to display it in a shell (and copy/paste it in Emacs, etc):
printf "\\u$hexval"
From: http://www.w3schools.com/charsets/ref_utf_arrows.asp
- (1961)How to draw Maths/Letter-like symbols in UTF-8?
Car Dec Hex Entity Name
ℂ 8450 2102 DOUBLE-STRUCK CAPITAL C
ℋ 8459 210B SCRIPT CAPITAL H
ℎ 8462 210E PLANCK CONSTANT
ℕ 8469 2115 DOUBLE-STRUCK CAPITAL N
ℙ 8473 2119 DOUBLE-STRUCK CAPITAL P
ℚ 8474 211A DOUBLE-STRUCK CAPITAL Q
ℛ 8475 211B SCRIPT CAPITAL R
ℜ 8476 211C ℜ BLACK-LETTER CAPITAL R
ℝ 8477 211D DOUBLE-STRUCK CAPITAL R
™ 8482 2122 ™ TRADE MARK SIGN
ℤ 8484 2124 DOUBLE-STRUCK CAPITAL Z
Ω 8486 2126 OHM SIGN
Å 8491 212B ANGSTROM SIGN
ℬ 8492 212C SCRIPT CAPITAL B
ℵ 8501 2135 ℵ ALEF SYMBOL
ℼ 8508 213C DOUBLE-STRUCK SMALL PI
⅀ 8512 2140 DOUBLE-STRUCK N-ARY SUMMATION
⅏ 8527 214F SYMBOL FOR SAMARITAN SOURCE
∀ 8704 2200 ∀ FOR ALL
∂ 8706 2202 ∂ PARTIAL DIFFERENTIAL
∃ 8707 2203 ∃ THERE EXISTS
∄ 8708 2204 THERE DOES NOT EXIST
∅ 8709 2205 ∅ EMPTY SET
∈ 8712 2208 ∈ ELEMENT OF
∉ 8713 2209 ∉ NOT AN ELEMENT OF
∏ 8719 220F ∏ N-ARY PRODUCT
∑ 8721 2211 ∑ N-ARY SUMMATION
√ 8730 221A √ SQUARE ROOT
∛ 8731 221B CUBE ROOT
∜ 8732 221C FOURTH ROOT
∞ 8734 221E ∞ INFINITY
∥ 8741 2225 PARALLEL TO
∦ 8742 2226 NOT PARALLEL TO
∧ 8743 2227 ∧ LOGICAL AND
∨ 8744 2228 ∨ LOGICAL OR
∩ 8745 2229 ∩ INTERSECTION
∪ 8746 222A ∪ UNION
∫ 8747 222B ∫ INTEGRAL
∬ 8748 222C DOUBLE INTEGRAL
∭ 8749 222D TRIPLE INTEGRAL
∮ 8750 222E CONTOUR INTEGRAL
∯ 8751 222F SURFACE INTEGRAL
∰ 8752 2230 VOLUME INTEGRAL
∴ 8756 2234 ∴ THEREFORE
∵ 8757 2235 BECAUSE
∶ 8758 2236 RATIO
∷ 8759 2237 PROPORTION
∼ 8764 223C ∼ TILDE OPERATOR
≃ 8771 2243 ASYMPTOTICALLY EQUAL TO
≄ 8772 2244 NOT ASYMPTOTICALLY EQUAL TO
≈ 8776 2248 ≈ ALMOST EQUAL TO
≉ 8777 2249 NOT ALMOST EQUAL TO
∿ 8767 223F SINE WAVE
≡ 8801 2261 ≡ IDENTICAL TO
≤ 8804 2264 ≤ LESS-THAN OR EQUAL TO
≥ 8805 2265 ≥ GREATER-THAN OR EQUAL TO
⊂ 8834 2282 ⊂ SUBSET OF
⊃ 8835 2283 ⊃ SUPERSET OF
⊄ 8836 2284 ⊄ NOT A SUBSET OF
⊅ 8837 2285 NOT A SUPERSET OF
⊆ 8838 2286 ⊆ SUBSET OF OR EQUAL TO
⊇ 8839 2287 ⊇ SUPERSET OF OR EQUAL TO
⊈ 8840 2288 NEITHER A SUBSET OF NOR EQUAL TO
⊉ 8841 2289 NEITHER A SUPERSET OF NOR EQUAL TO
⊓ 8851 2293 SQUARE CAP
⊔ 8852 2294 SQUARE CUP
⊕ 8853 2295 ⊕ CIRCLED PLUS
⊖ 8854 2296 CIRCLED MINUS
⊗ 8855 2297 ⊗ CIRCLED TIMES
⊙ 8857 2299 CIRCLED DOT OPERATOR
⊢ 8866 22A2 RIGHT TACK
⊣ 8867 22A3 LEFT TACK
⊤ 8868 22A4 DOWN TACK
⊥ 8869 22A5 ⊥ UP TACK
⊦ 8870 22A6 ASSERTION
⊧ 8871 22A7 MODELS
⊨ 8872 22A8 TRUE
⊲ 8882 22B2 NORMAL SUBGROUP OF
⊳ 8883 22B3 CONTAINS AS NORMAL SUBGROUP
⊶ 8886 22B6 ORIGINAL OF
⊷ 8887 22B7 IMAGE OF
⊸ 8888 22B8 MULTIMAP
⊹ 8889 22B9 HERMITIAN CONJUGATE MATRIX
⊾ 8894 22BE RIGHT ANGLE WITH ARC
⋀ 8896 22C0 N-ARY LOGICAL AND
⋁ 8897 22C1 N-ARY LOGICAL OR
⋂ 8898 22C2 N-ARY INTERSECTION
⋃ 8899 22C3 N-ARY UNION
⋄ 8900 22C4 DIAMOND OPERATOR
⋮ 8942 22EE VERTICAL ELLIPSIS
⋯ 8943 22EF MIDLINE HORIZONTAL ELLIPSIS
⋰ 8944 22F0 UP RIGHT DIAGONAL ELLIPSIS
⋱ 8945 22F1 DOWN RIGHT DIAGONAL ELLIPSIS
See Tip#1785 to display it in a shell (and copy/paste it in Emacs, etc):
printf "\\u$hexval"
From: http://www.w3schools.com/charsets/ref_utf_letterlike.asp
http://www.w3schools.com/charsets/ref_utf_math.asp
- (1962)How to draw in UTF-8?
Car Dec Hex Entity Name
│ 9474 2502 BOX DRAWINGS LIGHT VERTICAL
┃ 9475 2503 BOX DRAWINGS HEAVY VERTICAL
╎ 9550 254E BOX DRAWINGS LIGHT DOUBLE DASH VERTICAL
╏ 9551 254F BOX DRAWINGS HEAVY DOUBLE DASH VERTICAL
┆ 9478 2506 BOX DRAWINGS LIGHT TRIPLE DASH VERTICAL
┇ 9479 2507 BOX DRAWINGS HEAVY TRIPLE DASH VERTICAL
─ 9472 2500 BOX DRAWINGS LIGHT HORIZONTAL
━ 9473 2501 BOX DRAWINGS HEAVY HORIZONTAL
╌ 9548 254C BOX DRAWINGS LIGHT DOUBLE DASH HORIZONTAL
╍ 9549 254D BOX DRAWINGS HEAVY DOUBLE DASH HORIZONTAL
┄ 9476 2504 BOX DRAWINGS LIGHT TRIPLE DASH HORIZONTAL
┅ 9477 2505 BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL
┌ 9484 250C BOX DRAWINGS LIGHT DOWN AND RIGHT
┍ 9485 250D BOX DRAWINGS DOWN LIGHT AND RIGHT HEAVY
┎ 9486 250E BOX DRAWINGS DOWN HEAVY AND RIGHT LIGHT
┏ 9487 250F BOX DRAWINGS HEAVY DOWN AND RIGHT
┐ 9488 2510 BOX DRAWINGS LIGHT DOWN AND LEFT
┑ 9489 2511 BOX DRAWINGS DOWN LIGHT AND LEFT HEAVY
┒ 9490 2512 BOX DRAWINGS DOWN HEAVY AND LEFT LIGHT
┓ 9491 2513 BOX DRAWINGS HEAVY DOWN AND LEFT
└ 9492 2514 BOX DRAWINGS LIGHT UP AND RIGHT
┕ 9493 2515 BOX DRAWINGS UP LIGHT AND RIGHT HEAVY
┖ 9494 2516 BOX DRAWINGS UP HEAVY AND RIGHT LIGHT
┗ 9495 2517 BOX DRAWINGS HEAVY UP AND RIGHT
┘ 9496 2518 BOX DRAWINGS LIGHT UP AND LEFT
┙ 9497 2519 BOX DRAWINGS UP LIGHT AND LEFT HEAVY
┚ 9498 251A BOX DRAWINGS UP HEAVY AND LEFT LIGHT
┛ 9499 251B BOX DRAWINGS HEAVY UP AND LEFT
├ 9500 251C BOX DRAWINGS LIGHT VERTICAL AND RIGHT
┣ 9507 2523 BOX DRAWINGS HEAVY VERTICAL AND RIGHT
┤ 9508 2524 BOX DRAWINGS LIGHT VERTICAL AND LEFT
┫ 9515 252B BOX DRAWINGS HEAVY VERTICAL AND LEFT
┬ 9516 252C BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
┳ 9523 2533 BOX DRAWINGS HEAVY DOWN AND HORIZONTAL
┴ 9524 2534 BOX DRAWINGS LIGHT UP AND HORIZONTAL
┻ 9531 253B BOX DRAWINGS HEAVY UP AND HORIZONTAL
┼ 9532 253C BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
╋ 9547 254B BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL
═ 9552 2550 BOX DRAWINGS DOUBLE HORIZONTAL
║ 9553 2551 BOX DRAWINGS DOUBLE VERTICAL
╔ 9556 2554 BOX DRAWINGS DOUBLE DOWN AND RIGHT
╗ 9559 2557 BOX DRAWINGS DOUBLE DOWN AND LEFT
╚ 9562 255A BOX DRAWINGS DOUBLE UP AND RIGHT
╝ 9565 255D BOX DRAWINGS DOUBLE UP AND LEFT
╠ 9568 2560 BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
╣ 9571 2563 BOX DRAWINGS DOUBLE VERTICAL AND LEFT
╦ 9574 2566 BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
╩ 9577 2569 BOX DRAWINGS DOUBLE UP AND HORIZONTAL
╬ 9580 256C BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
╭ 9581 256D BOX DRAWINGS LIGHT ARC DOWN AND RIGHT
╮ 9582 256E BOX DRAWINGS LIGHT ARC DOWN AND LEFT
╯ 9583 256F BOX DRAWINGS LIGHT ARC UP AND LEFT
╰ 9584 2570 BOX DRAWINGS LIGHT ARC UP AND RIGHT
□ 9633 25A1 WHITE SQUARE
▢ 9634 25A2 WHITE SQUARE WITH ROUNDED CORNERS
▤ 9636 25A4 SQUARE WITH HORIZONTAL FILL
▥ 9637 25A5 SQUARE WITH VERTICAL FILL
▦ 9638 25A6 SQUARE WITH ORTHOGONAL CROSSHATCH FILL
▧ 9639 25A7 SQUARE WITH UPPER LEFT TO LOWER RIGHT FILL
▨ 9640 25A8 SQUARE WITH UPPER RIGHT TO LOWER LEFT FILL
▩ 9641 25A9 SQUARE WITH DIAGONAL CROSSHATCH FILL
▰ 9648 25B0 BLACK PARALLELOGRAM
▱ 9649 25B1 WHITE PARALLELOGRAM
▲ 9650 25B2 BLACK UP-POINTING TRIANGLE
△ 9651 25B3 WHITE UP-POINTING TRIANGLE
▶ 9654 25B6 BLACK RIGHT-POINTING TRIANGLE
▷ 9655 25B7 WHITE RIGHT-POINTING TRIANGLE
▼ 9660 25BC BLACK DOWN-POINTING TRIANGLE
▽ 9661 25BD WHITE DOWN-POINTING TRIANGLE
◀ 9664 25C0 BLACK LEFT-POINTING TRIANGLE
◁ 9665 25C1 WHITE LEFT-POINTING TRIANGLE
◆ 9670 25C6 BLACK DIAMOND
◇ 9671 25C7 WHITE DIAMOND
◈ 9672 25C8 WHITE DIAMOND CONTAINING BLACK SMALL DIAMOND
◉ 9673 25C9 FISHEYE
○ 9675 25CB WHITE CIRCLE
◌ 9676 25CC DOTTED CIRCLE
◍ 9677 25CD CIRCLE WITH VERTICAL FILL
◎ 9678 25CE BULLSEYE
◐ 9680 25D0 CIRCLE WITH LEFT HALF BLACK
◑ 9681 25D1 CIRCLE WITH RIGHT HALF BLACK
◒ 9682 25D2 CIRCLE WITH LOWER HALF BLACK
◓ 9683 25D3 CIRCLE WITH UPPER HALF BLACK
◔ 9684 25D4 CIRCLE WITH UPPER RIGHT QUADRANT BLACK
◕ 9685 25D5 CIRCLE WITH ALL BUT UPPER LEFT QUADRANT BLACK
◖ 9686 25D6 LEFT HALF BLACK CIRCLE
◗ 9687 25D7 RIGHT HALF BLACK CIRCLE
◜ 9692 25DC UPPER LEFT QUADRANT CIRCULAR ARC
◝ 9693 25DD UPPER RIGHT QUADRANT CIRCULAR ARC
◞ 9694 25DE LOWER RIGHT QUADRANT CIRCULAR ARC
◟ 9695 25DF LOWER LEFT QUADRANT CIRCULAR ARC
◢ 9698 25E2 BLACK LOWER RIGHT TRIANGLE
◣ 9699 25E3 BLACK LOWER LEFT TRIANGLE
◤ 9700 25E4 BLACK UPPER LEFT TRIANGLE
◥ 9701 25E5 BLACK UPPER RIGHT TRIANGLE
◧ 9703 25E7 SQUARE WITH LEFT HALF BLACK
◨ 9704 25E8 SQUARE WITH RIGHT HALF BLACK
◩ 9705 25E9 SQUARE WITH UPPER LEFT DIAGONAL HALF BLACK
◪ 9706 25EA SQUARE WITH LOWER RIGHT DIAGONAL HALF BLACK
◰ 9712 25F0 WHITE SQUARE WITH UPPER LEFT QUADRANT
◱ 9713 25F1 WHITE SQUARE WITH LOWER LEFT QUADRANT
◲ 9714 25F2 WHITE SQUARE WITH LOWER RIGHT QUADRANT
◳ 9715 25F3 WHITE SQUARE WITH UPPER RIGHT QUADRANT
◴ 9716 25F4 WHITE CIRCLE WITH UPPER LEFT QUADRANT
◵ 9717 25F5 WHITE CIRCLE WITH LOWER LEFT QUADRANT
◶ 9718 25F6 WHITE CIRCLE WITH LOWER RIGHT QUADRANT
◷ 9719 25F7 WHITE CIRCLE WITH UPPER RIGHT QUADRANT
◸ 9720 25F8 UPPER LEFT TRIANGLE
◹ 9721 25F9 UPPER RIGHT TRIANGLE
◺ 9722 25FA LOWER LEFT TRIANGLE
◿ 9727 25FF LOWER RIGHT TRIANGLE
◻ 9723 25FB WHITE MEDIUM SQUARE
◼ 9724 25FC BLACK MEDIUM SQUARE
◽ 9725 25FD WHITE MEDIUM SMALL SQUARE
◾ 9726 25FE BLACK MEDIUM SMALL SQUARE
See Tip#1785 to display it in a shell (and copy/paste it in Emacs, etc):
printf "\\u$hexval"
From: http://www.w3schools.com/charsets/ref_utf_box.asp
http://www.w3schools.com/charsets/ref_utf_geometric.asp
- (1963)How to draw funny symbols in UTF-8?
Car Dec Hex Entity Name
☀ 9728 2600 BLACK SUN WITH RAYS
☁ 9729 2601 CLOUD
☂ 9730 2602 UMBRELLA
☃ 9731 2603 SNOWMAN
☄ 9732 2604 COMET
★ 9733 2605 BLACK STAR
☆ 9734 2606 WHITE STAR
☇ 9735 2607 LIGHTNING
☌ 9740 260C CONJUNCTION
☍ 9741 260D OPPOSITION
☎ 9742 260E BLACK TELEPHONE
☐ 9744 2610 BALLOT BOX
☑ 9745 2611 BALLOT BOX WITH CHECK
☒ 9746 2612 BALLOT BOX WITH X
☓ 9747 2613 SALTIRE
☔ 9748 2614 UMBRELLA WITH RAIN DROPS
☘ 9752 2618 SHAMROCK
☚ 9754 261A BLACK LEFT POINTING INDEX
☛ 9755 261B BLACK RIGHT POINTING INDEX
☜ 9756 261C WHITE LEFT POINTING INDEX
☝ 9757 261D WHITE UP POINTING INDEX
☞ 9758 261E WHITE RIGHT POINTING INDEX
☟ 9759 261F WHITE DOWN POINTING INDEX
☠ 9760 2620 SKULL AND CROSSBONES
☢ 9762 2622 RADIOACTIVE SIGN
☣ 9763 2623 BIOHAZARD SIGN
☤ 9764 2624 CADUCEUS
☥ 9765 2625 ANKH
☩ 9769 2629 CROSS OF JERUSALEM
☪ 9770 262A STAR AND CRESCENT
☭ 9773 262D HAMMER AND SICKLE
☮ 9774 262E PEACE SYMBOL
☯ 9775 262F YIN YANG
☸ 9784 2638 WHEEL OF DHARMA
☹ 9785 2639 WHITE FROWNING FACE
☺ 9786 263A WHITE SMILING FACE
☼ 9788 263C WHITE SUN WITH RAYS
☽ 9789 263D FIRST QUARTER MOON
☾ 9790 263E LAST QUARTER MOON
♂ 9794 2642 MALE SIGN
♔ 9812 2654 WHITE CHESS KING
♕ 9813 2655 WHITE CHESS QUEEN
♖ 9814 2656 WHITE CHESS ROOK
♗ 9815 2657 WHITE CHESS BISHOP
♘ 9816 2658 WHITE CHESS KNIGHT
♙ 9817 2659 WHITE CHESS PAWN
♚ 9818 265A BLACK CHESS KING
♛ 9819 265B BLACK CHESS QUEEN
♜ 9820 265C BLACK CHESS ROOK
♝ 9821 265D BLACK CHESS BISHOP
♞ 9822 265E BLACK CHESS KNIGHT
♟ 9823 265F BLACK CHESS PAWN
♠ 9824 2660 ♠ BLACK SPADE SUIT
♡ 9825 2661 WHITE HEART SUIT
♢ 9826 2662 WHITE DIAMOND SUIT
♣ 9827 2663 ♣ BLACK CLUB SUIT
♤ 9828 2664 WHITE SPADE SUIT
♥ 9829 2665 ♥ BLACK HEART SUIT
♦ 9830 2666 ♦ BLACK DIAMOND SUIT
♩ 9833 2669 QUARTER NOTE
♪ 9834 266A EIGHTH NOTE
♫ 9835 266B BEAMED EIGHTH NOTES
♬ 9836 266C BEAMED SIXTEENTH NOTES
♭ 9837 266D MUSIC FLAT SIGN
♮ 9838 266E MUSIC NATURAL SIGN
♯ 9839 266F MUSIC SHARP SIGN
♲ 9842 2672 UNIVERSAL RECYCLING SYMBOL
♺ 9850 267A RECYCLING SYMBOL FOR GENERIC MATERIALS
♻ 9851 267B BLACK UNIVERSAL RECYCLING SYMBOL
♿ 9855 267F WHEELCHAIR SYMBOL
⚀ 9856 2680 DIE FACE-1
⚁ 9857 2681 DIE FACE-2
⚂ 9858 2682 DIE FACE-3
⚃ 9859 2683 DIE FACE-4
⚄ 9860 2684 DIE FACE-5
⚅ 9861 2685 DIE FACE-6
⚐ 9872 2690 WHITE FLAG
⚑ 9873 2691 BLACK FLAG
⚒ 9874 2692 HAMMER AND PICK
⚓ 9875 2693 ANCHOR
⚛ 9883 269B ATOM SYMBOL
⚜ 9884 269C FLEUR-DE-LIS
⚡ 9889 26A1 HIGH VOLTAGE SIGN
⚤ 9892 26A4 INTERLOCKED FEMALE AND MALE SIGN
⚥ 9893 26A5 MALE AND FEMALE SIGN
⚦ 9894 26A6 MALE WITH STROKE SIGN
⚭ 9901 26AD MARRIAGE SYMBOL
⚮ 9902 26AE DIVORCE SYMBOL
⚯ 9903 26AF UNMARRIED PARTNERSHIP SYMBOL
⛀ 9920 26C0 WHITE DRAUGHTS MAN
⛁ 9921 26C1 WHITE DRAUGHTS KING
⛂ 9922 26C2 BLACK DRAUGHTS MAN
⛃ 9923 26C3 BLACK DRAUGHTS KING
✁ 9985 2701 UPPER BLADE SCISSORS
✂ 9986 2702 BLACK SCISSORS
✃ 9987 2703 LOWER BLADE SCISSORS
✄ 9988 2704 WHITE SCISSORS
✅ 9989 2705 WHITE HEAVY CHECK MARK
✆ 9990 2706 TELEPHONE LOCATION SIGN
✈ 9992 2708 AIRPLANE
✉ 9993 2709 ENVELOPE
✊ 9994 270A RAISED FIST
✋ 9995 270B RAISED HAND
✌ 9996 270C VICTORY HAND
✍ 9997 270D WRITING HAND
✎ 9998 270E LOWER RIGHT PENCIL
✏ 9999 270F PENCIL
✐ 10000 2710 UPPER RIGHT PENCIL
✑ 10001 2711 WHITE NIB
✒ 10002 2712 BLACK NIB
✓ 10003 2713 CHECK MARK
✔ 10004 2714 HEAVY CHECK MARK
✕ 10005 2715 MULTIPLICATION X
✖ 10006 2716 HEAVY MULTIPLICATION X
✗ 10007 2717 BALLOT X
✘ 10008 2718 HEAVY BALLOT X
✛ 10011 271B OPEN CENTRE CROSS
✞ 10014 271E SHADOWED WHITE LATIN CROSS
✠ 10016 2720 MALTESE CROSS
✡ 10017 2721 STAR OF DAVID
✩ 10025 2729 STRESS OUTLINED WHITE STAR
✪ 10026 272A CIRCLED WHITE STAR
✿ 10047 273F BLACK FLORETTE
❀ 10048 2740 WHITE FLORETTE
❏ 10063 274F LOWER RIGHT DROP-SHADOWED WHITE SQUARE
❐ 10064 2750 UPPER RIGHT DROP-SHADOWED WHITE SQUARE
❑ 10065 2751 LOWER RIGHT SHADOWED WHITE SQUARE
❒ 10066 2752 UPPER RIGHT SHADOWED WHITE SQUARE
❖ 10070 2756 BLACK DIAMOND MINUS WHITE X
❛ 10075 275B HEAVY SINGLE TURNED COMMA QUOTATION MARK ORNAMENT
❜ 10076 275C HEAVY SINGLE COMMA QUOTATION MARK ORNAMENT
❝ 10077 275D HEAVY DOUBLE TURNED COMMA QUOTATION MARK ORNAMENT
❞ 10078 275E HEAVY DOUBLE COMMA QUOTATION MARK ORNAMENT
❤ 10084 2764 HEAVY BLACK HEART
❨ 10088 2768 MEDIUM LEFT PARENTHESIS ORNAMENT
❩ 10089 2769 MEDIUM RIGHT PARENTHESIS ORNAMENT
❪ 10090 276A MEDIUM FLATTENED LEFT PARENTHESIS ORNAMENT
❫ 10091 276B MEDIUM FLATTENED RIGHT PARENTHESIS ORNAMENT
❬ 10092 276C MEDIUM LEFT-POINTING ANGLE BRACKET ORNAMENT
❭ 10093 276D MEDIUM RIGHT-POINTING ANGLE BRACKET ORNAMENT
❮ 10094 276E HEAVY LEFT-POINTING ANGLE QUOTATION MARK ORNAMENT
❯ 10095 276F HEAVY RIGHT-POINTING ANGLE QUOTATION MARK ORNAMENT
❰ 10096 2770 HEAVY LEFT-POINTING ANGLE BRACKET ORNAMENT
❱ 10097 2771 HEAVY RIGHT-POINTING ANGLE BRACKET ORNAMENT
❲ 10098 2772 LIGHT LEFT TORTOISE SHELL BRACKET ORNAMENT
❳ 10099 2773 LIGHT RIGHT TORTOISE SHELL BRACKET ORNAMENT
❴ 10100 2774 MEDIUM LEFT CURLY BRACKET ORNAMENT
❵ 10101 2775 MEDIUM RIGHT CURLY BRACKET ORNAMENT
❶ 10102 2776 DINGBAT NEGATIVE CIRCLED DIGIT ONE
❷ 10103 2777 DINGBAT NEGATIVE CIRCLED DIGIT TWO
❸ 10104 2778 DINGBAT NEGATIVE CIRCLED DIGIT THREE
❹ 10105 2779 DINGBAT NEGATIVE CIRCLED DIGIT FOUR
❺ 10106 277A DINGBAT NEGATIVE CIRCLED DIGIT FIVE
❻ 10107 277B DINGBAT NEGATIVE CIRCLED DIGIT SIX
❼ 10108 277C DINGBAT NEGATIVE CIRCLED DIGIT SEVEN
❽ 10109 277D DINGBAT NEGATIVE CIRCLED DIGIT EIGHT
❾ 10110 277E DINGBAT NEGATIVE CIRCLED DIGIT NINE
❿ 10111 277F DINGBAT NEGATIVE CIRCLED NUMBER TEN
➀ 10112 2780 DINGBAT CIRCLED SANS-SERIF DIGIT ONE
➁ 10113 2781 DINGBAT CIRCLED SANS-SERIF DIGIT TWO
➂ 10114 2782 DINGBAT CIRCLED SANS-SERIF DIGIT THREE
➃ 10115 2783 DINGBAT CIRCLED SANS-SERIF DIGIT FOUR
➄ 10116 2784 DINGBAT CIRCLED SANS-SERIF DIGIT FIVE
➅ 10117 2785 DINGBAT CIRCLED SANS-SERIF DIGIT SIX
➆ 10118 2786 DINGBAT CIRCLED SANS-SERIF DIGIT SEVEN
➇ 10119 2787 DINGBAT CIRCLED SANS-SERIF DIGIT EIGHT
➈ 10120 2788 DINGBAT CIRCLED SANS-SERIF DIGIT NINE
➉ 10121 2789 DINGBAT CIRCLED SANS-SERIF NUMBER TEN
➩ 10153 27A9 RIGHT-SHADED WHITE RIGHTWARDS ARROW
➪ 10154 27AA LEFT-SHADED WHITE RIGHTWARDS ARROW
➫ 10155 27AB BACK-TILTED SHADOWED WHITE RIGHTWARDS ARROW
➬ 10156 27AC FRONT-TILTED SHADOWED WHITE RIGHTWARDS ARROW
➭ 10157 27AD HEAVY LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW
➮ 10158 27AE HEAVY UPPER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW
➯ 10159 27AF NOTCHED LOWER RIGHT-SHADOWED WHITE RIGHTWARDS ARROW
➴ 10164 27B4 BLACK-FEATHERED SOUTH EAST ARROW
➵ 10165 27B5 BLACK-FEATHERED RIGHTWARDS ARROW
➶ 10166 27B6 BLACK-FEATHERED NORTH EAST ARROW
➷ 10167 27B7 HEAVY BLACK-FEATHERED SOUTH EAST ARROW
➸ 10168 27B8 HEAVY BLACK-FEATHERED RIGHTWARDS ARROW
➹ 10169 27B9 HEAVY BLACK-FEATHERED NORTH EAST ARROW
➰ 10160 27B0 CURLY LOOP
➿ 10175 27BF DOUBLE CURLY LOOP
See Tip#1785 to display it in a shell (and copy/paste it in Emacs, etc):
printf "\\u$hexval"
From: http://www.w3schools.com/charsets/ref_utf_symbols.asp
http://www.w3schools.com/charsets/ref_utf_dingbats.asp
- (1968)How to manage CD command in a script?
Shell scripts run in their own subshell, so a cd in a script effects
only the subshell. To script a cd, use an alias instead.
or a function, or source a script.
Or use CDPATH!
From: https://twitter.com/UnixToolTip/status/821026777166450689
- (3876)How to mix/mux video and audio from different videos in FFmpeg?
PROBLEM: video files contains many streams (multiple videos, multiple audios). You need to instruct FFmpeg which one to use for each video.
-----
Assuming you have:
$ ffmpeg -i input_0.mp4 -i input_1.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input_0.mp4':
Duration: 00:01:48.50, start: 0.000000, bitrate: 4144 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 4014 kb/s, SAR 115:87 DAR 1840:783, 23.98 fps, 23.98 tbr, 16k tbn, 47.95 tbc (default)
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 124 kb/s (default)
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input_1.mp4':
Duration: 00:00:30.05, start: 0.000000, bitrate: 1754 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x480 [SAR 8:9 DAR 4:3], 1687 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc (default)
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 55 kb/s (default)
-----
* The -map option instructs ffmpeg what streams you want. To copy the video from input_0.mp4 and audio from input_1.mp4:
$ ffmpeg -i input_0.mp4 -i input_1.mp4 -c copy -map 0:0 -map 1:1 -shortest out.mp4
* This next example will do the same thing:
$ ffmpeg -i input_0.mp4 -i input_1.mp4 -c copy -map 0:v:0 -map 1:a:0 -shortest out.mp4
-map 0:v:0 can be translated as: from the first input (0), select video stream type (v), first video stream (0)
-map 1:a:0 can be translated as: from the second input (1), select audio stream type (a), first audio stream (0)
* Additional Notes
- With -c copy the streams will be stream copied, not re-encoded, so there will be no quality loss. If you want to re-encode, see FFmpeg Wiki: H.264 Encoding Guide.
- The -shortest option will cause the output duration to match the duration of the shortest input stream.
- See the -map option documentation (http://ffmpeg.org/ffmpeg.html#Advanced-options) for more info.
From: https://stackoverflow.com/questions/12938581/ffmpeg-mux-video-and-audio-from-another-video-mapping-issue/12943003#12943003
https://web.archive.org/web/20150103030913/https://cfc.kizzx2.com/index.php/muxing-audio-and-video-with-ffmpeg/
- (3878)How to install compatible nvidia driver / SMI / CUDA versions (a.k.a. How to solve "NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running")?
If you installed the NVIDIA driver from .run files or bundled driver from CUDA Toolkit, the driver may be lost when you upgrade your Linux kernel. You should reinstall the NVIDIA driver.
SOLUTION0: Final install/upgrade script
------------ Softs/Upgrade_NVIDIA_drivers.sh
VERSION=545
# Uninstall the NVIDIA drivers installed from .run files or bundled driver from CUDA Toolkit
apt purge *nvidia*
# Add PPA graphics-drivers
# sudo add-apt-repository ppa:graphics-drivers/ppa --yes
# sudo apt update
# Install NVIDIA driver from PPA
sudo apt install nvidia-driver-$VERSION nvidia-dkms-$VERSION nvidia-compute-utils-$VERSION libnvidia-compute-$VERSION xserver-xorg-video-nvidia-$VERSION nvidia-utils-$VERSION libnvidia-gl-$VERSION libnvidia-decode-$VERSION libnvidia-encode-$VERSION libnvidia-extra-$VERSION libnvidia-common-$VERSION
sudo apt install nvidia-firmware-$VERSION-$VERSION.29.06
# UnInstal CUDA
apt purge *cuda*
# Add PPA for CUDA
# sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
# sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
# sudo apt update
# sudo apt full-upgrade
# Install cuda
sudo apt install nvidia-cuda-toolkit
# Verify
nvcc --version # may require to set CUDA_HOME & PATH
nvidia-smi -l
------------
SOLUTION1: Simpler, but Ubuntu only:
- Uninstall the NVIDIA drivers installed from .run files or bundled driver from CUDA Toolkit
- Add PPA graphics-drivers:
sudo add-apt-repository ppa:graphics-drivers/ppa --yes
sudo apt update
- Install NVIDIA driver from PPA:
sudo apt install nvidia-driver-470 # or nvidia-driver-495
- (Optional) Mark the driver as hold to prevent auto-upgrading (since it is a server):
dpkg-query -W --showformat='${Package} ${Status}\n' | grep -v deinstall | awk '{ print $1 }' | \
grep -E 'nvidia.*-[0-9]+$' | \
xargs -r -L 1 sudo apt-mark hold
- The driver will be persisted when you change your Linux kernel.
SOLUTION2: from NVIDIA's proprietary blob
- You can install the driver with dkms option on:
sudo sh NVIDIA-Linux-x86_64-470.xx.xx.run --dkms
--dkms
nvidia-installer can optionally register the NVIDIA kernel module sources, if installed, with DKMS, then build and install a kernel module using the DKMS-registered sources. This will allow the DKMS infrastructure to automatically build a new kernel module when changing kernels. During installation, if DKMS is detected, nvidia-installer will ask the user if they wish to register the module with DKMS; the default response is ‘no’. This option will bypass the detection of DKMS, and cause the installer to attempt a DKMS-based installation regardless of whether DKMS is present.
From: https://forums.developer.nvidia.com/t/nvidia-smi-has-failed-because-it-couldnt-communicate-with-the-nvidia-driver-make-sure-that-the-latest-nvidia-driver-is-installed-and-running/197141/2
https://forums.developer.nvidia.com/t/nvidia-smi-has-failed-because-it-couldnt-communicate-with-the-nvidia-driver-make-sure-that-the-latest-nvidia-driver-is-installed-and-running/197141/5
- (1983)How to run a script every time a device (e.g. monitor, keyboard...) is plugged-in?
The support still varies quite a bit, but with recent kernels there is
some support for generating udev events when a display hotplug
occurs.
If you want to experiment with udev you could try the following steps:
- update to the newest kernel
- make sure that kernel mode setting (KMS) is enabled. If enabled, it
should be reported in your kernel output. Mine says [drm] radeon
kernel modesetting enabled and [drm] initializing kernel modesetting
- run udevadm monitor --property and see if events are reported when
you (dis-)connect displays
If you are getting udev events on display hotplug, you can trigger a
script with a udev rule like:
ACTION=="change", SUBSYSTEM=="drm", HOTPLUG=="1", RUN+="/path/to/hotplug.sh"
---
If you want to run the script on a specific device, you can use the vendor and product ids
- In /etc/udev/rules.d/test.rules:
ATTRS{idVendor}=="152d", ATTRS{idProduct}=="2329", RUN+="/tmp/test.sh"
- In test.sh:
#! /bin/sh
env >>/tmp/test.log
file "/sys${DEVPATH}" >>/tmp/test.log
if [ "${ACTION}" = add -a -d "/sys${DEVPATH}" ]; then
echo "add ${DEVPATH}" >>/tmp/test.log
fi
With env, you can see what environment is set from udev and with file, you will discover the file type.
See Tip#2701 on how to get the Vendor/Product IDs.
See Tip#2568 on how to execute an Xorg or user script.
See Tip#2212 for an example for dual monitors.
See Tip#1476 for an example for suspend/hibernate wakeup.
From: http://unix.stackexchange.com/questions/4489/a-tool-for-automatically-applying-randr-configuration-when-external-display-is-p
https://unix.stackexchange.com/questions/65891/how-to-execute-a-shellscript-when-i-plug-in-a-usb-device/65892#65892
- (1986)How to reload udev rules without reboot?
# udevadm control --reload-rules
From: http://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot
- (1989)How to save space with local DropBox copies ?
Select which folders to sync on Linux
- Click the Dropbox icon from the menu bar. If you don't see the Dropbox icon, press the white up arrow to see all system tray icons.
- Select Preferences.
- Click the Account tab.
- Click the Selective Sync button.
A window will appear with a list of all the top level folders in your
Dropbox folder. The folders with a check next to them will be synced
to your computer. Uncheck any folders that you don't need to sync to
your computer's hard drive. When you're done, select OK. Any folders
you deselected will be removed from your hard drive, but will still be
available through the website and on any computers linked to your
Dropbox account.
Use the Advanced View button to drill down into the folders in your
Dropbox. Click the arrow next to the folders in your Dropbox to drill
down and check or uncheck folders deep within your Dropbox hierarchy.
From the command line
If you have the Dropbox command line instructions script, then all you
need to do to add a folder to the selective sync "do not sync" list is
enter the following command in your Terminal.
/path/to/dropbox.py exclude add ~/Dropbox/path/to/folder/
Simply substitute the /path/to/ to the actual paths to the CLI script
and the folder or file, respectively.
Note: Wait until the folder has uploaded completely (it displays the
green checkmark) before unselecting it in your selective sync
settings.
From: https://www.dropbox.com/help/175
- (1991)How to list the Book pages I've created on wikipedia?
https://en.wikipedia.org/w/index.php?title=Special:PrefixIndex&prefix=User:LI+AR/Books/
- (1992)How to delete a book created in Wikipedia?
At the top of the page, add:
{{db-u1}} or {{db-test}}
From: https://en.wikipedia.org/wiki/Help:Books/FAQ
- (1996)How to to send email from linux command line?
1. Using "sendmail"
$ cat /tmp/email.txt
Subject: Terminal Email Send
Email Content line 1
Email Content line 2
$ sendmail toto@domain.com < /tmp/email.txt
2. Using "mail"
$ mail -s "Test Subject" -a <attachment> toto1@domain.com,toto2@domain.com < /dev/null
3. Using "mutt"
$ mutt -s "Test Email" -a <attachment> toto@domain.com < /dev/null
4. Using "sSMTP"
$ ssmtp toto@domain.com
Subject: Test SSMTP Email
Email send test using SSMTP
via SMTP server.
^d
5. Using 'telnet'
$ telnet localhost smtp
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
220 fbreveal.com ESMTP Sendmail 8.13.8/8.13.8; Tue, 22 Oct 2013 05:05:59 -0400
HELO yahoo.com
250 tecadmin.net Hello tecadmin.net [127.0.0.1], pleased to meet you
MAIL FROM: <from email>
250 2.1.0 [email protected].. Sender ok
RCPT TO: <to email>
250 2.1.5 [email protected].. Recipient ok
data
354 Enter mail, end with "." on a line by itself
Hey
This is test email only
Thanks
.
250 2.0.0 r9M95xgc014513 Message accepted for delivery
quit
221 2.0.0 fbreveal.com closing connection
Connection closed by foreign host.
From: http://tecadmin.net/ways-to-send-email-from-linux-command-line/
- (1997)What is the difference between “dnl” and “dnl #” in a sendmail.mc file?
There's a subtle but important difference between dnl and # here.
dnl means "delete through newline". When you process your sendmail.mc
into a sendmail.cf using m4 (or possibly some frontend), the
characters dnl and everything following them, including the next
newline, will be dropped. (And all of those lines end with dnl to
suppress extra blank lines in the sendmail.cf output.)
Nothing beginning with dnl through end of line will make it out of
sendmail.mc and into sendmail.cf.
Anything that remains in the output, of course, will either be
sendmail configuration, or a comment that begins with #, which will be
copied as-is into sendmail.cf, where they will be ignored.
Anything beginning with # and not deleted above will make it into
sendmail.cf unmolested as a comment.
In your example, someone meant for all of the commented features to be
removed from sendmail.cf, as well as the comments, since the comments
would be meaningless without the features present.
From: http://serverfault.com/questions/574115/what-is-the-difference-between-dnl-and-dnl-in-a-sendmail-mc-file#574118
- (1998)How to configure sendmail to be able to use GMail's SMTP relay (a.k.a. How to enable local deamons - fail2ban/trac/etc. - to send emails via GMail)?
NOTE: does not work (+ sendmail is crap) => prefer using sSMTP (See Tip#1260)
Ok this one was really a thinker. I spent at least 5 hours to get this
to work and finally I was able to use Sendmail to relay through my
Gmail account.
A little background:
I have a Linux VPS with CentOS installed. The only email MTA is the
default Sendmail. Everything else is pretty much the standard CentOS 4
installation. I don’t intend to use this box as a mail server or any
other type of email processor. What I was trying to do is to add some
basic capability to send out email from the box using my existing
email accounts hosted in Gmail. And I didn’t want to install any
additional software such as Postfix for this.
That being said, let me continue to take you down the path that I have
gone through, without the stumbling blocks.
My approach was basically: problem -> Google for solutions -> trouble
shoot -> Google again. So I found a lot of useful content on the web
during the process.
1. Check sendmail
Since gmail uses TLS, you will need to make sure your sendmail is
compiled with TLS (for encryption) and SASL (for authentication). This
is the command to use to check it:
/usr/sbin/sendmail -d0.1 -bv root
In my case, sendmail does have the necessary compilation flags so I
was good. If yours doesn’t, you’ll need to re-compile sendmail and
update the binary that is used to start the sendmail service, which is
not covered here.
2. Upgrading Cyrus SASL
If your SASL installation doesn’t have the “plain” and “login” lib you
will have authentication problem with Gmail. You can see why when you
get to the sendmail configuration in the later steps. The common error
in the /var/log/maillog is this:
AUTH=client, available mechanisms do not fulfill requirements
It was a vague error and I was so frustrated with it at one point I
was ready to give up. However, this article about setting up Postfix
with Gmail casted some light and helped me figured out the cause.
The problem is that SASL doesn’t have all the necessary plugins. The
“login” and “plain” are the plugins necessary to talk to Gmail
smtp. So I had to upgrade SASL to fix the problem. Here is what I did:
$ wget http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.21.tar.gz
$ tar -xzf cyrus-sasl-2.1.21.tar.gz
$ cd cyrus-sasl-2.1.21
$ ./configure
$ make
$ make install
$ mv /usr/lib/sasl2 /usr/lib/sasl2.orig
$ ln -s /usr/local/lib/sasl2 /usr/lib/sasl2
Note: if you have issue installing Cyrus SASL around compiling
digestmd5.c, it’s because your compiler is too new. Read here to find
out how to patch it.
Since I just switched out the old sasl2 lib without recompiling
sendmail, I was concerned sendmail would poop during runtime. Luckily
that didn’t happen. Dynamic lib rocks!
3. Generate SSL certificate
I made a directory called certs under /etc/mail. Here are the commands
that I used to generate the SSL certificates.
openssl req -new -x509 -keyout cakey.pem -out cacert.pem -days 3650
openssl req -nodes -new -x509 -keyout sendmail.pem -out sendmail.pem -days 3650
Notice I made the certificates good for almost 10 years. I didn’t
needed the cacert.pem to be exact.
I also copied /usr/share/ssl/ca-bundle.crt to /ect/mail/certs and
included it in the sendmail configuration file. Other wise you’ll see
some error like this:
unable to get local issuer certificate
The reason is that the ca bundle file has the Gmail certificate
issuer. Although I read it somewhere that email still goes out with
this error. Nonetheless, we don’t need to see this if we can fix it.
4. Configure sendmail
With the preparations above we are ready to configure sendmail. I
found this tutorial very useful in terms of getting the correct
sendmail configurations.
In summary, I have the /etc/mail/auth/client-info looks like this:
AuthInfo:smtp.gmail.com “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”
AuthInfo:smtp.gmail.com:587 “U:root” “I:username@gmail.com” “P:password” “M:PLAIN”
If you use Gmail hosted email with your own domain name, you will have
username@hostname.tld in there.
Make sure run:
$ makemap -r hash client-info.db < client-info
and chmod 600 on client info files.
Essential lines in my sendmail.mc
FEATURE(`authinfo’,`hash /etc/mail/auth/client-info.db’)dnl
define(`SMART_HOST’,`smtp.gmail.com’)dnl
define(`RELAY_MAILER_ARGS’, `TCP $h 587′)
define(`ESMTP_MAILER_ARGS’, `TCP $h 587′)
define(`CERT_DIR’, `/etc/mail/certs’)
define(`confCACERT_PATH’, `CERT_DIR’)
define(`confCACERT’, `CERT_DIR/ca-bundle.crt’)
define(`confCRL’, `CERT_DIR/ca-bundle.crt’)
define(`confSERVER_CERT’, `CERT_DIR/sendmail.pem’)
define(`confSERVER_KEY’, `CERT_DIR/sendmail.pem’)
define(`confCLIENT_CERT’, `CERT_DIR/sendmail.pem’)
define(`confCLIENT_KEY’, `CERT_DIR/sendmail.pem’)
define(`confAUTH_MECHANISMS’, `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN’)
NOTE: Be aware that smart-quotes used in the code examples will
not be recognised if pasted into your files! Ensure replacing
smart-quotes by regular quotes (see comments below for further
detail). – thanks Johnny for the suggestion.
The certificate files are generated/copied from the previous
step. I’m no sendmail expert so the configuration lines may not be
perfect. But it works. Let me know if you have better settings.
One tip I found very useful is to use the debugging feature. You can
set a high log level in the sendmail.mc to see at which step sendmail
choked and for what reason.
Also, make sure run “make” or m4 every time you touch the sendmail.mc.
m4 sendmail.mc > sendmail.cf
So that’s pretty much it. I restart the sendmail service and out goes
my email.
UPDATE:
Recently I installed Sendmail on a brand new VPS and had hard time get
the authentication working. It turned out saslauthd was not
running. So a note for new system is to make sure saslauthd has to be
up and running (better use chkconfig to make sure it starts up at run
level 3) in order to get Sendmail authentication working. This may
help resolve some issues in the comments.
From: http://www.linuxquestions.org/questions/linux-server-73/how-to-config-fail2ban-send-email-to-gmail-when-it-ban-ip-4175422187/
http://appgirl.net/2009/configuring-sendmail-to-relay-through-gmail-smtp/
http://www.phinesolutions.com/sendmail-gmail-smtp-relay-howto.html
- (1995)WikiBook: my own "Cracking the Coding interview" CheatSheet: basic stuff to know
======================================================================
======================================================================
[MERGE: 1995] Cracking Coding Interview
The format below is the one of the Wikipedia Book at:
https://en.wikipedia.org/wiki/User:LI_AR/Books/Cracking_the_Coding_Interview
NOTE: Each ":[[<page>]]" can be accessed directly using with "https://en.wikipedia.org/wiki/<page>"
======================================================================
======================================================================
{{saved book
|title=Cracking The Coding Interview
|subtitle=Basic Stuff To Know
|cover-image=
|cover-color=
|text-color=red
}}
=================== START COPY PASTE HERE !!! ==================================
== Cracking the Coding Interview ==
=== Basic Knowledge ===
; ChatGPT Prompts to prepare for job interviews
+ How to prepare for a job interview on [domain/position]
+ Here is the text for a job application. Act as a job interviewer for this position
+ I am an applicant for a job in [position]. Act as a job interviewer and ask tricky questions about [one of the position's requirement]. After each questions, I'll reply. Correct me when I'm wrong.
+ I am an applicant for a job in [position]. Act as a job interviewer and ask tricky questions about my personality
; Electronics
:[[Inverter_(logic_gate)]]
:[[AND_gate]]
:[[OR_gate]]
:[[NAND_gate]]
:[[NOR_gate]]
:[[XOR_gate]]
; Telecommunications
:[[Parity_bit]]
:[[Cyclic_code]]
:[[Hamming_code]]
:[[Hadamard_code]]
:[[Convolutional_code]]
; Base Maths
:[[Injective_function]]
:[[Surjective_function]]
:[[Bijection]]
; Types of programming
:[[Programming_paradigm]]
:[[Declarative_programming]]
:[[Imperative_programming]]
:[[Literate_programming]]
:[[Linear_programming]]
:[[Dynamic_programming]]
:[[List_of_programming_languages_by_type]]
:[[Functional_programming]]
:[[Object-oriented_programming]]
:[[Event-driven_programming]]
:[[Aspect-oriented_programming]]
:[[Component-based_software_engineering]]
:[[Dynamic_programming]]
:[[Transpile]]
; Architecture / Design
* Questions to ask
** :[[Five_Ws]] / https://fr.wikipedia.org/wiki/QQOQCCP
:[[Front_and_back_office_application]]
:[[Front_and_back_ends]]
:[[Model%E2%80%93view%E2%80%93controller]]
:[[Unified_Modeling_Language]]
:[[Microservices]]
:[[Modular_programming]]
:[[Design_by_contract]]
:[[Domain-driven_design]]
:[[Artifact_(software_development)]]
:[[Coupling_(computer_programming)]]
:[[Law_of_Demeter]]
:[[Service-oriented_architecture]]
:[[Web_service]]
:[[Three-tier_architecture]]
:[[Mvc]]
:[[Model%E2%80%93view%E2%80%93presenter]]
:[[Model_View_ViewModel_(MVVM)]]
* https://plus.google.com/+AngularJS/posts/aZNVhj355G2
* https://www.quora.com/What-is-MVW-Model-View-Whatever-How-is-it-different-from-MVC
; Code Design
:[[Best_coding_practices]]
:[[Coding_conventions]]
:[[Convention_over_configuration]]
** Also see design principles listed at:
https://en.wikipedia.org/wiki/User:LI_AR/Books/SoftwareDesignLaws#Software_Philosophy
; Security
:[[No_Starch_Press]]
:[[Hacking:_The_Art_of_Exploitation]]
:[[Buffer_overflow]]
:[[Fuzzing]]
:[[Memory_leak]]
:[[Return-to-libc_attack]]
:[[Heap_overflow]]
:[[Stack_overflow]]
* https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content
* Protections
:[[Buffer_overflow_protection]]
:[[PaX]]
:[[Grsecurity]]
:[[Address_space_layout_randomization]]
; Code Quality
:[[Static_program_analysis]]
:[[List_of_tools_for_static_code_analysis]]
:[[Dynamic_program_analysis]]
:[[Automated_code_review]]
:[[Software_metric]]
:[[Coverity]]
:[[SonarQube]]
:[[Veracode]]
:[[Checkstyle]]
:[[FindBugs]]
; Code Testing
:[[Software_testing]]
:[[Best_practice]]
:[[Unit_testing]]
:[[Functional_testing]]
:[[Integration_testing]]
:[[Regression_testing]]
:[[Verification_and_validation_(software)]]
:[[Usability_testing]]
:[[Black-box_testing]]
:[[Sanity_check]]
:[[Smoke_testing_(software)]]
:[[Shakedown_(testing)]]
:[[Acceptance_testing]]
:[[System_testing]]
* Java
:[[JUnit]]
:[[TestNG]]
:[[FitNesse]]
:[[Mockito]]
:[[Selenium_(software)]]
; Middleware
:[[Message_passing]]
:[[Inter-process_communication]]
:[[Message-oriented_middleware]]
:[[Publish%E2%80%93subscribe_pattern]]
:[[Web_Application_Messaging_Protocol]]
:[[Representational_state_transfer]]
:[[Streaming_Text_Oriented_Messaging_Protocol]]
:[[WebSocket]]
; DataStructure
:[[Data structure]]
:[[Linked list]]
:[[Queue (abstract data type)]]
:[[Stack (abstract data type)]]
:[[Pile (abstract data type)]]
:[[Hash table]]
:[[Tree (data structure)]]
:[[Trie]]
:[[Graph (abstract data type)]]
:[[Graph theory]]
:[[One-to-one_(data_model)]]
:[[One-to-many_(data_model)]]
; Algos
:[[Dijkstra's algorithm]]
:[[Search algorithm]]
:[[A* search algorithm]]
:[[Recursion (computer science)]]
:[[Dynamic programming]]
; Trees
:[[Tree traversal]]
:[[Breadth-first search]]
:[[Depth-first search]]
; Sorting
:[[Merge sort]]
:[[Quicksort]]
:[[Binary search algorithm]]
; Testing
:[[JUnit]]
:[[Unit testing]]
:[[Regression testing]]
* http://pages.zeroturnaround.com/RebelLabs---All-Report-Landers_Developer-Productivity-Report-2015.html?utm_rebellabsid=97
:[[Shift_left_testing]]
:[[Black-box_testing]]
:[[White-box_testing]]
:[[Code_coverage]]
; Threading
:[[Thread (computing)]]
:[[Lock (computer science)]]
:[[Mutual exclusion]]
:[[Semaphore (programming)]]
; Memory Management
:[[Memory management]]
:[[Stack-based memory allocation]]
:[[Call stack]]
:[[C_dynamic_memory_allocation]]
:[[Boehm_garbage_collector]]
:[[Protected_mode]]
; Complexity
:[[Time complexity]]
:[[NP_(complexity)]]
; Compilation
:[[Just-in-time_compilation]]
; Object-Oriented Programming Concepts
:[[Object_(computer_science)]]
:[[Instance_variable]]
:[[Class_variable]]
:[[Interface_(computing)]]
:[[Inheritance_(object-oriented_programming)]]
:[[Polymorphism_(computer_science)]]
:[[Delegation_(object-oriented_programming)]]
:[[Factory_(object-oriented_programming)]]
:[[Encapsulation_(computer_programming)]]
:[[Cloning_(programming)]]
:[[Forwarding_(object-oriented_programming)]]
:[[Restful_Objects]]
:[[Schizophrenia_(object-oriented_programming)]]
; Languages/Frameworks - JavaScript
:[[Comparison_of_JavaScript_frameworks]]
:[[AngularJS]]
:[[Node.js]]
:[[React_(JavaScript_library)]]
:[[JQuery]]
:[[Prototype_JavaScript_Framework]]
:[[Bootstrap_(front-end_framework)]]
:[[Backbone.js]]
:[[Dojo_Toolkit]]
:[[Ember.js]]
:[[Google_Web_Toolkit]]
:[[MooTools]]
:[[SproutCore]]
:[[Unified.js]]
:[[Vue.js]]
; Languages/Frameworks - Java
* https://zeroturnaround.com/rebellabs/java-8-streams-cheat-sheet/ / http://files.zeroturnaround.com/pdf/zt_java8_streams_cheat_sheet.pdf
* https://zeroturnaround.com/rebellabs/java-8-best-practices-cheat-sheet/ / http://files.zeroturnaround.com/pdf/zt_java8_best_practices.pdf
; Languages/Frameworks - HTML/CSS
* HTML: <iframe> vs <embed> vs. <object>
https://stackoverflow.com/questions/16660559/difference-between-iframe-embed-and-object-elements
https://www.w3.org/TR/html5/embedded-content-0.html#the-iframe-element
https://www.w3.org/TR/html5/embedded-content-0.html#the-embed-element
https://www.w3.org/TR/html5/embedded-content-0.html#the-object-element
; IDE
* Java
:[[IntelliJ_IDEA]]
:[[Eclipse_(software)]]
* Python
:[[PyCharm]]
* R
:[[RStudio]]
; Configuration
:[[Chef_(software)]]
; Versioning
* http://svnbook.red-bean.com/
* https://git-scm.com/book/en/v2
* http://nvie.com/posts/a-successful-git-branching-model/
; Online Java IDE (for testing candidates)
* http://ideone.com/
; Deployment
:[[Continuous_integration]]
:[[Continuous_delivery]]
:[[Jenkins_(software)]]
; Cloud
:[[Cloud_computing]]
:[[Cloud_computing#Infrastructure_as_a_service_.28IaaS.29]]
:[[Network_as_a_service]]
:[[Platform_as_a_service]]
:[[Software_as_a_service]]
:[[Content_as_a_Service]]
; Online Testing platforms
* https://www.testdome.com/
* https://projecteuler.net/
* https://codility.com/
* https://www.codewars.com/
; Google Interview
* https://github.com/avetisk/google-interview-university
* https://dev.to/areedev/google-launched-the-best-interview-preparation-tool-24n9
* See http://guillaumemuller1.free.fr/tips.php#563 + "Google Interview"
; Get info on the company (& bosses) before responding to an offer
* Previous employees opinions:
https://www.glassdoor.fr/Avis
* Typical Job Interview questions asked in this company
https://www.glassdoor.fr/Entretien
* Typical salaries in this company
https://www.glassdoor.fr/Salaires/
* Typical salaries
http://lentreprise.lexpress.fr/rh-management/remuneration-salaire/les-25-metiers-dont-les-salaires-vont-bondir-en-2018_1951696.html
https://stackoverflow.com/jobs/salary
; Curated list of similar pages
* Programming languages
https://github.com/search?utf8=%E2%9C%93&q=curated+list+awesome+frameworks&type=
https://github.com/petermbenjamin/awesome-podcasts
https://github.com/diegocard/awesome-html5
https://github.com/dhamaniasad/awesome-webframeworks
https://github.com/uhub/awesome-c
https://github.com/uhub/awesome-cpp
https://github.com/vinta/awesome-python
https://github.com/uhub/awesome-python
https://github.com/budacsik/awesome-python
https://github.com/haiyangd/awesome-python-
https://github.com/akullpp/awesome-java
https://github.com/wtsxDev/Amazing-Java-List
https://github.com/uhub/awesome-javascript
https://github.com/iwanjunaid/awesome-javascript
https://github.com/qinwf/awesome-R
* Shell
https://github.com/alebcay/awesome-shell
* Tools
https://github.com/lorien/awesome-web-scraping
https://github.com/atinfo/awesome-test-automation
https://github.com/gad0lin/awesome-kanban
; Books/MOOCs
* R
** The R book, MJ Crawley.
* Python
** Apprenez à programmer en Python. Le Goff. Open Classrooms: https://openclassrooms.com/courses/apprenez-a-programmer-en-python
* Hadoop
** http://www.cloudera.com/content/cloudera/en/training/courses/udacity/mapreduce.html
; Slide Alternative
:[[Prezi]]
; Softwares/"WebServers" used by n00bs
* https://en.wikipedia.org/wiki/Magento
* Wordpress + https://www.elegantthemes.com/gallery/divi/
; Other
* Test Language skills (English/French/..., not programming)
** https://tests.hermes.nflx.io/
- (2013)How to configure mdadm to send an email in case of problem with the RAID?
-- /etc/mdadm/mdadm.conf
# instruct the monitoring daemon where to send mail alerts
MAILADDR youremail@domain.com
MAILFROM my-server-name - mdadm ERRORS!!:
or:
-- /etc/default/mdadm
DAEMON_OPTIONS="--syslog -m youremail@domain.com"
+ configure sendmail/ssmtp/msmtp for the server to be able to send emails (See Tip#1260)
Also See Tip#1821 , Tip#1828, Tip#1830
From:https://ubuntuforums.org/showthread.php?t=1185134
- (2021)How to change the recipient of cron's error emails?
# vi /etc/crontab
...
MAILTO=yourmail@yourdomain
...
From: https://www.cyberciti.biz/faq/linux-unix-crontab-change-mailto-settings/
- (2028)How to solve "Failed to load module 'module-ladspa-sink'" error in PusleAudio (a.k.a what to do if pulseaudio refuses to start after big dist-upgrade)?
If starting pulseaudio leads to an error like:
E: [pulseaudio] module-ladspa-sink.c: Master sink not found
E: [pulseaudio] module.c: Failed to load module "module-ladspa-sink" (argument: "sink_name=ladspa_output.mbeq_1197.mbeq master=alsa_output.pci-0000_00_1b.0.hdmi-stereo plugin=mbeq_1197 label=mbeq control=3.0,3.0,7.3,7.0,3.0,-1.0,-6.6,-6.3,-4.5,-4.0,1.1,1.2,5.8,7.9,8.8"): initialization failed.
E: [pulseaudio] main.c: Module load failed.
E: [pulseaudio] main.c: Failure to start the daemon.
One solution is to (backup and) remove:
~/.pulse/
~/.config/pulse
From: http://askubuntu.com/questions/325262/what-is-a-failed-to-load-module-module-ladspa-sink-error
- (2030)What is swappiness and how do I change it?
The swappiness parameter controls the tendency of the kernel to move
processes out of physical memory and onto the swap disk. Because disks
are much slower than RAM, this can lead to slower response times for
system and applications if processes are too aggressively moved out of
memory.
- swappiness can have a value of between 0 and 100
* swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible
* swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache
The default setting in Ubuntu is swappiness=60. Reducing the default
value of swappiness will probably improve overall performance for a
typical Ubuntu desktop installation. A value of swappiness=10 is
recommended, but feel free to experiment. Note: Ubuntu server
installations have different performance requirements to desktop
systems, and the default value of 60 is likely more suitable.
To check the swappiness value
cat /proc/sys/vm/swappiness
To change the swappiness value A temporary change (lost on reboot)
with a swappiness value of 10 can be made with
sudo sysctl vm.swappiness=10
To make a change permanent
gksudo gedit /etc/sysctl.conf
vm.swappiness=10
Save the file and reboot.
From: http://askubuntu.com/questions/157793/why-is-swap-being-used-even-though-i-have-plenty-of-free-ram
- (2036)How to generate a list of all the month names in the year?
for i in {01..12} ; do date -d "2014-$i-01" "+%b|%B" ; done
Jan|January
Feb|February
Mar|March
Apr|April
May|May
Jun|June
Jul|July
Aug|August
Sep|September
Oct|October
Nov|November
Dec|December
NOTE: %b & %B output the name according to the locale. So by changing
the locale you can change the languages of the month names ouput by
the script above.
e.g. in French:
LC_ALL=fr_FR.UTF-8; for i in {01..12} ; do date -d "2014-$i-01" "+%b|%B" ; done
janv.|janvier
févr.|février
mars|mars
avril|avril
mai|mai
juin|juin
juil.|juillet
août|août
sept.|septembre
oct.|octobre
nov.|novembre
déc.|décembre
From: http://stackoverflow.com/questions/4351282/how-to-generate-a-sequence-of-dates-given-starting-and-ending-dates-using-awk-of#23508489
- (2038)How to get non-matching lines with sed?
sed pattern for lines not containing spam: /spam/!
From: https://twitter.com/UnixToolTip/status/847488707703816193
- (2039)How to wrap lines of text in console?
Use "fold"
E.g.:
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 20 | head -n 1
From: https://github.com/synhack/mercure
- (2048)Explanations of the output of 'free'
total=free+buffer+used
Also you can get the output in human-readable format:
$ free -m ## in MB
$ free -g ## in GB
From: http://www.linuxnix.com/find-ram-size-in-linuxunix/
http://www.linuxatemyram.com/
- (2050)How to know which process is using a file?
Following command will show you what process is holding the lock on this file:
sudo fuser -v /var/cache/debconf/config.dat
From: https://askubuntu.com/questions/136881/debconf-dbdriver-config-config-dat-is-locked-by-another-process-resource-t#353423
- (2051)How to unlock apt/dpkg when update-notifier/manager has crashed?
sudo rm /var/lib/dpkg/lock
sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/debconf/*.dat
From: https://askubuntu.com/questions/136881/debconf-dbdriver-config-config-dat-is-locked-by-another-process-resource-t#353423
- (2065)How to prevent errors with Thb/Lightning/GoogleProvider?
PROBLEM: By default ThB's extensions are automatically updated. This
often creates problems (access to calendar impossible, empty calendar,
etc.) when ThB's extensions' the Lightning/GoogleProvider APIs are not
in sync.
SOLUTION:
1. Goto = menu > Addons > Lightning/GoogleProvider > Preferences and
prevent the extension to update automatically
2. Install the "correct" versions of the app/extension (at least those
tested to work together):
apt-get install thunderbird xul-ext-gdata-provider xul-ext-lightning
PS: there are other neat extensions from FF/ThB that you can directly
install from the distribution's packages:
apt-get install xul-ext-colorfultabs xul-ext-video-without-flash xul-ext-y-u-no-validate
From: personal experience
- (2083)How to quickly calculate date differences?
datediff() {
d1=$(date -d "$1" +%s)
d2=$(date -d "$2" +%s)
echo $(( (d1 - d2) / 86400 )) days
}
$ datediff '1 Nov' '1 Aug'
From: https://unix.stackexchange.com/questions/24626/quickly-calculate-date-differences#24636
- (2093)How to merge consecutice lines with sed?
# Merge 2 consecutive lines
echo -e 'toto\ntata\ntiti\ntete' | sed -rn '{ N; s/\n/ /p }'
From: http://www.linuxquestions.org/questions/programming-9/merge-lines-in-a-file-using-sed-191121/
- (2096)How to add a user to the system in a script, specifying its password?
# useradd -m -p encryptedPassword username
Where "encryptedPassword" is generated with:
$ perl -e 'print crypt("password", "salt"),"\n"'
From: https://www.cyberciti.biz/tips/howto-write-shell-script-to-add-user.html
- (2110)How to configure/calibrate/test a joystic under Linux?
sudo apt-get install joystick
jscal /dev/input/js0
jstest /dev/input/js0
From: https://ubuntuforums.org/showthread.php?t=338457
- (2111)How to set defaults apps under Calibre (a.k.a. how to change the default app used by xdg-open)
1. Find the MIME type of the file you want to open
xdg-mime query filetype <filename>
e.g. application/pdf
2. Find a desktop file associated with an application that opens this type of documents (in /usr/share/applications)?
e.g. evince.desktop
3. Set xdg-open to use that as the default
xdg-mime default <desktop file> <MIME type>
e.g. xdg-mime default evince.desktop application/pdf.
From: http://jb-blog.readthedocs.io/en/latest/posts/0016-how-to-change-what-program-calibre-uses-to-open-stuff.html
- (2130)How to modify find's ouput (a.k.a. how to make find print only the filename, not the whole path)?
SOLUTION1: find has a -printf option where you can define the print
output format
find . -type f -mtime -14 -printf '%f\n' > deploy1.txt
find . -type f -mtime -14 -printf '%P\n' > deploy2.txt
SOLUTION2: in case your version does not have the printf option, you
can also pipe each line of find's output to the external "printf"
command:
find . -mtime -14 -exec sh -c 'printf "${0#./}\n"' {} \; >deploy.txt
From: https://serverfault.com/questions/354403/remove-path-from-find-command-output
- (2134)How to get an email if a problem occurs during the execution of a cron script?
= CONTEXT
When a cron script outputs text (or fails?), cron can send the results
to a given email address.
To set the email address where cron sends the output:
1. Edit crontab
# vi /etc/crontab
or
$ crontab -e
2. Add "MAILTO=username@domain.com" into the crontab file.
If you don't want a script to send its output, just add ">/dev/null 2>&1" at the end of its calling line
From: https://www.nixtutor.com/linux/sending-email-alerts-through-cron/
- (2256)How to get the date corresponding to last monday?
getLastMondaysDate() {
# Computation: [Get current day-of-week number, substract it to today <=> get LastSunday's Date ] + add one day
date -d "$1 -$(date -d $1 "+%u") days + 1 day" "+%Y-%m-%d"
}
From: https://stackoverflow.com/questions/19112772/get-monday-and-sunday-etc-for-a-week-for-any-date-as-parameter-in-unix#19113018
- (2258)How does dow (Day Of Week) work in crontab?
According to Cyril Bouthors answer
(https://stackoverflow.com/a/26830857/4137828), below is a list of the
English abbreviated day of the week, which can be used in place of
numbers:
0 -> Sun
1 -> Mon
2 -> Tue
3 -> Wed
4 -> Thu
5 -> Fri
6 -> Sat
7 -> Sun
Having two numbers for Sunday (0 and 7) can be useful for writing
weekday ranges starting with 0 or ending with 7.
From: https://stackoverflow.com/questions/18919151/crontab-day-of-the-week-syntax#18919183
- (2259)How to write sudoers rules (a.k.a. syntax of the /etc/sudoers file)?
What the different fields mean:
*root* ALL=(ALL:ALL) ALL
The first field indicates the username that the rule will apply to (root).
demo *ALL*=(ALL:ALL) ALL
The first "ALL" indicates that this rule applies to all hosts.
demo ALL=(*ALL*:ALL) ALL
This "ALL" indicates that the root user can run commands as all users.
demo ALL=(ALL:*ALL*) ALL
This "ALL" indicates that the root user can run commands as all groups.
demo ALL=(ALL:ALL) *ALL*
The last "ALL" indicates these rules apply to all commands. Commands are separated with a comma (',')
Also see Tip#901
From: https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
- (2151)How to set up an email alert when a ssh login is successful?
There a method with /etc/ssh/sshrc, but it does not work if user creates a ~/.ssh/rc
A Hacky solution would also be to setup something in the /etc/profile
and checking that the connection comes from SSH (+check existence of
$SSH_TTY), but that would probably not work if user creates a ~/.profile
WORKING SOLUTION:
You need an executable script file "login-notify.sh" (I put it in
/etc/ssh/ for example) with the following content. You can change the
variables to change the subject and content of the e-mail
notification. Don't forget to execute chmod +x login-notify.sh to make
it executable.
----✄ /etc/ssh/login-notify.sh
#!/bin/sh
# Change these two lines:
sender="sender-address@example.com"
recepient="notify-address@example.org"
if [ "$PAM_TYPE" != "close_session" ]; then
host="`hostname`"
subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
# Message to send, e.g. the current environment variables.
message="`env`"
echo "$message" | mailx -r "$sender" -s "$subject" "$recepient"
fi
----✄
Once you have that, you can add the following line to /etc/pam.d/sshd:
session [optional|required] pam_exec.so seteuid /path/to/login-notify.sh
For testing purposes, the module is included as "optional", so that
you can still log in if the execution fails. After you made sure that
it works, you can change "optional" to "required". Then login won't be
possible unless the execution of your hook script is successful (if
that is what you want).
From: https://askubuntu.com/questions/179889/how-do-i-set-up-an-email-alert-when-a-ssh-login-is-successful
WORKING SOLUTION 2:
We have been using monit to monitor processes on our linux
boxes. monit can also alert by emails on successful logins over
ssh. Our monit config looks like this
----✄
check file ssh_logins with path /var/log/auth.log
# Ignore login's from whitelist ip addresses
ignore match "100.100.100.1"
# Else, alert
if match "Accepted publickey" then alert
----✄
Note: The mailserver configuration, email format etc. should be set in
monitrc file
From: https://www.elitmus.com/blog/technology/using-monit-to-get-email-alert-on-unauthorized-login/
- (2172)How to install specific version of a package?
SOLUTION1: apt-get
apt-get install package=version
See Tip#1223 to know the available versions
SOLUTION2: install from bin/src tar
From: https://askubuntu.com/questions/428772/how-to-install-specific-version-of-some-package#428778
- (2185)How to run a GUI program in Headless mode?
sudo xvfb-run java -cp $CLASSPATH weka.core.FindWithCapabilities -superclass "weka.classifiers.Classifier" -generic
Works also for headless testing of sites in actual browsers like Firefox/Chrome with Selenium
- (2186)What are the differences between atime/ctime/mtime?
Unix keeps 3 timestamps for each file: mtime, ctime, and atime.
- atime (*access time*), it is when the file was *last read*.
- mtime is the *file modification time*. mtime changes when you write to
the file. It is the age of the data in the file.
- ctime is the *inode change time*. Whenever mtime changes, so does
ctime. But ctime changes a few extra times. For example, it will
change if you change the owner or the permissions on the file. As the
ionode as more information (e.g. metadata) as the file, it changes
on more occasions.
Also see Tip#1686
From: http://www.unix.com/tips-and-tutorials/20526-mtime-ctime-atime.html
- (2189)What is the mapping between Linux runlevels and systemd targets?
┌─────────┬───────────────────┐
│Runlevel │ Target │
├─────────┼───────────────────┤
│0 │ poweroff.target │
├─────────┼───────────────────┤
│1 │ rescue.target │
├─────────┼───────────────────┤
│2, 3, 4 │ multi-user.target │
├─────────┼───────────────────┤
│5 │ graphical.target │
├─────────┼───────────────────┤
│6 │ reboot.target │
└─────────┴───────────────────┘
You can temporarily change the current runlevel with:
systemctl [start|isolate] <xxx>.target
You can definitively change the runlevel with:
systemctl set-default <xxx>.target
Also see Tip#1508 and Tip#1931
- (2191)How to create temp dir in scripts?
Inspired from typical Dockerfiles
export TMPDIR="$(mktemp -d)" && \
cd "${TMPDIR}" && \
... do some stuff... && \
rm -rf "${TMPDIR}"
From: https://github.com/docker-library/logstash/blob/c257f0d648cd01631657a39e005911fc4c7c5aeb/5/Dockerfile
- (2193)How to detect too much activity in the logs?
$ top -i
....
jbd2/sda1-8 # pops up every few seconds when nothing much is running
....
=> this means journaling is very active.
This could be that a lot of errors occur, thus the log files are being filled a lot.
To analyze this (here an error with emails):
iotop -oPa -d 2: High I/O on /var partition
glances: High iowait and load
iostat -2: /var high I/O confirmation
ls -lhS /var/log/*log | head: Large mail.log
tail -f /var/log/mail.log: Rapid, continuous logging
From: https://www.linuxquestions.org/questions/linux-software-2/jbd2-sda1-8-what-exactly-is-this-process-that-keeps-running-every-few-seconds-788810/
- (2197)How to start/stop/enable/disable daemons/services?
- To temporarily start/stop/reload (in decreasing order of newness)
# systemctl <servicename> status/start/stop/reload
# service <servicename> status/stop/start/reload
# /etc/init.d/<servicename> status/start/stop/reload
# start/stop/status <servicename>
- To definitively enable/disable
# systemctl <servicename> enable/disable
From: https://askubuntu.com/questions/19320/how-to-enable-or-disable-services
- (2203)How to install most up-to-date VBox on Ubuntu/Mint?
## Prepare current install
# apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
# apt-get -y install gcc make linux-headers-$(uname -r) dkms
## Prepare apt
# wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | apt-key add -
# wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | apt-key add -
# echo "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list
## Actually upgrade VBox
# apt-get update
# apt-get install virtualbox-5.2
## Verify install
$ VBoxManage -v # To verify
## Install extension pack
# cd /tmp && curl -O http://download.virtualbox.org/virtualbox/5.2.0/Oracle_VM_VirtualBox_Extension_Pack-5.2.0-118431.vbox-extpack
# VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.0-118431.vbox-extpack
## Verify with:
VBoxManage list extpacks
## Get corresponding Guest Additions
$ cd .cache && wget http://download.virtualbox.org/virtualbox/5.2.0/VBoxGuestAdditions_5.2.0.iso
From: https://websiteforstudents.com/installing-virtualbox-5-2-ubuntu-17-04-17-10/
- (2205)How to solve error "This account is currently not available." (a.k.a How to run a command as another user which account is prevented from logging in with "/usr/sbin/nologin" in /etc/passwd)?
PROBLEM:
# su - www-data [<command>]
This account is currently not available.
SOLUTION1 (preferred):
sudo -u www-data <command>
SOLUTION2:
# su -s /bin/bash - www-data [<command>]
www-data$
NOTE:
- su is used to "switch user"
- sudo is used to "execute a command as another user".
From: https://unix.stackexchange.com/questions/327436/cannot-run-command-as-www-data-using-su
- (2208)How to prevent a daemon from starting at boot with systemd?
Use:
# update-rc.d <service name> disable
E.g.:
# update-rc.d tomcat8 disable
# update-rc.d postgresql disable
https://askubuntu.com/questions/27134/disable-autostart-for-a-service-without-uninstalling
- (2215)How to wait/monitor for a file change without using an active loop?
# apt-get install inotify-tools
- in your script:
inotifywait <file>
NOTE: below example does not work! From man inotify:
"Inotify reports only events that a user-space program triggers
through the filesystem API. As a result, it does not catch remote
events that occur on network filesystems. (Applications must fall
back to polling the filesystem to catch such events.) Furthermore,
various pseudo-filesystems such as /proc, /sys, and /dev/pts are not
monitorable with inotify."
E.g.
while [ 1 ]; do
# ... Do something when a monitor is plugged in/out <connector>
inotifywait -q -e close /sys/class/drm/card0-<connector>/status >/dev/null # non active/blocking wait on <connector> status
done
From: https://unix.stackexchange.com/questions/13746/how-can-i-detect-when-a-monitor-is-plugged-in-or-unplugged
- (2236)How to install skype 8+ on Ubuntu?
I]Snap
- Instal
sudo snap install skype --classic
- Run
/snap/bin/skype
II] APT
- Install
* pre-requisite
sudo apt install apt-transport-https
* echo "deb [arch=amd64] https://repo.skype.com/deb stable main" | sudo tee /etc/apt/sources.list.d/skype-stable.list
* wget https://repo.skype.com/data/SKYPE-GPG-KEY
sudo apt-key add SKYPE-GPG-KEY
* sudo apt update
sudo apt install skypeforlinux
- Run
skypeforlinux
III] FlatPack
- Install
sudo apt install flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak install flathub com.skype.Client
flatpak install skype # sudo not needed!!!
- Run
flatpak run com.skype.Client
From: https://www.linuxbabe.com/ubuntu/install-skype-ubuntu-18-04-lts-desktop
---
IV] Manual
$ wget https://go.skype.com/skypeforlinux-64.deb
$ sudo dpkg -i skypeforlinux-64.deb
From: https://www.skype.com/fr/get-skype/
- (2237)How to install Signal on Ubuntu/Mint?
## On Mint:
# mkdir -p /usr/local/bin/
# curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add -
# echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
# sudo apt update && sudo apt install signal-desktop
From: https://signal.org/download/#linuxModal
- (2271)How to turn on/off bluetooth from shell?
rfkill block bluetooth
rfkill unblock bluetooth
To do it at every boot: add the above line to /etc/rc.local
Also see Tip#2813 (blueman or systemd?) often re-activate it later on in the boot process...
From: https://askubuntu.com/questions/380096/turn-on-off-bluetooth-from-shell-not-from-applet#answer-834354
- (2277)How to extract files from a .deb package?
dpkg -x package.deb /tmp/out
From: https://linux-tips.com/t/how-to-extract-deb-package/169
- (2278)How to stop gitlab fully (gitlab-*, node-exporter, gitaly, nginx, prometheus, redis*, sidekiq, unicorn...)?
- To just stop the currently running instance:
gitlab-ctl stop
- To prevent it from launching at startup:
echo manual | sudo tee /etc/init/gitlab-runsvdir.override
From: https://superuser.com/questions/815464/how-do-you-stop-or-prevent-gitlab-from-running-on-startup#815469
- (2286)How do I check what kernel options were compiled in the currently running kernel?
/boot/config*
/proc/config.gz
From: https://serverfault.com/questions/51032/how-do-i-check-what-kernel-options-were-compiled-without-looking-at-boot-config#answer-51037
- (2291)How to install Linux on a Chromebook (ACER)?
I] Switch-off OS verification (NOTE: DELETES ALL THE DATA THE CHROMEBOOK!!!)
- Switch to Recovery
ESC+Refresh+POWER
You'll get a screen with a yellow exclamation mark
- Switch to developer mode
CTRL-D
You'll get multiple reboots, then a screen with a red exclamation mark
- In the end OS verification should be disabled
II] Install linux through crouton
- Download crouton
http://goo.gl/fd3zc
- Press Ctrl+Alt+T to bring up a terminal
- Ask for a true Ubuntu shell:
shell
- List available OSes
sudo sh ~/Downloads/crouton -r list
- Install the OS of your choice:
sudo sh ~/Downloads/crouton -r <chrootname/distrib: trusty> -t xfce
[-e] # -e for encryption
- When finished you'll have a new "chroot" environment in which ubuntu resides
- To list "chroot" environments:
sudo edit-chroot -a
- To enter a chroot environment and start ubuntu
sudo edit-chroot -n <chrootname: trusty>
startxfce4
You can switch between Ubuntu and ChromeOS, use:
CTRL-ALT- <- / CTRL-ALT- ->
III] Finish install
To complement the distrib you can install some useful packages:
sudo apt-get install language-selector-gnome
sudo apt-get install language-pack-fr* language-pack-gnome-fr*
sudo apt-get install cups avahi-daemon system-config-printer-common
system-config-printer-gnome
IV] To update crouton after a chromeOS update
sudo sh ~/Downloads/crouton -n <chrootname: trusty> -u
From: https://lifehacker.com/how-to-install-linux-on-a-chromebook-and-unlock-its-ful-509039343
https://doc.ubuntu-fr.org/chromebook
http://www.webupd8.org/2013/12/install-ubuntu-on-your-chromebook-using.html
http://www.webupd8.org/2013/12/things-to-do-after-installing-ubuntu-on.html
- (2325)How to remove sudo warning at start of terminal (a.k.a How to solve error "To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details.")?
Once you run a sudo command, the file ~/.sudo_as_admin_successful will
be created and the warning will go away. So either run a sudo command,
such as sudo apt-get update or create the ~/.sudo_as_admin_successful
file manually:
touch ~/.sudo_as_admin_successful
If you want the warning back for whatever reason, remove
~/.sudo_as_admin_successful:
rm ~/.sudo_as_admin_successful
From: https://askubuntu.com/questions/22607/remove-note-about-sudo-that-appears-when-opening-the-terminal
- (2307)How to access multiple GDrive?
google-drive-ocamlfuse -label <account1> /path/to/mountpoint1
google-drive-ocamlfuse -label <account2> /path/to/mountpoint2
...
From: https://askubuntu.com/questions/887755/how-can-we-mount-multiple-google-drive-accounts-on-our-system-using-google-drive#891522
- (2318)How to use youtube-dl?
Choosing a format:
youtube-dl -f mp4 URL
youtube-dl -f webm URL
youtube-dl -F URL //for available formats
--
By default the current version youtube-dl will download the highest quality audio and the highest quality video streams available and then join these streams into a compatible container.
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]' URL
Such a relatively complex command line can be placed permanently in the configuration file ~/.config/youtube-dl/config as follows:
-f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]'
--
-o '%(playlist_index)s-%(title)s.f%(format_id)s.%(ext)s' # names the files based on actual number & title of the video on youtube
--
-f 'best[filesize<75M]' # gets the best quality for a max file size of 75MB
See also Tip#2464
From: https://askubuntu.com/questions/806258/requested-formats-are-incompatible-for-merge#806272
https://askubuntu.com/questions/694848/how-to-download-a-youtube-playlist-with-numbered-prefix-via-youtube-dl#695031
- (2319)What to do if "kidle-inject" causes very high CPU load?
echo "blacklist intel_powerclamp" > /etc/modprobe.d/disable-powerclamp.conf
From: https://askubuntu.com/questions/584636/kidle-inject-causing-very-high-load
- (2328)How do you create a custom application launcher in Gnome Shell?
Try to create a <myapp>.desktop file under /usr/share/applications (or ~/.local/share/applications or directly in ~/Desktop) with the following content:
[Desktop Entry]
Encoding=UTF-8
Name=<My Application>
Exec=</path/to/executable>
Icon=</path/to/icon>
Type=Application
Categories=Development;...
Path=</path/to/working-dir>
Once you've created this new launcher in the menu/dash, you can search for it in the "activities" screen (top right) and then drag it to your panel/launcher.
From: https://askubuntu.com/questions/112186/how-do-you-create-a-custom-application-launcher-in-gnome-shell#112259
- (2332)How to set the date manually with "date"?
With default formatting:
date -s '2018-05-21 22:08:00'
Providing your own format:
date "+%Y%m%d" -s "20120418"
From: https://www.garron.me/en/linux/set-time-date-timezone-ntp-linux-shell-gnome-command-line.html
- (2334)How to run statup scripts?
Depending on what sort of scripts you need to run:
- For services and the like you should use upstart.
- But for a user script these should be launched as session scripts by
gnome! Have a look under System > Preferences > Startup Applications.
- On a side note if you need some scripts to be run on terminal login
you can add them to the .bash_login file in your home directory.
From: https://askubuntu.com/questions/814/how-to-run-scripts-on-start-up
- (2335)Where are SMB shares mounted in Nautilus/Thunar?
They are mounted in:
/run/user/<username>/gvfs
-- Exemple @astree
What you would have mounted manually as:
mount -t cifs -o username=guillaumem,workgroup=astree //astree-ic/DEPOT /mnt
Nautilus will put it in:
/run/user/1000/gvfs/smb-share:server=astree-ic,share=depot
From:
https://askubuntu.com/questions/343205/where-can-i-find-the-mount-point-for-smb-shares-in-13-04#343263
- (2343)How to download a .deb package and all its deps for offline installation?
SOLUTION1: If you have a debian based machine for the downloading part, run:
dwl-machine$ apt-get download $(apt-rdepends <package>|grep -v "^ ")
dwl-machine$ cp /var/cache/apt/archives/*.deb <your_usb_key>
instl-machine$ cp <your_usb_key>/* /tmp/
instl-machine$ dpkg -i /tmp/*.deb
SOLUTION2: If you do not have a .deb/apt-based machine, run:
instl-machine$ apt-get --print-uris --yes install <my_package_name> | grep ^\' | cut -d\' -f2 >downloads.list
## move the downloads.list file to a internet-connected machine, and run:
dwl-machine$ cd /tmp/ && wget --input-file myurilist
dwl-machine$ cp /tmp/*.deb <your_usb_key>
instl-machine$ cp <your_usb_key>/* /tmp/
instl-machine$ dpkg -i /tmp/*.deb
From: https://stackoverflow.com/questions/13756800/how-to-download-all-dependencies-and-packages-to-directory#answer-27469489
- (2379)How to install package as non root?
SOLUTION1:
apt-get source <package>
./configure --prefix <localdir>
make ; make install
SOLUTION2:
debootstrap precise myfancyinstall
chroot myfancyinstall
SOLUTION3:
apt-get download package
dpkg -i --force-not-root --root=$HOME package.deb
SOLUTION4:
mkdir /tmp/mytool
cp -r /var/lib/dpkg /tmp/mytool/
PATH=/sbin:/usr/sbin:$PATH fakeroot dpkg --force-not-root --root=/tmp/mytool/ -i package.deb
- then run with:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp/mytool/<installpath>/lib/<subdirs>/
/tmp/mytool/<installpath>/bin/<exe>
SOLUTION5:
mkdir -p fsys db/{info,updates}
touch db/status
PATH=/sbin:/usr/sbin:$PATH fakeroot dpkg --admindir=db --instdir=fsys -i somepkg.deb
From: https://askubuntu.com/questions/193695/installing-packages-into-local-directory
- (2387)How to find files that match a true regex, not a glob?
find . -regextype sed -regex "[a-f0-9\-]\{36\}\.jpg".
From: https://stackoverflow.com/questions/6844785/how-to-use-regex-with-find-command#6845194
- (2402)How to make UNetBootIn write to a NTFS USB stick (a.k.a. How do I use Unetbootin to make a bootable Windows 7 USB installer) (a.k.a. How to make UNetBootIn write on any -even non USB- disk)?
- In recent versions:
unetbootin installtype=USB targetdrive=/dev/sdd1 (for example)
- A dirty hack for old versions:
- Format your USB as FAT32 in GParted
- Open UNetbootin and get it as far as the stage where it brings up the USB partition to install to e.g. /dev/sdb1 - Don't install the ISO, though
- Leaving UNetbootin open as is, switch to GParted
- Format the USB in GParted as NTFS
- If GParted doesn't automatically add the "boot" flag, add it yourself
- Exit GParted, mount USB by running sudo mount /dev/sdb1 /mnt (don't forget to replace sdb1 with your one)
- Now, go back to UNetbootin, which you've left open in the meantime, and click OK
Doing so, UNetbootin will think you are using a FAT32 partition and will let you use NTFS format.
From: https://askubuntu.com/questions/162174/how-do-i-use-unetbootin-to-make-a-bootable-windows-usb-installer
- (2413)How to create a bootable Ubuntu USB flash drive from terminal?
You can use dd.
sudo umount /dev/sd<?><?>
where <?><?> is a letter followed by a number, look it up. Then, next:
sudo dd bs=4M if=input.iso of=/dev/sd<?> conv=fdatasync
where input.iso is the input file, and /dev/sd<?> is the USB device you're writing to (run lsblk to see all drives to find out what <?> is for your USB).
NOTE: If USB drive does not boot (this happened to me), it is because the target is a particular partition on the drive instead of the drive. So the target needs to be /dev/sdc and not dev/sdc <?> For me it was /dev/sdb .
NOTE2: This works because Ubuntu's ISOs are "hybrid" CD/HDD: they contain a bootloader.
From: https://askubuntu.com/questions/372607/how-to-create-a-bootable-ubuntu-usb-flash-drive-from-terminal#377561
- (2418)How to play midi files on Linux?
# apt-get install freepats timidity timidity-interfaces-extra
$ timidity awesometune.mid
From: https://sfxpt.wordpress.com/2015/02/02/how-to-play-midi-files-under-ubuntu-linux/
- (2419)How to make TuxGuitar output sound?
1. Install timidity
2. Run "timidity -iA" in a terminal
3. In TuXGuitar, go to Tools > Settings > Sound > MIDI Port and select Timidity
- (2420)How to slow down CPUs?
SOLUTION1: Use powerprofilesctl
powerprofilesctl list
powerprofilesctl set <profile_name>
From: https://linuxcommandlibrary.com/man/powerprofilesctl
SOLUTION2: Do it manually
# cat slow_cpus.sh
cpufreq-info
echo "1200000"> /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
echo "1200000"> /sys/devices/system/cpu/cpu1/cpufreq/scaling_max_freq
echo "1200000"> /sys/devices/system/cpu/cpu2/cpufreq/scaling_max_freq
echo "1200000"> /sys/devices/system/cpu/cpu3/cpufreq/scaling_max_freq
cpufreq-info
- (2422)How to get the status of an RAID HD managed with mdadm?
mdadm -D /dev/md4
From: https://serverfault.com/questions/178519/how-to-check-fsck-a-filesystem-on-a-md-device-linux-mdadm#178535
- (2424)What to do when mdadm mount a disk array as /dev/md127?
1) The ARRAY statement in mdadm.conf needs to be correct. I am not convinced the direct output of mdadm -Es is reliable anymore. Especially the name directive. Mine broke because I had a space in the name!
So I would try minimizing the specifiers in your ARRAY statements: all you normally need is device name and UUID:
Code:
ARRAY /dev/md0 UUID=e4665ceb:15f8e4b6:b186d497:7d365254
And there seems to be some change to do with /dev/md/* and /dev/md* which I don't yet understand.
2) You need to update initramfs so it contains your mdadm.conf settings during boot.
Code:
sudo update-initramfs -u
----
This is just a placemark. I found /dev/md0 not being built correctly after a crash. All I needed to do was a:
update-initramfs -u
and then when getting: “mdadm: unchecked config file” error just delete the:
rm /var/lib/mdadm/CONF-UNCHECKED
file.
Now, if you still do not get the raid array mounting on /dev/md0, but still on /dev/md127 do the following:
Find the mounted array:
df -kh
Then unmount the /dev/md127 device:
umount /dev/md127
Then stop the array:
mdadm -S /dev/md127
Then re-assemble the array:
mdadm –assemble –scan
Then check the array:
mdadm –detail /dev/md0
Once completed, do a:
fsck /dev/md0
and make sure everything is ok.
From: https://askubuntu.com/questions/209702/why-is-my-raid-dev-md1-showing-up-as-dev-md126-is-mdadm-conf-being-ignored#209750
https://ubuntuforums.org/showthread.php?t=1764861&page=2&s=e2a0c037f57c21194a7dc9c60c8b93e6
https://aubreykloppers.wordpress.com/2012/07/06/mdadm-devmd127/
- (2432)How to correct bug in Linux kernel 4.16+ that make kidle use >100% CPU on Intel chip-based machines?
- Temporary solution:
sudo rmmod intel_powerclamp seems to have stopped the kidle_inject processes and I haven't noticed any issues with doing so as of yet.
- For making this solution definitive:
echo "blacklist intel_powerclamp" > /etc/modprobe.d/disable-powerclamp.conf
From: https://askubuntu.com/questions/584636/kidle-inject-causing-very-high-load
- (2499)How to upgrade Ubuntu from GUI?
On versions of Ubuntu prior to 17.10 the program is "Software Updater"/"Update Manager".
For Ubuntu 17.10, the program is "Update Manager".
There's also "Update Notifier" that regularly checks for updates and proposes to update.
From: https://tutorials.ubuntu.com/tutorial/tutorial-upgrading-ubuntu-desktop#1
https://wiki.ubuntu.com/UpdateNotifier
- (2501)How to switch from Ubuntu to XUbuntu (a.k.a. How to install Xfce Desktop on Ubuntu and Turn it Into Xubuntu)?
== Install XFCE
sudo apt install xfce4
Once installed, log out, then at the login screen click on the user and then click the gear symbol and select Xfce session to login to use Xfce desktop.
== Install XUbuntu Desktop
sudo apt install xubuntu-desktop
This process will ask you to choose the display manager as well. I chose gdm3.
Once installed, log out, then at the login screen, click on the user first and then click the gear symbol and select Xubuntu session to login to use Xfce desktop.
== Remove Unity
sudo apt remove nautilus gnome-power-manager gnome-screensaver gnome-termina* gnome-pane* gnome-applet* gnome-bluetooth gnome-desktop* gnome-sessio* gnome-user* gnome-shell-common compiz compiz* unity unity* hud zeitgeist zeitgeist* python-zeitgeist libzeitgeist* activity-log-manager-common gnome-control-center gnome-screenshot overlay-scrollba* && sudo apt-get install xubuntu-community-wallpapers
sudo apt-get autoremove
#sudo apt install gnome-software
From: https://itsfoss.com/install-xfce-desktop-xubuntu/
- (2502)How to Switch Between GDM and LightDM in Ubuntu?
sudo apt install lightdm
sudo dpkg-reconfigure gdm3
From: https://itsfoss.com/switch-gdm-and-lightdm-in-ubuntu-14-04/
- (2503)How to enable numlock at boot time for login screen?
1. Ensure that numlockx is installed:
sudo apt-get install numlockx
2. Edit the file /etc/lightdm/lightdm.conf
gksudo gedit /etc/lightdm/lightdm.conf
3. Add the following line to the file:
greeter-setup-script=/usr/bin/numlockx on
From: https://askubuntu.com/questions/155679/how-to-enable-numlock-at-boot-time-for-login-screen#128038
- (2530)How to split a string into a character array in Bash?
echo "abcdefg" | fold -w1
echo "abcdefg" | grep -o .
bar=($(echo $foo|sed 's/\(.\)/\1 /g'))
read -a ARRAY <<< $(echo "abcdefg" | sed 's/./& /g')
$ echo hello | awk NF=NF FS=
From: https://stackoverflow.com/questions/7578930/bash-split-string-into-character-array
- (2537)How to display video/audio info in VLC's OSD?
https://forum.videolan.org/viewtopic.php?t=94925
https://forum.videolan.org/viewtopic.php?f=2&t=53824&p=177266#p177266
- (2541)How to find out if CPU supports Intel VT/AMD-V Virtualization?
grep --color -E '(vmx|svm)' /proc/cpuinfo # add lm for 64bits proc / aes for adv crypto
or
lscpu
From: https://www.cyberciti.biz/faq/linux-xen-vmware-kvm-intel-vt-amd-v-support/
- (2549)How to shrink root filesystem without booting a LiveCD?
The instructions below are crafted to work with CentOS 7, but they should be easily enough transferable to any distro that runs systemd. All commands are run as root.
1- Ensure the system is in a stable state
Make sure no one else is using it and nothing else important is going on. It's probably a good idea to stop service-providing units like httpd or ftpd, just to ensure external connections don't disrupt things in the middle.
systemctl stop httpd
systemctl stop nfs-server
# and so on....
2- Unmount all unused filesystems
umount -a
This will print a number of 'Target is busy' warnings, for the root volume itself and for various temporary/system FSs. These can be ignored for the moment. What's important is that no on-disk filesystems remain mounted, except the root filesystem itself. Verify this:
# mount alone provides the info, but column makes it possible to read
mount | column -t
If you see any on-disk filesystems still mounted, then something is still running that shouldn't be. Check what it is using fuser:
# if necessary:
yum install psmisc
# then:
fuser -vm <mountpoint>
systemctl stop <whatever>
umount -a
# repeat as required...
3- Make the temporary root
mkdir /tmp/tmproot
mount -t tmpfs none /tmp/tmproot
mkdir /tmp/tmproot/{proc,sys,dev,run,usr,var,tmp,oldroot}
cp -ax /{bin,etc,mnt,sbin,lib,lib64} /tmp/tmproot/
cp -ax /usr/{bin,sbin,lib,lib64} /tmp/tmproot/usr/
cp -ax /var/{account,empty,lib,local,lock,nis,opt,preserve,run,spool,tmp,yp} /tmp/tmproot/var/
This creates a very minimal root system, which breaks (among other things) manpage viewing (no /usr/share), user-level customizations (no /root or /home) and so forth. This is intentional, as it constitutes encouragement not to stay in such a jury-rigged root system any longer than necessary.
At this point you should also ensure that all the necessary software is installed, as it will also assuredly break the package manager. Glance through all the steps, and make sure you have the necessary executables.
4- Pivot into the root
mount --make-rprivate / # necessary for pivot_root to work
pivot_root /tmp/tmproot /tmp/tmproot/oldroot
for i in dev proc sys run; do mount --move /oldroot/$i /$i; done
systemd causes mounts to allow subtree sharing by default (as with mount --make-shared), and this causes pivot_root to fail. Hence, we turn this off globally with mount --make-rprivate /. System and temporary filesystems are moved wholesale into the new root. This is necessary to make it work at all; the sockets for communication with systemd, among other things, live in /run, and so there's no way to make running processes close it.
5- Ensure remote access survived the changeover
systemctl restart sshd
systemctl status sshd
After restarting sshd, ensure that you can get in, by opening another terminal and connecting to the machine again via ssh. If you can't, fix the problem before moving on.
Once you've verified you can connect in again, exit the shell you're currently using and reconnect. This allows the remaining forked sshd to exit and ensures the new one isn't holding /oldroot.
6- Close everything still using the old root
fuser -vm /oldroot
This will print a list of processes still holding onto the old root directory. On my system, it looked like this:
USER PID ACCESS COMMAND
/oldroot: root kernel mount /oldroot
root 1 ...e. systemd
root 549 ...e. systemd-journal
root 563 ...e. lvmetad
root 581 f..e. systemd-udevd
root 700 F..e. auditd
root 723 ...e. NetworkManager
root 727 ...e. irqbalance
root 730 F..e. tuned
root 736 ...e. smartd
root 737 F..e. rsyslogd
root 741 ...e. abrtd
chrony 742 ...e. chronyd
root 743 ...e. abrt-watch-log
libstoragemgmt 745 ...e. lsmd
root 746 ...e. systemd-logind
dbus 747 ...e. dbus-daemon
root 753 ..ce. atd
root 754 ...e. crond
root 770 ...e. agetty
polkitd 782 ...e. polkitd
root 1682 F.ce. master
postfix 1714 ..ce. qmgr
postfix 12658 ..ce. pickup
You need to deal with each one of these processes before you can unmount /oldroot. The brute-force approach is simply kill $PID for each, but this can break things. To do it more softly:
systemctl | grep running
This creates a list of running services. You should be able to correlate this with the list of processes holding /oldroot, then issue systemctl restart for each of them. Some services will refuse to come up in the temporary root and enter a failed state; these don't really matter for the moment.
If the root drive you want to resize is an LVM drive, you may also need to restart some other running services, even if they do not show up in the list created by fuser -vm /oldroot. If you find you are unable to resize an LVM drive under Step 7, try systemctl restart systemd-udevd.
Some processes can't be dealt with via simple systemctl restart. For me these included auditd (which doesn't like to be killed via systemctl, and so just wanted a kill -15). These can be dealt with individually.
The last process you'll find, usually, is systemd itself. For this, run systemctl daemon-reexec.
Once you're done, the table should look like this:
USER PID ACCESS COMMAND
/oldroot: root kernel mount /oldroot
7- Unmount the old root
umount /oldroot
At this point, you can carry out whatever manipulations you require. The original question needed a simple resize2fs invocation, but you can do whatever you want here; one other use case is transferring the root filesystem from a simple partition to LVM/RAID/whatever.
8- Pivot the root back
mount <blockdev> /oldroot
mount --make-rprivate / # again
pivot_root /oldroot /oldroot/tmp/tmproot
for i in dev proc sys run; do mount --move /tmp/tmproot/$i /$i; done
This is a straightforward reversal of step 4.
9- Dispose of the temporary root
Repeat steps 5 and 6, except using /tmp/tmproot in place of /oldroot. Then:
umount /tmp/tmproot
rmdir /tmp/tmproot
Since it's a tmpfs, at this point the temporary root dissolves into the ether, never to be seen again.
10- Put things back in their places
Mount filesystems again:
mount -a
At this point, you should also update /etc/fstab and grub.cfg in accordance with any adjustments you made during step 7.
Restart any failed services:
systemctl | grep failed
systemctl restart <whatever>
Allow shared subtrees again:
mount --make-rshared /
Start the stopped service units - you can use this single command:
systemctl isolate default.target
And you're done.
From: https://unix.stackexchange.com/questions/226872/how-to-shrink-root-filesystem-without-booting-a-livecd
http://www.ivarch.com/blogs/oss/2007/01/resize-a-live-root-fs-a-howto.shtml
- (2565)How to add specific DNS in resolv.conf?
I believe if you want to override the DNS nameserver you merely add a line similar to this in your base file under resolv.conf.d.
Example
$ sudo vim /etc/resolvconf/resolv.conf.d/base
Then put your nameserver list in like so:
nameserver 8.8.8.8
nameserver 8.8.4.4
Finally update resolvconf:
$ sudo resolvconf -u
If you take a look at the man page for resolvconf it describes the various files under /etc/resolvconf/resolv.conf.d/.
Also see Tip#1767 & Tip#3024
From: https://unix.stackexchange.com/questions/128220/how-do-i-set-my-dns-when-resolv-conf-is-being-overwritten#answer-128223
- (2566)How can I update youtube-dl in Ubuntu?
Try ppa:nilarimogard/webupd8. I do get upgrades every couple of days and I think, according to the message You get, that it should solve/answer Your question. If You did an upgrade from 13.04 to 13.10 You might have forgot (I guess) to update sources-list.d folder, for example, if You used WebUpd8 before.
sudo apt-add-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install youtube-dl
From: https://askubuntu.com/questions/380438/how-can-i-update-youtube-dl#answer-382655
- (2568)How to make a user/Xorg program work from scripts/udev rules?
- For running as a user: OWNER='<name>'
- For running a Xorg program: You need env variables DISPLAY and XAUTHORITY: ENV{DISPLAY}=":0", ENV{XAUTHORITY}="/home/<username>/.Xauthority"
See an example at Tip#1983
From: https://stackoverflow.com/questions/15488659/synclient-doesnt-work-from-udev-rules#answer-22738750
https://superuser.com/questions/249064/udev-rule-to-auto-load-keyboard-layout-when-usb-keyboard-plugged-in/350336#350336
https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Disable_touchpad_on_mouse_detection
- (2575)How to remove CPU-eating 'tracker-store' process?
==PROBLEM
Long story short, after an Arch update the annoying process called tracker-store started to hog my CPU and disk space (again).
==SOLUTION
Copy the autostart file and override it with a user-specific one: $ cp /etc/xdg/autostart/tracker-store.desktop ~/.config/autostart/tracker-store.desktop
and append to it:
Hidden=true
(The same step also applies for tracker’s friends, such as tracker-miner-fs, etc.)
Mask (which is the strongest yet nondestructive way to “disable” a static systemd service completely [4]) all tracker-related services:
$ systemctl --user mask tracker-store
From: https://www.soimort.org/notes/171103/
- (2579)How to display debug info at boot?
In grub menu, replace:
"splash quiet"
by:
"nosplash debug --verbose"
in the kernel line
From: https://askubuntu.com/questions/39057/how-do-i-enable-verbose-mode-at-boot
- (2580)How to resolve freeze at boot on Dell Inspiron booting kernel 4.xx?
First, boot with kernel options that allows to see the console logs (See Tip#2579), and ensure the freeze occurs right after configuring sound.
This bug is caused by the file /var/lib/systemd/backlight/platform-dell-laptop:leds:dell::kbd_backlight created by (I guess) systemd-backlight@.service, because I can boot with kernel-4.2.3-200.fc22.x86_64 after I remove that file.
As that file is re-created at shutdown, I have to mask the service systemd-backlight@leds\:dell\:\:kbd_backlight.service with:
sudo systemctl mask systemd-backlight@leds\:dell\:\:kbd_backlight.service
so kernel-4.2.3-200.fc22.x86_64 doesn't hang at boot.
As suggested by man systemd-backlight@.service, booting with the kernel command line parameter:
systemd.restore_state=0
also avoids the hang.
I think that file shouldn't be created in this laptop because it doesn't have a keyboard backlight or any LED in the keyboard.
From: https://bugzilla.redhat.com/show_bug.cgi?id=1253523#c12
- (2582)How to convert from ifconfig to ip?
# ifconfig => # ip a
# ifconfig eth0 add 192.168.80.174 => # ip a add 192.168.80.174 dev eth0
# ifconfig eth0 add 192.168.80.174 => # ip a add 192.168.80.174 dev eth0
# ifconfig eth0 del 192.168.80.174 => # ip a del 192.168.80.174 dev eth0
# ifconfig eth0 hw ether 00:0c:29:33:4e:aa => # ip link set dev eth0 address 00:0c:29:33:4e:aa
# ifconfig eth0 mtu 2000 => # ifconfig eth0 mtu 2000
# ifconfig eth0 multicast => # ip link set dev eth0 multicast on
# ifconfig eth0 txqueuelen 1200 => # ip link set dev eth0 txqueuelen 1200
# ifconfig eth0 promisc => # ip link set dev eth0 promisc on
# ifconfig eth0 allmulti => # ip link set dev eth0 allmulti on
# ifconfig eth0 down => # ip link set eth0 down
# ifconfig eth0 arp => # ip link set dev eth0 arp on
From: https://www.tecmint.com/ifconfig-vs-ip-command-comparing-network-configuration/
- (2591)How to resolve "System program problem detected" after upgrade to Ubuntu 19.04?
- Navigate to /var/crash/
- Select all the files you find in that directory and delete them.
- Upon your next boot, you shouldn't get the "System problem detected" dialog box.
From: https://ubuntu-mate.community/t/system-program-problem-detected-after-upgrade-to-ubuntu-mate-19-04/19393
- (2594)How to solve "Invalid signature" when trying to "apt-get update" on Kali?
Per: https://twitter.com/kalilinux/status/959515084157538304, your archive-keyring package is outdated. You need to do this (as root):
wget -q -O - https://archive.kali.org/archive-key.asc | apt-key add
From: https://unix.stackexchange.com/questions/421985/invalid-signature-when-trying-to-apt-get-update-on-kali#422184
- (2599)Why do I get "Required key not available" when install 3rd party kernel modules or after a kernel upgrade?
Since Ubuntu kernel 4.4.0-20 the EFI_SECURE_BOOT_SIG_ENFORCE kernel config has been enabled. That prevents from loading unsigned third party modules if UEFI Secure Boot is enabled.
The easiest way to fix this issue is to disable Secure Boot in UEFI (BIOS) settings.
In most cases you can get into UEFI settings using grub menu. Press ESC button on booting, get into grub menu and select System Setup. Secure Boot option should be in "Security" or "Boot" section of the UEFI.
You can get into UEFI directly, but it depends on your hardware. Read your computer manual to see how to get there. It may be Del, or F2 on boot, or something else.
An alternative way is to disable Secure Boot using mokutil.
Since Ubuntu kernel build 4.4.0-21.37 this can be fixed by running
sudo apt install mokutil
sudo mokutil --disable-validation
It will require to create a password. The password should be at least 8 characters long. After you reboot, UEFI will ask if you want to change security settings. Choose "Yes".
Then you will be asked to enter the previously created password. Some UEFI firmware asks not for the full password, but to enter some characters of it, like 1st, 3rd, etc. Be careful. Some people do not understand this. I did not get it from the first attempt either ;-)
From: https://askubuntu.com/questions/762254/why-do-i-get-required-key-not-available-when-install-3rd-party-kernel-modules
https://sourceware.org/systemtap/wiki/SecureBoot
- (2600)How to Fix Right Click Touchpad Not Working on Ubuntu 18.04?
If your laptop's touchpad doesn't have "physical buttons" for left and right click, the right click is achieved with two fingers tap.
This can be changed with:
- sudo apt install gnome-tweaks
- Run gnome-tweaks
- Click Keyboard & Mouse in the left sidebar
- Under Mouse Click Emulation section, select Area.
From: https://itsfoss.com/fix-right-click-touchpad-ubuntu/
- (2601)What are the VGA Boot modes to set screen resolution (to use with "vga=xxx" kernel boot option)?
A simple way to set your screen resolution and color depth for most Live Linux distro's is via the use of the vga=parameter boot option. For example at boot you might type: Live vga=795. This would set your system to boot using the Live label with a screen resolution to 24bit 1280X1024. Here are some more examples of common vga boot values.
VGA Resolution and Color Depth reference Chart:
Depth 800×600 1024×768 1152×864 1280×1024 1600×1200
8 bit vga=771 vga=773 vga=353 vga=775 vga=796
16 bit vga=788 vga=791 vga=355 vga=794 vga=798
24 bit vga=789 vga=792 vga=795 vga=799
From: https://www.pendrivelinux.com/vga-boot-modes-to-set-screen-resolution/
- (2602)How to boot from USB on a computer that does not support it?
Use PLoP Boot Manager: https://www.plop.at/
How to Create a PLoP Boot Manager CD
- Download PLoP Boot manager, and extract the files from the Zip to your Desktop
- Burn the plpbt.iso to a CD using your favorite CD/DVD burning software
- Insert your Newly created PLoP Boot CD and your pre-prepared Linux USB Flash Drive
- Reboot your PC and set your System BIOS to boot from the CD
If all goes as planned, you should now be presented with an alternate Boot Manager similar to the one pictured above that can be used to boot your USB Flash Drive or other device.
From: https://www.pendrivelinux.com/boot-from-usb-without-bios-support-via-plop-cd/
- (2603)How to resolve "Failed to start login service, booting impossible" in Kali (a.k.a. How to recover from a failed upgrade)?
I had the same problem, but I knew for a fact that this was due to the aborted upgrade and/or dist-upgrade processes.
Here is what I did to fix it:
- Enter recovery mode
- Start networking:
ifconfig eth0 up && dhclient eth0
- Complete the install:
dpkg --configure -a
- This returned some broken packages, including network-manager and network-manager-gnome.
As apt tells you, run:
apt-get --fix-broken install
- Start the upgrade and dist-upgrade process again:
- apt-get upgrade -y && apt-get dist-upgrade -y
- Reboot; it now works normally.
From: https://unix.stackexchange.com/questions/264994/kali-suddenly-fails-failed-to-start-login-service-booting-impossible
- (2604)How to resolve "error cannot perform the following tasks" "mount snap" "requires classic confinement" in snap?
You have to set a confinement level:
snap install <xxx> --classic
From: https://forum.snapcraft.io/t/cant-re-install-existing-snap/1824
- (2605)How to resolve "error: cannot find signatures with metadata for snap <xxx>" in Snap?
It means snapd was updated without also updating the documentation, I'm afraid.
The update has to do with assertions, in this case, that is the verification that the snap comes from a trusted party. Since you're installing a local snap, you have no assertions for it, and snapd doesn't trust it. The error message could be a little more helpful.
Regardless, you can get past this during your testing with the --dangerous flag:
$ sudo snap install --dangerous <local snap file>
From: https://askubuntu.com/questions/822765/snap-install-failure-error-cannot-find-signatures-with-metadata-for-snap
- (2607)How to activate/desactivate TouchPad?
== Manually
xinput list
xinput set-prop 12 "Device Enabled" 0
xinput set-prop 12 "Device Enabled" 1
synclient TouchpadOff=0
synclient TouchpadOff=1
== Automatically
synclient PalmDetect=1
syndaemon -i 0.5 -t -K -R
From: https://ubuntuforums.org/showthread.php?t=2326674
https://askubuntu.com/questions/65951/how-to-disable-the-touchpad
https://askubuntu.com/questions/886092/how-do-i-disable-the-touchpad-while-typing
- (2609)How to get one's IP address in Ubuntu 18.04+ (no more ifconfig!)?
ip addr show
From: https://tecadmin.net/check-ip-address-ubuntu-18-04-desktop/
- (2611)How to set volume manually?
amixer [-D pulse] [s]set Master 2-
amixer [-D pulse] [s]set Master 2+
amixer [-D pulse] [s]set Master toggle
pactl set-sink-volume 0 +1.5%
pactl set-sink-volume 0 -- -1.5%
pactl set-sink-mute 0 toggle
From: https://superuser.com/questions/389737/how-do-you-make-volume-keys-and-mute-key-work-in-xmonad/964733
- (2623)How do you empty the buffers and cache on a Linux system?
== Emptying the buffers cache
If you ever want to empty it you can use this chain of commands.
# free && sync && echo 3 > /proc/sys/vm/drop_caches && free
You can signal the Linux Kernel to drop various aspects of cached items by changing the numeric argument to the above command.
- To free pagecache:
# echo 1 > /proc/sys/vm/drop_caches
- To free dentries and inodes:
# echo 2 > /proc/sys/vm/drop_caches
- To free pagecache, dentries and inodes:
# echo 3 > /proc/sys/vm/drop_caches
You can also use: sudo sysctl vm.drop_caches=1
== SWAP
If you want to clear out your swap you can use the following commands.
$ swapoff -a
$ swapon -a
== Seeing what's in the buffers and cache
Take a look at linux-ftools (http://code.google.com/p/linux-ftools/) if you'd like to analyze the contents of the buffers & cache. Specifically if you'd like to see what files are currently being cached, use "fincore". With this tool you can see what files are being cached within a given directory.
From: https://unix.stackexchange.com/questions/87908/how-do-you-empty-the-buffers-and-cache-on-a-linux-system
http://kernel.org/doc/Documentation/sysctl/vm.txt
- (2628)How does rsync decides if a file is outdated?
There are 3 possibilities
- Compare the size of source and destination.
- Compare the timestamp of source and destination.
- Compare the static checksum of source and destination.
These checks are performed before transferring data. Notably, this means the static checksum is distinct from the stream checksum - the later is computed while transferring data.
*By default, rsync uses only 1 and 2*. Both 1 and 2 can be acquired together by a single stat, whereas 3 requires reading the entire file (this is independent from reading the file for transfer). Assuming only one modifier is specified, that means the following:
- By using --size-only, only 1 is performed - timestamps and checksum are ignored. A file is copied unless its size is identical on both ends.
- By using --ignore-times, neither of 1, 2 or 3 is performed. A file is always copied.
- By using --checksum, 3 is used in addition to 1, but 2 is not performed. A file is copied unless size and checksum match. The checksum is only computed if size matches.
From: https://stackoverflow.com/questions/13778889/rsync-difference-between-size-only-and-ignore-times#answer-44353773
- (2637)How to re-install grub? (a.k.a. How to repair/update an HD installation from a LiveCD/USB?) (a.k.a. How to make network work in a chroot'ed environment)?
1. Boot a LiveCD/USB
2. Open a terminal
3. Switch to root
Then:
### Mount some of the HD-installed-OS) partitions, mainly /
# mount /dev/sdXXX /mnt/ # If using LVM, See Tip#2745
# mount /dev/sdYYY /mnt/home/ # Might not be necessary (see "mount -a" below)
### Mount the LiveCD/USB kernel files into "Host" filesystem
# mount --bind /dev /mnt/dev
# mount --bind /proc/ /mnt/proc/
# mount --bind /sys/ /mnt/sys/
### Setup the HD-installed-OS network (copy LiveCD/USB configuration)
# cp /etc/resolv.conf /mnt/etc/resolv.conf
### Switch to HD-installed-OS system
# chroot .
### Mount all the necessary HD-installed-OS partitions
# mount -a # to mount
### You are now in the "exact" same environment as you would have got if you had booted from the HD-installed-OS directly
### The only noticeable difference is the running kernel is the one from the LiveCD/USB
### You can now repair/upgrade your system, for instance:
# grub-install /dev/sdXXX && update-grub
# apt update && apt dist-upgrade && apt clean && apt autoclean && apt autoremove
From: https://unix.stackexchange.com/questions/280500/unable-to-reach-network-from-chroot#answer-280534
# mount /dev/sdb3 /mnt/
# mount /dev/sdb2 /mnt/home/
# mount --bind /dev /mnt/dev
# mount --bind /proc/ /mnt/proc/
# mount --bind /sys/ /mnt/sys/
# cd /mnt
# chroot .
# ## grub-install /dev/sda
# grub-install /dev/sdb
# export DISPLAY=:0
$ xhost +
# qemu-system-x86_64 -m 1024 -hda /dev/sda -hdb /dev/sdb
- (2644)How to create portable scripts?
Use the "3 fingered claw": yell/die/try
--- three_fingered_claw.sh
#!/bin/sh
# From SO, of course:
# https://stackoverflow.com/questions/1378274/in-a-bash-script-how-can-i-exit-the-entire-script-if-a-certain-condition-occurs
# These functions are *NIX OS and shell flavor-robust.
# Put them at the beginning of your script (bash or otherwise), try() your statement and code on.
#
# yell: print the script name ($0) and all arguments ($*) to stderr/file descriptor 2 (>&2).
# die: calls yell, then exits with a non-0 exit status, indicating failure.
# try: uses boolean OR (||), which only evaluates the right side if the left one didn’t fail.
# $@ is all arguments again, but individually quoted (not as a single-argument blob).
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
# Examples:
# try cd /some/place
# try tar xzvfp /another/place/stuff.tbz
# (you may not want to 'try' that tar, depending)
From: https://gist.github.com/murphdasmurf/1b62727b8e71c80d033f164d292a2ad1
- (2660)How to fix “System program problem detected” error on Ubuntu?
# rm /var/crash/*
- (2673)How to clean snap's removal mess?
Every time a snap is removed, a snapshot is generated automatically. These snapshots are retained for 31 days before being deleted automatically.
To know the currently stored snapshots:
snap saved
To remove a particular snapshot:
snap forget <snapshot id>
From: https://snapcraft.io/docs/snapshots
- (2677)How to restart pulseaudio (a.k.a. what to do if sounds sudently stops)?
1- check if the sound is not muted or volume set to 0
pavucontrol
2- check if the hardware output device disappears from pavucontrol (and a dummy output device appears)
pulseaudio -k
From: https://askubuntu.com/questions/983257/low-sound-volume-with-sunrise-point-lp-hd-audio-alc3227-in-hp-15-bs576tx-lapto#1062525
- (2678)How to speedup/slow down a movie with FFMpeg
ffmpeg -i input.mkv -filter:v "setpts=0.5*PTS" output.mkv # speeds up video by factor 2
ffmpeg -i input.mkv -filter:a "atempo=2.0" output.mkv # doubles the speed
To completely switch off video or audi, use:
-an (audio off)
-vn (video off)
From: https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
- (2679)How to reduce size of video with FFMpeg?
Use -fs ("file size"):
ffmpeg -i in.avi -fs 100M out.avi
From: https://unix.stackexchange.com/questions/28803/how-can-i-reduce-a-videos-size-with-ffmpeg#comment38732_28803
- (2681)How to create a Linux swap file?
# SIZE=8192
# fallocate -l ${SIZE}M /swapfile
# chmod 600 /swapfile
# dd if=/dev/zero of=/swapfile bs=1M count=$SIZE
# mkswap /swapfile
# swapon /swapfile
Edit /etc/fstab:
/swapfile none swap sw 0 0
Optional: to change the swappiness value (usage of the swap even if RAM not full), add the following line to the file at /etc/sysctl.conf:
vm.swappiness=10
- (2682)How to enable hibernate (disk sleep)?
Edit /etc/default/grub
-If you have a swap partition:
GRUB_CMDLINE_LINUX="resume=/dev/sdXY"
or
GRUB_CMDLINE_LINUX="resume=UUID=XXXXX"
-If you have a swap file:
# the mount point where the swapfile is (if encrypted partition => put the unencrypted mount point)
# YYYY fi found by: filefrag -v /swapfile | awk '{ if($1=="0:"){print $4} }'
GRUB_CMDLINE_LINUX="resume=UUID=XXXXX resume_offset=YYYY"
From: https://superuser.com/questions/383140/linux-grub2-how-to-resume-from-hibernation#405922
https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption
https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file
- (2683)How to check if the home directory is encrypted?
SOLUTION1
cat /home/.ecryptfs/$USER/.ecryptfs/Private.mnt
If the file exists and contains your home directory path, your home directory is encrypted.
SOLUTION2
df $HOME
An encrypted home will be mounted at the ".Private" filesystem, otherwise it will be mounted at some regular partition device (/dev/*) .
Filesystem 1K-blocks Used Available Use% Mounted on
/home/username/.Private
315482376 101351268 198105472 34% /home/username
Regular device mount (no encryption):
df /home/schroot
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda7 315482376 101351332 198105408 34% /home
From: https://askubuntu.com/questions/17216/how-can-i-determine-if-just-the-private-folder-is-encrypted-or-the-whole-home-d
- (2684)How to encrypt Home/Swap after installation?
[NOTE: this process backups/copies the /home/<user> files => requires 2.5x size of /home/<user>]
- Install tools
# apt-get install ecryptfs-utils cryptsetup
- Create a new user account and make it an administrator (GUI:UserAccount, CLI:Tip#565)
- Logout to-be-migrated user and Switch to new admin user
- Do the migration
# ecryptfs-migrate-home -u <user>
- YOU MUST LOG IN AS THE OTHER USER ACCOUNT IMMEDIATELY – BEFORE ANY REBOOT!
- Verify that reading/writing files is OK
- Save encryption passphrase
# ecryptfs-unwrap-passphrase
- Cleanup stuff
# rm -rf /home/user.random
# userdel <new admin>
- Encrypt the swap BREAKS HIBERNATION (rather use a swapfile - See Tip#2681 - on an encrypted disk)
# ecryptfs-setup-swap
From: https://www.howtogeek.com/116032/how-to-encrypt-your-home-folder-after-installing-ubuntu/
- (2685)How to resolve failure to suspend/hibernate in dual monitor setup with XFCE4?
If the computer start to go to sleep, then wakes up immediately or if it does go to sleep with the external monitor plug out but not when plugged in, then run:
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/logind-handle-lid-switch -s false
From: https://bugzilla.xfce.org/show_bug.cgi?id=15300#c4
- (2689)How to Reset Forgotten Root Password in Fedora 19+ from Grub (a.k.a. how to circumvent SELinux from blocking boot because system files have been modified externally - e.g. with LiveUSB/CD)
1) change root password with LiveUSB/CD or in recovery mode (initramfs)
- boot with init=/bin/bash (editing the kernel line in grub)
- after booting: mount -o remount,rw /
- passwd root
> enter the new password twice
2) **Warn SELinux that some system files were modified and that it has to rebuild its index/md5sum list**
touch /.autorelabel
3) reboot with /sbin/reboot -f
From: https://unix.stackexchange.com/questions/85558/how-to-reset-forgotten-root-password-in-fedora-19-from-grub/125773#125773
- (2701)How to get the vendor ID and product ID for a USB device?
lsub
udevadm monitor # + plug/unplugyour device
From: https://superuser.com/questions/1106247/how-can-i-get-the-vendor-id-and-product-id-for-a-usb-device/1106248#1106248
- (2702)How to correct command-not-found crashes after upgrade to Ubuntu 19.04 ("Sorry, command-not-found has crashed!", " unable to open database file")?
After upgrade to 19.04 I get an ugly traceback every time I make a typo on the command line. I fixed the problem with the following command, but after the next aptitude update the db file was once again not readable for non-root users.
sudo chmod a+r /var/lib/command-not-found/commands.db
From: https://ubuntuforums.org/showthread.php?t=2417705&p=13855008#post13855008
- (2731)How to copy a bunch of system files while preserving everything (a.k.a. How to manually copy an OS to another disk)?
I] With cp
# cp -avx /src /dest/
-a : "archive" (recursivity, preserve mode, owner, link, etc.)
-x : for staying in the same filesystem (otherwise if dest=/mnt is recursively&infinitely copied inside /mnt/mnt, which is copied inside /mnt/mnt/mnt/ ...)
-v : for getting verbose info during the lengthy copy process
II] With rsync
rsync -avxAHXS --stats --progress /src /dest/
-a : "archive mode": all files, with permissions, etc..
-v : verbose, mention files
-x : stay on one file system
-A : preserve ACLs/permissions (not included with -a)
-H : preserve hard links (not included with -a)
-X : preserve extended attributes (not included with -a)
-S : account for sparse files
--stats & --progress are for getting infos during copy
III] With tar
# tar -cvpzf - --one-file-system /src | tar -xvpzf - -C /dest/ --numeric-owner
-c/-x : compress/extract
-v : verbose
-p : preserve permission,mode...
-z : compress
-f - : set output/input to/from stdin
From: https://superuser.com/questions/307541/copy-entire-file-system-hierarchy-from-one-drive-to-another/307543#307543
https://superuser.com/questions/307541/copy-entire-file-system-hierarchy-from-one-drive-to-another/307542#307542
https://superuser.com/questions/307541/copy-entire-file-system-hierarchy-from-one-drive-to-another/307543#307543
https://www.maketecheasier.com/back-up-entire-hard-drive-linux/
- (2744)What are the GRUB 2 rescue mode commands?
These are the commands that can be used when you enter the GRUB 2 terminal mode by pressing "c".
- boot (Initiate the boot, also F10 or CTRL-x)
- cat (view the contents of config or txt files; cat (hd0,1)/boot/grub/grub.cfg)
- configfile (Load a GRUB 2 configuration file such as grub.cfg; configfile (hd0,5)/boot/grub/grub.cfg.)
- initrd (Loads the initrd.img, necessary for booting; initrd (hd0,5)/initrd.img.)
- insmod (Loads a module; insmod (hd0,5)/boot/grub/normal.mod, or insmod normal.)
- linux (Loads the kernel; insmod /vmlinuz root=(hd0,5) ro.)
- loop (Mount a file as a device; loopback loop (hd0,2)/iso/my.iso.)
- ls (lists the contents of a partition/folder; ls, ls /boot/grub, ls (hd0,5)/, ls (hd0,5)/boot.)
- lsmod (List loaded modules.)
- normal (Activate the normal module, if loaded.)
- search (Search for a device. Type help search for the available options.)
- *set* (Review current settings, or set XXX to set a variable such as colors, prefix, root.)
- vbeinfo (Display GRUB 2 available resolutions.)
From: https://www.howtoforge.com/tutorial/repair-linux-boot-with-grub-rescue/#basic-commands-available
- (2745)How to manage LVM volume in CLI?
# vgscan # find info about LVM devices
# vgchange -ay # to activate a LVM group(s)
# lvdisplay # to list the group
# lvs
# ls -l /dev/<LVM Group>/ # to list mountable devices
# mount /dev/<LVM Group>/<mountable dev> /mnt/<mounta point>
or
--- /etc/fstab ---
/dev/mapper/<LVM Group>-<mountable device> /mnt/<mount point> ext4 defaults 0 0
From: https://www.cyberciti.biz/faq/linux-mount-an-lvm-volume-partition-command/
- (2746)How to convert a disk from GPT to MBR?
parted /dev/sda
parted> mklabel msdos
parted> quit
NOTE: this loses all the data on the disk!!!
From: https://random-linux-stuff.blogspot.com/2013/01/convert-disk-from-gpt-to-mbr.html
- (2751)How to Clear RAM Memory Cache, Buffer and Swap Space on Linux?
1. Clear PageCache only.
# sync; echo 1 > /proc/sys/vm/drop_caches
2. Clear dentries and inodes.
# sync; echo 2 > /proc/sys/vm/drop_caches
3. Clear PageCache, dentries and inodes.
# sync; echo 3 > /proc/sys/vm/drop_caches
How to Clear Swap Space in Linux?
4. Clear Swap space, you may like to run the below command.
# swapoff -a && swapon -a
From: https://www.tecmint.com/clear-ram-memory-cache-buffer-and-swap-space-on-linux/
- (2754)How to disable a user account in Linux?
SOLUTION1:
# vipw
#FILE: /etc/passwd
...
ravi:x:500:500:Ravi Kumar:/home/ravi:***/bin/nologin***
...
SOLUTION2: [BEWARE: with this solution, you can't ssh into the box using the password, but you can if you use a public key setup!!!]
Lock out the user:
# passwd -l <user>
Unlock the account:
# passwd -u <user>
SOLUTION3:
# usermod -s /bin/nologin <user>
or:
# chsh -s /sbin/nologin <user>
SOLUTION4:
You can lock a user account by setting the expiry date to yesterday or earlier.
# chage -E YYYY-MM-DD <user>
Check the expiry date of a user:
# chage -l <user>
Remove expiry date of a user:
# chage -E -1 <user>
From: http://www.aboutlinux.info/2005/10/different-ways-of-locking-users.html
- (2755)How to check the logs for failed logins?
All failed logins are audited and logged to the file /var/log/faillog. To see who all have unsuccessfully tried to login to their account, try the following:
# faillog -a
- (2756)How to read a password from a script?
SOLUTION1: the simplest [but not POSIX]
read -s -p "Password:" password
SOLUTION2: [100% POSIX]
#!/bin/sh
stty -echo
printf "Password: "
read PASSWORD
stty echo
printf "\n"
SOLUTION3: an intermediatry solution if "read" does not support "-p" on you platform
echo -n Password:
read -s password
echo
# Run Command
echo $password
- (2759)How to run a service at startup (a.k.a. How to start noip2 IP update service)?
Since Ubuntu 15.04 the standard way to control background processes (and much, much more) is systemd.
You can configure systemd to start a service by creating the file in /etc/systemd/system/<servicename>.service with a content similar to:
------
[Unit]
Description=description of the service
[Service]
Type=forking
ExecStart=/path/to/the/executable
Restart=always
[Install]
WantedBy=default.target
-------
Then issue:
# systemctl daemon-reload
to make systemd aware of the new unit (systemd caches unit files and this command makes systemd reconsider its cache).
Now you can try to start and stop your unit and see its status:
# systemctl status <servicename>
# systemctl start <servicename>
# systemctl status <servicename>
# systemctl stop <servicename>
# systemctl status <servicename>
To have the unit started at boot time you need to enable it:
# systemctl enable <servicename>
To disable autostart at boot time you must disable the unit:
# systemctl disable <servicename>
----- Note specific for running executables that fork themselves [eg: noip2]
Some research revealed the noip2 runs as a daemon, i.e. when you start it, it creates another process that runs in background (so called forking) and the foreground process immediately returns (exits). That's why the init.d script and the systemd unit failed: They started noip2 just to see it immediately exits. Hence, systemd tried to restart it over and over to no avail. (By default, systemd restarts a process at most 5 times within 10 seconds or so before giving up and leaving it in failed state.)
To tell systemd the unit is of type forking add the line
Type=forking
to the [Service] section as I just did in the snippet above. This tells systemd to expect the main process to return immediately but instead watch the process spawned (forked) by noip2.
From: https://askubuntu.com/questions/1089704/cant-get-service-noip2-to-start-on-boot/1089789#1089789
- (2760)systemd CheatSheet
Most of the time five commands are sufficient to control a units behaviour:
systemctl start $unit # starts a unit NOW
systemctl stop $unit # stops a unit NOW
systemctl status $unit # shows status
systemctl enable $unit # starts a unit at boot time (but not NOW)
systemctl disable $unit # stops autostart (but doesn't stop the unit NOW)
You may also enable autostart and start the unit imediately or disable autostart and stop it at once:
systemctl enable --now $unit # enable and start in one go
systemctl disable --now $unit # disable and stop in one go
From: https://askubuntu.com/questions/1089704/cant-get-service-noip2-to-start-on-boot/1089789#1089789
- (2766)How to restart the network interface after editing /etc/network/interfaces?
SOLUTION1:
# ifdown wlan0 && ifup wlan0
SOLUTION2:
# ip addr flush <interface-name>
# systemctl restart networking
From: https://askubuntu.com/questions/333063/restart-network-interface-after-editing-etc-network-interfaces
- (2786)How to send mails from CLI?
1. install mailutils package
# apt install mailutils
2. use "mail" CLI command to send emails
# To read mails
$ mail
# To send to a local user
$ mail -s "Hello World" username
# To send to a remote user
$ mail -s "Hello World" someone@example.com
# Non interactive body
$ echo "This is the body" | mail -s "Subject" -aFrom:Harry\<harry@gmail.com\> someone@example.com
# Body from a file
$ mail -s "Hello World" user@yourmaildomain.com < /home/user/mailcontent.txt
# -c email-address (CC - send a carbon copy to email-address)
# -b email-address (BCC - send a blind carbon copy to email-address)
$ mail -s "Hello World" user1@example.com -c usertocc@example.com -b usertobcc@example.com
From: https://www.binarytides.com/linux-mail-command-examples/
- (2787)How can I make a script in /etc/init.d start at boot?
1. Write your script in /etc/init.d/<myscript>. It should look like:
#!/bin/sh
### BEGIN INIT INFO
# Provides: <name>
# Required-Start: <start-dependencies>
# Required-Stop: <stop-dependencies>
# Default-Start: 2 3 4 5 # <runlevel numbers> See: https://unix.stackexchange.com/questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot/20360#20360
# Default-Stop:
# Short-Description: <short descr>
# Description: <long descr>
### END INIT INFO
#
...
case "$1" in
start|restart|reload|force-reload)
...
;;
stop)
;;
*)
echo "Usage: $0 {start|stop|restart|reload|force-reload}"
exit 1
esac
exit 0
2. Use /usr/sbin/update-rc.d to correctly do the symlinking in the various runlevel sub-directories (/etc/rc*.d/)
From: https://unix.stackexchange.com/questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot#comment27760_20360
- (2804)How to show a GUI message box from a bash script in linux?
A] OLD SCHOOL / Always working
xmessage -default Ok -nearmouse "Is xmessage enough for the job ?" -timeout 10
B] For specific desktop managers
gxmessage "my text"
kdialog "my text" [TO VERIFY]
zenity --info --text="Calculation complete"
echo My text | yad --text-info --width=400 --height=200
shellgui
xdialog
gtkdialog
C] For a beautiful system notification
notify-send "My name is bash and I rock da house"
D] Terminal only
whiptail --msgbox "my text" 10 20 [USED DURING KERNEL/UPDATES]
dialog --msgbox "my text" 10 20
From: https://stackoverflow.com/questions/7035/how-to-show-a-gui-message-box-from-a-bash-script-in-linux/21408784#21408784
- (2813)How can I deactivate Bluetooth on system startup?
Edit /etc/rc.local and add these lines:
#!/bin/sh
rfkill block bluetooth
exit 0
The problem is that when blueman-applet is installed bluetooth is often re-enabled somewhere later in the boot process (by systemd? blueman?).
SOLUTION:
gsettings set org.blueman.plugins.powermanager auto-power-on false
From: https://askubuntu.com/questions/67758/how-can-i-deactivate-bluetooth-on-system-startup
- (2814)How to display Date and Time for each command in Bash History?
In ~/.bash_profile, add:
HISTTIMEFORMAT="%d/%m/%y %T "
Then, using history, you'll get Date & Time printed before each entry.
From: https://www.cyberciti.biz/faq/unix-linux-bash-history-display-date-time/
- (2817)Ubuntu's unattended-upgrades CheatSheet
- How to tell when unattended upgrades will run today:
The random time is set by a cron job (/etc/cron.daily/apt.compat), and you can read the random time for today by asking systemd:
$ systemctl list-timers apt-daily.timer
NEXT LEFT LAST PASSED UNIT ACTIVATES
Tue 2017-07-11 01:53:29 CDT 13h left Mon 2017-07-10 11:22:40 CDT 1h 9min ago apt-daily.timer apt-daily.service
In this case, you can see that u-u ran 1 hour and 9 minutes ago.
- How to tell if unattended upgrades are still running:
One easy way is to check the timestamp files for the various apt components:
$ ls -l /var/lib/apt/periodic/
- How to tell which step apt is running right now:
One easy way is to check the u-u logfile.
$ less /var/log/unattended-upgrades/unattended-upgrades.log
**Once the list of packages is logged, DO NOT interrupt apt.**
From: https://askubuntu.com/questions/934807/unattended-upgrades-status/934863#934863
- (2838)How to encrypt the whole disk?
NOTE: CANNOT BE DONE AFTER INSTALLATION => DO IT AT INSTALLATION TIME!!!
WARNING: ON MY CURRENT COMPUTER, DOING A DATA-INTENSIVE OPERATION (LIKE COMPRESSING A FILE or RUNNING A VM) ALMOST FREEZES THE COMPUTER :{{{
- Get infos about LUKS slots (==saved keys)
# cryptsetup luksDump /dev/sdaXXX
- Create passphrase/subpassphrase (USAGE: The admin will create a MASTER passphrase at installation time and can add -a few- SLAVE passphrases for the users)
# cryptsetup luksAddKey /dev/sdaXXX
- Backup Key
# cryptsetup luksHeaderBackup --header-backup-file <backup file> /dev/sdaXXX
Thanks LabHC admins
- (2839)A small LVM cheatsheet
== Main concepts/vocabulary
- "Physical Volumes" = actual partition/disk (/dev/sda{,XXX})
=> Use pv* commands to manage them
- "Virtual Groups" = description of how you group actual partitions/disks into Virtual Disks (/dev/vg<group name>)
=> Use vg* commands to manage them
- "Logical Volumes" = virtual partition/disk you create inside your Virtual Groups(/Virutal Disks) (/dev/vg<group name>/<partition name>)
=> Use lv* commands to manage them
From: https://doc.ubuntu-fr.org/lvm#synthese_graphique
== Management of logical volumes
- MAKE LVMs VISIBLE
vgscan
vgchange -ay
- RESIZE (decrease) e.g. /root
lvdisplay
-> lvreduce -L 45G /dev/vgxubuntu/root
- RESIZE (increase) e.g. swap
lvdisplay
-> lvextend -L 9G /dev/vgxubuntu/swap_1
- CREATE e.g. /home
lvdisplay
-> lvcreate -L 186G home vgxubuntu
- enable AUTOMOUNTING at boot. e.g. /home
mount /dev/vgxubuntu/root /mnt/
vi /mnt/etc/fstab
add a line like:
/dev/vgxubuntu/home /home ext4 defaults 0 2
Note: if you enabled LVM because you encrypted your disk, See Tip#2840 for how to decrypt the partition/disk, otherwise vgscan will not see vg/lv.
From: https://doc.ubuntu-fr.org/lvm
https://www.tecmint.com/manage-and-create-lvm-parition-using-vgcreate-lvcreate-and-lvextend/#attachment_19222
https://www.thegeekdiary.com/lvreduce-command-examples-in-linux/
Personal Trial & Error
- (2840)How to decrypt/unlock a LUKS (whole disk encryption) partition?
udiskctl unlock /dev/sda3
Then you're asked to enter your passphrase (or any sub-passphrase)
Creates a /dev/dm-0 entry
See Tip#2838 for managing LUKS key/passphrases
FROM: https://askubuntu.com/questions/63594/mount-encrypted-volumes-from-command-line
- (2847)How to extract files from a split 7zip archive?
Normally you just give the first file to 7zip and it will detect automagically it needs to open the remaining files (if they are named correctly).
Otherwise:
7z x <first file>.001 -tsplit -o <output dir>
From: https://askubuntu.com/questions/134227/how-to-extract-files-from-a-split-7zip-archive#comment-1159782
- (2848)How to compress only files using 7z, without preserving the path?
Just add a dot before the path:
7z a -tzip -r myzip.zip ./relative/dir/*.*
From: https://stackoverflow.com/questions/10753667/compressing-only-files-using-7z-without-preserving-the-path#13051179
- (2861)How to protect Grub Editing with password?
1. Backup your Grub config:
cp /boot/grub/grub.cfg /boot/grub/old.grub.cfg
I] Temporary solution (until Grub recreates the config file)
1. Clear-text password (BAAAAAD!)
--- /boot/grub/grub.cfg ---
...
#Password
set superusers = "justegeek"
password justegeek justegeek
2. Hashed password (BETTER!)
a. Create Hash
grub-mkpasswd-pbkdf2
b. --- /boot/grub/grub.cfg ---
#Password
set superusers = "justegeek"
password_pbkdf2 justegeek grub.pbkdf2.sha512..xxxx # value returned by above command
II] Permanent solution
1. --- /etc/grub.d/00_header ---
cat << EOF
#Password
set superusers = "justegeek"
password_pbkdf2 justegeek grub.pbkdf2.sha512..xxxxx
EOF
2. $ update-grub
From: https://www.justegeek.fr/proteger-ledition-du-grub-avec-mot-de-passe/
https://help.ubuntu.com/community/Grub2/Passwords
- (2885)How to find the PID of the process that uses/has opened a given file?
SOLUTION1:
fuser /path/to/opened/file
SOLUTION2:
lsof /path/to/opened/file
SOLUTION3:
ls -o /proc/*/fd 2> /dev/null
From: https://unix.stackexchange.com/questions/423938/how-to-use-find-command-to-get-the-pid-of-file-and-where-its-located
- (2888)How to copy a folder keeping owners and permissions intact?
sudo cp -a /home/my_home/ /media/backup/my_home/
sudo cp -r --preserve=all /home/my_home/ /media/backup/my_home/
sudo rsync -a /home/my_home/ /media/backup/my_home/
Also see Tip#2731
From: https://unix.stackexchange.com/questions/43605/how-do-i-copy-a-folder-keeping-owners-and-permissions-intact/43608#43608
- (2894)How to preserve Symbolic links with tar command?
The documentation says we have to use the "-h" option:
# man tar
-h, --dereference
follow symlinks; archive and dump the files they point to
But how? It's not that easy to understand. Indeed: it's not at compression time, but decompression time that you need to use the option.
COMPRESSION:
You need to compress the directory without "-h" argument as you can see below
[root@test home]# tar -cvzf test.tar.gz test/
DECOMPRESSION:
While extracting the directory make sure you use "-h" argument to save the symlinks as they were while compressing
[root@test tmp]# tar -xhvzf test.tar.gz
From: https://www.golinuxhub.com/2013/12/how-to-preserve-symbolic-links-with-tar.html
- (2895)How to preserve Symbolic links with cp command?
It can be done with -P or -d.
# cp -dav /tmp/src_files/* /tmp/dst_files/ # "a" preserves rights, "v" is verbose
# cp -Prv /tmp/src_files/* /tmp/dst_files/
From: https://www.golinuxhub.com/2016/09/how-to-preserve-symbolic-link-while.html
- (2906)How to send sound through the network?
ssh user@remote_host "rec -t ogg -p" | play -p
From: https://www.limejack.org/doku.php/tooltips/sox
- (2907)How to draw a spectrogram from a sound file?
sox bike.ogg -n spectrogram -o bike-spectrogram.png
From: https://www.limejack.org/doku.php/tooltips/sox
- (2933)What is a POSIX timestamp?
It's simply the time expressed as the number of seconds that have passed since January 1, 1970. That zero moment, known as the epoch, is simply the start of the decade in which the Unix operating system (which first used this time representation) was invented.
From: https://teamtreehouse.com/community/what-is-a-posix-timestamp-im-looking-for-its-definition-the-documentation-doesnt-explain-the-concept-behind-it
https://en.wikipedia.org/wiki/Unix_time
- (2937)What to do if Evince is not allowed to open links from a PDF?
Add the following to /etc/apparmor.d/local/usr.bin.evince:
/usr/bin/exo-open ixr,
Then do:
sudo apparmor_parser -r /etc/apparmor.d/usr.bin.evince
From: https://bugs.launchpad.net/ubuntu/+source/evince/+bug/987578/comments/2
https://bugs.launchpad.net/ubuntu/+source/evince/+bug/987578/comments/13
- (2938)How to make sox work with mp3 (e.g. make "rec toto.mp3" work)?
sudo apt-get install libsox-fmt-mp3
From: https://nickhumphreyit.blogspot.com/2012/02/sox-fail-formats-no-handler-for-file.html
- (2951)How to reload udev rules without rebooting?
# udevadm control --reload-rules && udevadm trigger
https://unix.stackexchange.com/questions/39370/how-to-reload-udev-rules-without-reboot/39371#39371
- (2952)How to debug udev rules?
1. create a "shadow" debugging rule:
# Shadow rule:
ACTION=="add", KERNEL=="sdb*", RUN+="/bin/sh -c 'echo == >> /home/user/Desktop/udev-env.txt; env >> /home/user/Desktop/udev-env.txt'"
#ACTION=="add", KERNEL=="sdb*", RUN+="/usr/bin/mount /dev/sdb1 /media"
Note: udev-env.txt is created then the rule is triggered anyway. Line == corresponding to one matching node. The ENV recorded in that file could be mixture between 2 node or more, created almost in same time, it's a stdout buffering problem.
2. Use udevadm monitor -u, udevadm test ... and udevadm trigger ... to verify which rules processed the events.
From: https://unix.stackexchange.com/questions/200194/how-to-debug-an-udev-rule-in-etc-udev-rules-d/207712#207712
- (2953)How to permanently assign a different keyboard layout to a USB keyboard?
--- /etc/udev/rules.d/99-usb-kbd.rules
ACTION=="add", ATTRS{idVendor}=="04d9", ATTRS{idProduct}=="2323", ENV{XKBMODEL}="pc104", ENV{XKBLAYOUT}="us", ENV{XKBVARIANT}="euro", ENV{XKBOPTIONS}="compose:caps"
---
You can find out idVendor and idProduct of your device using lsusb or evtest
Also see Tip#2701
From: https://askubuntu.com/questions/337411/how-to-permanently-assign-a-different-keyboard-layout-to-a-usb-keyboard/809398#809398
- (2975)How to force firwmware update in CLI in Ubuntu?
sudo apt update && sudo apt upgrade -y
sudo service fwupd start
sudo fwupdmgr refresh
sudo fwupdmgr update --force
From: https://itsfoss.com/update-firmware-ubuntu/
- (2981)How to get a list of installed packages in Ubuntu?
dpkg --get-selections > ~/$(date '+%Y_%m')_installed_packages.list
From: https://askubuntu.com/questions/327370/get-list-of-installed-packages
- (2991)How to solve error "Image Resize Error libgomp: Thread creation failed: Resource temporarily unavailable" from ImageMagick?
SOLUTION1:
add -limit thread 1 to your command-line
SOLUTION2:
set the MAGICK_THREAD_LIMIT environment variable
SOLUTION3:
set the threads policy in /etc/ImageMagick-6/policy.xml
From: https://www.imagemagick.org/discourse-server/viewtopic.php?t=26232
- (2992)How to solve error "DistributedPixelCache" / "cache resources exhausted" from ImageMagick?
SOLUTION1:
-limit memory 80MB
SOLUTION2:
increase the memory limit in /etc/ImageMagic-6/policy.xml
From: https://github.com/ImageMagick/ImageMagick/issues/396
- (2997)How to configure/localize/remove the default folders (Desktop, Downloads, Pictures, Templates...) in Gnome/XFCE?
SOLUTION1: Use the CLI
xdg-user-dirs-update
SOLUTION2: Edit files manually:
--- ~/.config/user-dirs.dirs
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOCUMENTS_DIR="$HOME/Documents"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_MUSIC_DIR="$HOME/Music"
XDG_PICTURES_DIR="$HOME/Pictures"
XDG_PUBLICSHARE_DIR="$HOME/Public"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_VIDEOS_DIR="$HOME/Videos"
---
From: https://wiki.archlinux.org/index.php/XDG_user_directories
https://www.youtube.com/watch?v=VOSbgmg_fPU
- (2998)A script to read aloud whatever text selected in whatever application under linux
--- ~/Softs/READER.us (to be copied in /tmp/READER to switch to US reading)
export READ_SPEED=1.6
export READ_LANG=en-US
--- ~/Softs/READER.fr (to be copied in /tmp/READER to switch to FR reading)
export READ_SPEED=1.6
export READ_LANG=fr-FR
--- Softs/read_xselection.sh
#!/usr/bin/env bash
# Associate this script with xbinkeysrc or XFCE or i3 to CTRL-F9 or anything free key combo!
######
###### If key combo does nothing: pipe is stuck, waiting for xsel input => pkill -9 xsel
######
export DISPLAY=:0
export XAUTHORITY=$HOME/.Xauthority
## apt install libttspico-utils
## apt install mplayer # we could use sox to change the rate (but pitch would change too)
# Assign a value to these vars if they are not defined
: ${READ_LANG:="fr-FR"} # "en-US"
: ${READ_SPEED:="1.6"}
FIFO=/tmp/test2.wav
MAX_VOL="150"
if [[ -e /tmp/READER ]]; then
. /tmp/READER
fi
mkfifo "$FIFO"
text=$(timeout .5 xsel | sed 's/[^[[:print:]]]//g' | sed 's/[[:space:]][[:space:]]*/ /g' | sed '/^\s*$/d' | sed -r 's/[[][^]]*[]]//g')
echo $text
pico2wave -w "$FIFO" -l ${READ_LANG} " ${text}" & mplayer -softvol -softvol-max $MAX_VOL -af scaletempo -speed ${READ_SPEED} "$FIFO" # -volume 100 -af volume=30:0
\rm -f "$FIFO"
- (3007)How to graphically debug an executable?
Install nemiver, it's a GUI to gdb, it's very powerfull yet usable
From: https://wiki.gnome.org/Apps/Nemiver
- (3010)How to solve error 'CV_WINDOW_AUTOSIZE' was not declared in this scope in OpenCV?
SOLUTION1: include the right header file
#include <opencv2/highgui/highgui.hpp>
SOLUTION2: do not use this deprecated value, but the modern ones:
- WINDOW_AUTOSIZE instead, which is part of the C++ API
- Use namedWindow("Display Image"), without any 2nd arg, as it uses above value by default
From: https://stackoverflow.com/questions/18682201/opencv-where-can-i-find-cv-window-autosize-constants
- (3059)How to drastically reduce the size of a video with (e.g. a presentation with audio)?
You can recompress your video with codec libx264:
ffmpeg -i <inputvid> -preset <preset> -c:v libx264 -tune <tune> -hide_banner -c:a aac <outputvid>.mp4
preset can be (choice depends mostly on your hardware and time you want to spend re-encoding the video): ultrafast, superfast, veryfast, *faster*, fast, medium (default),
slow, slower, veryslow
tune can be:
- film – use for high quality movie content; lowers deblocking
- animation – good for cartoons; uses higher deblocking and more reference frames
- grain – preserves the grain structure in old, grainy film material
- *stillimage* – good for slideshow-like content
- fastdecode – allows faster decoding by disabling certain filters
- zerolatency – good for fast encoding and low-latency streaming
For a presentation (slides + audio) on a slow machine I used preset:faster & tune:stillimage
From: https://trac.ffmpeg.org/wiki/Encode/H.264
- (3062)How do you reset a USB device from the command line?
CLEAN SOLUTION 1: reset the problematic device
sudo sh -c "echo 0 > /sys/bus/usb/devices/<xxx>/authorized"
sudo sh -c "echo 1 > /sys/bus/usb/devices/<xxx>/authorized"
You can find the <xxx> number with:
for X in /sys/bus/usb/devices/*; do
echo "$X"
cat "$X/idVendor" 2>/dev/null
cat "$X/idProduct" 2>/dev/null
echo
done
BRUTAL SOLUTION 1: reset the whole usb ports/hubs (all of them!)
for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do
[ -e "$i" ] || continue
echo "${i##*/}" > "${i%/*}/unbind"
echo "${i##*/}" > "${i%/*}/bind"
done
BRUTAL SOLUTION 2: idem
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/unbind
echo -n "0000:00:1a.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
echo -n "0000:00:1d.0" | tee /sys/bus/pci/drivers/ehci_hcd/bind
BRUTAL SOLUTION 3: remove the USB driver modules
#!/bin/bash
# USB drivers
rmmod xhci_pci
rmmod ehci_pci
# uncomment if you have firewire
#rmmod ohci_pci
modprobe xhci_pci
modprobe ehci_pci
# uncomment if you have firewire
#modprobe ohci_pci
From: https://askubuntu.com/questions/645/how-do-you-reset-a-usb-device-from-the-command-line
- (3063)How to make an USB3 device/port work in USB2 mode?
It involves changing configuration registers in the xHCI controller, so it's obviously chipset-specific. This is how it's done on Linux [for Intel chipsets?].
To set both ports to USB 2.0 mode:
sudo setpci -H1 -d 8086:1e31 d8.l=0
Right port 3.0 and left port 2.0:
sudo setpci -H1 -d 8086:1e31 d8.l=1
Right port 2.0 and left port 3.0:
sudo setpci -H1 -d 8086:1e31 d8.l=2
Changing the register at d8 (USB3_PSSEN) sets the ports in USB 2.0 mode, but they are still on the xHCI controller. To switch over to EHCI, you also have to change the register at d0 (XUSB2PR). For example to run both ports off the EHCI contoller you have to do this:
sudo setpci -H1 -d 8086:1e31 d8.l=0
sudo setpci -H1 -d 8086:1e31 d0.l=0
The registers are documented in the following datasheet, in section 17.1.
http://www.intel.com/content/www/us/en/chipsets/7-series-chipset-pch-datasheet.html
From: https://superuser.com/questions/812022/force-a-single-usb-3-0-port-to-work-as-usb-2-0/875863#875863
- (3080)How to print using an "Account Number" on Sharp MX26XX printers with the PPD?
1. Download the PPD for your model. e.g.:
https://www.openprinting.org/printer/Sharp/Sharp-MX-2640N
2. Add the following lines at the end of the PPD
*% **** Account number
*JCLOpenUI *JCLMXaccount/numero: PickOne
*OrderDependency: 80 JCLSetup *JCLMXaccount
*DefaultJCLMXaccount: A#####
*JCLMXaccount A#####/#####: "@PJL SET ACCOUNTNUMBER=<22>#####<22><0A>"
*JCLCloseUI: *JCLMXaccount
Replace ##### with your "User number".
3. Reconfigure the printer to use this PPD file.
From: https://ubuntuforums.org/showthread.php?t=928892&s=bc1bce8dfd8afdba099e0c18fd59578b&p=8233340#post8233340
- (3095)How to use a phone or tablet as mousepad?
SOLUTION1:
http://www.remotedroid.net/ (2010 !!!)
SOLUTION2:
BlueputDroid (requires root + display ads :{)
AnyRemote (https://sourceforge.net/projects/anyremote)
From: https://askubuntu.com/questions/281149/how-can-i-use-my-phone-or-tablet-as-mousepad
- (3103)How to execute a mount --bind as a user?
bwrap --ro-bind / / \
--bind {EXTERNAL-DIR} {MOUNTPOINT-DIR} \
bash
From: https://stackoverflow.com/questions/86402/how-can-i-get-git-to-follow-symlinks/63645471#63645471
- (3110)How to create a USB file able to boot ISOs directly?
Use Ventoy!!!
From: https://framalibre.org/content/ventoy
- (3120)How to install Linux Mint on a non-pae-CPU computer?
SOLUTION1: if using VirtualBox, VM Config > System > check "Enable PAE/NX"
SOLUTION2: on actual computer, add "force pae" in the kernel boot options
From: https://askubuntu.com/questions/117744/how-can-i-install-on-a-non-pae-cpu-error-kernel-requires-features-not-present/185743#185743
https://forums.linuxmint.com/viewtopic.php?t=193426
- (3122)How to get full information about your computer (e.g. for use in a bug report)
inxi -Fxz
From: https://forums.linuxmint.com/viewtopic.php?t=193426
- (3123)How to make the changes to the kernel options permanent?
When you are booting a LiveCD/USB, you can change the options to the linux kernel using Grub's 'e' (=edit) option on any boot "line".
What is interesting to know is that options BEFORE the -- are for the Live/running kernel and options AFTER the -- are for the kernel that will be installed.
menuentry 'Linux' --class gnu-linux --class gnu --class os {
...
linux /vmlinuz-5.4.0-47-generic root=/dev/mapper/vgxubuntu-root ro quiet splash <live-kernel options> -- <installed-kernel options>
...
}
force pae (here)
nomodeset (see Tip#1669)
noapic acpi=off (see Tip#3124)
From: https://askubuntu.com/questions/117744/how-can-i-install-on-a-non-pae-cpu-error-kernel-requires-features-not-present/117751#117751 (Workaround 4)
- (3124)How to disable ACPI on boot (e.g. on a machine with faulty acpi tables)?
Edit /boot/grub/grub.conf or edit Grub's config live by hitting 'e' on a menu entry and add "noapic acpi=off" to the kernel options:
....
kernel /vmlinuz-2.6.18-194.el5 ro root=/dev/xxx rhgb quiet noapic acpi=off
....
From: https://access.redhat.com/solutions/58790
- (3128)How to find what filesystem fuse is using?
lsblk -no name,fstype
From: https://unix.stackexchange.com/questions/332712/how-do-i-find-out-what-filesystem-fuse-is-using#435596
- (3137)How to defrag a NTFS partition from Linux?
UltraDefrag is a powerful Open Source Defragmentation tool for the Windows Platform. It can defragment any system files including registry hives and paging file. Also one of the main goals of UltraDefrag is doing the job as fast and reliable as possible.
It has been ported to Linux and NTFS-3G for defragmenting NTFS partitions. Currently only a test version in console mode is available.
From: https://jp-andre.pagesperso-orange.fr/advanced-ntfs-3g.html
- (3139)How to run a script after each resume?
# file: /lib/systemd/system-sleep//00_restart_xxx.sh
#!/bin/sh
case "$1" in
pre)
<script to run before sleep>
;;
post)
<script to run after resume>
;;
esac
From: https://askubuntu.com/questions/92218/how-to-execute-a-command-after-resume-from-suspend/1247110#1247110
- (3154)How to download only recent videos from a YT channel?
From the youtube-dl man page:
--date DATE
Download only videos uploaded in this date
--datebefore DATE
Download only videos uploaded on or before this date (i.e. inclusive)
--dateafter DATE
Download only videos uploaded on or after this date (i.e. inclusive)
From: https://askubuntu.com/questions/811143/download-videos-from-youtube-playlist-or-user-based-on-date/813426#813426
- (3155)How to access/mount NextCloud Dirs/Public Shares from linux?
In GUI: Nautilus, Thunar, ...
In CLI: davfs2
- For personnal directories, use the following URL:
davs://example.com/nextcloud/remote.php/dav/files/USERNAME/
- For Public Shares, use the following URL:
{davs,https}://example.com/nextcloud/public.php/webdav
+ username : share token (random string in the URL)
+ password: (optional) share password
From: https://docs.nextcloud.com/server/15/user_manual/files/access_webdav.html#accessing-public-shares-over-webdav
- (3159)How to swap two (adjacent) rows/columns in Gnumeric?
- Select both rows/columns (using the Shift key or by dragging the mouse - don't use the Ctrl key)
- Copy
- Right-click > Paste Special
- In Region operation, choose Flip Vertically
From: https://superuser.com/questions/306449/swap-rows-in-gnumeric
- (3185)How to change where a symlink points?
The most secure solution is to delete the link and recreate it.
Another solution is to use
ln -sfn /path/to/actual/files name-of-link
where :
-f : force the (re)creation of the link
-n : if you are linking to a folder, prevents from creating a link inside the target "name-of-link folder"
From: https://unix.stackexchange.com/questions/151999/how-to-change-where-a-symlink-points
- (3188)How to duplicate an install (a.k.a. How to re-install the exact same packages as another machine)?
1. On source machine
dpkg --get-selections > /tmp/dpkg-selections
2. put the file on the target machine
3. On the target machine
dpkg --set-selections < /path/to/dpkg-selections
apt-get dselect-upgrade
From: https://help.ubuntu.com/community/ReinstallingSamePackages
- (3193)How many (Modifier) keys can be hit at the same time?
If you are using an USB keyboard:
USB protocol limitation - A max of 10 simultaneous key presses are recognized, 6 non-modifier keys ('w', 'a', 's', 'd', etc) + 4 modifier keys (Shift, Caps, Ctrl, etc).
From: https://askubuntu.com/questions/264113/how-many-different-modifier-keys-can-we-have-on-a-keyboard/278941#278941
https://blog.controlspace.org/2010/08/n-key-rollover-what-it-is-and-how-to.html
- (3199)How to auto-log out from console after given timeout (if no activity)?
# echo 'TMOUT=120' >> /etc/profile
From: https://www.tecmint.com/tmout-auto-logout-linux-shell-idle-sessions/
- (3200)How to use a GUI to schedule tasks (a.k.a. What is a good GUI to cron & at)?
Zeit (https://github.com/loimu/zeit) is a Qt GUI for cron and at,
There are even Basic & Advanced mode, and documentation in hint popup...
# stable releases
sudo add-apt-repository ppa:blaze/main
sudo apt update
sudo apt install zeit
From: https://www.linuxuprising.com/2020/10/schedule-commands-and-scripts-in-linux.html
- (3205)How to draw a spectrogram from a sound file?
sox music.wav -n spectrogram -o spectro.png
From: https://www.youtube.com/watch?v=k1TRq5lk0Sg
- (3213)How to install useful software without snap (a.k.a. How to install Chromium, KeepassXC, Eclipse, IDEA in Linux Mint)?
- For KeepassXC: use ppa
add-apt-repository ppa:phoerious/keepassxc
From: https://keepassxc.org/blog/2017-10-25-ubuntu-ppa/
- For i3-gaps
add-apt-repository ppa:regolith-linux/release
apt update
apt install i3-gaps
From: https://github.com/Airblader/i3/wiki/installation#ubuntu
- For Chrome/Chromium: use ppa
add-apt-repository ppa:phd/chromium-browser1
echo '
Package: *
Pin: release o=LP-PPA-phd-chromium-browser
Pin-Priority: 1001
' | tee /etc/apt/preferences.d/phd-chromium-browser # to prevent installation from snap
From: https://doc.ubuntu-fr.org/chromium-browser#depuis_un_ppa
(UNMAINTAINED https://github.com/ungoogled-software/ungoogled-chromium-debian)
- For Wine
wget -nc https://dl.winehq.org/wine-builds/winehq.key && sudo apt-key add winehq.key
sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu/ focal main"
From: https://www.numetopia.fr/comment-installer-wine-sur-ubuntu-ou-linux-mint/
- For VirtualBox
wget -q -O- http://download.virtualbox.org/virtualbox/debian/oracle_vbox_2016.asc | apt-key add -
echo "deb http://download.virtualbox.org/virtualbox/debian focal contrib" | sudo tee -a /etc/apt/sources.list.d/virtualbox.list
From: https://www.skyminds.net/linux-installer-virtualbox-via-le-ppa-doracle/
https://forums.virtualbox.org/viewtopic.php?t=77492
- For R:
apt-get purge r-base* r-recommended r-cran-*
apt autoremove
apt update
add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
apt install r-base r-base-core r-recommended r-base-dev
From: https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/
- For VSCodium
wget -qO - https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/raw/master/pub.gpg | gpg --dearmor | sudo dd of=/usr/share/keyrings/vscodium-archive-keyring.gpg
echo 'deb [ signed-by=/usr/share/keyrings/vscodium-archive-keyring.gpg ] https://download.vscodium.com/debs vscodium main' | sudo tee /etc/apt/sources.list.d/vscodium.list
From: https://vscodium.com/#install
- For Eclipse: install from binaries - as user
https://www.eclipse.org/downloads/download.php
https://www.itzgeek.com/how-tos/linux/linux-mint-how-tos/how-to-install-eclipse-ide-on-linux-mint-19.html
- For IDEA: install from binaries - as user
https://www.jetbrains.com/idea/download/#section=linux
- (3216)How can I use aliased commands with xargs?
SOLUTION1:
alias gi='grep -i'
find -name \*bar\* | xargs bash -ic gi foo
SOLUTION2: if filenames have spaces/protected chars
alias gi='grep -i'
find -name \*bar\* | xargs -I{} bash -ic "gi foo {}"
SOLUTION3:
alias grep='grep -i'
find -maxdepth 1 -name ".bashrc" | xargs grep name # grep alias not expanded
### no matches found ###
alias xargs='xargs ' # create an xargs alias with trailing space
find -maxdepth 1 -name ".bashrc" | xargs grep name # grep alias gets expanded
### Name : .bashrc
Example: you want to play videos in reverse order, but "mplayerF" is an alias
alias mplayerF='mplayer -vo x11'
find . -maxdepth 1 -mindepth 1 -name '*.mp4' | sort | tac | sed -r 's/^(.*)$/"\1"/g' | tr '\n' ':' | xargs -d':' -I{} bash -ic "mplayerF {}" # TODO: works only for the first entry
From: https://stackoverflow.com/questions/979453/how-can-i-use-aliased-commands-with-xargs#979657
For solution3:
man alias : A trailing space in VALUE causes the next word to be checked for alias substitution when the alias is expanded.
- (3220)How/Where to find online services like those of Framasoft?
https://entraide.chatons.org/en/
- (3225)How to determine the size of a package prior to downloading using apt?
apt-cache --no-all-versions show $package | grep '^Size: '
From: https://askubuntu.com/questions/35956/how-to-determine-the-size-of-a-package-while-using-apt-prior-to-downloading#35957
- (3226)How to set the date from a time server when behind a proxy (a.k.a. How to set date on Http instead of ntpdate/UDP)?
Assuming environment variable http_proxy is already set:
sudo date -s "$(curl -H'Cache-Control:no-cache' -sI google.com | grep '^Date:' | cut -d' ' -f3-6)Z"
There's also a tool: htpdate http://www.vervest.org/htp/
From: https://superuser.com/questions/307158/how-to-use-ntpdate-behind-a-proxy/807326#807326
- (3227)How to create an alias for a command that needs arguments?
It's not possible, but you can easily define functions in your .bashrc:
function dif () { diff "$1" "$2" | less; }
From: https://unix.stackexchange.com/questions/294573/aliasing-command-which-takes-argument-with-using-pipe
- (3228)How to make sure .bashrc is loaded from login shells?
Because of a design defect in bash, .bashrc is not read by login shells even if they're interactive, so you should put this line in your .bash_profile:
-- .bash_profile
if [[ $- == *i* ]]; then . ~/.bashrc; fi
- (3231)My .bashrc @TSE2020
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
## GM: always use colors if available + change color for root
colors=$(tput colors)
if (($colors >= 256)); # Terminal supports 256 colours
then
# ESC[ … 38;2;<r>;<g>;<b> … m Select RGB foreground color
color_root='\[\e[1m\e[38;5;196m\]'
color_user='\[\e[1m\e[38;5;220m\]' # 245 = grey / 21 = blue / 126 = magenta / 220 = yellow / 40 = green / 51 = lightblue
color_undo='\[\e[0m\]'
elif (($colors >= 8)); then # Terminal supports only eight colours
color_root='\[\e[1;31m\]'
color_user='\[\e[1;32m\]'
color_undo='\[\e[0m\]'
else # Terminal may not support colour at all
color_root=
color_user=
color_undo=
fi
if ((EUID == 0)); then
PS1="[\$(date '+%D-%T')] ${color_root}\u${color_undo}@\h:\w# "
else
PS1="[\$(date '+%D-%T')] ${color_user}\u${color_undo}@\h:\W$ "
fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# GM: for more privacy
umask 077
export LOCATE_PATH="$HOME/.mlocate.db"
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
export JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1-2)
export LC_COLLATE=C
alias ls='ls -ahl --color'
alias rm='~/.myrm'
alias mv='mv -i'
alias cp='cp -i'
alias R='R --no-save'
alias bc='bc -l'
alias less='less -r'
alias mg='emacs -nw'
alias cal='ncal -M -3 -b'
alias pdfnup='pdfjam'
alias sudo='sudo -i'
alias su='su -'
xhost local:root + > /dev/null
alias pdf2imgportrait='convert -quality 98 -resize 1240x1753 -extent 1240x1753 -gravity center -units PixelsPerInch -density 150x150 '
alias pdf2imglandscape='convert -quality 98 -resize 1753x1240 -extent 1753x1240 -gravity center -units PixelsPerInch -density 150x150 '
alias img2pdfportrait='convert -quality 98 -resize 1240x1753 -extent 1240x1753 -gravity center -units PixelsPerInch -density 150x150 '
alias img2pdflandscape='convert -quality 98 -resize 1753x1240 -extent 1753x1240 -gravity center -units PixelsPerInch -density 150x150 '
alias vlcF='vlc --audio-time-stretch --rate 1.4'
alias mplayerF='mplayer -af scaletempo -speed 1.4'
alias mplayerM='mplayer -shuffle'
PROXY="http_proxy=$http_proxy https_proxy=$https_proxy"
alias megals="$PROXY megals"
alias megadf="$PROXY megadf"
alias megamkdir="$PROXY megamkdir"
alias megaput="$PROXY megaput"
alias megaget="$PROXY megaget"
alias megacopy="$PROXY megacopy"
alias git="$PROXY git"
alias impressive="impressive --time-display"
## Use T to display timer / R to reset timer
## Use F to enter/exit fullscreen
## Use ESC/q to exit
# impressive -d 10:00 xxx.pdf # --tracking -f -g 800x600 -L margin=16,alpha=1,time=BR,title=BL,page=BR,status=TL
# Can't use an alias if arguments are needed => use functions!!!
function a2pdf () { # cups-pdf met dans ~/stdin.pdf => choix possible ?
if [[ $# != 1 && $# != 2 ]]; then echo "USAGE: $0 <in_file.text> <a2ps_args> # outfile is ~/stdin.pdf"; fi
iconv -c -f utf-8 -t ISO-8859-1//TRANSLIT "$1" | a2ps -Ppdf -1 "$2";
}
function clean_emacs_packages () {
emacs -q -batch -l ~/.emacs.d/config.el -f package-autoremove -kill
}
function upgrade_emacs_packages () {
emacs -q -batch -l ~/.emacs.d/config.el -f package-list-packages -f package-menu-mark-upgrades -f package-menu-execute -kill
}
function upgrade_R_packages () {
echo 'update.packages(lib.loc="~/.R/x86_64-pc-linux-gnu-library/3.6/", ask=F)' | R
}
function upgrade_Python_packages() {
cd ~/Python
for dir in $(find . --maxdepth 1 -- mindepth 1 -type d)
do
cd $dir
./bin/activate
. ../upgrade_all_packages.sh
deactivate
cd -
done
}
source ~/.i18n
# adding Softs in PATH
for dir in ~/.cargo/bin $(find ~/Softs/ -maxdepth 1 -mindepth 0 -type d)
do
PATH=$dir:$PATH
done
export PATH
calendar -A3 -B3 -f ~/Softs/.dates_naissances
- (3234)How to slow down file copy (e.g. for bad USB keys)?
SOLUTION1: with pv
cat inputfile | pv -q -L 3k > outputfile # for files
tar -cf - indir | pv -q -L 3k | tar -C outdir -xvf - # for dirs
SOLUTION2: with rsync
rsync -av --bwlimit=1.5m --progress /foo /bar
SOLUTION3: with ssh
scp -l 8192 `# in k*bits*` infile outfile # (BEWARE: might not work as expected with symlinks!)
SOLUTION4: with trickle ?
tar -cf - indir | trickle -d 20 `#dwl in kB` -u 20 `#upload in kB` ssh localhost "tar -C outdir -xvf -"
From: https://unix.stackexchange.com/questions/117680/make-disk-disk-copy-slower#comment183728_117680
https://serverfault.com/questions/57519/can-i-limit-my-ssh-tunneling-speed/57521#57521
https://wiki.archlinux.org/index.php/Trickle
- (3238)How to echo the command line executed at the command line itself (not in a script)?
SOLUTION1: with bash buildin tools
set -x
SOLUTION2: with script
script output.log
...
exit
cat output.log
SOLUTION3: hand made commands
echo_command() { printf '%s\n' "${*}"; "${@}"; } # does not take into account redirections
echo_command() { # manages redirections
local arg
for arg; do
printf 'Command line: %s\n' "${arg}"
eval "${arg}"
done
}
From: https://unix.stackexchange.com/questions/459697/bash-echo-the-command-line-executed-at-the-command-line-itself-not-in-a-script
- (3318)How to ensure that a command does not hang (a script that calls it) for too long?
PROBLEM:
Let's say you call a command like "xclip" or "xsel" or "scrot" that might hang for some reason (waiting for user inputs, etc), but you do not want the calling script to be hanged for too long. How can you automatically kill the the command when it takes too long?
SOLUTION:
Just prefix your command with
timeout <max_duration> <command & args>
max_duration is a floating point number with an optional suffix:
- 's' for seconds (the default)
- 'm' for minutes
- 'h' for hours
- 'd' for days
From: https://emacs.stackexchange.com/questions/39019/xclip-hangs-shell-command/59440#59440
- (3322)How to configure xdg-open/gnome-open/exo-open/gvfs-open/kde-open from CLI?
SOLUTION1: for xdg-open
- To get the mime type of any file:
$ xdg-mime query filetype <file>
- To make the file association:
$ xdg-mime default <desktop file of the App> <mime-type>
- Examples
+ To make Thunar the default file-browser, i.e. the default application for opening folders.
$ xdg-mime default Thunar.desktop inode/directory
+ To use xpdf as the default PDF viewer:
$ xdg-mime default xpdf.desktop application/pdf
This should create the following entry in your local MIME database ~/.config/mimeapps.list
----
[Default Applications]
application/pdf=xpdf.desktop
---
SOLUTION2: For Gnome stuff
2023 NOTE: "gvfs-mime" seems to have been replaced by "gio"
- To find which application is associated to a given mime-type:
$ gvfs-mime --query <mime-type>
- To change the association
$ gvfs-mime --set <mime-type> <desktop file of App>
From: https://unix.stackexchange.com/questions/36380/how-to-properly-and-easy-configure-xdg-open-without-any-environment#59088
https://unix.stackexchange.com/questions/34434/change-default-applications-used-by-gnome-open-exo-open-xdg-open-gvfs-open-an
- (3323)How to create/customize a tmux StatusBar with Bash scripts?
1. Configure tmux:
✂------ ~/.tmux.conf
# Status bar
set -g status on
set -g status-interval 1
set -g status-justify centre # Careful! It is spelled centre not center.
set -g status-style fg=white,bg=black
# Highlight the current window.
setw -g window-status-current-fg white
setw -g window-status-current-bg red
setw -g window-status-current-attr bright
# Status Bar Left side
set -g status-left-length 65
set -g status-left-style default
set -g status-left "#h #( ~/.tmux/left_status.sh )"
# Status Bar Right side
set -g status-right-length 50
set -g status-right-style default
set -g status-right "#( ~/.tmux/right_status.sh )"
✂------
2. Get infos for the left part of the status bar
✂------ ~/.tmux/left_status.sh
#!/bin/bash
function ip_address() {
# Create an empty array.
interface_arr=()
# Loop through the available interfaces.
for i in $(ls -1 /sys/class/net/); do
# Add every interface to the array except for the loopback device.
if [ "$i" != 'lo' ]; then
interface_arr+=($i)
fi
done
# Loop through the array of interfaces. Check to see which interface is up.
for j in ${interface_arr[@]}; do
if [ "$(cat /sys/class/net/${j}/operstate)" == "up" ]; then
local iface="${j}"
else
local iface=""
fi
done
if [ ! -z "$iface" ]; then
# Print the ip address of the interface.
printf "%s " "$(ip addr show $iface | awk '/inet /{print $2}')"
fi
}
function cpu_temperature() {
# Display the temperature of CPU core 0 and core 1.
sensors -f | awk '/Core 0/{printf $3" "}/Core 1/{printf $3" "}'
}
function memory_usage() {
if [ "$(which bc)" ]; then
# Display used, total, and percentage of memory using the free command.
read used total <<< $(free -m | awk '/Mem/{printf $2" "$3}')
# Calculate the percentage of memory used with bc.
percent=$(bc -l <<< "100 * $total / $used")
# Feed the variables into awk and print the values with formating.
awk -v u=$used -v t=$total -v p=$percent 'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}'
fi
}
function vpn_connection() {
# Check for tun0 interface.
[ -d /sys/class/net/tun0 ] && printf "%s " 'VPN*'
}
function main() {
# Comment out any function you do not need.
ip_address
cpu_temperature
memory_usage
vpn_connection
}
# Calling the main function which will call the other functions.
main
✂------
3. Get infos for the right part of the status bar
✂------ ~/.tmux/right_status.sh
#!/bin/bash
function battery_meter() {
if [ "$(which acpi)" ]; then
local fgdefault='#[default]'
if [ "$(cat /sys/class/power_supply/AC/online)" == 1 ] ; then
local charging='+'
else
local charging='-'
fi
# Check for existence of a battery.
if [ -x /sys/class/power_supply/BAT0 ] ; then
local batt0=$(acpi -b 2> /dev/null | awk '/Battery 0/{print $4}' | cut -d, -f1)
case $batt0 in
100%|9[0-9]%|8[0-9]%|7[5-9]%) fgcolor='#[fg=brightgrey]'
;;
7[0-4]%|6[0-9]%|5[0-9]%) fgcolor='#[fg=brightgreen]'
;;
4[0-9]%|3[0-9]%|2[5-9]%) fgcolor='#[fg=brightyellow]'
;;
2[0-4]%|1[0-9]%|[0-9]%) fgcolor='#[fg=brightred]'
;;
esac
# Display the percentage of charge the battery has.
printf "%s " "${fgcolor}${charging}${batt0}%${fgdefault}"
fi
fi
}
function load_average() {
printf "%s " "$(uptime | awk -F: '{printf $NF}' | tr -d ',')"
}
function date_time() {
printf "%s" "$(date +'%Y-%m-%d %H:%M:%S %Z')"
}
function main() {
# Comment out any function you do not need.
battery_meter
load_average
date_time
}
# Calling the main function which will call the other functions.
main
✂------
From: https://dev.to/brandonwallace/make-your-tmux-status-bar-100-better-with-bash-2fne
- (3341)How to update an old PV header in a LVM drive?
PROBLEM: Mounting a LVM partition, you get "WARNING: PV /dev/sdaX in VG ubuntu-vg is using an old PV header, modify the VG to update" error.
SOLUTION:
sudo vgck --updatemetadata ubuntu-vg
From: https://askubuntu.com/questions/1299499/warning-pv-dev-sda3-in-vg-ubuntu-vg-is-using-an-old-pv-header-modify-the-vg-t/1299628#1299628
- (3366)How to (re)generate the locales (a.k.a. How to solve "warning: setlocale: LC_ALL: cannot change locale")?
SOLUTION1: all locales / permanent
# echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
# echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen
#...
# locale-gen
SOLUTION2: a single locale
# locale-gen fr_FR.UTF-8
SOLUTION3: a single locale
# update-locale LANG=fr_FR.UTF-8
From: https://askubuntu.com/questions/114759/warning-setlocale-lc-all-cannot-change-locale#114781
- (3369)A (hacky/simple) alternative to (never working) udev rules?
Use inotify! See Tip#2215 & Tip#3523
- Example for a monitor hotplug:
------- Softs/monitor_autoconfig.sh
#!/usr/bin/env bash
DEVICE=/sys/devices/pci0000:00/0000:00:02.0/drm/card0/
INT_MONITOR=eDP-1
EXT_MONITOR=DP-2
while [ 1 ] ;
do
inotifywait -q -e access "$DEVICE"
connected=$(xrandr | grep "^$EXT_MONITOR" | grep ' connected')
echo "$connected"
if [[ ! -z "$connected" ]]; then
echo "External Plugged IN => Setting dual screen"
. $HOME/Softs/set_screens_labhc.sh
else
echo "External Plugged OUT => Setting single screen"
xrandr --output "$INT_MONITOR" --primary --auto
fi
done
- Example for a keyboard hotplug:
-------- cat Softs/keyboard_autoconfig.sh
#!/usr/bin/env bash
DEVICE=/sys/devices/pci0000:00/0000:00:14.0/usb1/
VENDOR=413C
PRODUCT=2107
while [ 1 ] ;
do
out=$(inotifywait -e open -q $DEVICE)
echo "$out"
if [[ $out =~ " manufacturer" ]]; then
expanded=$(\ls -d $DEVICE/*/*/0003\:$VENDOR\:$PRODUCT.* $DEVICE/*/*/*/0003\:$VENDOR\:$PRODUCT.* | head -n 1)
echo $expanded
if [[ -d $expanded ]]; then
echo "External Plugged IN => Setting 2nd keyboard"
sleep 1
. $HOME/Softs/set_keyboard.sh
fi
fi
done
From:
- (3370)How to prevent files from accidental deletion (a.k.a. prevent damages from "rm -fr *")?
SOLUTION1: Make file immutable with chattr => you'll not be able to change/edit the file
sudo chattr +i <very important file>
SOLUTION2: Simulate a Trash bin AND NEVER USE '\rm' again!!!
See Tip#88
SOLUTION3: Install a dedicated software solution, like:
https://github.com/alanzchen/rm-protection
- (3394)How to prevent emptying a file when redirecting to it after executing some commands on it?
PROBLEM:
If you do something like
grep -v '^#' cities.txt | sponge cities.txt
i.e. redirect output into the original file, the original content is lost :{
SOLUTION: use "sponge" command (from moreutils package) instead of redirecting
grep -v '^#' cities.txt | sponge cities.txt
It does everything in memory before writing to the output file, thus not opening file in read & write mode at the same time, thus not emptying the original file.
BEWARE: this might be memory intensive!!!
From: https://www.putorius.net/linux-sponge-soak-up-standard-input-and-write-to-a-file.html
- (3396)How to display the Glyphs from FontAwesome?
- You can use a tool like GnuCharMap
- Then select FontAwesome in the Font list
- View > By Unicode Block
- View > Show only glyphs from this font
Then in the left panel select the "blocks" that you are interested in, like "...Symbols...", "...Emoticons...", etc.
Then on the right panel in "Character Details" panel you can get the char name (which can be used e.g. to insert in Emacs, See Tip#3180).
From: https://askubuntu.com/questions/700229/how-can-i-display-font-awesome-fonts-in-character-map
- (3414)How to find the uptime since last wake from standby?
journalctl -b 0 | grep \"PM: suspend\"
From: https://superuser.com/questions/357275/how-to-find-the-uptime-since-last-wake-from-standby
- (3420)What is the best way to store Linux configuration files (dot files)?
SOLUTION1: git bare repository
- Creation
# creates a folder ~/.cfg which is a Git bare repository that will track our files
git init --bare $HOME/.cfg
# creates \"config\" alias, to be used instead of git when interacting with the configuration repository
echo \"alias config=\'/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME\'\" | tee eval &gt;&gt; ~/.bashrc
# Local flag to hide files we are not explicitly tracking yet
config config --local status.showUntrackedFiles no
- Usage on local machine
config status
config add .vimrc # track a new file
config commit -m \"Add vimrc\" # commit changes to a file
config push # push changes
- Install on a new system
# creates \"config\" alias, to be used instead of git when interacting with the configuration repository
echo \"alias config=\'/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME\'\" | tee eval &gt;&gt; ~/.bashrc
# ignores the local repo folder
echo \".cfg\" &gt;&gt; .gitignore
# clones your dotfiles into a bare repository in a \"dot\" folder of $HOME:
git clone --bare &lt;git-repo-url&gt; $HOME/.cfg
# sets the local configuration
config config --local status.showUntrackedFiles no
# Checkouts the actual content from the bare repository to $HOME:
config checkout
You might encounter the following error, during the last step:
error: The following untracked working tree files would be overwritten by checkout:
.bashrc
.gitignore
Please move or remove them before you can switch branches.
Aborting
This is because your $HOME folder might already have some stock configuration files which would be overwritten by Git. The solution is simple: back up/remove the files, then execute again the *config checkout* step
From: https://www.atlassian.com/git/tutorials/dotfiles
- (3435)How to create a shortcut to a particular directory in the left pane of Thunar?
SOLUTION 1: Drag & Drop
SOLUTION 2: Send to
- Right-click on the folder you want to add as bookmark
- Send to > Side Pane (Create Shortcut)
SOLUTION 3: Editing config file
- "bookmarks" are saved in ~/.gtk-bookmarks file, you can edit it manually
From: https://unix.stackexchange.com/questions/87687/how-to-create-folder-shortcuts-in-file-manager/87691#87691
https://docs.xfce.org/xfce/thunar/the-file-manager-window
- (3459)A simple 'screen' cheatsheet for beginners
- Create a session
screen -S <name>
- List existing sessions
screen -ls
- Re-attach to an existing session
screen -x <name>
- Detach from a running session
C-a d
- Create a new window
C-a c
- Kill current window
C-a k
- Switch to next window
C-a Tab
- Switch to specific window
C-a <int>
- Split screen
C-a S # split horizontally
C-a | # split vertically
See Tip#1145 to save layout (split windows)
From: https://i.pinimg.com/originals/6a/f1/1e/6af11ea87b217f08e382e9cfae6016dc.jpg
- (3468)How to prevent volumes of some applications/streams to become too loud w.r.t others in Ubuntu? [TO VERIFY]
$ cat .config/pulse/daemon.conf
flat-volumes = yes
In firefox :
> about:config page > change the media.volume_scale to 0.1
From: https://askubuntu.com/questions/1257380/inconsistent-sound-volume-ubuntu-20-04
https://wiki.archlinux.org/title/PulseAudio/Troubleshooting#Per-application_volumes_change_when_the_Master_volume_is_adjusted
- (3472)How To Remove Write Protection From USB Flash Drive In Ubuntu Linux? [DID NOT WORK with Win8 OEM]
hdparm -r0 /dev/sdX
From https://www.youtube.com/watch?v=Z9A1-NeXfJU
- (3491)How to find out when a Debian or Ubuntu package was installed or updated?
# grep <package name> /var/log/dpkg.log
# zgrep <package name> /var/log/dpkg.log.*
From: https://www.cyberciti.biz/faq/debian-ubuntu-linux-find-package-installed-updated-date/
- (3506)How to change the default browser (a.k.a. How to set opening of urls not files in xdg-open)?
Find the .desktop file for your browser
$ ls /usr/share/applications/iceweasel.desktop
iceweasel.desktop
Assured you have the file, run:
$ xdg-settings set default-web-browser iceweasel.desktop
Test that it works
$ xdg-open "http://example.com"
From: https://stackoverflow.com/questions/41172692/xdg-open-not-open-default-browser
- (3507)Howto install snap packages behind a proxy?
Set variables
$ sudo mkdir -p /etc/systemd/system/snapd.service.d/
$ echo -e '[Service]\nEnvironment="http_proxy=http://1.2.3.4:3128/"' \
| sudo tee /etc/systemd/system/snapd.service.d/http-proxy.conf
$ echo -e '[Service]\nEnvironment="https_proxy=http://1.2.3.4:3128/"' \
| sudo tee /etc/systemd/system/snapd.service.d/https-proxy.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart snapd
Verify
$ systemctl show snapd | grep proxy
Environment=http_proxy=http://1.2.3.4:3128/ https_proxy=http://1.2.3.4:3128/
DropInPaths=/etc/systemd/system/snapd.service.d/http-proxy.conf /etc/systemd/system/snapd.service.d/https-proxy.conf
From: https://askubuntu.com/questions/764610/how-to-install-snap-packages-behind-web-proxy-on-ubuntu-16-04/1084862#1084862
- (3508)How to launch a process via screen from within ansible?
Further testing has shown, that sleep 1 right after calling the screen helped. It seems the ssh script that ansible calls exits before the screen call is fully detached (or something else, that would explain that the sleep 1 helps)
screen -L -d -m bash -c <some_script> && sleep 1
From: https://stackoverflow.com/questions/22225095/trying-to-launch-a-process-via-screen-from-within-ansible
- (3509)How to install multiple packages in Ansible?
- name: Install packages
become: yes
package:
name:
- tmux
- rsync
- zsh
- rsync
- wget
state: present
(Or state: latest.) This feature is only documented for Ansible 2.9, so it may be new.
From: https://stackoverflow.com/questions/54944080/installing-multiple-packages-in-ansible/63242570#63242570
- (3510)How to run command on remote host in background with Ansible?
Simplified answer from link [https://superuser.com/questions/870871/run-a-remote-script-application-in-detached-mode-in-ansible] I mentioned in the comment:
---
- hosts: centos-target
gather_facts: no
tasks:
- shell: "(cd /; python -mSimpleHTTPServer >/dev/null 2>&1 &)"
async: 10
poll: 0
Note subshell parentheses.
Update: actually, you should be fine without async, just don't forget to redirect stdout:
- name: start simple http server in background
shell: cd /tmp/www; nohup python -mSimpleHTTPServer </dev/null >/dev/null 2>&1 &
From: https://stackoverflow.com/questions/39347379/ansible-run-command-on-remote-host-in-background
- (3511)How to change the SSH port in playbook in Ansible?
PROBLEM:
Here is the inventory file
---
[de-servers]
192.26.32.32
[uk-servers]
172.21.1.23
172.32.2.11
and my playbook is look like this:
- name: Install de-servers configurations
hosts: de-servers
roles:
- de-server-setup
- name: Install uk-servers configurations
hosts: uk-servers
roles:
- uk-server-setup
- name: Do some other job on de-servers (cannot be done until uk-servers is installed)
hosts: de-servers
roles:
- de-servers-rest-of-jobs
In role de-servers-setup role the ssh port is changed from 22 to 8888, so when the last task is called it fails because it cannot connect to host through 22 port. How to overcome this ssh port change?
SOLUTION1:
In the role de-server-setup add a task to change the ansible_port host variable.
- name: Change ssh port to 8888
set_fact:
ansible_port: 8888
SOLUTION2:
Create ssh aliases for your hosts. In your .ssh/config:
Host de.1.before
HostName 192.26.32.32
Port 22
Host de.1.after
HostName 192.26.32.32
Port 8888
Then use these aliases in your Ansible inventory:
[de-servers-before]
de.1.before
[de-servers-after]
de.1.after
And the defined groups then respectively in your plays:
- name: Install de-servers configurations
hosts: de-servers-before
roles:
- de-server-setup
- name: Install uk-servers configurations
hosts: uk-servers
roles:
- uk-server-setup
- name: Do some other job on de-servers (cannot be done until uk-servers is installed)
hosts: de-servers-after
roles:
- de-servers-rest-of-jobs
From: https://stackoverflow.com/questions/34333058/ansible-change-ssh-port-in-playbook/34333804#34333804
- (3515)Some tools for modern command line unix
https://github.com/ibraheemdev/modern-unix
- (3516)How to get pretty fonts with icons in Ubuntu?
Install fontawesome
# apt install fonts-font-awesome
Install Nerd Fonts
https://github.com/ryanoasis/nerd-fonts/tree/master/patched-fonts [goto the complete/ sub dir of a font. Click on a .ttf file, Ubuntu will open a "Font" GUI app that proposes to install the font!]
Install tools that use such fonts, like
https://github.com/Peltoche/lsd
Set your terminal to use the fonts [search for "Nerd" in the font names]
Enjoy!
From: https://github.com/Peltoche/lsd/issues/199#issuecomment-494218334
https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/UbuntuMono/Regular/complete/Ubuntu%20Mono%20Nerd%20Font%20Complete.ttf
https://github.com/ibraheemdev/modern-unix
- (3517)How to edit PDF under Linux (a.k.a. add highlightings, annotations, signature...)?
- Simple Annotations only:
- Evince
- Okular (has ability to add "stamps" thus signature, but in a custum format that will not appear in other PDF viewers)
- Complete tool
- Xournal++ (allows to add signature without transforming the PDF into an image-PDF)
https://github.com/xournalpp/xournalpp
- (3553)How to correct fully encrypted HD (LUKS) machine not booting (Volume group "xxx" not found / WARNING: target 'xxx' not found in /etc/crypttab")?
PROBLEM:
- Booting a PC with full HD encrypted (LUKS) does not work. Grub menu appears, then Linux Mint splash screen with rotating wheel shows for a long time. When hitting ESC, an error is displayed.
- Error messages:
+ At boot, after Grub menu:
Volume group "xxx" not found
[xxx = "ubuntu-vg-root" or "vgx-ubuntu" => this is the name is the LVM volume in which "/" and "/home" are]
+ When trying to re-create the initramfs:
cryptsetup: WARNING: target 'xxx' not found in /etc/crypttab"
[xxx = "luks-yyyyyyyy" => this is the name of the LUKS volume currently mounted by "udiskctl" ]
SOLUTION:
- Boot with a LiveUSB/DVD
- Decrypt the disk
cryptsetup luksOpen /dev/sda5 sda5_crypt (*IPORTANT*: use same name as crypttab)
- Make kernel see the LVM volumes
vgchange -ay
- Mount/Bind the various "Host" system partitions & chroot in the "Host" system
mount /dev/mapper/vgx-ubuntu/root /mnt
mount /dev/sdxY /mnt/boot
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
chroot /mnt
[Also See Tip#2637 for network]
- Regenerate initramfs
update-initramfs -c -k all
- Reinstall/Update grub just to be sure:
update-grub2 /dev/sdX # or grub-install /dev/sdX
From: https://blog.anw.fr/2018/09/27/repair-grub2-lvm2-luks-encrypted-system-volume-group-not-found.html
- (3562)Why is the Snap system bad (and thus deactivated in Linux Mint)?
- Centralized control: only Ubuntu knows how it works, only Ubunu decides which/how packages gets distributed there.
"Snap [...] only works with the Ubuntu Store. Nobody knows how to make a Snap Store and nobody can. The Snap client is designed to work with only one source, following a protocol which isn’t open, and using only one authentication system. Snapd is nothing on its own, it can only work with the Ubuntu Store."
- Backdoor via APT
"When Snap was introduced Canonical promised it would never replace APT. This promise was broken. Some APT packages in the Ubuntu repositories not only install snap as a dependency but also run snap commands as root without your knowledge or consent and connect your computer to the remote proprietary store operated by Canonical."
From: https://linuxmint-user-guide.readthedocs.io/en/latest/snap.html
- (3567)How to force 'cp' to overwrite files in destination directory (a.k.a. How to make behave like Thunar's copy+"Replace All")?
You can do this using -T option in cp.
See Man page for cp.
-T, --no-target-directory
treat DEST as a normal file
Example:
$ tree test
test
|-- bar
| |-- a'
| `-- b'
`-- foo
|-- a
|-- b
`-- c
2 directories, 4 files
$ cp -TRv foo/ bar/
`foo/b' -> `bar/b'
`foo/a' -> `bar/a'
$ tree
|-- bar
| |-- a'
| `-- b'
`-- foo
|-- a'
|-- b'
`-- c
2 directories, 4 files
NOTE: With the -T option, files that are in an existing target (bar/) but not in the source (foo/) will be left in place. This is what I wanted, but if you want to ensure bar/ ends up identical to foo/, use rsync instead:
rsync -a --delete foo/ bar/
From: https://stackoverflow.com/questions/23698183/how-to-force-cp-to-overwrite-directory-instead-of-creating-another-one-inside/24486142#24486142
- (3591)How to install fonts as a user in Linux?
If you want to install fonts, like
https://fontawesome.com/
https://nerdfonts.com/
Just put them in ~/.fonts, then run:
fc-cache -f -v
From: https://www.techrepublic.com/blog/linux-and-open-source/how-do-i-install-and-use-fonts-in-linux/
- (3601)How to contenerize a Python Application (a.k.a. How to run Dash - or whatever daemon/service/server - in a Docker container & make it accessible from outside)?
PROBLEM: By default, most daemons/servers listen to localhost/127.0.0.1/lo-interface, which accepts local/internal connections only.
SOLUTION: You have to configure the daemon/server to listen to external connections (for instance all of them '0.0.0.0' on any other interface than lo)
Example for Dash:
app.run_server(host='0.0.0.0', debug=True, port=8050)
From: https://community.plotly.com/t/running-dash-app-in-docker-container/16067/7
https://digicactus.com/conteneuriser-vos-applications-python-part-1/
https://www.docker.com/blog/containerized-python-development-part-1/
- (3602)What is the format of the /etc/crypttab file?
Format of /etc/crypttab is:
<crypt_vol_name> <volume_name> <key_file> <options>
NOTE: for luks, there is no keyfile => 'none', but we need to use the options to tell dm to use 'luks' method. 'discard' is needed to allow discard requests (TRIM) through the encrypted block device (this has security implications, but is the default in Mint)
Example:
sdb3_crypt UUID=a137527a-9871-4a48-845c-806f81711f06 none luks,discard
From: https://linuxconfig.org/introduction-to-crypttab-with-examples
- (3603)How to correct fully encrypted HD (LUKS) machine not booting (Volume group "xxx" not found / WARNING: target 'xxx' not found in /etc/crypttab")?
PROBLEM:
- Booting a PC with full HD encrypted (LUKS) does not work. Grub menu appears, then Linux Mint splash screen with rotating wheel shows for a long time. When hitting ESC, an error is displayed.
- Error messages:
+ At boot, after Grub menu:
Volume group "xxx" not found
[xxx = "ubuntu-vg-root" or "vgx-ubuntu" => this is the name is the LVM volume in which "/" and "/home" are]
+ When trying to re-create the initramfs:
cryptsetup: WARNING: target 'xxx' not found in /etc/crypttab"
[xxx = "luks-yyyyyyyy" => this is the name of the LUKS volume currently mounted by "udiskctl" ]
SOLUTION:
- Boot with a LiveUSB/DVD
- Decrypt the disk
cryptsetup luksOpen /dev/sda5 sda5_crypt (*IMPORTANT*: use same name as crypttab. See Tip#3602)
- Make kernel see the LVM volumes
vgchange -ay
- Mount/Bind the various "Host" system partitions & chroot in the "Host" system
mount /dev/mapper/vgx-ubuntu/root /mnt
mount /dev/sdxY /mnt/boot
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /dev /mnt/dev
chroot /mnt
[Also See Tip#2637 for network]
- Regenerate initramfs
update-initramfs -c -k all
- Reinstall/Update grub just to be sure:
update-grub2 /dev/sdX # or grub-install /dev/sdX
From: https://blog.anw.fr/2018/09/27/repair-grub2-lvm2-luks-encrypted-system-volume-group-not-found.html
- (3618)How to get the list of packages installed manually with apt (+ How to know if a given package was installed manually)?
- To list the packages installed manually
apt list --installed
apt list --manual-installed
zgrep 'Commandline: apt' /var/log/apt/history.log /var/log/apt/history.log.*.gz
apt-mark showmanual
- GUI solution:
- Open Synaptic
- Go to Status
- Click Installed (manual).
- By comparing with packages installed by default
aptitude search '~i !~M' -F '%p' --disable-columns | sort -u > currentlyinstalled.txt
wget -qO - http://mirror.pnl.gov/releases/<precise/ubuntu-12.04.3-desktop-amd64.manifest> | cut -f1 | sort -u > defaultinstalled.txt
comm -23 currentlyinstalled.txt defaultinstalled.txt
Note: file /var/log/installer/initial-status.gz also give the initial set of packages installed with the distribution
- To know if a package was installed manually:
apt-mark showauto | grep -iE 'foobar' ## will output "foobar" if the package was installed automatically
apt-mark showmanual | grep -i foobar' ## will output "foobar" if the package was installed manually
From: https://askubuntu.com/questions/2389/how-to-list-manually-installed-packages
https://unix.stackexchange.com/questions/3595/list-explicitly-installed-packages/3624#3624
- (3633)How to get auto-completion everywhere in Linux (+ How to insert Emojis everywhere)?
1. Install the tool
apt install ibus-typing-booster
2. Run it
ibus-daemon
3. Configure it
- Desktop Panel Icon for Keyboards/Languages > Preferences > Input Method > Add > Search "Other" > Typing Booster
- Desktop Panel Icon for Keyboards/Languages > Select it as the current input method
- Desktop Panel Icon for Keyboards/Languages > Setup > Add dictionaries for your language(s) + order them correctly
From: https://mike-fabian.github.io/ibus-typing-booster/
- (3636)How to change the swap *partition* on which the system will hibernate?
--- /etc/initramfs-tools/conf.d/resume
RESUME=UUID=....
---
# update-initramfs -uk all
From: https://askubuntu.com/questions/1060917/swap-from-partition-to-file-now-get-no-matching-swap-device-is-available#comment2093907_1126353
- (3637)How to get the UUID of a swapfile?
swaplabel /swapfile
NOTE: Does not work for setting a swapfile as the RESUME partition :{ (See Tip#3636)
From: https://askubuntu.com/questions/1060917/swap-from-partition-to-file-now-get-no-matching-swap-device-is-available#comment2093907_1126353%22
- (3638)How to hibernate
NOTE: This use of resume_offset is dangerous: in case you change your partitions setup, the hibernation data might end up overwriting an important data partition
1. Create a swapfile (See Tip#2681)
2. Get UUID of the disk where the swapfile is
blkid /dev/...
3. Get ID of the first block of the swapfile
filefrag -v /swapfile | grep "First block:"
4. Set resume "partition" to this position in grub or in /etc/initramfs-tools/conf.d/resume (See Tip#3636)
"resume=UUID=<your UUID> resume_offset=<youroffset>"
From: https://ubuntuforums.org/archive/index.php/t-1042946.html
- (3639)How to correct bug on fresh Mint 20.3 installation where some Apps (KDE ones) take >20sec to open?
PROBLEM: Some applications (in fact all KDE Apps on a Gtk Desktop env/WM) take >20sec to open
EXPLANATION: This is due to bad theming library
SOLUTION:
apt purge qt5ctl
From: https://forums.linuxmint.com/viewtopic.php?f=47&p=2131317
- (3643)How to type emoji on Linux?
See Tip#3633 to install ibus-typing-booster
Configure it to enable typing emojis
From: https://opensource.com/article/19/10/how-type-emoji-linux
- (3645)Where to find a very small Linux VM (3GB VirtualBox image) with all the tools for Computer Science (Python, Java, Git, Docker, etc)?
https://mega.nz/#!wURnlYTR!pyCOzguuRqEtY4hS41pLEjIDEVTx5H01Wb0-S0eZrt8
Thanks JC!
From: https://code.telecomste.fr/muller.guillaume/fise2-devopsproject-studentsview/-/blob/master/07_Docker.md
- (3646)How to use sed to merge 2 lines?
sed 'N;s/\n/ /' input.txt > output.txt
From: https://unix.stackexchange.com/questions/281939/using-sed-to-merge-two-lines
- (3657)sed CheatSheet
A.3 Command Summary for sed
: : label
Label a line in the script for the transfer of control by b or t . label may contain up to seven characters. (The POSIX standard says that an implementation can allow longer labels if it wishes to. GNU sed allows labels to be of any length.)
= [ address ] =
Write to standard output the line number of addressed line.
a [ address ] a\ text
Append text following each line matched by address . If text goes over more than one line, newlines must be "hidden" by preceding them with a backslash. The text will be terminated by the first newline that is not hidden in this way. The text is not available in the pattern space and subsequent commands cannot be applied to it. The results of this command are sent to standard output when the list of editing commands is finished, regardless of what happens to the current line in the pattern space.
b [ address1 [, address2 ]] b [ label ]
Transfer control unconditionally (branch) to : label elsewhere in script. That is, the command following the label is the next command applied to the current line. If no label is specified, control falls through to the end of the script, so no more commands are applied to the current line.
c [ address1 [, address2 ]] c\ text
Replace (change) the lines selected by the address with text . When a range of lines is specified, all lines as a group are replaced by a single copy of text . The newline following each line of text must be escaped by a backslash, except the last line. The contents of the pattern space are, in effect, deleted and no subsequent editing commands can be applied to it (or to text ).
d [ address1 [, address2 ]] d
Delete line(s) from pattern space. Thus, the line is not passed to standard output. A new line of input is read and editing resumes with first command in script.
D [ address1 [, address2 ]] D
Delete first part (up to embedded newline) of multiline pattern space created by N command and resume editing with first command in script. If this command empties the pattern space, then a new line of input is read, as if the d command had been executed.
g [ address1 [, address2 ]] g
Copy (get) contents of hold space (see h or H command) into the pattern space, wiping out previous contents.
G [ address1 [, address2 ]] G
Append newline followed by contents of hold space (see h or H command) to contents of the pattern space. If hold space is empty, a newline is still appended to the pattern space.
h [ address1 [, address2 ]] h
Copy pattern space into hold space, a special temporary buffer. Previous contents of hold space are wiped out.
H [ address1 [, address2 ]] H
Append newline and contents of pattern space to contents of the hold space. Even if hold space is empty, this command still appends the newline first.
i [ address1 ] i\ text
Insert text before each line matched by address . (See a for details on text .)
l [ address1 [, address2 ]] l
List the contents of the pattern space, showing nonprinting characters as ASCII codes. Long lines are wrapped.
n [ address1 [, address2 ]] n
Read next line of input into pattern space. Current line is sent to standard output. New line becomes current line and increments line counter. Control passes to command following n instead of resuming at the top of the script.
N [ address1 [, address2 ]] N
Append next input line to contents of pattern space; the new line is separated from the previous contents of the pattern space by a newline. (This command is designed to allow pattern matches across two lines. Using \n to match the embedded newline, you can match patterns across multiple lines.)
p [ address1 [, address2 ]] p
Print the addressed line(s). Note that this can result in duplicate output unless default output is suppressed by using "#n" or the -n command-line option. Typically used before commands that change flow control ( d , n , b ) and might prevent the current line from being output.
P [ address1 [, address2 ]] P
Print first part (up to embedded newline) of multiline pattern space created by N command. Same as p if N has not been applied to a line.
q [ address ] q
Quit when address is encountered. The addressed line is first written to output (if default output is not suppressed), along with any text appended to it by previous a or r commands.
r [ address ] r
file Read contents of file and append after the contents of the pattern space. Exactly one space must be put between r and the filename.
s [ address1 [, address2 ]] s / pattern / replacement /[ flags ]
Substitute replacement for pattern on each addressed line. If pattern addresses are used, the pattern // represents the last pattern address specified. The following flags can be specified:
n Replace n th instance of / pattern / on each addressed line. n is any number in the range 1 to 512, and the default is 1.
g Replace all instances of / pattern / on each addressed line, not just the first instance.
p Print the line if a successful substitution is done. If several successful substitutions are done, multiple copies of the line will be printed.
w file Write the line to file if a replacement was done. A maximum of 10 different files can be opened.
t [ address1 [, address2 ]] t [ label ]
Test if successful substitutions have been made on addressed lines, and if so, branch to line marked by : label . (See b and : .) If label is not specified, control falls through to bottom of script.
w [ address1 [, address2 ]] w file
Append contents of pattern space to file . This action occurs when the command is encountered rather than when the pattern space is output. Exactly one space must separate the w and the filename. A maximum of 10 different files can be opened in a script. This command will create the file if it does not exist; if the file exists, its contents will be overwritten each time the script is executed. Multiple write commands that direct output to the same file append to the end of the file.
x [ address1 [, address2 ]] x
Exchange contents of the pattern space with the contents of the hold space.
y [ address1 [, address2 ]] y / abc / xyz /
Transform each character by position in string abc to its equivalent in string xyz . docstore.mik.ua/orelly/unix/sedawk/appa_03.htm
From: https://docstore.mik.ua/orelly/unix/sedawk/appa_03.htm
- (3668)How to use sed to replace a multi-line string?
SOLUTION1: replace \n symbol with some other symbol, and then work as usual:
cat alpha.txt | tr '\n' '\r' | sed -e 's/a test\rPlease do not/not a test\rBe/' | tr '\r' '\n'
BEWARE: when working with Windows/Mac file this will not work!
NOTE: '\f' can also be used relatively safely.
SOLUTION2: sed has three commands to manage multi-line operations: N, D and P (compare them to normal n, d and p).
In this case, you can match the first line of your pattern, use N to append the second line to pattern space and then use s to do your substitution.
/a test$/{
N
s/a test\nPlease do not/not a test\nBe/
}
NOTE: there are other (more complicated) solution on the SE page.
From: https://unix.stackexchange.com/questions/26284/how-can-i-use-sed-to-replace-a-multi-line-string
- (3675)How to use "Github Flavoured Markdown" with pandoc (e.g. to generate docx with colored code)?
pandoc -f gfm -t docx -s myfile.md > myfile.docx
gfm = GitHub flavored Markdown. Unfortunately, it is not a complete implementation...
At least, it supports:
pipe_tables, raw_html, fenced_code_blocks, auto_identifiers, gfm_auto_identifiers,
backtick_code_blocks, autolink_bare_uris, space_in_atx_header,
intraword_underscores, strikeout, task_lists, emoji, shortcut_reference_links,
angle_brackets_escapable, lists_without_preceding_blankline.
From: https://stackoverflow.com/questions/58874286/github-flavoured-markdown-and-custom-style-attribute-for-docx
- (3679)How to monitor and manage error recovery of Linux machines?
Use monit
From: https://mmonit.com/monit/
- (3682)What are Swappiness and VFS cache pressure?
I] Swappiness
- The swappiness sysctl parameter represents the kernel's preference (or avoidance) of swap space.
- Swappiness can have a value between 0 and 200 (max 100 if Linux < 5.8), the default value is 60.
- A low value causes the kernel to avoid swapping
To temporarily set the swappiness value:
# sysctl -w vm.swappiness=10
To set the swappiness value permanently, create a sysctl.d(5) configuration file. For example:
---- /etc/sysctl.d/99-swappiness.conf
vm.swappiness=10
II] VFS cache pressure
- vm.vfs_cache_pressure controls the tendency of the kernel to reclaim the memory which is used for caching of VFS caches, versus pagecache and swap.
- Increasing this value increases the rate at which VFS caches are reclaimed.
- The default value is 100.
- Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. When vfs_cache_pressure=0, the kernel will never reclaim dentries and inodes due to memory pressure and this can easily lead to out-of-memory conditions.
- Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes. Increasing vfs_cache_pressure significantly beyond 100 may have negative performance impact. Reclaim code needs to take various locks to find freeable directory and inode objects. With vfs_cache_pressure=1000, it will look for ten times more freeable objects than there are.
From: https://wiki.archlinux.org/title/Swap#Swappiness
https://wiki.archlinux.org/title/Swap#VFS_cache_pressure
https://web.archive.org/web/20171004100853/
http://doc.opensuse.org/documentation/leap/tuning/html/book.sle.tuning/cha.tuning.memory.html#cha.tuning.memory.vm.reclaim
https://forum.garudalinux.org/t/vfs-cache-and-swappiness/3026
https://sysctl-explorer.net/vm/vfs_cache_pressure/
- (3683)How to find when (exact date) linux was installed?
ls -lt /var/log/installer/media-info
ls -lt /var/log/installer/initial-status.gz
From: https://geekonweb.fr/retrouver-la-date-a-laquelle-linux-a-ete-installe.html
- (3685)How to disable terminal feedback (stars being written for each typed char) when writing password for sudo (a.k.a. How to make password asterisks non-visible in the terminal window in Linux)?
This is a very bad security practice, as it reveals the number of chars in your password...
sudo mv /etc/sudoers.d/pwfeedback /etc/sudoers.d/pwfeedback.disabled
From: https://elementaryos.stackexchange.com/questions/10354/how-to-disable-terminal-feedback-when-writing-password-for-sudo/10375#10375
https://www.howtogeek.com/194010/HOW-TO-MAKE-PASSWORD-ASTERISKS-VISIBLE-IN-THE-TERMINAL-WINDOW-IN-LINUX/
- (3699)How to set a network range in the proxy-related environment variables?
Use this trick:
export no_proxy="$(echo "10.1.1."{1..254}",") 10.1.1.255"
From: https://unix.stackexchange.com/questions/23452/set-a-network-range-in-the-no-proxy-environment-variable
- (3704)How to compare 2 files (to find differences or similarities)?
- diff -> find "diff"erences
- comm -> find "comm"on things AND MUCH MORE!!!
- uniq -> find "uniq"ue lines
From: https://man7.org/linux/man-pages/man1/diff.1.html
https://man7.org/linux/man-pages/man1/comm.1.html
https://man7.org/linux/man-pages/man1/uniq.1.html
- (3709)How to share your terminal to work with colleagues on the same shell without GUI?
Use tmate (~tmux)
From: https://ostechnix.com/tmate-share-terminal-instantly-anyone-anywhere/
- (3710)How to move a running process from one terminal to another one without closing/stopping the process?
Use reptyr
From: https://ostechnix.com/reptyr-move-running-process-new-terminal/
- (3723)How to extract tar files to specific directory?
# tar -xf file_name.tar -C /target/directory
# tar -xf file_name.tar.gz --directory /target/directory
From: https://www.tecmint.com/extract-tar-files-to-specific-or-different-directory-in-linux/
- (3726)Userful linux tools
tldr is a man on steroids
From: https://github.com/tldr-pages/tldr
- (3740)How to get/display a count down/up timer?
Use gnome-clocks
From: https://help.gnome.org/users/gnome-clocks/stable/timer.html.en
- (3746)How to split tar archive into multiple blocks of a specific size?
tar cvzf - example-dir/ | split --bytes=5MB - myfiles.tar.gz.
From: https://linuxconfig.org/how-to-split-tar-archive-into-multiple-blocks-of-a-specific-size
- (3767)How to replay a suite of commands?
USE: "fc"
e.g. "fc -5 0" opens a text editor with the last 5 commands, where you can modify them, then re-execute them.
See "help fc" for more help
Thanks Achille?
- (3768)How to easily manipulate a long list of files in a directory?
USE: "vidir"
It opens a text editor with the names of the files in the current dir, where you can easily renamme them or mark them for deletion.
Same can be done with dired-mode in Emacs
Thanks Achille?
- (3772)Howto make 'exa' (ls on steroids) sort correctly (respecting case)?
exa --sort=Name
From: https://github.com/ogham/exa/issues/410
- (3775)A little script to save your terminal work before rebooting
---- ~/Softs/replay.sh
# This script saves the last command and where it was executed in the ~/REPLAY file
# This is very useful to save what you where doing in your various shells before rebooting
# Usage: call it in the various shells you were working in
#
# From: https://stackoverflow.com/a/9502698
# set -o history -o histexpand # ⇒ to use !! or !:* in a script
MYTERM="xfce4-terminal -e"
last=$(history | tail -n2 | head -n1 | sed -rn 's/^\s*[0-9]*\s*(.*)/\1/p')
echo $MYTERM "\"bash -c 'cd $(pwd) ; $last ; bash'\"" >> ~/REPLAY
----
Example: you where running evince with a few articles/books opened in a specific directory in a terminal and you where running emacs with files opened in another directory in another terminal, etc.
- (3776)How to use last-command/arg expansions (e.g. !!, !:1) in a script?
---- example_script.sh
set -o history -o histexpand # <- required to allow last-command/arg expansions
echo this is a test
echo !!
----
In a script, history expansion is turned off by default, you need to enable it!
- (3778)How can I display uptime with sleep-mode time excluded?
The following commands will display the uptime excluding sleep time.
python3 -c 'import time;print(f" {(time.clock_gettime(time.CLOCK_MONOTONIC))}")' # time in seconds with a decimal.
python3 -c 'import time;second=int(time.clock_gettime(time.CLOCK_MONOTONIC));print(f" {second} seconds")' # time in seconds with no decimal.
python3 -c 'import time;second=int(time.clock_gettime(time.CLOCK_MONOTONIC));minute=second//60;print(f" {minute} minutes")' # time in minutes.
python3 -c 'import time;s=int(time.clock_gettime(time.CLOCK_MONOTONIC));h=s//3600;m=(s-h*3600)//60;print(f"{h} hours {m} minutes")' # time in hours and minutes.
python3 -c 'import time,datetime;print(datetime.timedelta(seconds=time.clock_gettime(time.CLOCK_MONOTONIC)))' # time in hours, minutes, and seconds.
python3 -c 'import time,datetime;d=datetime.datetime(1,1,1)+datetime.timedelta(seconds=time.clock_gettime(time.CLOCK_MONOTONIC));print(f"{d.day-1} days, {d.hour} hours, {d.minute} minutes")' # time in days, hours, and minutes.
From: https://unix.stackexchange.com/a/532416
- (3782)How to get data on current per-core/per-device (CPU/GPU)/per-process usage/frequencies/consumption?
Use 'powertop' of 'btop'
You can also change the policy used to set the CPU frequencies (governor)
sudo powertop --auto-tune
From: https://forum.ubuntu-fr.org/viewtopic.php?id=2031477#p21982886
https://askubuntu.com/questions/1054579/disable-dedicated-nvidia-graphic-card/1058705#1058705
https://github.com/aristocratos/btop
- (3787)How to get the display number assigned by X (it is :0? :1?)?
$ who
<user> *:0* Oct 17 09:07 (*:0*)
From: https://superuser.com/a/1342501
- (3788)How To Switch Between Intel and Nvidia Graphics Card on Ubuntu (a.k.a. How to use Optimus/PRIME)?
1. Check What Graphics Card You’ve Got
lspci -k | grep -A 2 -i "VGA"
2. Install Nvidia Graphics Card Driver
- GUI
sudo software-properties-gtk
- CLI
sudo ubuntu-drivers devices
sudo apt-get install nvidia-<version>
3. Switch form/to Intel/Nvidia Graphics Card
- GUI
nvidia-settings
- CLI
prime-select query
sudo prime-select {intel,nvidia}
From: https://www.linuxbabe.com/desktop-linux/switch-intel-nvidia-graphics-card-ubuntu
- (3794)How to limit CPU Usage of a Process in Linux?
Use CPULimit:
sudo apt install cpulimit
sudo cpulimit --pid 17918 --limit 50
From: https://www.tecmint.com/limit-cpu-usage-of-a-process-in-linux-with-cpulimit-tool/
- (3798)What are the possible setxkbmap configuration options?
List of all setxkbmap configuration options (including models/layout/etc):
https://gist.github.com/Sayutizxc/421639dbac353e40e34fc40b77a54f58
- (3799)How to manually compute the hash of a password on Linux?
Use: mkpasswd, which is part of "whois"
sudo apt install whois
mkpasswd -m <hashing-algorithm>
# To get available hashing-algorithms:
mkpasswd -m help
From: https://linuxconfig.org/how-to-hash-passwords-on-linux
- (3808)How to allow Evince to start default browser in AppArmor?
Add the following line to /etc/apparmor.d/abstractions/exo-open
/{,usr/}bin/xfce4-mime-helper rix,
Then reload AppArmor:
sudo service apparmor reload
From: https://groups.google.com/g/linux.debian.bugs.dist/c/r9OF_v7rV5g/m/MIVULtHbAAAJ
https://help.ubuntu.com/community/AppArmor#Reload_all_profiles
- (3809)How to clear Evince/Gnome's "recent documents" list?
rm ~/.local/share/recently-used.xbel
From: https://unix.stackexchange.com/questions/634461/how-do-i-clear-evinces-recent-documents-list
- (3810)How to use inotifywait to watch a directory for creation of files (e.g. of a specific extension)?
inotifywait -m /path -e create -e moved_to |
while read directory action file; do
if [[ "$file" =~ .*xml$ ]]; then # Does the file end with .xml?
echo "xml file" # If so, do your thing here!
fi
done
-m => monitor mode
-e => what event to listen to
From: https://unix.stackexchange.com/a/323919
- (3815)How to define a function for later use in "bc"?
From the bc POSIX specifications:
It shall take input from any files given, then read from the standard input.
SOLUTION:
- Define your function in a file:
-------- factorial.bc
define fact(x) {
if (x>1) {
return (x * fact(x-1))
}
return (1)
}
----------
- Then call "bc" with that file as argument and rest of stuff in stdin:
bc factorial.bc <<< '1/fact(937)'
From: https://unix.stackexchange.com/questions/41957/how-to-define-a-bc-function-for-later-use
- (3819)What are the best FOSS alternatives to GitHub?
https://sourcehut.org/
https://github.com/theonedev/onedev
https://about.gitlab.com/install/
https://gitea.io
https://gogs.io/
https://codeberg.org/
https://gitbucket.github.io/
https://phacility.com/phabricator/
- (3824)How to solve pk7zip error "Can't allocate required memory"?
SOLUTION: reduce the number of working threads
-mmt2 or -mmt4
From: https://github.com/dordnung/System2/issues/6#issuecomment-737733259
- (3902)How to fix the "Key is stored in legacy trusted.gpg keyring" issue in Ubuntu?
PROBLEM: If you use a PPA or add an external repository in Ubuntu 22.04 and later versions, chances are that you will see a message like this: "Key is stored in legacy trusted.gpg keyring"
SOLUTION: Import the key in its own .gpg file
- Note the URL of the repository that causes the problem
- Get the list of currently registered keys
sudo apt-key list
- Find the ID (last 8 characters of the "pub" entry for the key) of the key in this list that matches the URL of the problematic repository
- Extract this key into its own .gpg file
sudo apt-key export <KeyID> | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/<RepoName>.gpg
- Make the source file use (only) this particular key
--- /etc/apt/sources.list.d/<RepoName>.list
deb [signed-by=<GPG file above>] <repoURL> <distro> <part>
From: https://itsfoss.com/key-is-stored-in-legacy-trusted-gpg/
https://itsfoss.com/apt-key-deprecated/
- (3908)Where to test Linux Distros online?
https://distrotest.net/
https://www.onworks.net/
- (3934)How to connect to a serial console?
cu -l /dev/device -s baud-rate
screen /dev/device baud-rate
minicom -D /dev/device -b baud-rate
tip -<speed> device
From: https://www.cyberciti.biz/hardware/5-linux-unix-commands-for-connecting-to-the-serial-console/
- (3941)How to print the middle-dot/centered-period for inclusive writing on French Keyboard?
SOLUTION1:
AltGr + :
SOLUTION2:
Compose + asciicircum + period
- (3945)How To Enable Hibernation On Ubuntu (When Using A Swap File)
NOTE: DOES NOT WORK WITH SecureBoot Enabled
1. Find out the UUID of the partition on which the swap file resides.
findmnt -no UUID -T /swapfile
2. Find out and the swap file offset.
sudo filefrag -v /swapfile
From this command's output, the first number from the "physical_offset" column is the swap file offset which you'll need later on. Only copy the numbers, and not the dots that follow the number block.
3. Edit the /etc/default/grub file in order to boot with the resume and resume offset kernel parameters.
sudo nano /etc/default/grub
In this file, at the end of the GRUB_CMDLINE_LINUX_DEFAULT line, before the ending ", add the following: resume=UUID=UUID_FROM_STEP_1 resume_offset=SWAP_OFFSET_FROM_STEP_2. Replace the values with the UUID you've got under step 1 and the swap resume offset you've got under step 2.
4. Update the GRUB configuration.
sudo update-grub
5. Create (or edit if already exists) /etc/initramfs-tools/conf.d/resume with the swap UUID and resume offset.
sudo nano /etc/initramfs-tools/conf.d/resume
In this file, if you have a line beginning with "RESUME", edit that line, or if there's no such line (or the file is completely empty), add the line so that it looks like this:
RESUME=UUID=UUID_FROM_STEP_1 resume_offset=SWAP_OFFSET_FROM_STEP_2
6. Regenerate initramfs.
sudo update-initramfs -c -k all
7. Reboot your computer.
8. After rebooting, hibernate your computer using the following command:
sudo systemctl hibernate
From: https://www.linuxuprising.com/2021/08/how-to-enable-hibernation-on-ubuntu.html
- (3948)How do to turn off snap in Ubuntu?
BEWARE: Chromium browser fiasco: if you are a chromium browser user and install it using apt, the snap will automatically be reinstalled in your Ubuntu.
1. List installed snaps
$snap list
2. Remove installed snaps
$sudo snap remove snap-store
$sudo snap remove gtk-common-theme
$sudo snap remove gnome-3-34-1804
3. unmount the snap core services
$sudo umount /snap/core/<core-id>
$sudo umount /var/snap
4. Entirely remove the "snapd"
$sudo apt purge snapd
5. Erase the remaining snap-associated directories
$sudo rm -rf ~/snap /snap /var/snap /var/lib/snapd
From: https://linuxhint.com/turn-off-snap-ubuntu/
- (3961)How to install latest LibreOffice in Ubuntu?
sudo add-apt-repository ppa:libreoffice/libreoffice-still
sudo apt update
From: https://launchpad.net/~libreoffice/+archive/ubuntu/libreoffice-still
- (3982)How to record computer/Apps sound with fake microphone?
With "pulseaudio volume control" (pavucontrol, to beinstalled if not present), you can add , in input device tab, a "monitor of audio internal" so that playing sound can be recorded by f.i. Audacity .
To do so, select "all input devices" in the input device bottom ,then click on the green button on the right of the new "monitor " input, to make it default.
From: https://askubuntu.com/questions/1257664/how-to-record-dektop-sound-from-chrome-browser-microphone
- (3995)How to clone a partition (onto another of different - superior - size)?
- Partclone
https://partclone.org/usage/partclone.php
- (4017)What is the rule-of-thumb to decide on the size of the swap partition?
The "traditional" rule for swap space is to make it about twice your RAM size. These days, that's usually overkill. You need at least as much swap as RAM if you expect to use the suspend-to-disk feature. If not, then many uses don't need swap at all, although I'd be reluctant to recommend a no-swap setup by default. Setting swap to a percentage of the root (/) filesystem size is a poor rule of thumb unless that value happens to work out to something sensible. In your case, the value you set might be OK if you don't need to use suspend-to-disk.
- (4026)How to enable Linux commands on ChromeBooks?
Linux is off by default. You can turn it on any time from Settings.
- On your Chromebook, at the bottom right, select the time.
- Select Settings and then Advanced and then Developers.
- Next to "Linux development environment," select Turn On.
- Follow the on-screen instructions. Setup can take 10 minutes or more.
- A terminal window opens. You have a Debian 11 (Bullseye) environment. You can run Linux commands, install more tools using the APT package manager, and customize your shell.
From: https://support.google.com/chromebook/answer/9145439?hl=en
- (4043)How to find the package containing a given/specific file?
apt-file search <file>
From: https://stackoverflow.com/questions/12670517/how-to-find-packages-containing-a-specific-file
- (4061)How to mute mic only from CLI?
pactl set-source-mute @DEFAULT_SOURCE@ toggle
# amixer set Capture toggle
From: https://unix.stackexchange.com/questions/636398/mute-all-microphons-with-one-command/638743#638743
- (4086)How to set Thunar as a default file manager?
SOLUTION1: with GUI
- Run exo-preferred-applications
- Go to Utilities > Default File Manager, and choose the file manager that you want to use as your default
SOLUTION2: with CLI
xdg-mime default Thunar.desktop inode/directory
SOLUTION3: config file
Edit line with "inode/directory=" in
~/.local/share/applications/mimeapps.list
and
~/.local/share/applications/defaults.list
Also see Tip#4087
From: https://askubuntu.com/questions/253131/how-to-set-thunar-as-a-default-file-manager
https://askubuntu.com/questions/267514/open-containing-folder-in-firefox-does-not-use-my-default-file-manager
https://askubuntu.com/questions/73979/stop-folders-opening-with-different-application-than-the-file-manager
https://help.ubuntu.com/community/DefaultFileManager
- (4097)How to solve error "dpkg: error processing package python3 (--configure): subprocess installed post-installation script returned error exit status 4"?
Fixed by :
- Removing the <missing-package-name>.rtupdate files in /usr/share/python3/runtime.d
- Reinstalling python3.
From: https://askubuntu.com/questions/862367/running-python-rtupdate-hooks-for-python3-5-failing/941789#941789
- (112)Build the DVD ISO from site dump (for i386 arch)
mkisofs -vrTJV "OpenBSDXY" -b X.Y/i386/cdromXY.fs -c boot.catalog -o OpenBSDXY.iso /tmp/OpenBSD/
where:
* XY is the version number.
* /tmp/OpenBSD contains the 'i386/' and 'packages/i386' subdirs, plus the following files: ANNOUNCEMENT ftplist HARDWARE PACKAGES PORTS ports.tar.gz README root.mail SIZES src.tar.gz sys.tar.gz
* -v is verbose mode
* -r is rockridge support
* -T is TRANS.TBL generation
* -J is joliet support
* -V is volume ID
- (113)mount / umount a disk image
# vnconfig -c /dev/svnd0c /the/disk/image
# mount /dev/svnd0a /mnt
# umount /dev/svnd0a
# vnconfig -u /dev/svnd0c
- (141)How to change the kernel configuration
config -e -o bsd.new /bsd
- (143)Equivalent of strace.
use kdump + ktrace
- (150)Under OpenBSD, when someone runs 'java -XmxYYY' and YYY is greater than the (bash-)allowed data seg size for a process, then java just closes while complaining.
Unfortunately 'ulimit -d' did not help, returning a "operation not permitted". Indeed, I felt that the limitation comes from 'above': it might be limited by some configuration that is set for the current bash at launch-time.
The dialog below indicates a solution: the launch-time configuration of bash is in /etc/login.conf.
> Indeed! Please keep us posted! I'd wager that you're ready to go if
> you can unlimit the data seg size.
I found that the default settings (modifiable in /etc/login.conf) are
a soft limit of 64MB and a hard limit of 256MB.
- (156)If X has trouble launching itself (driver initialization problems)
Might be linked with allowing access to hardware
machdep.allowaperture=2
machdep.userldt=1
- (162)How to allow users to mount drives
One (violent) solution is to add them the the sudoers or wheel group.
Another, more secure, is to set the kern.usermount to 1:
# sysctl kern.usermount=1
ATTENTION:
http://en.wikibooks.org/wiki/Guide_to_Unix/Explanations/Filesystems_and_Swap#Mounts_by_Users
"The user can pick any mount point which the user owns."
This means you cannot mount /dev/cd0c in /mnt/dvdrom since you probably do not have rwx rights on /mnt/... . However, you can mount cd or USB sticks in ~/mytmp ;)
- (164)Del Key do not act correctly in Terminal
http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
--------
* Typing <CTRL>-V <BS> and <CTRL>-V <DEL> both yield "^?" so bash sees them as the same key.
* xev shows they are distinct, namely (keycode 22 / BackSpace) and (keycode 107 / Delete).
* The readline binding of \C-? is backward-delete-char. In my .inputrc I have these definitions:
Code:
"^?" : delete-char
"\C-h" : delete-char
"\C-?" : delete-char
In some vain attempt to get <DEL> to do delete-char but to no avail. After doing bind -f .inputrc (even though it is definitely loaded when bash starts), bind -p | grep delete shows that \C-? is still bound to backward-delete-char.
* I can do bind '^?=delete-char-forward' in ksh, after which both <DEL> and <BS> delete the current char, but this is still a problem since I want them to be different. Probably related to the first point above.
----------
In my ~/.Xresources file I have mapped the Delete keys to a string:
Code:
*VT100.Translations: #override \
!<Key>BackSpace: string(0x7F) \n\
!<Key>KP_Begin: string(0x1b) string("[25~") \n\
!<Key>Home: string(0x1b) string("[7~") \n\
!<Key>KP_Home: string(0x1b) string("[7~") \n\
<Key>Insert: string(0x1b) string("[2~") \n\
!<Key>KP_Insert: string(0x1b) string("[2~") \n\
<Key>Delete: string(0x1b) string("[3~") \n\
!<Key>KP_Delete: string(0x1b) string("[3~") \n\
...(etc.)...
Note the last two lines especially. Then, in my ~/.inputrc I use that string:
Code:
"\e[3~": delete-char # Delete
I hope that can get you started on what you want to do. (BTW, thanks for the tip about Ctrl-V, didn't know about that.)
----------
"David, you probably need to reload the Xresources file with: xrdb -merge ~/. Xresources.
----------
# Make sure the backspace key erases:
stty erase "^H"
Reply With Quote
----------
http://www.daemonforums.org/showthread.php?t=2560
----------
Finally, if all this did not work:
CTL+Right clic in terminal window and select "Delete is DEL"
- (166)Problems playing sound with multiple softs (e.g. xmms) at the same time
esd (to have several progs playing sound at the same time => no gnash crash if /dev/audio is already used - gnash as to be configured to use esd also using gst-esd) : pkg_add xmms-esd
cdda / digital audio extraction => change xmms for audacious!
UPDATE: OpenBSD 4.5 introduced aucat (launch aucat -l once for all at boot)
- (173)Boot problem
if you have a line in fstab to mount XXX in /boot (even in
noauto mode), and if /boot exists but IS A FILE (e.g.,
copy of /usr/mdec/boot) and not a directory
=> boot is stopped
- (181)How to restore/reset MBR
1. fdisk -u
2. /usr/mdec/installboot -[n]v /usr/mdec/boot /usr/mdec/biosboot wd0
- (183)How to get the serial number on a Dell machine
sysctl | grep serial
hw.serialno=404CW3J
- (185)How to switch off the bell
$ wsconsctl
keyboard.bell.pitch=400
keyboard.bell.period=100
keyboard.bell.volume=50
keyboard.bell.pitch.default=400
keyboard.bell.period.default=100
keyboard.bell.volume.default=50
$ xset b off
$ xset b on
- (192)How to change a mounted disk options (e.g., remount RW a partition mounted RO by Single User boot)
mount -u -o <option>
e.g.: mount -u -o rw
- (193)Qemu refuses to start because it cannot allocate enough memory (a.k.a "Could not map physical memory" error)
Under OpenBSD there is a limit on the amount of memory for user processes.
- 'ulimit -d' allows to dynamically change the value.
- However, there is a harder limit that even ulimit cannot change. It is set in the /etc/login.conf (:datasize-max=xxxM and :datasize-cur=yyyM)
- (216)How to set the brightness/luminosity of the screen
wsconsctl display.brightness=100.00%
- (228)Get colors in XTerm and vi
#pkg_add colorls vim
$echo "export TERM=xterm-color" >> .xinitrc
$echo "alias ls='colorls -Gahl'" >> .bashrc
$echo "alias vi='vim'" >> .bashrc
- (238)How to replace an installed package with another of its flavors
use option -r of pkg_add
e.g. replace an installed ghostscript-8.63p11 by ghostscript-8.63p11-a4:
# pkg_add -r ghostscript-8.63p11-a4
- (239)How to install two machines with the exact same packages (or brutally remove all packages and re-install them, for instance to move from i386 to amd64)
use option -l of pkg_add
machine1# pkg_info > list_of_packages
machine2# pkg_add -l list_of_packages
- (243)Resolve error Gtk-WARNING **: Error loading theme icon 'xxx' for yyy: Unrecognized image file format
- remove ~/.local?
- change .gtkrc-2.0 to point to an installed theme (or simply remove it...)
- (268)Make a crypted file system / mounted point / directory
$ touch <cryptedfs file>
$ dd if=/dev/[u]random of=<cryptedfs file> bs=512 count=<cryptedfs size in blocks>
# vnconfig -ck -v svnd0 <cryptedfs file>
# fdisk -i svnd0
# disklabel -E svnd0 # add a 'a' slice taking all free space
# newfs svnd0a
# mount /dev/svnd0a <cryptedfs mount point>
- (275)Should we use /dev/random or /dev/urandom ?
> On the line
> dd if=/dev/urandom of=$CRYPTFILE bs=1M count=$CRYPTSIZE
> why not /dev/random instead? Isn't that more secure?
/dev/random blocks until more entropy can be gathered
On the N900, producing even 1 kilobyte of random data with /dev/random takes ages (it just sits there waiting for environment "noise")
/dev/urandom takes less a second to fill 1 MB of random data
Unless you are exchanging above top secret government documents, /dev/urandom is good enough.
From: http://talk.maemo.org/showthread.php?t=40154
- (278)How to use UTF8 in Xorg, while not touching the console configuration
It would be very hard to make the text console support UTF-8 display.
That is certainly out-of-scope for me. I won't touch that.
It's definitely not a good idea to run the entire system with
LC_CTYPE=en_US.UTF-8 in the environment.
It's a bad idea to set LC_CTYPE=en_US.UTF-8 in ~/.profile, because
it could cause gibberish being displayed on the text console.
I run my entire X session with LC_CTYPE=en_US.UTF-8, like this:
$ cat ~/.xsession
env LC_CTYPE="en_US.UTF-8" /usr/local/bin/startxfce4
I'd recommend doing it this way when helping with testing.
The most important thing to look out for is stuff that used to work
with single-byte character sets like ISO8859-1 but does not work with UTF-8.
- (286)How to compile a pkg from current into stable?
-1. # chmod a+w /usr/ports/
0. $ cd ~/
1. $ cvs -danoncvs@anoncvs.fr.openbsd.org:/cvs co ports/productivity/sunbird
2. $ mv ~/ports/productivity/ /usr/ports/mystuff
3. $ cd /usr/ports/productivity/sunbird/
4. $ make package
- (293)How to compile a custom kernel (for instance to enable NFTS reading)
# cd /usr/src/sys/arch/`machine`/conf
# cp GENERIC GENERIC.NTFS
# vi GENERIC.NTFS # + add "option NTFS"
# config GENERIC.NTFS
# cd ../compile/GENERIC.NTFS
# make clean && make depend && make
[...lots of output...]
# make install
- (294)What device to use to check a Crypted FS FFS file?
1. bind the FFS file to an svnd device (e.g. svnd0)
2. fsck_ffs /dev/rsvnd0a
- (296)What to do if the sound does not come back correctly when OpenBSD48 is APM-suspended?
when there is no sound played, apm -z does not necessarily reloads correctly the aucat -l
=> kill and restart it as a user
- (300)After upgrading, how to see if there are ".libXXX" packages to be cleaned?
pkg_info -A | cut -d ' ' -f 1 | grep '\.lib'
- (316)What to do if arrow keys do not work in aMule under OpenBSD/AwesomeWM?
its probably because the area is not selected correctly => use tab to select the good part, then the arrow will work correctly ;)
- (320)An equivalent of lsof in OpenBSD
fstat
- (325)Problems when using Home and End keys when xterm is set to use colors (TERM=xterm-xfree86 or TERM=xterm-colors) and utf8 (Open 48++)
In fact, these keys are not working.
When the text moves (colors chars are offsetting it?) just do:
CTL-e/End (goto end of line) and CTL-l (clear screen)
Then, do not use CTL-a/CTL-e or End/Home, rather use CTL-rightarrow and CTL-leftarrow
reset ?
- (326)How to get Evolution's notifications to appear?
http://lists.debian.org/debian-user/2010/09/msg00039.html
For now created the following wrapper:
#!/bin/sh
/usr/lib/evolution/2.30/evolution-alarm-notify &
exec /usr/bin/evolution
---
In openbsd: add
/usr/local/libexec/evolution/2.28/evolution-alarm-notify &
in your .xinitrc
- (327)What is the boot process sequence?
schmilblick (MBR) -> biosboot (PBR) -> /boot (on the slice) -> /bsd (kernel, on the slice)
- (328)What command line editor to use?
- vi
- mg (emacs-like)
- (330)What is the equivalent of lsusb in OpenBSD?
usbdevs
usbctl (in pkg: usbutil)
- (335)What to do right after the end of the install of an OpenBSD box?
The install program leaves root an initial mail message. We recommend
you read it, as it contains answers to basic questions you might have
about OpenBSD, such as configuring your system, installing packages,
getting more information about OpenBSD, sending in your dmesg output
and more. To do this, run
mail
and then just enter "more 1" to get the first message. You quit mail by
entering "q".
Some of the files in the OpenBSD 4.9 distribution might need to be
tailored for your site. We recommend you run:
man afterboot
which will tell you about a bunch of the files needing to be reviewed.
If you are unfamiliar with UN*X-like system administration, it's
recommended that you buy a book that discusses it.
- (378)What if Xorg does not start?
Particularly after a fresh install (generally not an upgrade), verify that sysctl's aperture is set to 2
- (379)How to manually install the base system?
#From: http://openbsd.org/faq/faq4.html
Using the upgrade process
Simply boot your install media (CD-ROM or Floppy), and choose Upgrade (rather than Install). When you get to the lists of file sets to install, choose the sets you neglected to install first time around, select your source, and let it install them for you.
Using tar(1)
The install file sets are simply compressed tar files, and you can expand them manually from the root of the filesystem:
# cd /
# tar xzvphf comp49.tgz
***Do NOT forget the 'p' option in the above command in order to restore the file permissions properly!***
One common mistake is to think you can use pkg_add(1) to add missing file sets. This does not work. pkg_add(1) is the package management tool to install third party software. It handles package files, not generic tar files like the install sets.
If you are installing the xbase file set on your system for the first time using tar(1) and without rebooting, the shared library cache must be updated after the installation using ldconfig(8). To add all the X libraries to the cache:
# ldconfig -m /usr/X11R6/lib
Alternatively, you can just reboot your system, and this will be done automatically by the rc(8) startup script.
- (389)My pf.conf
# $OpenBSD: pf.conf,v 1.49 2009/09/17 06:39:03 jmc Exp $
#
# See pf.conf(5) for syntax and examples.
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.
set skip on lo
# block in all
# filter rules and anchor for ftp-proxy(8)
anchor "ftp-proxy/*"
pass in quick proto tcp to port ftp rdr-to 127.0.0.1 port 8021
# anchor for relayd(8)
#anchor "relayd/*"
pass # to establish keep-state
# rules for spamd(8)
#table <spamd-white> persist
#table <nospamd> persist file "/etc/mail/nospamd"
#pass in on egress proto tcp from any to any port smtp \
# rdr-to 127.0.0.1 port spamd
#pass in on egress proto tcp from <nospamd> to any port smtp
#pass in log on egress proto tcp from <spamd-white> to any port smtp
#pass out log on egress proto tcp to any port smtp
#block in quick from urpf-failed to any # use with care
# By default, do not permit remote connections to X11
block in on ! lo0 proto tcp to port 6000:6010
ext_if=192.168.0.2
dns_port="{domain}"
ssh_port="{22, 2222}"
web_port="{80,8080}"
mail_port="{smtp, pop3, pop3s, imap, imaps}"
ftp_port="{20,21,2100}"
dwl_port="{4400:5999,6500:8000}"
# DNS
pass out on $ext_if proto tcp to any port $dns_port
pass out on $ext_if proto udp to any port $dns_port
# SSH
pass in on $ext_if proto tcp to any port $ssh_port
pass out on $ext_if proto tcp to any port $ssh_port
# Web
pass out on $ext_if proto tcp to any port $web_port
pass out on $ext_if proto udp to any port $web_port
# Mail
pass out on $ext_if proto tcp to any port $mail_port
pass out on $ext_if proto udp to any port $mail_port
# FTP
pass out on $ext_if proto tcp to any port $ftp_port
pass in on $ext_if proto tcp to any port $ftp_port
pass in on $ext_if proto tcp to any port > 49151
# DWL
pass in on $ext_if proto tcp to any port $dwl_port
pass out on $ext_if proto tcp to any port $dwl_port
pass in on $ext_if proto udp to any port $dwl_port
pass out on $ext_if proto udp to any port $dwl_port
- (390)How to configure mg?
global-set-key "\e[H" beginning-of-line
global-set-key "\e[F" end-of-line
global-set-key "\e[1;5C" forward-word
global-set-key "\e[1;5D" backward-word
global-set-key "\e[1;3C" forward-word
global-set-key "\e[1;3D" backward-word
; make C-M-up/dwn keys move by paragraph
;global-set-key "\e[1;5B" forward-block-of-lines ; do not exists in mg
;global-set-key "\e[1;5A" backward-block-of-lines ; do not exists in mg
global-set-key "\e[1;5B" forward-paragraph
global-set-key "\e[1;5A" backward-paragraph
global-set-key "\e[1;5H" beginning-of-buffer
global-set-key "\e[1;5F" end-of-buffer
;;global-set-key "\et" transpose-words
;; allow accentuated chars
meta-key-mode
;; bind ESC-g with goto-line as in XEmacs
global-set-key "\eg" goto-line
;; Makes delete key work
global-set-key "\e[3~" delete-char
;; always end a file with a newline - prevents questions on exit
;(require-final-newline 0)
;; Disables backup files
make-backup-files nil
;; Turn on column numbering in status line
;;(column-number-mode t)
;set-default-mode blink
;auto-indent-mode
;dired-backup-unflag
; Makes ESC-suppr and ESC-dele erase words
global-set-key "\e\e[3~" kill-word
global-set-key "\e^H" backward-kill-word
TIPS: to see the exact chars associated to a control key, just type C-q<the key>
- (411)How to switch Control_L/Caps_Lock in console?
[does not work!
wsconsctl keyboard.map+="keysym Caps_Lock = Control_L"
#wsconsctl keyboard.map+="keysym Control_L = Caps_Lock"
]
wsconsctl keyboard.encoding=fr.swapctrlcaps
- (412)How to get a more useable console?
From: http://openbsd.org/faq/faq7.html#80x50
wsfontload -h 8 -e ibm /usr/share/misc/pcvtfonts/vt220l.808
wsconscfg -dF 5
wsconscfg -t 80x50 5
[This can be done automatically at boot by adding the following lines to the end of your rc.local(8)]
The first line above loads the 8x8 font. The second line deletes screen 5 (which would be accessed by [CTRL]+[ALT]+[F6]). The third line creates a new screen 5 with 50 lines of 80 characters each. If you do this, you will see your primary screen, and the other three default virtual consoles, come up in the standard 80x25 mode, but a new screen 5 at 80x50 accessible through [CTRL]+[ALT]+[F6].
- (413)How to split screen in console mode?
Use screen, or BETTER, tmux:
http://openbsd.org/faq/faq7.html#tmux
- (478)How to swap Caps_Lock and Control_Left in console?
wsconsctl keyboard.encoding=fr.swapctrlcaps
- (486)How to search for a program in the ports' tree?
Host ~# cd /usr
Host ~# tar xzf /tmp/ports.tar.gz
Host ~# cd /usr/ports
Host ~# make search key=qemu
- (532)The list of packages that I generally install on a new machine
GraphicsMagick,ImageMagick,ORBit2,OpenEXR,R,Xaw3d,a2ps,aalib,ac3dec,agg,amd,amule,antiword,antlr2,apache,apr,arc,arts,asclock,aspell,atk,atk2mm,audacious,aumix,autossh,avahi,awesome,babl,base64,bash,bison,bladeenc,blame,blas,bluetooth,boehm,boost,bsd,bug,bzip2,cairo,cairomm,cdk,cdparanoia,cdrdao,cdrtools,chmlib,clamav,classpath,clearsilver,cmake,colorls,cups,curl,cvsps,cyrus,db,dbus,dconf,dcraw,decss,desktop,detex,devhelp,dictd,dillo,djview4,djvulibre,docbook,dvd+rw,dvi2tty,e2fsprogs,ectags,eggdbus,ekiga,enchant,enigmail,erlang,esound,evince,evolution,exiv2,exo,faac,faad,fcgi,feh,festival,festlex_CMU,festlex_OALD,festlex_POSLEX,festvox_cmu_us_bdl_arctic_hts,festvox_don,festvox_kallpc16k,festvox_rablpc16k,ffcall,ffmpeg,fftw3,fileutils,findutils,flac,foomatic,freefont,freetype,fribidi,gamin,garcon,gcj,gconf2,gd,gdbm,gdk,gegl,gettext,gftp,ghc,ghostscript,ghostview,giblib,gimp,git,glade3,glib,glib2,glib2mm,glitz,gmake,gmime,gmp,gnome,gnuchess,gnugo,gnumeric,gnupg,gnuplot,gnutls,gocr,goffice,gperf,gphoto,gqview,grip,gsl,gsm,gstreamer,gtar,gtg,gtk+,gtk+2,gtk,gtk2mm,gtkhtml3,gtkimageview,gtksourceview,gtkspell,gucharmap,guile,gv,gvfs,hexedit,hicolor,hpcups,hplip,hs,icu4c,id3lib,ifstat,ijs,ilmbase,imlib,imlib2,inkscape,intltool,iodbc,iso,iso8879,jack,jamvm,jasper,javaPathHelper,jbigkit,jdk,jikes,jpeg,jre,kdebase,kdeedu,kdegraphics,kdelibs,kile,kismet,koffice,kqemu,ktorrent,lame,lapack,lcms,lha,libIDL,liba52,libao,libarchive,libart,libaudiofile,libbonobo,libbonoboui,libcanberra,libcdaudio,libcddb,libcdio,libconfuse,libcroco,libcue,libdaemon,libdca,libdnet,libdockapp,libdv,libdvbpsi,libdvd,libdvdcss,libdvdnav,libdvdread,libebml,libelf,liberation,libev,libexecinfo,libexif,libf2c,libffi,libgadu,libgamin,libgcrypt,libgdata,libgdiplus,libglade2,libgnome,libgnomecanvas,libgnomecups,libgnomekbd,libgnomeprint,libgnomeprintui,libgnomeui,libgpg,libgphoto,libgsf,libgtop2,libguess,libgweather,libical,libiconv,libid3tag,libidn,liblrdf,libltdl,libmad,libmagic,libmatroska,libmikmod,libmms,libmng,libmp4v2,libmpcdec,libmpeg2,libmspack,libnasl,libnotify,libogg,liboil,libpaper,libpqxx,libproxy,libpst,librsvg,libsamplerate,libsexy,libshout,libsigc++,libsigsegv,libslang,libsndfile,libsoup,libspectre,libstdc++,libtasn1,libtheora,libtool,libungif,libunique,libusb,libvorbis,libvpx,libwmf,libwnck,libwpd,libxdg,libxfce4ui,libxfce4util,libxfcegui4,libxklavier,libxml,libxslt,libyaml,lightning,links,lsof,lua,luarexlib,luasocket,luastdlib,lyx,lzo,lzo2,lzop,mc,mcs,meanwhile,memtester,metaauto,metacity,midori,minitube,mldonkey,mono,monodevelop,mousepad,mowgli,mozilla,mplayer,mysql,nasm,neon,nessus,net,netpbm,nmap,notification,nspr,nss,ntp,octave,oniguruma,opal,openclipart,openjpeg,openldap,openmotif,openoffice,orc,osd_clock,ossp,p5,p7zip,pango,pangomm,pciutils,pcre,pdfjam,pgadmin3,physfs,png,polkit,poppler,popt,postgresql,ps2eps,pstree,psutils,ptlib,py,python,qemu,qgo,qt3,qt4,qtoctave,quake2,quirks,raptor,rarian,rdesktop,recordmydesktop,redis,redland,rednotebook,regionset,rlwrap,rsync,ruby,sane,scanssh,schroedinger,scribus,sdl,shared,silc,skill,slib,smpeg,sound,soundtouch,sox,speex,sqlite3,ssldump,startup,streamripper,subversion,sudognu,sudoku,t1lib,t1utils,taglib,tcl,testdisk,texlive_base,texlive_texmf,thunar,tiff,tightvnc,tk,toolame,tor,totem,transcode,transfig,tremor,ufconfig,umfpack,unzip,vim,vlc,vorbis,vte,wavpack,webkit,wget,windowmaker,wmapm,wmcalclock,wmclock,wmcube,wmminichess,wmmixer,wmnet,wmnetload,wmtictactoe,wmtz,wordnet,wpi,wv2,wxWidgets,x11vnc,x264,xawtv,xblast,xcd,xchat,xchm,xcursor,xdg,xemacs,xfce,xfce4,xfconf,xfdesktop,xfig,xfwm4,xmlrpc,xmonad,xosd,xpdf,xsane,xulrunner,xvidcore,xxxterm,xz,yelp,yencode,yt,zenity,zip,zoo
- (607)How to generate a sequence in openBSD?
jot <# values needed> <start value>
e.g., jot 10 50
From: http://www.patpro.net/blog/index.php/2008/12/02/644-jot-et-seq-creer-des-sequences-en-ligne-de-commande/
- (608)How to get the IRQs in use by the devices attached to the PC?
$ vmstat -i
interrupt total rate
irq0/clock 27470521 200
irq0/ipi 33769193 245
irq144/acpi0 1 0
irq145/inteldrm0 144567 1
irq176/azalia0 378904 2
irq112/wpi0 7 0
irq106/bge0 1923025 14
irq96/uhci2 672 0
irq96/ehci1 21 0
irq105/ahci0 852129 6
irq146/pckbc0 27022 0
irq147/pckbc0 889140 6
Total 65455202 476
- (635)What to do if everything typed at the login prompt is in caps?
This is a feature, not a bug, actually.
Hitting CTRL-D at the login prompt will cause getty(8) to terminate, and init(8) will relaunch a new one, which will accept uppercase and lowercase properly.
- (697)How to burn a DVD from commandline?
growisofs -overburn -dry-run -Z /dev/rcd0a -r -J -iso-level 3 /path/to/burn
- (706)Script to automatically mount SMB shares (e.g. sent by mail and clicable in ThB)
#!/usr/local/bin/bash
# USAGE
# ~/open_win_shares '\\dtasac1\DCSI\LIMA\AFIA2011\EvenementGrandPublic'
if [[ x"$#" != x"1" ]]
then
kdialog --error "Error, no shared directory provided! ($# args)"
else
shared_dir="$1"
pass=`kdialog --password "Please enter your SMB@Intra password for $1"`
/usr/local/sbin/shlight "`echo ${shared_dir:7} | tr '\' '/'`" ~/Shares/WinSMB -W INTRA -U gm224627 -P ${pass}
konqueror ~/Shares/WinSMB
fi
# umount ~/Shares/WinSMB/
- (709)How to start FTP server (in OpenBSD only?)?
/usr/libexec/ftpd -A -4 -D -l -l
- (713)Patterns od commands to connect/copy files from home
ssh -X -p 2222 user@domain.org
scp -r -P 2222 user@domain.org:~/ .
- (757)How to configure Grub2?
Configuring GRUB 2
Do the following to configure GRUB 2.
Open the file /etc/grub.d/40_custom with your preferred editor. You will probably need root privileges.
Add the following to the end of the file. This assumes that OpenBSD is installed on the fourth partition of the first hard disk. Adjust the second line if OpenBSD is installed on another partition.
menuentry "OpenBSD" {
set root=(hd0,4)
chainloader +1
}
The GRUB 2 configuration file needs to be regenerated. By default, this file is located in /boot/grub/grub.cfg. Run the following command with root privileges to regenerate it.
# grub-mkconfig -o /boot/grub/grub.cfg
See the GRUB 2 manual for more information about grub-mkconfig.
If you run Ubuntu, however, you should run following command instead of the previous one.
# update-grub
The update-grub command does essentially the same as grub-mkconfig. See the update-grub(8) manual page for more information.
Reboot your machine. An entry named ‘OpenBSD’ should appear in the GRUB menu.
If GRUB 2 fails with the message ‘error: invalid signature’ when you attempt to boot OpenBSD, you should check whether you really specified the correct partition in the configuration file.
From: http://www.kariliq.nl/openbsd/grub2.html
- (759)How to make a backup of the OpenBSD boot loader?
# dd if=/dev/rwd0a of=openbsd.pbr bs=512 count=1
- (795)How to generate One Time Passwords (OTP), S/Key, unique use passwords?
skey, otp-md4, otp-md5, otp-rmd160, otp-sha1
From: http://www.openbsd.org/cgi-bin/man.cgi?query=skey&sektion=1
- (1620)How to make NVIDIA driver work on PC-BSD/FreeBSD on GL's old laptop?
1. Install "legacy" package: nvidia-340 instead of nvidia-346
2. Change permissions on nvidia.ko: a+rx / u+w
3. Use Xorg-configure to generate the /etc/X11/xorg.conf file instead of nvidia-settings(core dumps)/nvidia-config(generates wrong file)
- (1638)How to make SSH server work on PC-BSD?
Comment out line containing "PARANOID" in /etc/hosts.allow , but be aware that this removes a protection against spoofing.
Thanks Dru Lavigne
- (1639)How to follow stable AND get security (bin)patches in OpenBSD?
==NEW
Use syspatch (nammed like sysmerge!) it replaces M:Tiers external solution
From: https://man.openbsd.org/syspatch
==OLD
You can use the "openup" tools (see url below) or do it manually:
1) Install the M:Tier public key (https://stable.mtier.org/mtier-58-pkg.pub )
/etc/signify/mtier-58-pkg.pub
2) Setup your PKG_PATH to also retrieve M:Tier packages
export PKG_PATH=https://stable.mtier.org/updates/$(uname -r)/$(arch -s):${PKG_PATH}
3) Updating all packages to their latest stable version is just a matter of running:
pkg_add -u
4) Installing binpatches must be done manually (since they update the base system)/
pkg_add <name of the patch>-<version>.tgz
From: https://stable.mtier.org/
http://www.mtier.org/index.php/solutions/apps/openup/
- (1641)How to change the keyboard mapping/language in PC/FreeBSD?
kbdmap # opens a menu
- (1642)How to resolve "Fontconfig warning: "local.conf", line 1093: saw number, expected matrix" on PC-BSD 10.2?
Just remove some lines in /usr/local/etc/fonts/local.conf
- <!-- FIXME: dirty_hack(tm) - fontconfig reports syntax errors -->
- <match target="font">
- <test qual="any" name="matrix" compare="not_eq">
- <double>0</double>
- </test>
<!-- another approach - no errors but freezes Firefox 1.5 -->
- <!--
<match target="font">
+ <!--
<test qual="any" name="matrix" compare="eq">
From: https://github.com/pcbsd/pcbsd/commit/b67e5b443742d370daadb21c1b2289c7261c21b2
- (1646)How to solve "error: file 10.2-RELEASE-p11-up-20160115-120016 not found" at PC-BSD's grub menu?
PROBLEM: used PC-BSD's "Disk Manager" to remove some snapshots in order to free some disk space => PC is not booting anymore
SOLUTION:
- Startup with Ubuntu USB key
- Install QEmu
- Download PC-BSD's Net Install ISO
- Run:
qemu-system-x86_64 -m 1024 -boot d -cdrom pcbsd_netinstall.iso -drive file=/dev/sda,index=0,media=disk,format=raw
- Before installation, menu asks to select keyboard layout. At bottom you can see several bouttons, one is a shell icon
- Click on it, it will open a text prompt that asks what you want: open root shell, import ZFS, fix grub, etc.
- I've imported+mounted the disk (ZFS pool nammed "tank"), verified its content
- Then ran fix grub
- (1671)How to solve error "at: you do not have permission to use this program" on PC-BSD?
- You have to create a /var/at/at.allow file (/etc/at.allow on linux)
- The format of the file is a single user name on each line, with no char before/after & a carriage return at the end of the line, even the ast one!
From: https://www.freebsd.org/cgi/man.cgi?query=at&sektion=1
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/3/html/System_Administration_Guide/s1-autotasks-at-batch.html#S2-AUTOTASKS-AT-BATCH-CONTROLLING-ACCESS
- (1697)How to install rJava on BSD?
FreeBSD uses BSD-make instead of GNU-make (gmake).
Therefore, you have to build packages like rJava at the shell (command prompt).
It can be done with a sccript like:
--script begins--
#!/bin/sh
export MAKE=gmake
R CMD INSTALL rJava_0.9-3.tar.gz
--script ends--
From: http://r.789695.n4.nabble.com/rjava-on-FreeBSD-td4287033.html
- (1889)How to freshly re-install all packages?
# pkg_info -A > list
# pkg_delete -vvv -X
# pkg_add -z -l list
- (1890)How to allow simple users to mount devices?
sysctl ' kern.usermount' to '1'
NOTE: disabled in 6.0!!!
"Finally, the kern.usermount sysctl is also no more. Administrators who want to let users mount devices will need to configure doas(1) for that task."
From: http://undeadly.org/cgi?action=article&sid=20160901090415
- (1891)How to set the max amount of memory that each user can use?
Set a profile for himem in login.conf:
:datasize-max=1536M:\
:datasize-cur=1536M:\
Set this profile as the user's login one:
usermod -L <profile> <user>
- (1892)What to do if the package database is bogus?
# pkg_check
From: http://comments.gmane.org/gmane.os.openbsd.ports/53347
- (3841)How to solve "undefined symbol '_tthread_timespec_get'" when compiling an R package?
Use these makevars (thanks to @wch and https://github.com/rstudio/httpuv/issues/120):
CXX11 = clang++
CXX11STD = -std=gnu++17
You can find default values in /usr/local/lib/R/etc/Makeconf
From: https://github.com/r-lib/later/issues/115
- (2447)How to create a device in OpenBSD, when it has not created it automagically (e.g. during some installs)?
# cd /dev
# sh MAKEDEV sd1 sd2
From: https://www.openbsd.org/faq/faq14.html#softraidDI
- (2526)How to customize resolution for OpenBSD in VirtualBox?
VBoxManage setextradata OpenBSD CustomVideoMode1 1360x768x32
VBoxManage.exe getextradata OpenBSD
Key: CustomVideoMode1, Value: 1360x768x32
Key: CustomVideoMode2, Value: 1366x768x32
Key: CustomVideoMode3, Value: 1368x768x32
Key: GUI/LastCloseAction, Value: SaveState
Key: GUI/LastNormalWindowPosition, Value: 9,40,720,442
Key: GUI/LastScaleWindowPosition, Value: 640,280,640,480
Key: GUI/ScaleFactor, Value: 1
From: https://www.tumfatig.net/20190131/customized-resolution-for-openbsd-in-virtualbox/
- (2528)Avoiding multiple instances of cronjobs to collide?
Sometimes you want to run a cronjob on a frequent basis, but you rarely want a new one to start before the old one has finished.
There is an easy tool in FreeBSD base called lockf. It is similar to the flock tool.
Here is an example I am using:
04 * * * * /usr/bin/lockf -t 0 /tmp/.rsyncer.rsync.papers ${HOME}/bin/rsync-backup-from-papers.sh
Based on the man page, the lockf utility acquires an exclusive lock on /tmp/.rsyncer.rsync.papers, creating it if necessary, and removing the file on exit unless explicitly told not to. While holding the lock, it executes a command with optional arguments.
From: https://dan.langille.org/2019/01/13/avoiding-duplicate-cronjobs/
- (2574)How to change the machine ID in *BSD?
/etc/machine-id
systemd-machine-id-setup(1) may be used by installer tools to initialize the machine ID at install time, but /etc/machine-id may also be written using any other means.
From: https://www.freedesktop.org/software/systemd/man/machine-id.html
- (2576)How to switch keyboard in CLI in OpenBSD?
wsconsctl keyboard.encoding=us
From: https://unix.stackexchange.com/questions/11652/how-to-change-the-usb-keyboard-layout-in-an-openbsd-console#11653
- (2598)How to enable Action Button Shutdown&Restart in the Dialog that appears when quitting XFCE?
== NEW (2024)
---8< ~/.xsession
exec startxfce4 --with-ck-launch ## + user in 'wheel' group?
---8< /etc/rc.conf.local
xenorama=...
dbus_enable
pkg_scripts=dbus_daemon avahi_daemon messagebus
== From PhJ
1 / installer dbus (deja là avec xfce)
2 / rcctl enable messagebus
3 / rcctl enable apmd (si on veut suspend et hibernate)
4 / ajouter le <user> dans le groupe _shutdown pour restart et shutdown, dans le groupe wheel pour suspend et hibernate
5 / démarrer messagebus et apmd à la main si nécessaire (sinon, ils sont démarrés lors du prochain reboot)
En fait, c’est polkit qui gère ça (voir /usr/local/share/polkit-1/rules.d/* )
== OLD
To be able to shutdown the computer, you have to be listed in the systems sudoers file, in particular, you must be allowed to execute the command ${libdir}/xfce4/session/xfsm-shutdown-helper (/usr/sbin/xfsm-shutdown-helper on Debian GNU/Linux) as user root (where ${libdir} is the lib sub directory in the prefix you installed xfce4-session, for example /usr/local/lib/xfce4/session).
For example, lets say, you installed xfce4-session into /usr/local, your hostname is myhost and your user account is named myuser, then you would have to add the following line to your sudoers file (remember to use visudo to edit that file):
myuser myhost=/usr/lib/xfce4/session/xfsm-shutdown-helper
From: https://docs.xfce.org/xfce/xfce4-session/logout
----
Programs used to shutdown/suspend the computer from XFCE are : xfsm-shutdown-helper and xfce4-session-logout
Shutdown&Restart seem to work out-of-the-box with basic install of OpenBSD (6.1+) + installation of packages: "consolekit2", "xfce" and "xfce-extras" + using "xenodm" and using the following .xsession script:
exec ck-launch-session startxfce4
Other people indicate the use of policykit, with rules.d/30-stop_restart.session.rules:
--
polkit.addRule (function (action, subject) {
if (action.id == "org.xfce.session.xfsm-shutdown-helper"
&& subject.isInGroup ("users")) {
return polkit.Result.YES;
}
});
---
From: https://forum.xfce.org/viewtopic.php?id=11601
- (2632)How to run Docker on OpenBSD 6.2+?
Steps:
1- Use vmm/vmd (OpenBSD's virtualization system) to run a basic/cloud linux, e.g. AlpineLinux (https://www.alpinelinux.org/downloads/) and configure its network interface:
http://www.h-i-r.net/2017/04/openbsd-vmm-hypervisor-part-2.html
https://medium.com/@dave_voutila/tips-for-alpine-linux-under-openbsd-dca8d09568b4
https://wiki.alpinelinux.org/wiki/Installation
vmctl create alpine-virt.img -s 6G
## UPDATE: network config can now be done automagically with -L!!!! https://man.openbsd.org/vmctl.8#LOCAL_INTERFACES
doas sysctl net.inet.ip.forwarding=1 # for NATing
doas vmctl start alpine-vm [-L] -c -d alpine-virt-xxx.iso -d alpine-virt.img -m 1024M -n local # You might need to pass "console=ttyS0,115200" to the Alpine's kernel to be able to use the console
2- Install Docker in this linux
doas vmctl start alpine-vm -c -d alpine-virt.img -m 1024M -n local
# Edit /etc/apk/repositories un-commenting the line that looks like: http://dl-3.alpinelinux.org/alpine/v3.6/community
apk add docker
adduser dave -G wheel,docker
apk add sudo # + edit /etc/sudoers to allow your user or members of wheel ability to run sudo'd commands.
# Do the old ~. routine to detach the serial console
3- Now use ssh to login to your VM
From: https://medium.com/@dave_voutila/docker-on-openbsd-6-1-current-c620513b8110
- (2710)How to clean unused packages (a.k.a. What is the equivalent of 'apt autoremove' in OpenBSD)?
Per the pkg_delete(1) manpage:
-a Delete unused dependencies (packages that are not needed
by anything tagged as installed manually). Can be used
without pkgnames. If used with pkgnames, it will only
delete non manual installs in the list.
From: http://daemonforums.org/showthread.php?t=6989#post43386
- (2711)How to enable the starting of Xorg at boot after installation?
# rcctl enable xenodm
# rcctl start xenodm
From: https://www.openbsd.org/faq/faq11.html#StartingX
- (2735)How to set a custom resolution for OpenBSD in VBox?
1 - In the Host
VBoxManage setextradata OpenBSD CustomVideoMode1 1360x768x32
VBoxManage getextradata OpenBSD # to verify above command worked
2 - In the Guest
# mkdir -p /etc/X11/xorg.conf.d
# vi 00-virtualbox-monitor.conf
# X11 configuration for VirtualBox
Section "Device"
Identifier "VirtualBox-Card"
Driver "vesa"
VendorName "InnoTek"
BoardName "VirtualBox Graphics Adapter"
EndSection
Section "Monitor"
Identifier "VirtualBox-Monitor"
VendorName "InnoTek"
ModelName "VirtualBox Screen"
HorizSync 1.0 - 1000.0
VertRefresh 1.0 - 1000.0
EndSection
Section "Screen"
Identifier "VirtualBox-Screen"
Device "VirtualBox-Card"
Monitor "VirtualBox-Monitor"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
#Modes "1368x768" "1360x768" "1280x800" "1024x768"
Modes "1360x768"
EndSubSection
EndSection
Restart xenodm to apply the custom resolution:
# rcctl restart xenodm
From: https://www.tumfatig.net/20190131/customized-resolution-for-openbsd-in-virtualbox/
- (2825)How to upgrade an OpenBSD 65+ box?
# sysupgrade
# syspatch
# pkg_add -Uu
# sysmerge -d
From: https://www.openbsdhandbook.com/upgrade/
- (2994)How to Boot OpenBSD kernels in EFI mode with QEMU?
As it turns out, it's possible to achieve using OVMF (Open Virtual Machine Firmware), a BSD licensed UEFI firmware implementation targeted at virtual machines. A prebuilt image can be downloaded here.
We will need to create two drives:
One drive using a FAT filesystem to store the EFI payload (the OpenBSD bootloader)
Another drive using a FFS filesystem containing the OpenBSD kernel
Thankfully, QEMU allows to create virtual drives with FAT filesystems from local directories, and we can easily create an FFS filesystem image using makefs(8).
We will start by creating a directory structure:
mkdir -p bootloader/efi/boot
mkdir -p kernel/etc
We then copy the OpenBSD EFI bootloader:
cp /usr/mdec/BOOTX64.EFI bootloader/efi/boot
Alternatively, an OpenBSD EFI bootloader can be downloaded here.
Then, we need to place the EFI firmware image at the root of our directory, and the OpenBSD kernel we want to boot in the kernel directory.
The directory structure should look as follow:
OVMF.fd
bootloader
bootloader/efi
bootloader/efi/boot
bootloader/efi/boot/BOOTX64.EFI
kernel
kernel/etc
kernel/bsd
We can now create the random.seed file and build the FFS filesystem image:
dd if=/dev/random of=kernel/etc/random.seed bs=512 count=1
makefs -t ffs kernel.img kernel
Finally, let's start QEMU:
qemu-system-x86_64 -s --bios OVMF.fd \
-drive format=raw,file=fat:rw:bootloader,media=disk \
-drive format=raw,file=kernel.img,media=disk
And boot our kernel:
boot> boot hd1a:/bsd
NOTE: The ISO image does not contain an UEFI boot loader, it only supports legacy BIOS boots. A EFI loader for CD doesn't exist yet for OpenBSD.
You need to use the USB media install66.fs for UEFI installations which contains BOOTX64.efi and BOOTIA32.efi (for machines with 64-bit CPUs, but 32-bit UEFI.)
https://www.reddit.com/r/openbsd/comments/efm1v0/cant_boot_install66iso_on_uefi/
From: https://www.cambus.net/booting-openbsd-kernels-in-efi-mode-with-qemu/
- (3069)How to upgrade manually (e.g., if HDD is broken and normal install stops on / fcsk)?
Install kernel:
cp bsd.[sp/mp] /bsd
Install base packages:
cp /sbin/reboot /sbin/oreboot
tar -C / -xzphf xshare67.tgz
tar -C / -xzphf xserv67.tgz
tar -C / -xzphf xfont67.tgz
tar -C / -xzphf xbase67.tgz
tar -C / -xzphf man67.tgz
tar -C / -xzphf game67.tgz
tar -C / -xzphf comp67.tgz
tar -C / -xzphf base67.tgz # Install last!
/sbin/oreboot
Create devices:
cd /dev && ./MAKEDEV all
Update boot loader:
installboot sdx
Update system:
sysmerge
fw_update
syspatch
pkg_add -u
From: https://www.openbsd.org/faq/upgrade67.html#NoInstKern
- (3312)How to get the instantaneous network traffic in *BSD?
Goal: be able to display this info in Awesome/i" statusbar
/usr/bin/netstat -i -b -n -I $INTERFACE
From: https://superuser.com/questions/197904/how-to-see-network-traffic-per-interface-in-freebsd/231714#231714
- (3384)How to enter an Hexadecimal WEP key with ipconfig?
You need to prefix the key with '0x':
ifconfig bwi0 nwid MyNetwork nwkey 0x37324a7f
From: http://daemonforums.org/showpost.php?s=b878763825e10942d0206cde84c2a621&p=38430&postcount=11
- (3523)Howto execute a commands every time a file changes?
"entr" allows that in BSDs.
Also see Tip#3369
From: https://openports.se/sysutils/entr
- (3552)How to get color in "ls" output?
SOLUTION1: With "colorls"
export TERM=wsvt25
alias ls='/usr/local/bin/colorls -G'
SOLUTION2: With "lsd"
- Install Nerd fonts
apt install fonts-ubuntu
- Add this to .bashrc
export TERM=xterm-256color
alias ls='lsd -ahl --color auto'
- Set your terminal to use "Ubuntu Mono Nerd font" (xfce4-terminal > Edit > Preferences > Appearance)
SOLUTION3: With exa (NOT TESTED)
export TERM=xterm-256color
alias ls='exa --color automatic --color-scale --icons -a'
From: https://packetfilter.wordpress.com/2008/04/18/color-ls-on-openbsd/
https://github.com/Peltoche/lsd
https://github.com/ogham/exa
- (3554)How to find which package provides a given file in OpenBSD?
SOLUTION 1: if package is installed
pkg_info -E /path/to/file
SOLUTION 2: if package is not installed
- Install package pkglocatedb
- Use its command pkglocate
pkglocate */bin/<searched_file>
From: https://dataswamp.org/~solene/2020-09-04-pkglocate-openbsd.html
- (3609)How to make OpenBSD+XFCE work in VirtualBox?
OpenBSD-amd64+xfce inside VirtualBox seems to freeze and not respond to mouse clicks or keystrokes when left alone for some time.
PROBLEM: xfce4-screensaver becomes active & does not work correctly within VirtualBox
SOLUTION1: disable it (who needs it anyway in a VM?)
xfce4-power-manager > Display & xfce4-power-manager > Security
SOLUTION2: TO BE TESTED : change VBox's graphics driver (sVGA, etc.)?
From: https://misc.openbsd.narkive.com/QDbmqgOi/6-9-current-amd64-xfce-seems-to-freeze-and-not-respond-to-mouse-clicks-or-keystrokes
- (3700)How to get faster packages updates with OpenBSD?
PROBLEM:
When you use "pkg_add", some magic happens to expand the base url (configured in /etc/installurl) into full paths usable by PKG_PATH:
http://ftp.fr.openbsd.org/pub/OpenBSD
becomes:
http://ftp.fr.openbsd.org/pub/OpenBSD/%v/packages-stable/%a/:http://ftp.fr.openbsd.org/pub/OpenBSD/%v/packages/%a/
The '/packages/' URL is useless as the packages from the -release will never change.
SOLUTION1: One shot modification for a single run, reusing the content of /etc/installurl
env PKG_PATH="$(cat /etc/installurl)/%v/packages-stable/%a/" pkg_add -u
SOLUTION2: Hard coding the url in PKG_PATH or /etc/installurl
env PKG_PATH="http://ftp.fr.openbsd.org/pub/OpenBSD/%v/packages-stable/%a/" pkg_add -u
NOTE: messages like "Couldn't find updates for ..." will be normal as some packages might never have received any patches thus not appear in /packages-stable/.
From: https://dataswamp.org/~solene/2021-08-06-openbsd-pkgadd-tuning-updates.html
- (3701)What are the "flavors" of OpenBSD?
-release: shipped every six months
-stable: == -release plus patches (support for 2 previous releases)
-current: development branch
From: https://www.openbsdjumpstart.org/#/6
- (3702)How to register multiples wifi networks on OpenBSD?
Use the "join" keyword in /etc/hostname.if
join android_hotspot wpakey t00345Y4Y0U
join my-home wpakey goodbyekitty
join friends1 wpakey ilikeb33r5
join favorite-bar-hotspot
From: https://dataswamp.org/~solene/2021-08-05-openbsd-wifi-list.html
https://man.openbsd.org/ifconfig.8#join
https://www.openbsd.org/faq/faq6.html#Wireless
- (3708)How to run a LiveDVD/USB of OpenBSD?
Use FuguIta, there's even a way to store modifications (installed packages, etc.) on the media without changing the base system (in a cyphered FS!!!)!
From: http://fuguita.org/index.php
http://fuguita.org/index.php?FuguIta%2FStartGuide
http://fuguita.org/index.php?FuguIta%2FStartGuide#fbb637bf
http://fuguita.org/index.php?FuguIta%2FStartGuide#vfc178d9
http://fuguita.org/index.php?FuguIta%2FStartGuide#r3ded977
http://fuguita.org/index.php?FuguIta%2FBBS%2F9#i79876b5
http://fuguita.org/index.php?FuguIta%2FStartGuide#t502cf6e
- (3731)How to debug wifi/WEP connection in OpenBSD?
Rather than DHCP, you can try running
# tcpdump -ni bwi0
No IP address is needed for this. If the connection and encryption are right, and if there is wireless network traffic, you should see packets being reported.
From: http://daemonforums.org/showthread.php?t=5985&page=2
- (3796)How to set the time (from network) immediatly?
rdate -n time.cloudflare.com
From: https://daemonforums.org/showthread.php?t=3646#post26165
- (3928)How to get the Disk UID in OpenBSD?
sysctl hw.disknames
From: https://fluca1978.github.io/2021/11/25/OpenBSDMount.html#find-out-the-disk-uid
- (4054)How to boot OpenBSD disabling devices (e.g. Faulty athn Wifi that crashes at boot)?
NOTE: Everything has to be written in QWERTY here since we are even before the OS has booted
> boot -c
UKC> list
.... # Find your device class
UKC> disable ath* # Disable the whole class of devices...
UKC> disable athn* # ...not sure which one of the 2 lines is the correct one
UKC> quit
From: https://man.openbsd.org/boot_config
- (4098)What is the proper way to upgrade OpenBSD (at least to 7.4)?
sysupgrade # Upgrade to new version
syspatch # Get latest patch since release
pkg_add -Uu # new faster dependencies management
sysmerge -d # non-interactive/manual mode
From: https://www.openbsdhandbook.com/upgrade/
- (4109)How to clone a machine (a.k.a. How to reinstall the same packages on dest machine as on src machine)?
pkg_info -m -z # -m is for user installed only / -z is for "fuzzy" names (without version number)
Thanks PhJ
- (4110)How to install a package/flavour without specifying version number?
PROBLEM: in OpenBSD packages are name like "pkgname-version-flavor"
SOLUTION: Just skip the version number
pkg_add "pkgname--flavor"
e.g.: pkg_add vim--no_x11
Thanks PhJ
- (13)Send a message to a windows machine
echo "Hello World!" | smbclient -M <WorkGroup> -I<IPADDRESS> -Utest -d3
- (14)Path and Environment Variables
You can view the environment variables on your PC by typing set in the
command shell. The variables of interest to you are Home and Path. You
can set the path and create/edit environment variables on Windows
2000/XP by clicking System in the Control Panel. On the Advanced tab,
click Environment Variables. Click Edit to make a change to a variable
(example: adding a directory to the path), and click New to create a
new variable (example: creating the Home variable). In order to add a
program to the path variable, you need to add the directory that
contains the executable for the program. The executable directory for
each of the programs listed on this page is given under Executable
directory. Make sure to include the root directory of each program
while entering the directory names in the path variable.
- (15)Mount Samba directory
smbmount //<SERVER>/<SHARED DIR> <MOUNT POINT> \
-o username=<DOMAIN>\\<user> workgroup=<WORK GROUP>
- (16)List offered services
smbclient -L <SERVER> -U <USER> -W <WORK GROUP>
- (17)Getting IP address
winipconfig
- (18)Knowing progs that launches at boot
msconfig
- (19)To kill these pop ups, disable the Messenger service
Run the Services Microsoft Management Console by typing //services.msc// at
a command prompt
- (20)Registry files
ntuser.dat (inside Doc&Settings) and system.dat
- (21)Windows Logs
.evt files
- (249)How to get a multi_key/compose key under windows?
Il suffit, dans n'importe quelle application, d'utiliser le code ASCII adéquat : ALT+0199. Mais le plus simple est encore d'installer ce pilote [http://club.euronet.be/frederique.bouras/kbdfrac.htm].
from: http://www.commentcamarche.net/forum/affich-420768-comment-mettre-une-cedille-a-un-c-majuscule#6
Compose/Multi Key on win
========================
http://en.wikipedia.org/wiki/Compose_key
- (284)How to make windows behave like a REAL OS?
To install the following software, the best option is to install a package manager:
https://portableapps.com/
https://chocolatey.org/
https://www.slant.co/topics/1843/~best-windows-package-managers
It allows you to easily install/remove/auto-update many Free&Libre software.
---
0a - Get Win10 ISO
https://www.microsoft.com/en-us/software-download/windows10 {NOTE: set UserAgent to Linux to get ISO links!}
See Tip#2638
0b - Register/Activate windows
See Tip#1876 & Tip#2606
0c - Install PkgManager + Apps below
https://portableapps.com/
See Tip#2802 to add PortableApps to the start menu
0d - Debloat Windows
NEW https://github.com/builtbybel/BloatyNosy [ThisIsWin11 replacement]
OLD https://github.com/builtbybel/ThisIsWin11/ [privatezilla replacement]
OLDOLD https://www.builtbybel.com/ms-apps/privatezilla [debotnet replacement]
OLDOLD https://www.builtbybel.com/ms-apps/sharpapp [debotnet replacement]
OLDOLDOLD https://gist.github.com/tkrotoff/830231489af5c5818b15
See Tip#1721 & Tip#1856
0e - Disable Tracking
https://alternativeto.net/software/debotnet/ [Discontinued => see above]
https://github.com/10se1ucgo/DisableWinTracking
---
1a - Install "Microsoft PowerToys"
https://dev.to/ivanjeremic/microsoft-powertoys-is-a-must-have-for-developers-on-windows-3a6o
1b - Install and use "Dexpot"/"VirtuaWin" to access multiple desktop
http://www.dexpot.de/index.php?lang=en
http://downloads.sourceforge.net/portableapps/VirtuaWinPortable_4.4_English.paf.exe
1c - Install a pseudo-tiling window manager
https://www.nurgo-software.com/products/aquasnap
2 - Install and use "True X-Mouse Gizmo"/"AutoHotKeys" to get normal copy&paste behaviour, through simple selection (without needing to type CTL-v)
http://fy.chalmers.se/~appro/nt/TXMouse/
https://autohotkey.com/ + script
3a - Install and use "AllChars"/"WinCompose" to be able to put accents on any letter (uppercase included, since it is said mandatory by typographists of the Journal Officiel)
http://allchars.zwolnet.com/ [-> DEAD]
https://github.com/SamHocevar/wincompose or http://webcomposekey.dt1.org/ [win10] (see: https://superuser.com/questions/64178/compose-key-on-windows)
3b - Install "AutoHotKeys" to enable launching of scripts on MultiKey press and swapcaps (See Tip#2353)
https://autohotkey.com/
4 - Install and use "MyDefrag"/"JkDefrag" to intelligently defrag your FAT/NFTS HD (i.e, freeing the ends of partitions, in order to make room to create new partitions and install REAL OSes)
http://www.mydefrag.com/Manual-DownloadAndInstall.html
http://downloads.sourceforge.net/portableapps/JkDefragPortable_3.36_Rev_2.paf.exe
5 - To get a real Process listing:
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
http://downloads.sourceforge.net/portableapps/ProcessExplorerPortable_16.04_online.paf.exe
http://downloads.sourceforge.net/portableapps/ProcessHackerPortable_2.33_English.paf.exe
http://downloads.sourceforge.net/portableapps/DaphnePortable_2.04.paf.exe
http://portableapps.com/redirect/?a=SystemExplorerPortable&t=http%3A%2F%2Fdownloads.portableapps.com%2Fportableapps%2Fsystemexplorerportable%2FSystemExplorerPortable_6.2.0.paf.exe
6 - To get e real Text Editor: notepad++
http://sourceforge.net/projects/notepad-plus/
7 - Add a PDF printer in order to be able to generate PDFs
http://sourceforge.net/projects/pdfcreator/
8 - Install "Filezilla"/"Putty" to be able to communicate with other machines (in a secured way)
http://downloads.sourceforge.net/portableapps/FileZillaPortable_3.10.0.1.paf.exe
http://www.chiark.greenend.org.uk/~sgtatham/putty/
9 - Install MikTeX in order to be able to write papers/posters/slides with a serious & scientific appearance
http://miktex.org/
10 - Install Bibus/JabRef to manage BibTeX database
http://bibus-biblio.sourceforge.net/wiki/index.php/Main_Page
http://jabref.sourceforge.net/
11 - Install TortoiseSVN to be able to synch and versionize your productions between @home and @work machines
http://tortoisesvn.tigris.org/
12 - Install Firefox and Thunderbird to be able to surf and read emails
http://www.mozilla.org
13 - Install p7zip or peazip in order to be able to de/compress any archive
http://p7zip.sourceforge.net/
https://peazip.github.io/
14 - Install The GIMP to manupilate/transform images
http://www.gimp.org/
15 - Eventually install MPClassic and VLC to view films in any format
http://sourceforge.net/projects/guliverkli/
http://www.videolan.org/vlc/
16 - Eventually install gs/gv to manipulate PS files
http://pages.cs.wisc.edu/~ghost/
17 - Eventually install PDFXchange/Okular to manipulate pdf files
http://www.tracker-software.com/product/pdf-xchange-viewer/
http://okular.kde.org/
18 - Install InfraRecorder to burn CD/DVDs
http://infrarecorder.org/
19 - Install DaemonTools or CloneDrive to be able to read/mount ISO files
http://www.daemon-tools.cc/fra/downloads
http://www.slysoft.com/fr/virtual-clonedrive.html
- (339)How to set/change the network identity?
Clic droit / Poste de travail -> Nom de L'ordinateur -> Identité Réeau
From: http://www.tutoriaux-excalibur.com/forum-7/partager-une-imprimante-reseau-avec-xp-partie2-t866.html
- (404)How to manage certificates? (7even?)
Look for a tool called "console mmc"
- (405)How to swap MAJ and CTL keys?
I] Version using Windows commands only (REQUIRES REBOOT EACH TIME CHANGED!!)
Create a file containing:
---- swapcaps.reg
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
[HKEY_CURRENT_USER\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
---
2. Execute it
3. Reboot (YES! you're under windows! :))
Form: http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc14
II] Version with AutoHot Key
; -------------------------------------------------------------------------
; Swap CTRL-L and CapsLock
; -------------------------------------------------------------------------
Capslock::Ctrl
LControl::Capslock
From: http://xahlee.info/mswin/autohotkey_swap_capslock.html
- (406)How to create a network bridge under windows 7?
Panneau Configuration -> Réseau -> Connections Réseau -> configurer la carte -> Sélectionner 2 cartes (clic+rectangle) / clic droit -> "Créer un pont"
- (582)How to synchronize a linux with a M$ Windows TimeServer?
net time set -W <windows domain> -U <user> -S <server>
- (583)How to Easily Print a Large Image to Multiple Pages in Windows?
- Open the image you~d like to print in Paint
- Select: Print -> Page Setup (Vista and 7), or File -> Page Setup (in XP)
- Under Scaling, select Fit to and change the setting to something like "2 by 2 page(s)"
- Click OK
- Print the image from Paint, and make sure to select "All Pages"
From: http://scottiestech.info/2009/08/08/how-to-easily-print-a-large-image-to-multiple-pages-in-windows/
- (633)How to set the session manager so that it does not ask for a password (a.k.a How to automatically login a user in Win7)?
Press the Windows key + R on your keyboard to launch the "Run" dialog box.
Type in control userpasswords2
Press Enter. The User Accounts window will display.
Uncheck the option ´Users must enter a user name and password to use this computer¡
Click OK
You will then be prompted to enter the current password and confirm it.
After doing so, you will no longer be prompted to enter your password upon login.
[For Win7]
- Run netplwiz
- Click the username for which you want to automatically login
- Uncheck "Users must enter a user name and password to use this computer"
From: http://channel9.msdn.com/Blogs/coolstuff/Tip-Auto-Login-Your-Windows-7-User-Account
http://windows7themes.net/en-us/how-to-automatically-log-into-a-user-account-in-windows-7-or-8/
- (720)How to run an executable as a different user?
Run as different user feature is built-into as an option in the hidden extended right click contextual menu of Windows 7. Which means by simply right clicking, there won’t be Run as different user option been shown in right click context menu. To display Run as different user command, press and hold Shift key while right clicking on an executable file or its shortcut.
For older M$ oses:
http://support.microsoft.com/kb/294676
- (741)How do I bring up Task Manager in Windows Server 2008 Core?
To bring up Task Manager, use the Ctrl+Shift+Esc key combination, as with typical Windows installations
From: http://www.windowsitpro.com/article/tips/how-do-i-bring-up-task-manager-in-windows-server-2008-core-
- (748)How to loop on values?
for /L %%i (start, increment, end) DO <command>
- (749)How to remove echoing of commands in batch files?
@echo off
- (750)How to increment a variable in batch file?
set /a "var = var + 1"
- (751)How to comment out a line in batch file?
REM the line to be commentted out
- (752)How to run multiple commands in a FOR loop (included: How to increment a variable)?
Within a FOR loop, variables are expanded at the start of the loop and don't update until the entire DO section has completed.
The following example counts the files in the current folder, but %count% always returns 1:
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (
echo %count%:%%G
set /a count+=1 )
To update variables within each iteration of the loop we must either use EnableDelayedExpansion or else use the CALL :subroutine mechanism as shown below:
@echo off
SET count=1
FOR /f "tokens=*" %%G IN ('dir /b') DO (call :subroutine "%%G")
GOTO :eof
:subroutine
echo %count%:%1
set /a count+=1
From: http://ss64.com/nt/for.html
- (753)How to turn off the "Unknown Publisher" warning when opening an executable file (from a mapped drive)?
Change Group Policy
Run gpedit.msc on the terminal server
Locate the setting Computer Configuration, Administrative Templates, Internet Explorer, Security Zones: Use only machine settings, and set the option to "Enabled"
Note – this will make the IE zone settings the same for all users on the computer
Add UNC paths to Security Zone
Log in as an administrator on the terminal server
Click Start ~ Run ~ and type inetcpl.cpl
On the Security tab highlight Local intranet and click Sites
Make sure the Automatically detect intranet network is unchecked
Make sure Include all network paths (UNCs) is checked
Click Advanced
In the Add this website to the zone box, one at a time type every letter from f: through z: and click add. If the drive is mapped it will add in a UNC in the pattern file://VOLUME_NAME
When you are done close out and save your changes.
From: http://www.displacedguy.com/tech/turning-off-the-unknown-publisher-warning-dialog/
- (754)How to add an item to the Context Menu for All Files?
Example for add a "Open with Notepad++" item:
Registry Hack
Open regedit.exe and navigate to the following key:
HKEY_CLASSES_ROOT\*\shell
Right-click on "shell and choose to create a new key, calling it "Open with Notepad++".
Create a new key below that one called "command".
Double-click on the (Default) value in the right-hand pane and enter in the following:
C:\Program Files (x86)\Notepad++\notepad++.exe %1
NOTE: your path may be different.
The change should take effect immediately. Now you can right-click on any file and you~ll see the new "Open With Notepad++" menu entry.
From: http://www.powercram.com/2009/12/add-open-with-notepad-to-context-menu.html
- (758)How to set Windows to use UTC instead of LocalTime
I realise this is old but it ranks high in search results so figured i would post.
Windows 7 can use UTC instead of Localtime. The time is stored in the bios, and of course is set to utc by linux and localtime by windows by default
To make this change you do need to alter the registry to be able to do this. This is an easy task if you are comfortable with windows registry
You will need admin privledges to do this, if your dual booting im guessing you know what you are doing
Create the following file WindowsUtcTime.reg and then place the following contents into the file.
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation] "RealTimeIsUniversal"=dword:00000001
Once Saved open and windows will take care of the rest.
You will need to reboot for this to take affect.
From: http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/does-windows-7-use-utc/e722ad92-a65b-4c0a-8c05-b8a84fb155d1
- (760)How to set Windows 7 bootloader to boot other OSes?
Microsoft has enhanced BCD since releasing Vista to allow multiple versions of Windows to be booted through bcdedit. Because of this greater control, five commands are required to configure a multiboot environment with OpenBSD.
After copying OpenBSD's PBR into Windows 7's system partition, issue the following command to initialize the needed registry hive:
C:\Windows\system32> bcdedit /create /d "OpenBSD/i386" /application bootsector
The entry {0154a872-3d41-11de-bd67-a7060316bbb1} was successfully created.
### GM : L'entrée {573aa504-1052-11e2-a166-88bc512bce91} a été correctement créée.
C:\Windows\system32>
As admonished before, the {0154a872-3d41-11de-bd67-a7060316bbb1} GUID is system-dependent. Note the value you receive when executing, and copy it into the following commands:
C:\Windows\system32> bcdedit /set {0154a872-3d41-11de-bd67-a7060316bbb1} device boot
The operation completed successfully.
C:\Windows\system32> bcdedit /set {0154a872-3d41-11de-bd67-a7060316bbb1} path \openbsd.pbr
The operation completed successfully.
C:\Windows\system32> bcdedit /set {0154a872-3d41-11de-bd67-a7060316bbb1} device partition=c:
The operation completed successfully.
C:\Windows\system32> bcdedit /displayorder {0154a872-3d41-11de-bd67-7060316bbb1} /addlast
The operation completed successfully.
C:\Windows\system32>
- (767)How to completely remove a printer from the computer?
Indeed, 'Remove a Device' isn't working in Windows 7, as the printer re-appears from time to time!
Method 2: Uninstall printer driver’s completely
a) Reboot the machine and login as “Administrator”.
b) Go to the start menu and start typing MMC, you will see the Microsoft Management Console shortcut appear in the start menu; click on it
c) Go up to the file menu and select Add/Remove Snap-in
d) Then scroll down in the list and select the “Print Management” snap-in and then hit “Add”.
e) At this screen you are going to want to select “Add the Local Server”, hit Finish, and then hit ok
f) Then you can scroll down to your computer name, select the driver’s tree and then right click on the driver you want to remove and select “Remove Driver Package”.
g) Make sure you reboot your machine before trying to add new or different print drivers.
From: http://answers.microsoft.com/en-us/windows/forum/windows_7-hardware/how-to-completely-remove-a-printer-from-the/38d47195-915d-e011-8dfc-68b599b31bf5?msgId=8a9a337c-717d-4534-b0a6-9bbcaaf8870b
- (776)How to make Outlook 2007++ not be so slooooooooow when getting imap emails?
- The work around in Outlook is to right click on your gmail account and select IMAP FOLDERS. Click on QUERY, after list is updated click on SUBSCRIBED tab. Unsubscribe everything except INBOX, SENT MAIL and DRAFTS.
- Limit GMAIL IMAP Messages to 1000 messages. Leave Outlook overnight to sync folders. Once completed, it is very fast with OL 2010.
- Most important: in outlook goto «send and receive» groups setup, edit the default group there and make sure it downloads only the headers for every account.
- Install Google Sync: https://tools.google.com/dlpage/gappssync
From: http://www.makeuseof.com/answers/outlook-2010-gmail-imap-account-slow/
--
1. Press Ctrl+Alt+S to open your Outlook Send and Receive groups*. Select the Gmail account that you have configured with Microsoft Outlook and now click Edit.
2. The next screen will have all the default Gmail labels (like All Mail, Trash, Inbox, Spam, etc) For Spam and Trash folders, select «Download holders only». For Inbox and Drafts, select «Download complete item including attachments.» Press OK.
[This prevents Outlook from downloading mails and attachments that are marked as Spam by Gmail]
3. You go back to the previous Send and Receive groups screen. Here adjust the time that Outlook should wait before checking for new email on Gmail server.
4. While the above tweak should solve most of your Microsoft Outlook problems, here's one extra tip: Work Offline even while you are always connected to the Internet.
From: http://www.labnol.org/software/tutorials/solutions-for-slow-gmail-imap-with-microsoft-outlook/1761/
- (778)How to prevent Outlook from sending winmail.dat?
Do recipients of your emails, seemingly out of the blue, complain about a mysterious attachment called "winmail.dat" (of the even more mysterious content type "application/ms-tnef"), which they cannot open, no matter what they try? Do files you attach disappear in that winmail.dat moloch? Does winmail.dat show up for some but not all recipients of your messages?
When, How and Why Winmail.dat-Application/MS-Tnef is Created
It's Outlook's fault, in a way. Or the recipient's email client's. If Outlook sends a message using the RTF format (which is not very common outside Outlook) for bold text and other text enhancements, it includes the formatting commands in the winmail.dat file. Receiving email clients that do not understand the code therein display it as a stale attachment. To make matters worse, Outlook may also pack other, regular file attachments in the winmail.dat file.
Fortunately, you can get rid of winmail.dat altogether by making sure Outlook does not even try to send mail using RTF.
Prevent Winmail.dat Attachments from Being Sent in Outlook
To prevent Outlook from attaching winmail.dat when you send an email:
Step by Step Screenshot Walkthrough
Select Tools | Options... from the menu.
Go to the Mail Format tab.
Under Compose in this message format:, make sure either HTML or Plain Text is selected.
Click Internet Format.
Make sure either Convert to Plain Text format or Convert to HTML format is selected under When sending Outlook Rich Text messages to Internet recipients, use this format:
Click OK.
Click OK again.
From: http://email.about.com/od/outlooktips/qt/Prevent_Winmail_dat_Attachments_from_Being_Sent_in_Outlook.htm
- (961)How to configure (system-wise) Proxy settings in Win7?
- Click Start, and then click Control Panel.
- Click Network and Internet, and then click Internet Options.
- In the Internet Options dialog box, click the Connections tab.
- Click the LAN Settings button.
- To enable the use of a proxy server, check the box for “Use a proxy server for your LAN (These settings will not apply to dial-up or VPN connections),”
From: http://answers.oreilly.com/topic/675-how-to-configure-proxy-settings-in-windows-7/
- (1365)How to start a script/exe at the insertion of a CD ? [For security reasons M$ has finally disabled this "feature"]
[autorun]
open=setup.exe
icon=setup.exe,0
label=My install CD
From : https://en.wikipedia.org/wiki/Autorun.inf
- (1366)How to run a batch script from within a batch script in Windows?
CALL nameOfOtherFile.bat
From: http://stackoverflow.com/questions/4798879/how-to-run-a-batch-script-from-within-a-batch-script
- (1364)How do I make a self-installing executable using WinRAR?
- New Archive, set to SFX mode.
- Go to Advanced tab, SFX Options button.
- General tab, "Run after extraction" textbox. Enter the file to execute, with relative path if any.
- Then go to Modes tab and set it to Temporary mode
- It will not prompt the user if you leave the question fields blank, and you can make it silent with the radio buttons at the bottom.
From: http://stackoverflow.com/questions/9265639/how-do-i-make-a-self-installing-executable-using-winrar
- (1106)What is wrong when some text randomly disappear (a.k.a mouse moves/clics occur magically) on a laptop computer?
This is often linked to a too sensitive trackpad that detects a move/clic when your hand just passes on top of it when you access the keyboard.
On windows:
1. Install the best driver possible for your trackpad
2. find the option that renders it less sensitive
On Linux (see Tip#997):
1. Install synclient & syndaemon
2. Set palm detection on
$ synclient PalmDetect=1 # (and see other palm* options)
3. To actually *disable TouchPad while tying* even on buggy devices
syndaemon -d -i .6 # .6 <=> time before auto-reenabling the trackpad after user stopped typing text, might required tuning for you
- (1100)How to escape a " on a windows prompt?
The problem is that ‘\’ does not seem to escape a double quote on the
Windows command line - try:
java weka.core.converters.CSVLoader -S 1,2 -E """" inputFile.csv >
outputFile.arff
From: http://list.waikato.ac.nz/pipermail/wekalist/2014-January/059757.html
http://stackoverflow.com/questions/19815531/how-do-i-escape-a-double-quote-with-gnu-grep-for-windows-dos
- (1077)How to fix windows 7 bootloader/MBR?
- Find a way to boot the Recovery Console
- bootrec /fixboot
- bootrec /fixmbr
From: http://kb.acronis.com/content/1507
- (1074)How to remove the multiboot menu in windows XP?
Goto tab "BOOT.INI" in
> msconfig
and remove any unwanted OS.
From: http://answers.microsoft.com/en-us/windows/forum/windows_xp-system/how-to-remove-the-dual-boot-selection-received-at/a6f9f8b7-897b-4da1-8d09-a0c72e75bf2aS
To set the timeout under 3, use:
> bootcfg /timeout 0
From: http://msdn.microsoft.com/en-us/library/windows/hardware/ff543423%28v=vs.85%29.aspx
- (1076)How to fix windows XP bootloader/MBR?
- Find a way to boot the Recovery Console
- fdisk /mbr
- bootcfg /rebuild
- fixboot
- fixmbr
From: http://chrisburgess.com.au/reinstalling-or-repairing-the-windows-xp-bootloader/
- (1073)How to skip error 0x000000C4 when running Win8 in Vbox?
VBoxManage setextradata "VBoxName" VBoxInternal/CPUM/CMPXCHG16B 1
Where "VBoxName" should be replaced by the correect name found with VBoxManage.exe list vms
- (1428)How to run a Program in Compatibility Mode in Windows 7++ (e.g. Jaws 15 in Win8)?
- Right-click on the EXE file
- Choose Properties
- Click on the Compatibility tab
- You can tick "Run this program in compatibility mode" and select a windows version from Windows 95 and 98 to Windows 7.
* Under Settings, you can also choose to run the program in reduced color/resolution mode, etc.
* Under Privilege, you can also have the program run as administrator in case it’s having permissions issues. You can always use this technique to always run a program in administrator mode.
- Lastly, you might need to "Change settings for all users"
See: https://encrypted.google.com/search?tbm=isch&q=options%20de%20compatibilit%C3%A9%20windows%208&tbs=imgo:1#facrc=_&imgdii=_&imgrc=MGrY8iKecj25OM%253A%3BWjPxmDHufDrnfM%3Bhttp%253A%252F%252Fwww.online-tech-tips.com%252Fwp-content%252Fuploads%252F2012%252F07%252Fcompatiblity-windows-8.jpeg%3Bhttp%253A%252F%252Fwww.online-tech-tips.com%252Fwindows-8%252Frun-a-program-in-compatibility-mode-in-windows-8%252F%3B367%3B507
- (1429)How to stop windows 7++ asking permission to run a software (a.k.a. get rid of the "Do you want to allow the following program to make changes to this computer." dialog box + darkening screen)?
- Right click on the executable.
- Select Properties.
- Select the Compatibility Tab.
- Check the box for Run as Admin.
NOTE: This should stop the UAC from prompting you everytime. This is basically a cheat method to get around UAC. It is not advised to do it, but this is how you do it. Bypassing the UAC can leave you system open for security risks.
From: http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/how-can-i-stop-win-7-from-asking-permission-to/23953064-5dd7-42b1-a3c8-540066f2a6df
- (1454)How to add an application to the startup folder in Win7++ (a.k.a. where is the startup folder in Win8++)?
- Press the hotkeys Windows + R. Or Windows + W & "run" in the search field
- Once the Run dialog has opened, you have to enter "%AppData%" (without the quotes) and then click OK.
[2 previous steps can be shortened by open a directory in the explorer and replacing the address in the "address bar" by "%AppData%"]
- In the new window, navigate to \Microsoft\Windows\Start Menu\Programs.
From: http://dottech.org/88876/windows-8-where-is-the-startup-folder-and-how-to-make-apps-or-processes-to-run-automatically-at-windows-boot/
- (1550)How to recursively remove a dir in Windows7+?
rd <dirname> /s /q
http://stackoverflow.com/questions/905500/fastest-way-to-delete-a-tree-of-directories-in-batch-file
- (1551)How to remove Windows.old Folder in Windows8+?
If you haven’t formatted the partition and installed Windows 8 over it with custom install option instead of Upgrade or after Windows 8 Refresh, then the files in previous version of Windows will be stored in Windows.old folder. They do occupy large hard drive space, after using Windows 8 for 1 or 2 weeks if you’re sure you won’t require those files in future, then you can safely remove this folder and reclaim disk space by running built-in Disk Cleanup tool in Windows 8, here is how to do that.
1. Use Win+R command to open run box and use 'cleanmgr' command.
2. Select Windows8 installed drive and click Ok,
3. Disk Cleanup tool scans the drive and shows shows lists of unnecessary files found, click Cleanup system filesNow Disc Cleanup again asks to select the drive, select Windows 8 installed drive, click ‘OK’, this time, the tool scans for previous Windows installation files and displays them if found.
4. Select “Previous Windows Installation” and click ‘OK’ to let Windows delete them safely.
ANOTHER SOLUTION IS TO USE CCLEANER
From: http://techdows.com/2011/09/windows-old-folder-in-windows-8.html
- (1572)How to search for a file in Windows command line?
dir <filename> /s /p
From: http://www.dummies.com/how-to/content/how-to-search-for-files-from-the-dos-command-promp.html
- (1573)How to run the Windows Update from the command line?
%windir%\system32\wuapp.exe startmenu
From: http://www.sevenforums.com/windows-updates-activation/235764-run-window-update-command-line.html
- (1637)How to reset windows 7/8/10 password / create admin account with install cd?
[This can be useful particularly if you can't use a Linux LiveCD/DVD with chntpw]
Boot your problematic Windows 10 computer from a Windows 10 Installation DVD.
When you see the message “Press any key to boot from CD or DVD” on the screen, just press any key to let the computer boot from CD instead of hard drive.
Windows 10 Setup will greet you and prompt you to configure your language settings. Press Shift + F10 to open a Command Prompt.
Replace the file utilman.exe with cmd.exe. Before you do this, you should rename utilman.exe so that you can restore it later after password reset.
ren d:\windows\system32\utilman.exe utilman.exe.bak
copy d:\windows\system32\cmd.exe d:\windows\system32\utilman.exe
Close the Command Prompt and quit the Windows 10 Setup. Next click Yes to confirm that you want to cancel the Windows 10 installation.
Restart your computer and remove the DVD. When you get to the Windows 10 sign-in screen, click the Ease of Access icon in the lower-right corner.
You should see a Command Prompt where you can enter the following commands to add a local administrator account. Replace test with the account name of your choice.
net user test /add
net localgroup administrators test /add
Close the Command Prompt and reboot the computer. When you come back to Windows 10 sign-in screen again, your new account should show up and you can login without a password.
Once logging in, you have full access to all files on your computer and reset the password of any user account from the Control Panel. It’s that simple!
From: http://www.chntpw.com/reset-forgotten-windows-10-password/
- (1687)Where is the SYSTEM sound folder in Windows (7+)?
C:\windows\media
From: http://freewindowsvistatutorials.com/whereIsSoundFolderLocationSystemSoundsMediaInWindows7.php
- (1720)How to run a powershell script?
Powershell v1:
$ powershell -noexit "& ""<myscript>.ps1"""
Powershell v2:
$ powershell -File <myscript>.ps1
See Tip#1857 to bypass execution restrictions
From: https://stackoverflow.com/questions/2035193/how-to-run-a-powershell-script
- (1721)How to remove the built-in/forcibly-installed applications of Win10?
--- removeapps.ps1
Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *windowsalarms* | Remove-AppxPackage
Get-AppxPackage *windowscalculator* | Remove-AppxPackage
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
Get-AppxPackage *windowscamera* | Remove-AppxPackage
Get-AppxPackage *officehub* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
Get-AppxPackage *getstarted* | Remove-AppxPackage
Get-AppxPackage *zunemusic* | Remove-AppxPackage
Get-AppxPackage *windowsmaps* | Remove-AppxPackage
Get-AppxPackage *solitairecollection* | Remove-AppxPackage
Get-AppxPackage *bingfinance* | Remove-AppxPackage
Get-AppxPackage *zunevideo* | Remove-AppxPackage
Get-AppxPackage *bingnews* | Remove-AppxPackage
Get-AppxPackage *onenote* | Remove-AppxPackage
Get-AppxPackage *people* | Remove-AppxPackage
Get-AppxPackage *windowsphone* | Remove-AppxPackage
Get-AppxPackage *photos* | Remove-AppxPackage
Get-AppxPackage *windowsstore* | Remove-AppxPackage
Get-AppxPackage *bingsports* | Remove-AppxPackage
Get-AppxPackage *soundrecorder* | Remove-AppxPackage
Get-AppxPackage *bingweather* | Remove-AppxPackage
Get-AppxPackage *xboxapp* | Remove-AppxPackage
---
And run it as powershell script (see Tip#1720)
From: http://www.howtogeek.com/224798/how-to-uninstall-windows-10s-built-in-apps-and-how-to-reinstall-them/?PageSpeed=noscript
- (1737)How to reboot computer into UEFI/BIOS directly from Windows (8, 8.1, 10)?
* GUI version:
- Click the Start Start menu and select Settings.
- Select Update and Security.
- Click Recovery.
- Under Advanced startup, click Restart now. The system will restart and show the Windows 10 boot menu.
- Select Troubleshoot.
- Choose Advanced options.
- Select UEFI Firmware Settings.
- Click Restart to restart the system and enter UEFI (BIOS).
* Commandline version:
shutdown.exe /r /o
From: https://acer.custhelp.com/app/answers/detail/a_id/37064/~/windows-10%3A-access-the-uefi-bios
https://www.lifewire.com/shutdown-command-2618100
- (1740)How to make Windows10 menus appear more quickly?
- Type "regedit" in Windows search bar
- Navigate to \HKEY_CURRENT_USER\Control Panel\Desktop
- Double clic on key "MenuShowDelay"
- Set it to "0"
From: http://korben.info/windows-10-gagnez-400-millisecondes-a-cliquez-menu.html
- (1817)How to adjust R:G:B Gamma/Color balance in Windows 7+?
1. Click on Start >> Control Panel
2. Step Click on ‘Appearance and Personalization’ on next step.
3. Step Click on Display.
4. Step Next, click on ‘Calibrate color’.
5. Step Now click ‘Next’
6. Step Again click ‘Next’
7. Step A low, good and high gamma sample:.
8. Step You can move the slider to increase or decrease the gamma. If
you want to reset, you can click the reset button located below the
slider. Then after you finish changing the gamma, click on ‘Next’
9. Step Now click on ‘Skip brightness and contract adjustment’.
10. Step Now click on ‘Next’
11. Again click ‘Next’
12. Finally, click on ‘Finish’
From: http://windows7themes.net/en-us/how-to-change-gamma-in-windows-7/
- (1834)How to get IP address of a Samba server (a.k.a. Ho to perform name resolution with Samba servers)?
1. List samba machines in your surroundings
$ smbtree -N -U guest
WORKGROUP
\\RMX-TURB PaperCut Server
\\RMX-TURB\IPC$ IPC Service (PaperCut Server)
\\RMX-TURB\Drivers Lexmark Drivers
\\RMX-TURB\PCClient PaperCut Client
\\RMX-TURB\print$ Printer Drivers
\\RMX-TURB\Lexmark_X748_1_Turb TURBIGO
\\MARIELAURE-PC
2. Get IP address
$ nmblookup RMX-TURB
From: https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/diagnosis.html
- (1856)How to allow execution of powershell scripts in win7+?
[Also see Tip#1857]
Run the following command from an administrative PowerShell:
Set-ExecutionPolicy <level>
It is *RECOMMENDED* to use "Remote Signed" as level, then set back the
level to "Restricted".
Possible levels are:
- Restricted: Default execution policy, does not run scripts,
interactive commands only.
- All Signed: Runs scripts; all scripts and configuration files must
be signed by a publisher that you trust; opens you to the risk of
running signed (but malicious) scripts, after confirming that you
trust the publisher.
- Remote Signed: Local scripts run without signature. Any downloaded
scripts need a digital signature, even a UNC path.
- Unrestricted:Runs scripts; all scripts and configuration files
downloaded from communication applications such as Microsoft
Outlook, Internet Explorer, Outlook Express and Windows Messenger
run after confirming that you understand the file originated from
the Internet; no digital signature is required; opens you to the
risk of running unsigned, malicious scripts downloaded from these
applications
From: http://www.howtogeek.com/106273/how-to-allow-the-execution-of-powershell-scripts-on-windows-7/
- (1857)How to bypass restrictions on execution of powershell scripts in win7+?
powershell -ExecutionPolicy ByPass -File script.ps1
From: http://stackoverflow.com/questions/4037939/powershell-says-execution-of-scripts-is-disabled-on-this-system
- (1876)How to fix windows 10 activation error: 0xC004F074 (a.k.a How to change win10 product keys)?
PROBLEM: If you hava a KMS activated version of Win7/8/10 with a
Product Key from Win7/8, you might get Win10's "activation error:
0xC004F074"/"Windows is unable to reach your company's activation
service".
SOLUTION: Change the Product Key to a Win10 one (works if a KMS
service is running):
1. Open Admin command
2. Execute: slmgr.vbs /dlv # Will show a popup (Note "description" line)
3. Execute: slmgr.vbs /upk # Will uninstall the existing KMS key
4. Execute: slmgr.vbs /ipk # Will install a new key [Win10Pro: W269N-WFGWX-YVC9B... / Win10Entr: NPPR9-FWDCX-D2C8J... / Win10Home: TX9XD-98N7V-6WMQ6...]
5. Go to PC Settings > Update & Security > Activation # Should show "Windows is activated"
SOLUTION2: You might also want to register with an external Server Key:
slmgr /ipk <key> # cf. above
slmgr /skms kms.xspace.in
slmgr /ato
From: https://www.youtube.com/watch?v=mL4N4ZEQywI
https://www.youtube.com/watch?v=xMdXsxVqArQ
https://www.youtube.com/watch?v=QuSePs0qGY4
https://msguides.com/
- (1880)How to find computer model name or serial number on Windows?
Open a command prompt and run:
wmic csproduct get name
wmic csproduct get vendor, version
wmic bios get serialnumber
wmic computersystem get model
wmic computersystem get model,name,manufacturer,systemtype
msinfo32
From: http://www.thewindowsclub.com/how-to-find-computer-model-name-or-serial-number
https://www.windows-commandline.com/get-computer-model/
http://www.howtogeek.com/196893/how-to-open-the-system-information-panel-on-windows-8/
- (1885)How to get out of "Public Network" when "Domestic Network" or "Office" is selected in Win7?
Il est impossible de sortir de ‘réseau public’, alors que réseau domestique
ou bureau est modifiable. Voici comment faire :
Dans REGEDIT, normalement, on trouve chaque réseau et on peut changer son
emplacement :
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
Dans chaque sous-clef (ayant la forme d'un ID, p.ex. "{438BFD5C-C2CD-4FE3-BE90-405F2125A2D8}"), on trouve plusieurs entrées dont
"ProfileName" (REG_SZ) qui contient le nom du réseau
"Category" (REG_DWORD) qui vaut respectivement :
0 : réseau public
1 : réseau privé
2 : réseau domaine
From: https://social.technet.microsoft.com/Forums/en-US/b0b97546-7c57-42e3-90b7-c17bc7b68af0/windows-7-pro-64-bits-modifier-rseau-public-en-rseau-domestique?forum=win7fr
- (1893)How to use CheckDisk in Windows7+?
Cancelling the Scheduled Disk Check
chkntfs /x c:
How to Tell if a Manual Disk Check is Scheduled
chkntfs c:
How to Tell if an Automatic Disk Check is Scheduled
chkntfs c:
fsutil dirty query c:
Using CheckDisk from the Command Line
chkdsk /f /r C:
C:\>chkdsk /?
Checks a disk and displays a status report.
CHKDSK [volume[[path]filename]]] [/F] [/V] [/R] [/X] [/I] [/C] [/L[:size]] [/B]
volume Specifies the drive letter (followed by a colon),
mount point, or volume name.
filename FAT/FAT32 only: Specifies the files to check for fragmentation.
/F Fixes errors on the disk.
/V On FAT/FAT32: Displays the full path and name of every file
on the disk.
On NTFS: Displays cleanup messages if any.
/R Locates bad sectors and recovers readable information
(implies /F).
/L:size NTFS only: Changes the log file size to the specified number
of kilobytes. If size is not specified, displays current
size.
/X Forces the volume to dismount first if necessary.
All opened handles to the volume would then be invalid
(implies /F).
/I NTFS only: Performs a less vigorous check of index entries.
/C NTFS only: Skips checking of cycles within the folder
structure.
/B NTFS only: Re-evaluates bad clusters on the volume
(implies /R)
The /I or /C switch reduces the amount of time required to run Chkdsk by
skipping certain checks of the volume.
From: http://www.howtogeek.com/howto/windows-vista/guide-to-using-check-disk-in-windows-vista/
- (1898)How to boot in Safe Mode ("mode sans échec") in Windows 10?
I] When the system is not accessible
Start you computer while maintaing Shift pressed.
Observe the keyboard. It is not active directly. As soon as you see a
LED light up (Num Lock, Caps Lock, etc.), press F8.
If it does not work reboot and try pressing Shift+F8
simultaneously multiple times.
If the system asks on which media to boot (dvd/hard drive), ignore
this demande by pressing Esc/Echap, then right after that start again
pressing Shift+F8 multiple times.
After a few secondes, a blue screen will appear.
If it does not work, try again. You probably pressed the keys to early
or too late.
II] When the system is still accessible
In "Settings" (Paramètres)
Clic on Windows+I to open "Settings" (Paramètres).
If this does not work, select the "Start" (Démarrer) button on the
bottom left of the screen and select "Settings" (Paramètres).
Select "Update and Security" (Mise à jour et sécurité) > "Recovery"
(Récupération)
Below "Advanced boot" (Démarrage avancé), select "Restart Now"
(Redémarrer maintenant).
Once the computer reboots, there's a blue screen with a menu. In this
menu, select "Troubleshooting" (Dépannage) > "Advanced Options"
(Options avancées) > "StartUp Settings" (Paramètres de démarrage) >
"Restart" (Redémarrer)
Once the computer has restarted many options are shown. Select 4 (or
F4) to restart the computer in "Safe Mode" (mode sans échec). If you
want to be able to access internet, select 5 (or F5) to boot into
"Safe Mode with network" (mode sans échec avec prise en charge
réseau).
III] From the connexion screen
Restart you PC
When you see the connexion screen, press Shift at the same time you
select "Power" (Alimentation) > "Restart" (Redémarrer).
After the computer has restarted in the screen "Select an option"
(Choisir une option), select "Troubleshooting" (Dépannage) > "Advanced
Options" (Options avancées) > "StartUp Settings" (Paramètres de
démarrage) > "Restart" (Redémarrer).
Once the computer has restarted many options are shown. Select 4 (or
F4) to restart the computer in "Safe Mode" (mode sans échec). If you
want to be able to access internet, select 5 (or F5) to boot into
"Safe Mode with network" (mode sans échec avec prise en charge
réseau).
From: http://sospc.name/windows-10-mode-sans-echec/
https://support.microsoft.com/fr-fr/help/12376/windows-10-start-your-pc-in-safe-mode
- (3859)What are the best recovery BootCD for Windows?
- Hiren's BootCD
https://www.hirensbootcd.org/
- Malekal
https://www.malekal.com/creer-live-cd-malekal-depanner-ordinateur/
- MediCat
https://medicatusb.com/
- (3865)How do I remove the lock screen in Windows 10?
- Open Start > Settings > Personalization > Lock Screen
- Scroll down
- Toggle off 'Show lock screen background picture on the sign-in screen'
From: https://answers.microsoft.com/en-us/windows/forum/all/how-do-i-remove-the-lock-screen-in-windows-10/82f525b7-ba63-4885-ab7b-346143a688af
- (3872)How to disable Hyper-V?
PROBLEM: VirutalBox does not work weel with Hyper-V enabled.
SOLUTION1: Disable Hyper-V in Control Panel
- In Control Panel, select Programs and Features.
- Select Turn Windows features on or off.
- Expand Hyper-V, expand Hyper-V Platform, and then clear the Hyper-V Hypervisor check box.
SOLUTION2: Disable Hyper-V in PowerShell
- Open an elevated PowerShell window.
- Run the following command:
- Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-Hypervisor
From: https://learn.microsoft.com/en-us/troubleshoot/windows-client/application-management/virtualization-apps-not-work-with-hyper-v
https://blog.zeddba.com/2017/09/25/disabling-microsofts-hyper-v-to-use-oracles-virtualbox/
- (2040)What are the various version of Windows 10 (N, KN, Single)?
I] Download versions
- Windows 10 - All features such as Media, Apps and many more
- Windows 10 KN - The KN version stems from an antitrust ruling in South
Korea. This version removes Windows' media playing capabilities. At
the time, it also removed the now-defunct Windows Messenger. The
December 2005 ruling by the Korea Fair Trade Commission (KFTC) also
fined Microsoft $34 million.
- Windows 10 N - The N version of Windows comes without a media player
baked into the system. This version stems from a European Commission
order back in 2004, which fined Microsoft €497 million for
anti-competitive practices.
- Windows 10 Single Language - It can be installed with the only
selected language. You cannot change or upgrade later on to a
different language.
II] Version numbers
- La version 1507 correspond à la première version disponible de
Windows 10.
- La version 1511 est la November Update et a constitué la première
mise à jour majeure de Windows 10.
- L'Anniversary Update ou version 1607 a été diffusée un an après les
débuts de Windows 10.
- La version 1703 est la Creators Update qui est disponible depuis
mercredi 5 avril 2017 pour les utilisateurs avancés.
From: https://www.quora.com/What-is-the-difference-between-Windows-10-Windows-10-KN-Windows-10-N-and-Windows-10-Single-Language
https://www.generation-nt.com/windows-10-microsoft-mise-jour-anniversary-update-creators-actualite-1941344.html
- (2052)How to remove OneDrive from Windows10?
- cmd.exe
gpedit.msc
Local Machine Strategy > Computer Configuration > Administration Templates > Windows Components > OneDrive > change Key to Activate
- taskkill /f /im OneDrive.exe
(32 bits uniquement)
- %SystemRoot%\System32\OneDriveSetup.exe /uninstall
(64 bits uniquement)
- %SystemRoot%\SysWOW64\OneDriveSetup.exe /uninstall
- If One Drive is still there
-> 64bits
[HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
"System.IsPinnedToNameSpaceTree"=dword:00000000
[HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
"System.IsPinnedToNameSpaceTree"=dword:00000000
-> 32bits
[HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}]
"System.IsPinnedToNameSpaceTree"=dword:00000001
From: https://www.youtube.com/watch?v=OHrjVJSQp1A
- (2053)How to create a restauration point in Windows 10?
Vous pouvez créer des points de restauration dans Windows pour vous
permettre de restaurer votre système d'exploitation à une date
antérieure. Cela peut être utile si vous avez installé des mises à
jour ou des programmes qui posent problème. Nous vous invitons à
suivre les étapes ci-dessous pour créer un point de restauration.
Ecrivez dans la barre de recherche Windows « Points de restauration » et appuyez sur la touche entrée.
Cliquez sur « Configurer » et sélectionnez « Activer le système de protection ».
Cliquez sur « Appliquer » et sélectionnez « OK ».
Sélectionnez « Créer » et nommer votre point de restauration.
Cliquez sur « Créer » et choisissez « Fermer » pour créer le point de restauration
From: http://packard-bell-fr.custhelp.com/app/answers/detail/a_id/37154/~/windows-10-%3A-créer-un-point-de-restauration
- (2054)How to set/add default apps in Windows 10 that are not in WindowsStore (e.g. independent .exe from PortableApps)?
Regarding current situation, I suggest we directly edit the exported Fileassociation.xml file, and import to change to what you want:
Dism.exe /Online /Export-DefaultAppAssociations:C:\FileAssociations.xml
Open the XML file in notepad. Find the protocol you want to change like:
<Association Identifier="mailto" ProgId="Outlook.URL.mailto.15" ApplicationName="Outlook (desktop)" />
We can find the progID (you want to change to) under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ in regedit.
For more information about ProgID, refer to this link:
ProgID Key
http://msdn.microsoft.com/en-us/library/aa911706.aspx
At last, import your customized xml file:
Dism.exe /Online /Import-DefaultAppAssociations:C:\FileAssociations.xml
From: https://social.technet.microsoft.com/Forums/office/en-US/45b771f3-8b83-43d8-8133-3b5eb6f71a79/setting-default-programprotocol-associations-without-windows-store?forum=w8itproappcompat
https://blogs.technet.microsoft.com/mrmlcgn/2013/02/26/windows-8-associate-a-file-type-or-protocol-with-a-specific-app-using-gpo-e-gdefault-mail-client-for-mailto-protocol/
- (2102)How to create popup messages in a Batch script?
--
$ NET SEND %ComputerName% This is a popup message.
$ NET SEND %ComputerName% This is line 1 of the popup message.ˆ
This is line 2.ˆ
And this is line 3.
-- Win* Pro (not win10)
$ msg * "Enter Your Message"
--
$ start "" cmd /c "echo Hello world!&echo(&pause"
If you want your script to pause until the message box is dismissed,
then you can add the /WAIT option.
$ start "" /wait cmd /c "echo Hello world!&echo(&pause"
--
$ mshta "about:<script>alert('Hello, world!');close()</script>"
$ mshta "javascript:alert('message');close()"
--
$ powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""Hello World""", """My PopUp Message Box""")
From: https://stackoverflow.com/questions/12514475/how-can-you-create-pop-up-messages-in-a-batch-script
- (2330)How to (temporarily/permanently) disable Cortana?
- Temporarily
- Right-clic the taskbar
- Select "Search" then "Masked".
- The search zone is masked, thus disabling (temporarily) Cortana.
- Permanently (access search bar but without Cortana)
- CREATE: [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Windows Search]
"AllowCortana"=dword:00000000
- MODIFY: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TapiSrv]
"Start"=dword:00000004
- MODIFY: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WbioSrvc]
"Start"=dword:00000004
- Permanently (totally remove Cortana)
- Open Task Manager
- Search for Cortana, then right clic on it. Clic on "Open directory" ("C:\Windows\SystemApps\Microsoft.Windows.Cortana_xxxxxxx")
- Open antoher Explorer AS ADMIN in this same directory
- Open a cmd in the parent directory (move to parent dir, then type "cmd" in the Explorer address bar)
- Type "REN Microsoft.Windows.Cortana_xxxxxxx Microsoft.Windows.Cortana_xxxxxxx.bak" in the commandline
- Keep that window opened
In parallel:
- Open Task Manager
- Search for "SearchUI.exe"
- Kill this task
- VERY QUICKLY (<1 sec, before the process is restarted/respawned), execute the REN command line above
From: https://www.varcap-informatique.net/tutoriels/comment-desactiver-cortana-sur-windows-10/
- (2331)How to open a shell/cmd in a specific directory?
- Go to the wanted directory in Explorer
- Type "cmd" in the Explorer address bar
- A shell/cmd will pop up that is automatically set up to the directory you want
Thanks Ilyes
- (2336)How to find who is logged-in & what Workgroup they belong to in Windows 10?
whoami
query user [/server:<computername> # if remote]
WMIC /NODE:<computername/IP> COMPUTERSYSTEM GET USERNAME
Task Manager > "Users" tab # GUI
From: https://www.technipages.com/windows-10-find-who-is-logged-in
- (2341)How to remove the extra key press and delay at login screen of Windows 10?
- Type WinKey + R, enter gpedit.msc & press Enter:
- This invokes the Microsoft Management Console, with the Group Policy snap-in.
- Navigate to Computer Configuration > Administrative Templates > Control Panel > Personalization:
- Navigate to Do not display Lock Screen, right-click and go to Properties:
- Set the value to Enabled:
Group Policy is a great way of getting 'under the bonnet' of Windows, and allows for a more refined Windows experience.
From: https://superuser.com/questions/979239/is-there-a-work-around-for-the-extra-key-press-and-delay-at-login-screen#answer-979242
- (2342)How to correctly create a shortcut in the Windows taskbar for any PortableApps?
If you simply drag&drop to the taskbar, you'll have a lot of errors
about "<file>" that cannot be found.
The correct way to make the shortcuts:
- Open PortableApps Platform
- Right Click on the wanted app and select "Explore Here"
- Create a (temporary) shortcut on the Desktop (ex: drag with the right
button and select "Create Shortcut" on the drop)
- Drag & Drop this shortcut to the TaskBar
- Remove the temporary shortcut from the Desktop
See Tip#2802 to add PortableApps to the start menu
Found by myself
- (2344)How to find the directory where are stored the apps that auto start in Windows 10 (startup folder)?
- enter "shell:startup" in address bar of MS Explorer.
- Win+R > shell:startup
For the startup folder of all users, use "shell:common startup"
The actual paths are the following:
- Autostart for currently logged-on user:
shell:startup = %appdata%\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
- And startup folder all users:
shell:common startup = %programdata%\Microsoft\Windows\Start Menu\Programs\Startup
Tip
shell:start menu = start menu in Windows-10
shell:common start menu = start menu for all users in Windows-10
From: http://www.softwareok.com/?seite=faq-Windows-10&faq=28
- (2350)How to manipulate rectangular selections in Notepad++?
Like MS Word, hold down the Alt key while marking with the mouse
From: https://sourceforge.net/p/notepad-plus/discussion/331754/thread/5d0b29d6/
- (2353)How to SwapCaps/Ctrl in Windows?
; -------------------------------------------------------------------------
; Swap CTRL-L and CapsLock
; -------------------------------------------------------------------------
Capslock::Ctrl
LControl::Capslock
From: http://xahlee.info/mswin/autohotkey_swap_capslock.html
-----
AS THERE IS A BUG IN WINDOWS (WHICH CONSIDERS ERRONEOUSLY THAT AltGr=LControl+RAlt), THE ABOVE CODE WOULD LOCK CAPS EVERYTIME YOU HIT AltGr, WHICH IS A VERY UNWANTED SIDE EFFECT AS WE'VE NEVER OVERRIDDEN THE AltGr KEY!!!
THE CODE BELOW TRIES TO CIRCUMVENT THIS BUG (plus one that occurs when suspending the computer):
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;; Putting the computer to sleep breaks the script => we need the following code to reload the script.
;; Unfortunately it works only when the scipt is not compiled :{
OnMessage(536, "OnPBMsg") ;WM_POWERBROADCAST
Return
OnPBMsg(wParam, lParam, msg, hwnd) {
If (wParam = 7) ;PBT_APMRESUMESUSPEND
Sleep 1000
Reload
Sleep 1000 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
MsgBox, 4,, The script could not be reloaded.
Return
}
;;;; Actual swapping of keys
CalledFromRWin := 0
; Disable AltGr
LControl & RAlt::
; Simulate AltGr on RWin
RWin::
CalledFromRWin := 1
Send, {LControl down}{RAlt down}
Sleep 500
Send, {RAlt up}{LControl up}
CalledFromRWin := 0
Return
; Swap LCtrl & CapsLock
CapsLock::LCtrl
LControl::
;MsgBox, "%CalledFromRWin%"
If (CalledFromRWin == 0) {
;;;MsgBox, "Sending CapsLock"
;;;Send {CapsLock}
;MsgBox, "Toggling CapsLock"
if GetKeyState("CapsLock", "T") = 1 {
SetCapsLockState, off
} else if GetKeyState("CapsLock", "T") = 0 {
SetCapsLockState, on
}
}
Return
- (2360)How to delete registry subkeys and values by using a .reg file?
To delete a *registry key* with a .reg file, put a hyphen (-) in front of the RegistryPath in the .reg file.
e.g.
[-HKEY_LOCAL_MACHINE\Software\Test]
To delete a registry *value* with a .reg file, put a hyphen (-) after the equals sign following the DataItemName in the .reg file.
e.g.
HKEY_LOCAL_MACHINE\Software\Test
"TestValue"=-
To create the .reg file, use Regedit.exe to export the registry key that you want to delete, and then use Notepad to edit the .reg file and insert the hyphen.
From: https://support.microsoft.com/en-us/help/310516/how-to-add-modify-or-delete-registry-subkeys-and-values-by-using-a-reg
- (2361)How to manage the long delay when hitting Ctrl+C in ConEmu with GitBash?
There is action to "Terminate all but shell processes in the current console". Personally I set it to Ctrl+X and use it often. But it really terminates processes, they will not receive any signals.
https://conemu.github.io/en/SettingsHotkeys.html
From: https://github.com/Maximus5/ConEmu/issues/402
- (2383)How to record a screenshot/video under Windows 10?
- Hit the Windows key and G, and a popup will appear asking if you would like to open Game bar -- there are no Yes and No buttons, but check the 'Yes, this is a game' box (you will have to do this the first time you access the screen recorder in any application).
- Things are pretty self-explanatory here -- just hit the standard record button to start capturing footage. Hit the button again to stop recording, or you can use the Windows key + Alt + R keyboard shortcut.
- The Settings button can be used to place a limit on the length of videos that can be recorded -- this helps you to avoid filling up your hard drive if you forget to stop a recording.
- Videos are saved in MP4 format in the Videos\Captures folder.
From: https://betanews.com/2015/07/19/windows-10-secret-screen-recording-tool/
- (2394)How to manually create a file with a . dot prefix in windows for example .htaccess / .gitignore?
Just put an extra dot AFTER the file. Windows will drop it. .this. => .this
NOTE: WTF??!!??
From: https://stackoverflow.com/questions/5004633/how-to-manually-create-a-file-with-a-dot-prefix-in-windows-for-example-htacce#comment-38467947
- (2396)How to export a calendar from microsoft office 365?
- Log into your 365 account (The default login is portal.office.com)
- Go to your calendar app by selecting the "Calendar" option under "Use the online apps"
- On the top right of the calendar page click the settings icon
- Open up the "My app settings" section and click the "Calendar" link
- Under the the "Calendar" section select "Publish Calendar"
- Select the calendar that you would like to import into Zola Suite and give "Full details" permission
- Click the ICS link. This will download the ICS file needed
From: https://help.zolasuite.com/portal/kb/articles/how-do-i-export-my-calendar-from-microsoft-office-365
- (2400)How to disable "Game bar" in Windows 10?
- Press Win+G or Xbox button to open Game bar (choose "Yes, this is a game.")
- Open the settings (cog icon) on Game bar and uncheck "Open Game bar using [Xbox logo] on a controller"
- Uncheck "Remember this as a game" and Game bar should close
To open Game bar later, press Win+G.
From: https://www.reddit.com/r/Steam/comments/3f5734/windows_10_how_to_disable_game_bar/
- (2442)How to circumvent problems with (git)-bash translating forward slash with a directory path when calling Windows commands?
In general, putting two forward slashes is the solution. Therefore, this works.
$ tasklist //?
From: https://github.com/bmatzelle/gow/issues/196#issuecomment-165947882
- (2443)How can I emulate middle click in Windows on a touchpad [TOVERIFY]?
Try this: Middle Click Simulator (direct download link)
http://cybernetnews.com/helpful-tip-middle-click-on-a-touchpad-laptop-mouse/
Alternatively, have you tried installing he Synaptics Touchpad drivers?
https://www.synaptics.com/resources
From: https://superuser.com/questions/13185/how-can-i-emulate-middle-click-in-windows-on-a-touchpad#13203
- (2446)How to Disable the Startup Sound in Windows7?
Do you want to disable the annoying startup sound in Windows 7? Here’s how to quickly do it.
- Open Start Menu and go to Control Panel.
- Click on Hardware and Sound.
- Under Sound Options, click on Change System Sounds.
- From the Sounds Settings window, uncheck Play Window Startup sound and click OK.
- If you want to enable it again, follow the same steps. Then check the Windows Startup Sound option.
- To get to the sound settings without clicking through the UIa, click Start and type: sound options then click Enter.
- Then click the Sounds tab and uncheck Play Windows Startup Sound and click OK.
From: https://www.groovypost.com/howto/disable-startup-sound-windows/
- (2449)How to choose newline character in Notepad++?
For a new document: Settings -> Preferences -> New Document/Default Directory
-> New Document -> Format -> Windows/Mac/Unix
For an already-open document: Edit -> EOL Conversion
From: https://stackoverflow.com/questions/8195839/choose-newline-character-in-notepad#8195860
- (2450)How to solve "fatal error C1010 - stdafx.h in VisualStudio?
Look at https://stackoverflow.com/a/4726838/2963099
Turn off pre compiled headers:
Project Properties -> C++ -> Precompiled Headers
set Precompiled Header to "Not Using Precompiled Header".
---
In VS2010:
Common Properties->Configuration Properties->C/C++->Precompiled Headers ; then Precompiled Header should be Not Using Precomiled Header
From: https://stackoverflow.com/questions/20113280/fatal-error-c1010-stdafx-h-in-visual-studio-how-can-this-be-corrected#20113446
- (2469)How to find out the default character encoding in Windows?
You can check with PowerShell:
[System.Text.Encoding]::Default
From: https://superuser.com/questions/670197/finding-out-the-default-character-encoding-in-windows
- (2470)How to get the short filename (MSDOS/8.3-format) using cmd.exe?
SOLUTION1:
A batch-file with a command line argument works as intended:
---- short.bat
@echo OFF
echo %~s1
-----
calling
short.bat C:\Documents and Settings\User\NTUSER.DAT
returns
C:\DOCUM~1\USER\NTUSER.DAT
SOLUTION2:
dir /x filename.txt
From: https://stackoverflow.com/questions/10227144/convert-long-filename-to-short-filename-8-3-using-cmd-exe
- (2474)How to toggle CapsLock in AutoHotKey (AHK)?
SOLUTION1: (from doc, not working)
Send, CapsLock
SOLUTION2:
if GetKeyState("CapsLock", "T") = 1 {
SetCapsLockState, on
} else if GetKeyState("CapsLock", "T") = 0 {
SetCapsLockState, off
}
From: https://autohotkey.com/board/topic/88211-toggle-capslock/
- (2475)How do I display the value of a variable in a Msgbox in AutoHotKey?
MyVar := 0
Msgbox, "%MyVar%"
From: https://autohotkey.com/board/topic/49749-getting-variable-to-display-in-message-box/
- (2476)How do I determine which version of AutoHotkey is installed?
SOLUTION1:
msgbox % "my ahk version: " A_AhkVersion
SOLUTION2:
The main page of the help file (that comes with the distribution) also has a version number.
From: https://autohotkey.com/board/topic/44365-how-do-i-determine-my-autohotkey-version-number/
- (2477)How to hold down a key in AutoHotKey?
Send {TAB down} ; Press down the up-arrow key.
Sleep 1000 ; Keep it down for one second.
Send {TAB up} ; Release the up-arrow key.
From: https://autohotkey.com/board/topic/11321-can-autohotkey-hold-down-a-key/
- (2481)How to connect to mysql using mysql CLI client in git-bash?
PROBLEM: using "mysql -u ... -p" displays nothing, but does not retrun.
SOLUTION:
winpty mysql -u ... -p
From: https://stackoverflow.com/questions/32620670/git-bash-mysql-blank
- (2484)How to catch/react to power management events with AutoHotKey?
/* TheGood
Wrapper to catch Power Management events
;http://msdn.microsoft.com/en-us/library/aa373162(VS.85).aspx
;SUPPORTED ONLY BY WINDOWS 2000 AND UP
WM_POWERBROADCAST := 536 ;Notifies applications that a power-management event has occurred.
PBT_APMQUERYSUSPEND := 0 ;Requests permission to suspend the computer. An application
;that grants permission should carry out preparations for the
;suspension before returning.
BROADCAST_QUERY_DENY := 1112363332 ;Return this value to deny the request.
PBT_APMQUERYSUSPENDFAILED := 2 ;Notifies applications that permission to suspend the computer
;was denied. This event is broadcast if any application or
;driver returned BROADCAST_QUERY_DENY to a previous
;PBT_APMQUERYSUSPEND event.
PBT_APMSUSPEND := 4 ;Notifies applications that the computer is about to enter a
;suspended state. This event is typically broadcast when all
;applications and installable drivers have returned TRUE to a
;previous PBT_APMQUERYSUSPEND event.
PBT_APMRESUMECRITICAL := 6 ;Notifies applications that the system has resumed operation.
;This event can indicate that some or all applications did not
;receive a PBT_APMSUSPEND event. For example, this event can be
;broadcast after a critical suspension caused by a failing
;battery.
PBT_APMRESUMESUSPEND := 7 ;Notifies applications that the system has resumed operation
;after being suspended.
PBT_APMBATTERYLOW := 9 ;Notifies applications that the battery power is low.
PBT_APMPOWERSTATUSCHANGE := 10 ;Notifies applications of a change in the power status of the
;computer, such as a switch from battery power to A/C. The
;system also broadcasts this event when remaining battery power
;slips below the threshold specified by the user or if the
;battery power changes by a specified percentage.
PBT_APMOEMEVENT := 11 ;Notifies applications that the APM BIOS has signaled an APM
;OEM event.
PBT_APMRESUMEAUTOMATIC := 18 ;Notifies applications that the computer has woken up
;automatically to handle an event. An application will not
;generally respond unless it is handling the event, because
;the user is not present.
*/
OnMessage(536, "OnPBMsg") ;WM_POWERBROADCAST
Return
OnPBMsg(wParam, lParam, msg, hwnd) {
If (wParam = 0) { ;PBT_APMQUERYSUSPEND
If (lParam & 1) ;Check action flag
MsgBox The computer is trying to suspend, and user interaction is permitted.
Else MsgBox The computer is trying to suspend, and no user interaction is allowed.
;Return TRUE to grant the request, or BROADCAST_QUERY_DENY to deny it.
} Else If (wParam = 2) ;PBT_APMQUERYSUSPENDFAILED
MsgBox The computer tried to suspend, but failed.
Else If (wParam = 4) ;PBT_APMSUSPEND
MsgBox The computer is about to enter a suspended state.
Else If (wParam = 6) ;PBT_APMRESUMECRITICAL
MsgBox The computer is now resuming from a suspended state, which may have taken place unexpectedly.
Else If (wParam = 7) ;PBT_APMRESUMESUSPEND
MsgBox The computer is now resuming from a suspended state.
Else If (wParam = 9) ;PBT_APMBATTERYLOW
MsgBox The computer battery is running low.
Else If (wParam = 10) ;PBT_APMPOWERSTATUSCHANGE
MsgBox The computer power status has changed.
Else If (wParam = 11) ;PBT_APMOEMEVENT
MsgBox The APM BIOS has signaled an APM OEM event with event code %lParam%
Else If (wParam = 18) ;PBT_APMRESUMEAUTOMATIC
MsgBox The computer is now automatically resuming from a suspended state.
;Must return True after message is processed
Return True
}
From: https://autohotkey.com/board/topic/36718-wrapper-to-catch-power-management-events-like-standby/
- (2523)How to get the number/ID windows associates to a physical drive?
- GUI version
WindowsKey + R > Type diskmgmt.msc
- CLI version
wmic diskdrive list
From: https://superuser.com/questions/451573/use-virtualbox-to-boot-a-physical-drive-partition
https://www.lifewire.com/how-to-open-disk-management-from-command-prompt-2626097
https://stackoverflow.com/questions/327718/how-to-list-physical-disks#327724
- (2534)How to change the target display (video projector, external screen, etc) in Windows, using CLI ?
C:\Windows\System32\DisplaySwitch.exe
From: https://www.sevenforums.com/tutorials/2019-presentation-mode-change.html
- (2535)How to change the refresh rate in Windows
- Step 1: First, Right click on the free area on the desktop, then click on "Display Settings".
- Now, Click on the "Advanced settings".
- Go to the "Monitor" panel.
- Under the Monitor settings, set "Screen refresh rate" and press "OK".
- If you want to set the screen resolution as well, then click on "Adapter" and select "List All Modes".
- From the list of modes, select the screen resolution and its corresponding refresh rate will set automatically. Then click on "OK" button.
From: https://quehow.com/how-to-change-monitor-refresh-rate-in-windows-10/4531.html
- (2538)How to use rectangular selections (a.k.a. Column Mode Editing) in Notepad++/VStudio
Alt + Mouse dragging
Alt + Shift + Arrow keys
From: https://notepad-plus-plus.org/features/column-mode-editing.html
- (2539)How to number an array in Numpad++?
array[] =
array[] =
array[] =
array[] =
array[] =
--->
array[0] =
array[1] =
array[2] =
array[3] =
array[4] =
- Put your cursor between the two []
- Press ALT to use column editing mode and go the last row with the mouse
- Press simultaneously ALT + C to open Column / Multi Selection editor
- Fill "Number to insert" with 0 to n and press OK
Also se Tip#2538
From: https://stackoverflow.com/questions/6072346/notepad-numbering-an-array
- (2540)How do I view, edit and create keyboard shortcuts in PDF-XChange Editor?
Keyboard shortcuts can be edited/created as follows:
1. Right-Click on the blank area of any Toolbar
2. Click Customize Toolbars:
3. The Customize Toolbars dialog box will open. Click the Commands tab:
4. Use the Categories submenu to select a section of the software. (The default selection is <All Commands>, which means all available keyboard shortcuts are displayed). When sections are selected their actions and associated keyboard shortcuts will be displayed in the list on the right.
5. Select actions and click Properties to view additional information. The Command Properties dialog box for the Add Bookmark function is detailed below:
6. Assigned shortcuts are detailed in the Assigned pane. Use the Keys text box to determine new shortcuts and then press OK. (Please note that if the key combinations entered are already in use, the associated feature will be displayed in the Shortcut currently used by text box).
From: https://www.tracker-software.com/knowledgebase/340-How-do-I-view-edit-and-create-keyboard-shortcuts-in-PDF-XChange-Editor
- (2547)How can I set Visual Studio to use K&R style bracketing?
- Go to tools > Options > Text Editor > C# > Formatting > New Lines
- Uncheck every option you see there.
From: https://stackoverflow.com/questions/3048800/how-can-i-set-visual-studio-to-use-kr-style-bracketing
- (2551)How to solve "error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup" in VisualStudio?
PROBLEM: You've create a project for a Windows GUI App, but you wrote code for a CLI App.
- Go to Properties > Linker > System > SubSystem
- Change Windows (/SUBSYSTEM:WINDOWS) to Console (/SUBSYSTEM:CONSOLE)
From: https://stackoverflow.com/questions/6626397/error-lnk2019-unresolved-external-symbol-winmain16-referenced-in-function
- (2552)How to comment region of code in VisualStudio?
Comment Code Block : Ctrl+K+C
Uncomment Code Block : Ctrl+K+U
NOTE: if selection does not start/end on first char of the line, /**/ is used, otherwise // is used.
From: https://vslive.com/Blogs/News-and-Tips/2015/04/5-VS-Keyboard-Shortcuts.aspx
- (2553)How to set up an alarm using Windows 7 Task Scheduler?
- Click Start button, type "task scheduler" (without the quotation marks)
- Hit Enter key from the keyboard to run it. In the extreme right pane, under "Actions" ; click "Create a Basic Task"
- Give a name and description of the task in the Wizard window and then click Next button
- In next Window, select when you want the alarm, then in the Action windows option, select Start a program
- Then Browse for any sound file (*.wav, *.mp3 etc)
- Click Next and then Finish the wizard.
From: https://thecustomizewindows.com/2011/03/set-up-your-own-alarm-clock-using-windows-7-task-scheduler/
- (2581)Where to get Windows10 ISO images?
https://getintopc.com
https://update10.info/windows-10-build-18343-19h1-1903-download-iso/
https://uup.rg-adguard.net/
- (2585)How to crack a registration-key-based program (& What softs to use)?
1. Disassembler/Decompiler
- !!FOSS!! x64dbg (https://x64dbg.com/)
- !!FOSS!! REDasm https://redasm.io/
- !!FOSS!! Boomerang Decompiler (http://boomerang.sourceforge.net/)
- !!FOSS!! Ghidra (NSA, https://ghidra-sre.org/)
- !!FOSS!! SnowMan (https://derevenets.com/)
- !!FOSS!! RetDec (https://retdec.com/)
- !!FOSS!! Radare2 (https://github.com/radare/radare2)
- W32DASM
- IDA Pro
- OllyDbg
2. Hex viewer
- !!FOSS!! FrHed (PortableApps, no Undo!)
- !!FOSS!! ImHew (https://github.com/WerWolv/ImHex)
- !!FOSS!! wxHexEditor (https://www.wxhexeditor.org)
- !!FOSS!! Hex Edit (https://www.catch22.net/software/hexedit , https://sourceforge.net/projects/hexedit/)
- !!FOSS!! Hexplorer (https://sourceforge.net/projects/hexplorer/)
- !!FOSS!! BEYE (https://sourceforge.net/projects/beye/)
- !!FOSS!! Okteta (https://kde.org/applications/utilities/okteta/, KDE libs)
(https://alternativeto.net/software/hiew/?license=opensource&platform=windows)
- UltraEdit
- Hiew
Cracking Process:
0- Backup
Make copies of the .exe/.dll file you analyze (Windows does not allow multiple open on the same file => cannot be opened in DisASM&HexViewer at the same time!)
1- Reconnaissance
Study the code, find elements of interest (= where there are references to the fact the the program is/is not registered)
- Strings
- Resources (Menu, Images...)
- DialogBoxes
- Win API calls (DialogBoxA, RegCreateKeyW, EnableMenuItem...)
- Imports/Exports (external DLLs functions)
- *External DLLs* (=> Goto step 0)
2- Reverse Engineer
Study the code around those places. Right above these places, there is often a *Function Call* to a function that check if the user-entered regkey is correct or not, then a *Test+JMP* that registers the program/displays a warning following the results of the check.
3- Patch the code
There are multiple actions possible, depending on the case, some will work and others not:
- Switch the condition of the registration key check: JNE(75)->JE(74), ... See Tip#2584
- Remove the calls to the checking function: NOP(90)
- Run the code step-by-step and extract from memory the registration key generated by the checking function based on the user input. Use this to register the program without patching it!
- [If you are very good] Extract the checking function code and put it in an external ASM/C code that will act as a KeyGen.
From: http://reverseengineeringtips.blogspot.com/2015/01/an-introduction-to-x64dbg.html
https://www.youtube.com/watch?v=yiX1pz-J1Xo
https://www.youtube.com/watch?v=wq6fk5oDbVg
- (2587)How to find/view String References in x64dbg?
- MainMenu > Debug > Run to user code
- Go to "References" Tab
From: https://reverseengineering.stackexchange.com/questions/18504/how-to-view-string-references#answer-18505
- (2588)How to find Call/Jumps to a given address in x64dbg?
- In the CPU Tab, select the address where the Jump/Call should land
- Right Click > Select "Search References to" (Last entry) > "Selected Address" (First entry)
- (2606)How to activate Windows 7/8/10/11?
Use scripts on MSGuide or run KMSPico or MSToolkit
From: https://msguides.com/
https://kmspico10.com/
https://github.com/bouletmarc/Microsoft_Toolkit
http://www.microsofttoolkitofficial.info/
https://www.teamos-hkrg.com/index.php?forums/activators-crack-patch-keygen.71/
https://windowsactivators.com/windows-10-activation-kmspico/
https://github.com/ekistece/vlmcsd-autokms
https://getintopc.com
- (2633)How to handle command-line arguments in PowerShell?
You are reinventing the wheel. Normal PowerShell scripts have parameters starting with -, like script.ps1 -server http://devserver
Then you handle them in param section in the beginning of the file.
You can also assign default values to your params, read them from console if not available or stop script execution:
param (
[string]$server = "http://defaultserver",
[Parameter(Mandatory=$true)][string]$username,
[string]$password = $( Read-Host "Input password, please" )
)
Inside the script you can simply
write-output $server
since all parameters become variables available in script scope.
In this example, the $server gets a default value if the script is called without it, script stops if you omit the -username parameter and asks for terminal input if -password is omitted.
Update: You might as well want to pass a "flag" (a boolean true/false parameter) to a PowerShell script. For instance, your script may accept a "force" where the script runs in a more careful mode when force is not used.
The keyword for that is [switch] parameter type:
param (
[string]$server = "http://defaultserver",
[string]$password = $( Read-Host "Input password, please" ),
[switch]$force = $false
)
Inside the script then you would work with it like this:
if ($force) {
//deletes a file or does something "bad"
}
Now, when calling the script you'd set the switch/flag parameter like this:
.\yourscript.ps1 -server "http://otherserver" -force
If you explicitly want to state that the flag is not set, there is a special syntax for that
.\yourscript.ps1 -server "http://otherserver" -force:$false
Links to relevant Microsoft documentation (for PowerShell 5.0; tho versions 3.0 and 4.0 are also available at the links):
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-5.1
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions?view=powershell-5.1
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-5.1
From: https://stackoverflow.com/questions/2157554/how-to-handle-command-line-arguments-in-powershell#2157625
- (2636)How to troubleshoot Network File-Sharing Problems (a.k.a. What to do if VirtualBox Windows Guest does not see the \\vboxsrv machine and/or host's Shared Folder)?
PROBLEM
Can't open a shared folder or even see the computer on the network, or edit a shared folder or its files when you want to?
#1 Manually Access Shares
\\<computer_name>\<share_name>\[file_name]
#2 Use the Windows Repair and Diagnostics Tools
Network and Sharing Center > Diagnose and Repair.
#3 Check Sharing Settings
Network and Sharing Center > Sharing and Discovery
Network and Sharing Center > Network Location
If it says "Public", click the Customize link on the right to change the location.
#4 Verify Firewall Status and Settings
Control Panel > Windows Firewall > File and Printer Sharing
#5 Verify the Sharing Protocol Is Enabled
Control Panel > Network Connections > Select problematic "Connection" > Properties > check "Client for Microsoft Networks" "File and Printer Sharing for Microsoft Networks"
#6 Restart the Network Connection
Control Panel > Network Connections > Right Click problematic adapter > Disable / Enable.
#9 Verify the Sharing Permissions
Right Click on the to-be-shared folder > Share.
#10 Verify the File (NTFS) Permissions
Right-click on the to-be-shared-folder > Properties > Security tab.
From: http://www.practicallynetworked.com/sharing/network_sharing_troubleshooting_tips.htm
- (2638)How to Get Windows 10 ISO?
1. Set your browser's User Agent to Linux
2. Go to
https://www.microsoft.com/en-us/software-download/windows10
The web site will propose ISOs downloads instead of Utility to build one
3. Select the Version & Language
Enjoy!
From: https://windows10.help/blogs/entry/24-how-to-download-the-latest-windows-10-iso-files-directly-using-your-web-browser/
- (2639)How to split an (already existing) archive into multiple files?
- Open 7ZipFM
- Select the archive file you want to split
- File > Split File.
From: https://www.newsgroupreviews.com/7-zip-split-archive.html
- (2640)How to make Firefox (Portable) your default browser (a.k.a. How to open Thunderbird Portable's links into Firefox Portable)?
Make Firefox Portable the Default With its Own Options
This solution will work fine if Portable Firefox Browser is running, or if a non-portable Firefox is NOT installed.
I just got updated to Firefox 3.5.8 for my portable version. However, even before that last update, when I was checking on clearing out Offline Storage in Firefox's 'Options' window, I explored a bit and came across the way to make Firefox Portable the default browser. The procedure is shown as follows:
1. Make sure that the Firefox that you want to make the default browser is running.
2. Click on 'Tools' and from the drop-down menu select 'Options'.
3. From the row of icons at the top of the 'Options' window, select 'Advanced'.
4. From the tabs just directly below that, make sure the 'General' tab is selected.
5. Now, near the bottom of the window in the 'System Defaults' section, click on the 'Check Now' button.
6. A window labeled 'Default Browser' will pop up and, if the browser is the default browser, the window will state: "Firefox is already set as your default browser." If the browser is not the default browser, the window will ask if you would like to make Firefox your default browser; click the 'Yes' button (the 'Default Browser' window will disappear), then click the 'OK' button at the bottom of the 'Options' window.
After that you should be all set.
From: https://portableapps.com/node/17483#post-143915
- (2642)How to change WAMP 's default password?
- You can change the MySQL password from within the PhpMyAdmin interface
- Then you need to reconfigure PhpMyAdmin:
--- File: config.inc.php of PhpMyAdmin
$cfg['Servers'][$i]['password']
From: https://www.developpez.net/forums/d1320688/php/langage/passe-defaut-wamp/#post_7182293
- (2645)How to set an app to always run as admin in Win10+?
NOTE: This generally a very bad idea!!!!!
- Open Start Menu
- Search for the app that you want to run elevated.
- Right-click the top result, and select Open file location.
Quick Tip: If you're running the October 2018 Update, as you search, you can click the Open file location option on the list of actions that appears on the right.
- Right-click the app shortcut and select Properties.
- Click on the Shortcut tab.
- Click the Advanced button.
- Check the Run as administrator option.
- Click the OK button.
From: https://www.windowscentral.com/how-set-apps-always-run-administrator-windows-10
- (2646)How to force Windows to set a portable App as a default for a file extension?
* Using regedit
Follow the steps below:
1. Type "regedit" in the Run line or from an elevated CMD prompt.
2. Navigate to Computer\HKEY_CLASSES_ROOT\Applications and find your .exe name.
3. Navigate under its name to shell>open>command.
4. Under Default, make sure the application location points to the actual location of the executable.
5. Press OK and then try and reassociate the file type as you normally would.
* Using assoc
- To view the current file type association for the file name extension <.ext>, type:
assoc <.ext>
- To delete the file type association for the file name extension <.ext>, type:
assoc <.ext>= # white space after '='
- To create an association, use:
assoc <.ext> = <filetype> , where filetype can be found with the command "ftype"
See Tip#2802 to add PortableApps to the start menu
From: https://support.microsoft.com/en-us/help/2159999/sometimes-you-can-not-associate-a-program-with-an-extension-in-windows
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490865(v=technet.10)
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-xp/bb490912%28v%3dtechnet.10%29
- (2647)How to fix the Middle mouse button for Asus touchpad in windows 10?
Install the fix from: http://ceezblog.info/2015/09/22/middle-mouse-button-fix-for-asus-touchpad-in-windows-10/
- (2648)How to ACTUALLY shutdown windows 10 (a.k.a. correct bug/feature that sets hibernate as the default action when selecting "shutdown" in Start Menu)?
You can do a full kernel shutdown by holding Shift while using the normal power button in the Start menu. Or use the Win+X menu (or right-click Start button) to shutdown, it accomplishes the same thing. Just two easy options without needing to modify any registry keys.
If you want to turn it off, right-click on the battery icon in the notification bar and click on "Power Options" (on laptops - if you're on a desktop search for "Power Options"). There, click on "Change settings that are currently unavailable", accept the UAC prompt, and untick "Turn on fast start-up (recommended)".
From: https://www.reddit.com/r/Windows10/comments/3qi2yz/windows_10_shut_down_is_actually_hybernate/
https://superuser.com/questions/508050/difference-between-shutting-down-and-turning-on-vs-restart-in-windows-8
https://www.tenforums.com/tutorials/4189-turn-off-fast-startup-windows-10-a.html
https://lifehacker.com/shutting-down-windows-10-doesnt-actually-shut-down-wind-1825532376
- (2649)What is the difference between shutting down and turning on vs. restart in Windows?
From: https://superuser.com/questions/508050/difference-between-shutting-down-and-turning-on-vs-restart-in-windows-8
- (2650)How to get hard disk information from PowerShell?
get-wmiobject -class win32_logicaldisk
0 -- Unknown
1 -- No Root directory
2 -- Removable Disk
3 -- Local Disk
4 -- Network Drive
5 -- Compact Disc
6 -- Ram Disk
wmic diskdrive get
- (2655)How To Compare Two Text Files Using Notepad++?
1. Open up the two files that you want to compare in Notepad++.
2. Goto Plugins > Compare > Compare
3. That’s it! Both files will show up side by side and you will see the differences highlighted.
From: https://www.davidtan.org/how-to-compare-two-text-files-using-notepad-plus/
https://www.davidtan.org/how-to-get-compare-plugin-back-into-notepad/
- (2659)How to boot from RAW image disk with VBox on Win7 host?
Success!
In summary:
To gain full hard drive access in a VBox guest on Win7 host
0. close all open programs or documents on any partition on the disk to pass-through
1. run DISKPART (command line utility)*
2. select hard drive carefully using SELECT DISK. disk numbering starts at zero. you can roughly verify your selection with LIST PARTITION if you know what your partitions should look like or LIST DISK to see disk sizes.
3. offline the disk using OFFLINE DISK. all volumes will disappear from windows explorer.
4. ATTRIBUTES DISK CLEAR READONLY
5. verify with ATTRIBUTES DISK
6. create VMDK file as shown in several howtos on the web
7. enjoy
As always with the dumb numeric representation of physical disks in windows: keep an eye on the ordering of your disks, especially removables, before booting the wrong one.
*administrative rights required for operating vbox and utilities but not for desktop
- (2686)How to get Windows uptime?
I] In CLI-Netstat
1. Go to "Start" -> "Run".
2. Write "CMD" and press on "Enter" key.
3. Write the command "net statistics server" and press on "Enter" key.
4. The line that start with "Statistics since …" provides the time that the server was up from.
The command "net stats srv" can be use instead.
II] In CLI-WMIC
- Open Start.
- Search for Command Prompt, right-click the top result, and click the Run as administrator option.
- Type the following command to query the device's last boot time and press Enter:
wmic path Win32_OperatingSystem get LastBootUpTime
III] In CLI-SystemInformation
- Open Start.
- Search for Command Prompt, right-click the top result, and click the Run as administrator option.
- Type the following command to query the device's last boot time and press Enter:
systeminfo | find "System Boot Time"
IV] In CLI-PowerShell
- Open Start.
- Search for Command Prompt, right-click the top result, and click the Run as administrator option.
- Type the following command to query the device uptime and press Enter:
(get-date) - (gcim Win32_OperatingSystem).LastBootUpTime
V] In GUI-TaskMAnager
- Open Start.
- Search for Task Manager and click the top result to open the experience.
Quick Tip: You can also open Task Manager using the Ctrl + Shift + Esc keyboard shortcut, or by right-clicking the taskbar and selecting Task Manager from the menu.
- Click the More details button (if you're using the compact view).
- Click the Performance tab.
- Select the CPU section.
Uptime is at the bottom of the page
VI] In GUI-Network
- Open Start.
- Search for Control Panel and click the top result to open the experience.
- Click on Network and Internet.
- Click on Network and Sharing Center.
- Click the Change adapter settings option in the left pane.
- Double-click the network adapter connected to the internet.
After completing the steps, you can deduce your computer uptime using the "Duration" information, which indicates the uptime from the network connection that resets every time the device starts. (Of course, these methods work as long as you didn't reset your network connection since the last time you booted the device.)
From: https://support.microsoft.com/en-us/help/555737/how-to-find-windows-uptime
https://www.windowscentral.com/how-check-your-computer-uptime-windows-10
- (2707)How to create a local account in Windows 10 1909 if the option is not available?
- Option 1: disconnect the network connection
The first option is without doubt a straightforward one. If your Windows PC is connected to the Internet, cut the Internet connection as it is not possible to create a Microsoft account without Internet connection.
If it is connected via a cable to a router or mode, unplug the cable from the PC before you start the PC. If it is connected via Wi-Fi, consider disabling Wi-Fi on the router/modem before you do so.
- Option 2: Disable the Internet connection during setup
disable network connection
If you have started setup already and don't see an option to create an offline account, you may be able to enforce the creation of an offline account in the following way:
- While on the account creation page: use Shift-F10 to open a command prompt.
- Type control netconnections and hit the Enter-key on the keyboard.
- Left-click on the active Internet connection and select disable this network device.
- Click on the setup screen to go back to it. If that does not work, use Alt-Tab to switch to it. The
- Click on the left facing arrow to go back a page to reload the account creation page as it is essentially reloaded when you do so.
- The page should ask for a Name at this point as it is required to create an offline account.
- Use Alt-Tab to switch to the Network Connections control panel window.
- Left-click on the Internet connection and select enable this device this time.
- Close the control panel window and the command line window.
- Proceed with the account creation.
From: https://www.ghacks.net/2019/09/30/how-to-create-a-local-account-in-windows-10-1909-if-the-option-is-not-available/
- (2778)How to really kill a process in Windows CLI?
taskkill /im myprocess.exe /f
- (2779)How to really delete a file in Windows CLI/powershell?
Remove-Item <file>
From: https://www.petri.com/delete-folder-file-from-command-line-powershell
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item?view=powershell-7
- (2790)How to block the automatic installation of suggested Windows 10 apps?
- Open the Windows Registry Editor, e.g. by using the shortcut Windows-R to open the runbox, typing regedit.exe and hitting the Enter-key-
- Confirm the UAC prompt that is displayed.
- Paste the following key into the path field at the top or navigate to the key manually: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager
- Check if the Dword value SilentInstalledAppsEnabled exists.
+ If it does exist, double-click on it and set its data value to 0. A value of 0 turns the suggested apps feature off on the Windows 10 system. You may turn it on again at any point in time by setting the data value to 1.
+ If the Dword value does not exist, right-click on ContentDeliveryManager and select New > Dword (32-bit) Value. Name it SilentInstalledAppsEnabled and give it the value 0.
- Restart the PC after closing the Registry Editor.
From: https://www.ghacks.net/2019/12/23/how-to-block-the-automatic-installation-of-suggested-windows-10-apps/
- (2802)How to add Portable Apps (or any independant .exe file) in the start menu of Windows?
Use ISMONISM app
From: https://www.donationcoder.com/forum/index.php?topic=49299.0
- (2818)How to delete a wireless network profile in Windows 10?
To delete a wireless network profile in Windows 10:
- Click the Network icon on the lower right corner of your screen.
- Click Network settings.
- Click Manage Wi-Fi settings.
- Under Manage known networks, click the network you want to delete.
- Click Forget. The wireless network profile is deleted.
From: https://kb.netgear.com/29889/How-to-delete-a-wireless-network-profile-in-Windows-10
- (2976)How to make the webcam not return an up side down image?
This is a well known bug in ASUS firmware/driver, that they will never correct because it appears on machines > 3 years age.
Many web sites recommend to use manycam, but it is proprietary software and will advertise itself on all the images you produce with the cam.
There's an open-source program that provides the same (and much more!) functionality: Webcamoid (https://webcamoid.github.io/)
The principle is the same: the external tools grabs your camera raw output, applies some filters and re-publishes the result as a fake camera device. You can then use this fake camera in any application (Skype, Zoom, etc.).
The filter to apply with Webcamoid is a mirroring transformation:
- Choose the filter called "Matrix Transformation" and specify a matrix like:
-0.75 0 0
0 1 0
From: https://superuser.com/questions/201439/how-to-get-the-video-not-mirrored-when-skype-video-chat/1256781#1256781
- (3009)How to solve error "The program can't start because libgcc_s_dw2-1.dll is missing" when trying to run an exe file generated from Code::Blocks in Windows?
This is a MinGW/gcc compiler issue.
The libgcc_s_dw2-1.dll should be in the compiler's bin directory. You can add this directory to your PATH environment variable for runtime linking, or you can avoid the problem by adding "-static-libgcc -static-libstdc++" to your compiler flags.
From: https://stackoverflow.com/questions/4702732/the-program-cant-start-because-libgcc-s-dw2-1-dll-is-missing/4703059#4703059
http://www.codeblocks.org/docs/main_codeblocks_en3.html#x3-1060003.11
https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
- (3023)What is the equivalent of 'which' on the Windows command line?
where /?
From: https://stackoverflow.com/questions/304319/is-there-an-equivalent-of-which-on-the-windows-command-line
- (3026)What are the numerical comparators in if-then-else statements in batch scripts?
EQU - equal
NEQ - not equal
LSS - less than
LEQ - less than or equal
GTR - greater than
GEQ - greater than or equal
From: https://www.instructables.com/id/Batch-If-Statements/
- (3194)What version of Office (2016+) am I using (32/64bit)?
1. Open any Office application, such as Word or Excel
2. Select Account.
Note: If you don't see Account or you already have a file or document open, choose File from the menu, and then select either Account or Help from the list on the left.
3. Under Product Information, you'll find your Office product name and, in some cases, the full version number.
4. For more information, such as the bit-version, choose About Excel. A dialog box opens, showing the full version number and bit version (32-bit or 64-bit).
From: https://support.microsoft.com/en-us/office/about-office-what-version-of-office-am-i-using-932788b8-a3ce-44bf-bb09-e334518b8b19
- (3195)How to remove "Windows.old" (large) files after an upgrade?
There used to be an option in CCleaner, but it broke windows for many people (Some of the stuff in the folder are still used by Windows and slowly are migrated out)
To clean this directory, use windows inbuilt cleaner (In Explorer, RightClick on Drive name > Properties > Disk CleanUp > "CleanUp System Files")
From: https://community.ccleaner.com/topic/52715-what-happened-to-old-windows-installation/?tab=comments#comment-300276
- (3237)How To Compare Two Text Files Using Notepad++?
0. Plugins menu > Plugin Manager, check "Compare" to install the so-called plugin
1. Open up the two files that you want to compare in Notepad++.
2. Goto Plugins > Compare > Compare
3. That’s it! Both files will show up side by side and you will see the differences highlighted.
From: https://www.davidtan.org/how-to-compare-two-text-files-using-notepad-plus/
- (3241)How to Crack Excel Password without Software?
SOLUTION1: Manually
Before we proceed, it is important if you understand that Excel files are a compilation of several XML files stacked together. This means an Excel file is simply a zipped file. To modify these files as we would do with password cracking, you need to change the file extension from XLSX to ZIP. After modifying the file, you have to revert it to .xlsx. This way, you have cracked the Excel file password by simply changing the file extension. So let's see how we can seamlessly do this.
1- Open the File Explorer window and locate the password-protected Excel worksheet.
2- Change the file extension to .zip. The program will then prompt you whether you want to make the change. Click "Yes" to allow the file extension change.
3- Now click on the "Extract" tab within the explorer window and choose "Extract all". Extract the ZIP file to the desired folder.
4- After extracting the ZIP file, open the folder labelled "xl" and subsequently locate the "sheet.xml" file. Right-click on this file and choose "Open with". Select either Notepad or WordPad.
5- When the selected program opens the XML file, identify the "sheetProtection" code section and delete it as shown below.
6- After deleting the protection code, go back and select all the files you extracted from ZIP. Right-click on them, choose the "Send to" option, and select "Compressed (zipped) folder" as shown below. Finally, change the ZIP extension back to .xlsx.
SOLUTION2: Using Google Sheet
1- Navigate to Google sheet and sign in via your email account.
2- Hover your cursor over the "File" menu and select "Import" from the drop-down list.
3- The "Import file" dialogue box will be displayed on the next window. Locate and click the "Upload" tab then chose a convenient way to upload your Excel file.
4- When the protected file is uploaded, you will be prompted to make some choices. Select the "Replace spreadsheet" and subsequently hit the "Import data" button. The protected Excel sheet can be edited now.
5- Finally, you need to download this editable file to your computer. To do so, simply go to "File" then "Download As" and choose "Microsoft Excel".
From: https://passper.imyfone.com/excel/how-to-crack-excel-password-without-software/
- (3282)How to disable Windows Update in Windows 10 (any version) [Always Working Hack]?
This is how to disable Windows Update in Windows 10:
1. On Start type \'services.msc\'
2. Scroll down in services and find the Windows Update service.
3. Right Click then open \'Properties\'
4. Set \'Start Up\' type to \'disabled\'
5. Stop the Service.
DONE! If you try to use windows update it will give you an error.
From: https://answers.microsoft.com/en-us/insider/forum/insider_wintp-insider_update-insiderplat_pc/how-to-disable-windows-update-in-windows-10-pro/3a9d4a23-3c40-47da-ba30-0e249047e3da#7b62b630-7bc4-4178-bd74-8895c277b959
- (3362)How to fix the (shitty) VS2019 online-only install process?
PROBLEM:
- VS2019 is VERY heavy (40GB for simple C++ IDE!!)...
- Direct install will often fail on slow connection
- net install-only is very shitty on does not know how to restart a download were it stopped, thus it'll re-download everything every time.
- Using 2 steps install below is suposed to help.
- Using the two steps install corresponds to the following process:
- Create local "layout" (i.e. copy files locally without installing)
vs_community.exe --layout c:\vslayout --add Microsoft.VisualStudio.Workload.ManagedDesktop ... --lang en-US
- Installing from layout:
C:\vslayout>vs_community.exe --noweb --add Microsoft.VisualStudio.Workload.ManagedDesktop ...
Unfortunately, this rarely works smoothly. Even if there's no error during step 1, You'll often encounter strange & cryptic ("number only") errors during step 2.
You might, for instance, encounter "Error 0x80131509" ("No suitable download engine found")
In this case this means there was a problem during Step1 and downloads did not end up correctly (even if you got no error during Step1!)
SOLUTION1:
1. Ensure you have a fast & stable connection (dixit M$ tech guys!!!)
2. Run
vs_community.exe --layout --verify
vs_community.exe --layout --fix
3. If it does not work, restart the whole layout creation (dixit M$ tech guys!!! Welcome to the famous solve-everything-by-rebooting solution from the M$ world!)
From: https://developercommunity.visualstudio.com/t/tried-installing-visual-studio-2019-168/1283138
- (3380)List of wrong things in the M$ world
- Windows
- timers
- keyboard management hacks (AltGr = Alt+Maj => impossible to SwapCaps)
- MS Office
- Whole Suite : Impossible to reuse pieces from one doc type to another (schemas from Powerpoint in Word, tables from Excel in Word...) a.k.a. the failure of OLE a.k.a. buying softs from other companies and failing to integrate them to one another
- Whole suite : Way too many situations will lead to the exact same document being rendered differently
+ Opening the same document in Windows and Mac with the same Office Suite version
+ Opening the same document between two different machines (both Windows or both Mac), and the same Office suite version, because the patch level will not be the same.
+ Opening the same document but on different versions of the Office Suite (e.g. Office 2010 doc opened in Office 2016)
+ Opening the same document but a few days/weeks/months/years later (because the patch level will have changed)
- Excel : dates are stored with 2 digits => awful hacks
- Excel : wrong operators' precedence (-2^2 = -4!!!) => Makes other Suites (eg LibreOffice) necessary buggy if they want to stay "compatible"
- Word : how to insert (colorized) code?
- Word : how to manage TOC/Biblio without external tools?
- Word : does not know how to hyphenize words => justified text looks ugly with random & large spaces between words
- Word : does not know about ligatures
- PowerPoint : Opening the same document several times (with days/weeks/years, thus updates?, in-between) will lead to your drawings being totally scrambled!
- What M$ "borrowed" from others
- [All Windows] GUI (concept of "Windows" and "Desktop" + mouse) = Xerox
- [Windows NT] Network stack = BSD
- [Windows 98?] Multi-Task = from Unices (NOTE: cmd.exe is still mono-task!!! No Ctrl-z!)
- [Windows 7?] Multi-User = from Unices
- [Windows 10] Multi-Desktop = from Unices
- [Windows 10] OpenSSH to connect to other machines securely = from OpenBSD?
- (3382)How to move/resize a Window that is too big for the screen?
- Type Alt+Space , this will open the "window" menu (top left corner of any window)
- Select "move" (type "m" or move the mouse there) or "size" ("s") according to what you want to do
- Use arrow keys to move/resize the window
- Once placed correctly, use "Enter" to validate the new position/size
From: https://www.techsupportalert.com/content/how-use-keyboard-move-or-resize-window-too-big-screen.htm
- (3464)How to list available smb shares on a network?
This command is a very little known secret of Samba. It returns IP adresses of all Samba servers in one's own broadcast domain:
nmblookup __SAMBA__
This one returns a list of all NetBIOS names and their aliases of all Samba servers in the neighbourhood (it does a 'node status query'):
nmblookup -S __SAMBA__
This one returns a list of all IP adresses of SMB servers (that is, Linux+Unix/Samba or Windows) in the neighbourhood:
nmblookup '*'
Finally, all NetBIOS names and their aliases of all SMB servers (Linux+Unix/Samba or Windows):
nmblookup -S '*'
From: https://serverfault.com/questions/160396/listing-available-smb-shares-on-a-network-through-the-command-line-in-linux#166255
- (3471)How to run an application with a fake date (e.g to skip a trial)?
https://www.nirsoft.net/utils/run_as_date.html
- (3473)How To Remove Write Protection From USB Flash Drive In Windows? [TO TEST]
Use USB-MP-ALL
From: https://www.youtube.com/watch?v=diH9uyzvB1U
- (3481)How to Enable or Disable the Startup Sound on Windows 11?
- Right-click on the Start menu and select Settings.
- Select the Personalization category.
- Click on the Themes tab.
- Go to the right and click on the Sounds option.
- On the Sound tab, uncheck the box next to the Play Windows Startup sound option. This will disable the startup sound.
- To enable it back, check the Play Windows Startup sound checkbox.
- Click on Apply > OK button to save the changes you made.
From: https://www.thewindowsclub.com/how-to-enable-or-disable-the-startup-sound-on-windows-11
- (3556)Where to get Windows 10/11 ISO?
https://www.microsoft.com/en-us/software-download/windows11 {NOTE: set UserAgent to Linux to get ISO links!}
https://getintopc.com
- (3564)How to Disable the Write Protection on Dell Windows 10 USB Recovery Sticks?
- Download MPALL_F1_7F00_DL07_v503_0A.rar from https://mega.nz/#!RYsGVLTI (key: !3mpx__atjBu-zBVtxTlvsya-uiIsSFK7q5ddcULiCgw) and uncompress it to a folder
- Run MPALL_F1_7F00_DL07_v503_0A.exe
- Plug your USB stick and click the Update button
- Click the Setting button
- Select Basic Setting and New Setting and click OK
- Select PS2251-07 in Controller drop down
- Select USB 2.0 or 3.0 from the Host Port drop down depending on what type of port you have
- Check the Do ISP and Erase code block check boxes
- Select to browse to the burner file BN07V502TAW.BIN and the firmware file FW07V50253TW.BIN in the MPALL_F1_7F00_DL07_v503_0A folder.
- Under the Customise Setting section, uncheck the Auto Detect box and input the VID 0930 and PID 1400.
- Save As
- Ensure the Drop Down on the top right corner is on your newly created .ini file
- Click Start button
From: http://www.techunboxed.com/2016/09/how-to-disable-write-protection-on-dell.html
- (3565)How to Stop Windows 11 Update (Block It Forever)?
Many possibilities:
1. Turn off Windows Update Services in Windows 11
Step 1. Press "Window + R" to open the Run window.
Step 2. Open the "Services Window" by typing services.msc and hit the "Enter" key.
Step 3. Locate and pick the "Windows Update" option from the "Services" list, then click the "Stop" button.
Step 4. Change the "Startup Type" to "Disabled" by clicking on the "General" tab.
2. Block Windows 11 Update with Group Policy Editor
Step 1. Press Win + R. Type gpedit.msc to load the Group Policy Editor.
Step 2. Navugate to "Local Computer Policy > Computer Configuration > Administrative Templates > Windows Components > Windows Update > Windows Update for Business".
Step 3. Double-click on "Select the target feature update version".
Step 4. Set the policy to "Enabled", type 21H1 into the field, and close the Group Policy Editor.
3. Pause Windows 11 Updates for Every Week
...
4. Stop Windows 11 Update with Registry Editor
Step 1. Press Win + R and type regedit.exe to open Registry Editor.
Step 2. Go to "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate".
Step 3. Set the "DWORD (32-bit)" value to 1.
If the value does not exist, right-click on Windows Update, and select New > Dword (32-bit) Value. Then, set the value of TargetReleaseVersionInfo to 21H1.
5. Disable Windows 11 Update with Third-party Tool
EaseUS Clean Genius
From: https://www.easeus.com/knowledge-center/stop-windows-11-update.html
- (3568)How to enable/use God Mode in Windows 11 or 10?
I] Enable
- Right-click a blank area of the desktop
- Select New > Folder
- Select the new folder on the desktop
- Press F2/rename
- Call it "GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}"
The folder's icon may change to a Control Panel icon
II] Use
- Double-click the special folder to enter God Mode.
- A list of 200 Windows tools and settings appears
- For even easier access to a specific Windows tool or setting, you can "Create shortcut" for it, e.g. on your Desktop (Drag 'n Drop ? or via Context Menu)
- You can display the content "By Category/Name/..." with Right-click a blank area of the folder and choose "Group by"
- You can display God Mode's settings with icons with Right-click a blank area and choose "View", then select either "Medium icons" or "Large icons"
From: https://www.tomsguide.com/how-to/how-to-enable-god-mode-in-windows
- (3600)How to always run an App as Admin in Windows 10/11?
- Find the app you need and right-click it.
- Select Properties.
- Go to the Compatibility tab
- Place a checkmark next to the "Run this app as an administrator" option.
From: https://winaero.com/run-as-administrator-in-windows-11-multiple-way-to-start-apps-elevated/#Launch_a_pinned_app_from_the_taskbar
- (3634)How to install Addons in VSCodium?
VSCodium "market place" does not get as much add ons as VSCode.
You can still install the packages as follows:
- Go to the Web Market Place for VSCode
https://marketplace.visualstudio.com/items?itemName=tootone.org-mode
- Download the .vsix file
- Install it in VSCode
- Go to "Addons" tab
- Select "..." menu (top of column that lists available addons)
- "Install from VSIX file"
- In CLI
- Downlod the VSIX file
- code --install-extension myextension.vsix
From: https://milicendev.netlify.app/article/install-vs-codium-and-integrate-vs-code-extensions/
https://iqcode.com/code/shell/how-to-can-i-install-vscode-extension-on-vs-codium
- (3672)How to use multi-cursors/selection in VSCode?
1. [ctrl + alt + arrow down|up].
It will simply create some multi-cursors below or above your line.
If you want to exit the multi-cursor, press escape.
2. [pushed mouse wheel + go down|up].
It will create some multi-cursors too, it's a bit faster than the one above.
3. [ctrl + d].
[ctrl + d] will help you find some occurrences. For example, if you want to change several divs into paragraphs, pressing [ctrl + d] after highliting one will allow you to do that faster!
4. [ctrl + shift + l].
You can also find all occurrences at once after highliting something with [ctrl + shift + l]. For example, this will select all the divs!
5. [alt + click].
Finally, you can use [alt + click] to place a new cursor wherever you want.
From: https://dev.to/ziratsu/vscode-awesome-multi-cursorsselection-tricks-1052
- (3763)How to Remove the “Chat” Taskbar Icon on Windows 11?
- Right-click an empty spot on the taskbar
- Select “Taskbar Settings” in the pop-up.
- Go to Personalization > Taskbar
- Expand the "Taskbar Items" section near the top
- Toggle the "Chat" switch to "Off".
From: https://www.howtogeek.com/744131/how-to-remove-the-chat-taskbar-icon-on-windows-11/
- (3764)How to delete the Windows.old Folder in Windows 10+?
SOLUTION1: using Disk Cleanup (VERY SLOW!!!)
1. Press Windows + E to enter the File Explorer. Click "This PC" at the left panel.
2. Right click the C: drive under the "Devices and drives", select "Properties".
3. In the next window, click "Disk cleanup"
4. Click "Clean up system files".
5. Select "Previous Windows Installation(s)" only, then press “OK” to start cleanup. You can delete other related files by your own needs.
SOLUTION2: using Settings > Storage Sense
1. Go to Start > Settings > System > Storage.
2. Slide to Storage sense tab and select Change how we free up space automatically option.
3. Slide to Free up space now and tick Delete previous versions of Windows, then click Clean now.
--- Alternative
SOLUTION5: using Settings > Storage Sense
- Open Settings.
- Click on System.
- Click on Storage.
- Under the "Storage sense" section, click the Change how we free up space automatically option
- Under the "Free up space now" section, check the Delete previous version of Windows option.
- Click the Clean now button.
SOLUTION3: using Settings > Temp Files
1. Go to Storage and click Free up space now under the Storage sense tab.
2. Under the Temporary files settings, tick Previous Windows installations and uncheck other options.
3. Click the Remove files button.
SOLUTION4: using CLI
1. Type cmd in the search box, select it and run as administrator.
2. Type the following commands and hit Enter after each one.
takeown /F c:\Windows.old\* /R /A /D Y
cacls c:\Windows.old\*.* /T /grant administrators:F
rmdir /S /Q c:\Windows.old
Note:
The first command takeown is used to give ownership to the administrator group. The second command is to displays or modifies DACL (discretionary access control list) files. And the last one is to remove a specific directory.
From: https://www.ubackup.com/windows-10/delete-windows.old-folder-windows-10-5740.html
https://www.windowscentral.com/how-properly-remove-windowsold-folder-windows-10
- (3765)How to disable "Folder 'Group by' View" in Windows 11 File Explorer (a.k.a. How to remove 'Today', 'Yesterday', etc. grouping of files in the Downloads/ folder)?
SOLUTION1: Sort menu
- Open Explorer on a directory that show the Grouping problem
- Open "Sort" menu (in the "ribbon" menu)
- Go to "Group By"
- Select "None"
SOLUTION2: Popup menu
- Open Explorer on a directory that show the Grouping problem
- Right-click in an empty space
- Select "Group By"
- Select "None"
From: https://www.youtube.com/watch?v=w2GkG4Di1lg
- (3890)Where to get the default windows Server/10/11 Product Keys?
https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys
https://wiki.flexible-computing-advanced.orange-business.com/wiki/Activation_des_licences_Microsoft_Office
- (3893)What is the difference between upgrade and update in windows?
- An update can consist of bug and security fixes and new features in a version of Windows. They tend to roll out throughout the year.
- An upgrade is when you change versions—for example, moving from Windows 10 to Windows 11, or moving editions from Windows Home to Windows Pro.
In the Linux world, the definition are very different:
- apt update = get the freshest list of packages & versions
- apt upgrade = install the most recent versions of already installed packages
From: https://www.microsoft.com/en-us/windows/get-windows-11#simpleDrawer8
- (3897)How to turn of Windows activation (a.k.a. How to prolong Windows VMs evaluation/trial period)?
TOVERIFY: this allows to revert activation of "Free" MSEDGE Windows 10 VMs
https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/
(
and maybe others:
https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
https://github.com/magnetikonline/linux-microsoft-ie-virtual-machines
)
In order to:
- use it more than 60 days
- create a snapshot & rearm it
SOLUTION1: Remove the ProductKey
- Open an elevated command prompt.
- Uninstall the Product Key
slmgr /upk
- Remove the Product Key from the Registry
slmgr /cpky
NOTE:
- To get the information about all the installed Licenses
slmgr.vbs /dlv all
- You can remove a specific License/Activation
slmgr /upk <Activation ID>
- You can install a new Key
slmgr /ipk <Windows Product Key> # see: Tip#3890 https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys
- You can reset the activation timers
slmgr /rearm
From: https://www.tenforums.com/tutorials/35979-uninstall-product-key-deactivate-windows-10-a.html
https://www.thewindowsclub.com/deactivate-uninstall-windows-product-key
https://www.minitool.com/news/how-to-deactivate-windows-10-11.html
SOLUTION2a: You can also stop the "SoftwareProtection" service [with services.msc]
- Open Start Menu
- Type "services" into Start
- Click Services
- Scroll down and click "Software Protection" (or "sppsvc")
- Click the "Properties" icon
- Click Stop.
- Click OK.
SOLUTION2b: You can also stop the "SoftwareProtection" service [through Registry]
- Open Start
- Type "regedit"
- Click regedit
- Click Yes when prompted for Admin rights
- Go the "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\sppsvc"
- Select the "Start" entry
- Set it to 4
- Save
From: https://www.wikihow.com/Turn-Off-Windows-Activation
- (3899)How to get the original Windows ProductKey/Set a new ProductKey (a.k.a. How to solve error "Your Windows License Will Expire Soon")?
PROBLEM: If you try to activate a version of Windows (e.g. Home) with a key for another version (e.g. Enterprise), you might get this error.
- To get the original key:
wmic path SoftwareLicensingService get OA3xOriginalProductKey
- To change the key:
Settings > Update & Security > Activation > "Change ProductKey"
Also See Tip #3890 and https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys for the default keys
From: https://www.youtube.com/watch?v=Prq5BL1FydY
- (3947)How to get CPU/RAM/Disk info in Windows 10/11?
Click Start > Performance Monitor or run "perfmon"
From: https://www.windowscentral.com/how-use-performance-monitor-windows-10
https://www.ghacks.net/2021/12/13/how-to-display-cpu-gpu-and-ram-usage-natively-on-windows-11/ DOES NOT WORK
- (3950)Where to get a very lite version of Win10/Win11?
https://www.buildsometech.com/windows-10-lite-iso-download/
https://www.buildsometech.com/ghost-spectre-windows-11-superlite-iso-download/
https://www.buildsometech.com/tiny11-iso-download-windows-11-tiny-edition/
https://www.buildsometech.com/windows-11-lite-iso-download/
- (3951)Another way to register the product key in Win10/11
DISM /online /Set-Edition:ServerStandard /ProductKey:ENTER-YOUR-SERIAL-KEY-HERE /AcceptEula
To get supported editions
DISM.exe /Online /Get-TargetEditions
From: https://www.tombullock.co.uk/2019/05/27/server-2019-activation-error-run-slui-exe-0x2a-0xc004f069-to-display-the-error-text/
https://answers.microsoft.com/en-us/windows/forum/all/solved-error-0x800f0805-installing-product-key/9d274cef-1d97-4b77-af7f-7df5155f294e
- (3958)How to Exclude a File or Folder from Windows Defender Scan In Windows 10?
Settings > Windows Security > "Virus & Threat Protection" > "Virus & Threat Protection Settings" > "Manage Settings" > "Add or Remove Exclusions" > "Add an Exclusion" > Folder/File
From: https://www.youtube.com/watch?v=BonLkFNnO9w
- (3963)How to convert a "Win10Edge" free VM (Win10EntrepriseEval) into a full Win10Enterprise?
- Open the following dir:
C:\Windows\System32\spp\tokens\skus
- Decompress SKUs for all windows versions in this dir
Get the SKUs here: https://appsforpcfree.net/skus-Windows-10.zip (or HelloWorld62)
- Register the wanted SKU by running the following script
----
cscript.exe %windir%\system32\slmgr.vbs /rilc
cscript.exe %windir%\system32\slmgr.vbs /upk >nul 2>&1
cscript.exe %windir%\system32\slmgr.vbs /ckms >nul 2>&1
cscript.exe %windir%\system32\slmgr.vbs /cpky >nul 2>&1
cscript.exe %windir%\system32\slmgr.vbs /ipk M7XTQ-FN8P6-TTKYV-9D4CC-J462D
REM See
sc config LicenseManager start= auto & net start LicenseManager
sc config wuauserv start= auto & net start wuauserv
clipup -v -o -altto c:\
echo
---
- Reboot
NOTE: This method force the OS to see itself as a particular version, but some "modules" of this particular version might still be lacking, thus some things might crash (in my case: next upgrades)
From: https://appsforpcfree.net/upgrade-windows-10-evaluation-full-version-easily/
- (4002)How to Floating Performance Panels in Win10
SOLUTION I: Activate the Task Manager's Performance Window
- Open the Task Manager by pressing Ctrl+Shift+Esc or right-clicking the taskbar and selecting "Task Manager."
- Click Options > Always on Top
- Click the "Performance" tab at the top of the window (you might need to click "More Details" at the bottom first)
- Choose the performance graph you want to see in the sidebar: CPUs, memory, storage devices, network connections, and GPUs
- To show just a performance graph, double-click anywhere on a graph in the right pane. You can also right-click a graph and select Graph Summary View
- You can resize this smaller window
- By the way, you can also double-click anywhere the left pane to see the left pane in a smaller floating window. It's a good way to keep an eye on multiple resource stats at once.
SOLUTION2: Pin the Game Bar's Performance Panel to Your Screen
- Open Xbox Game Bar overlay by pressing Windows+G
- If the Game Bar doesn't appear, head to Settings > Gaming > Xbox Game Bar. Ensure the Game Bar is enabled and check its keyboard shortcut here
- Locate the "Performance" window, which is near the bottom left corner of the Game Bar overlay screen by default. If you don't see it, click the "Performance" button on the Game Bar menu at the top of the screen to show it.
- Click the "Pin" button above the little Performance window.
From: https://www.howtogeek.com/685379/how-to-show-windows-10s-hidden-floating-performance-panels/
- (4012)What are the Generic Product Keys to Install or Upgrade Windows 11 Editions?
| Windows 11 Edition | RTM Generic Key (retail) | KMS Client Product Key |
|--------------------------------------+-------------------------------+-------------------------------|
| Windows 11 Home | YTMG3-N6DKC-DKB77-7M9GH-8HVX7 | TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 |
| Windows 11 Home N | 4CPRK-NM3K3-X6XXQ-RXX86-WXCHW | 3KHY7-WNT83-DGQKR-F7HPR-844BM |
| Windows 11 Home Home Single Language | BT79Q-G7N6G-PGBYW-4YWX6-6F4BT | 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH |
| Windows 11 Home Country Specific | N2434-X9D7W-8PF6X-8DV9T-8TYMD | PVMJN-6DFY6-9CCP6-7BKTT-D3WVR |
| Windows 11 Pro | VK7JG-NPHTM-C97JM-9MPGT-3V66T | W269N-WFGWX-YVC9B-4J6C9-T83GX |
| Windows 11 Pro N | 2B87N-8KFHP-DKV6R-Y2C8J-PKCKT | MH37W-N47XK-V7XM9-C7227-GCQG9 |
| Windows 11 Pro for Workstations | DXG7C-N36C4-C4HTG-X4T3X-2YV77 | NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J |
| Windows 11 Pro for Workstations N | WYPNQ-8C467-V2W6J-TX4WX-WT2RQ | 9FNHH-K3HBT-3W4TD-6383H-6XYWF |
| Windows 11 Pro Education | 8PTT6-RNW4C-6V7J2-C2D3X-MHBPB | 6TP4R-GNPTD-KYYHQ-7B7DP-J447Y |
| Windows 11 Pro Education N | GJTYN-HDMQY-FRR76-HVGC7-QPF8P | YVWGF-BXNMC-HTQYQ-CPQ99-66QFC |
| Windows 11 Education | YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY | NW6C2-QMPVW-D7KKK-3GKT6-VCFB2 |
| Windows 11 Education N | 84NGF-MHBT6-FXBX8-QWJK7-DRR8H | 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ |
| Windows 11 Enterprise | XGVPP-NMH47-7TTHJ-W3FW7-8HV2C | NPPR9-FWDCX-D2C8J-H872K-2YT43 |
| Windows 11 Enterprise N | WGGHN-J84D6-QYCPR-T7PJ7-X766F | DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4 |
| Windows 11 Enterprise G | | YYVX9-NTFWV-6MDM3-9PT4T-4M68B |
| Windows 11 Enterprise G N | FW7NV-4T673-HF4VX-9X4MM-B4H4T | 44RPN-FTY23-9VTTB-MP9BX-T84FV |
| Windows 11 Enterprise LTSC 2019 | | M7XTQ-FN8P6-TTKYV-9D4CC-J462D |
| Windows 11 Enterprise N LTSC 2019 | | 92NFX-8DJQP-P6BBQ-THF9C-7CG2H |
From: https://www.elevenforum.com/t/generic-product-keys-to-install-or-upgrade-windows-11-editions.3713/
- (4013)What are the Generic Product Keys to Install or Upgrade Windows 10 Editions?
| Windows 10 Edition | RTM Generic Key (retail) | KMS Client Setup Key |
|-----------------------------------+-------------------------------+-------------------------------|
| Windows 10 Home | YTMG3-N6DKC-DKB77-7M9GH-8HVX7 | TX9XD-98N7V-6WMQ6-BX7FG-H8Q99 |
| Windows 10 Home N | 4CPRK-NM3K3-X6XXQ-RXX86-WXCHW | 3KHY7-WNT83-DGQKR-F7HPR-844BM |
| Windows 10 Home Single Language | BT79Q-G7N6G-PGBYW-4YWX6-6F4BT | 7HNRX-D7KGG-3K4RQ-4WPJ4-YTDFH |
| | | |
| Windows 10 Pro | VK7JG-NPHTM-C97JM-9MPGT-3V66T | W269N-WFGWX-YVC9B-4J6C9-T83GX |
| Windows 10 Pro N | 2B87N-8KFHP-DKV6R-Y2C8J-PKCKT | MH37W-N47XK-V7XM9-C7227-GCQG9 |
| Windows 10 Pro for Workstations | DXG7C-N36C4-C4HTG-X4T3X-2YV77 | NRG8B-VKK3Q-CXVCJ-9G2XF-6Q84J |
| Windows 10 Pro N for Workstations | WYPNQ-8C467-V2W6J-TX4WX-WT2RQ | 9FNHH-K3HBT-3W4TD-6383H-6XYWF |
| | | |
| Windows 10 S | 3NF4D-GF9GY-63VKH-QRC3V-7QW8P | |
| | | |
| Windows 10 Education | YNMGQ-8RYV3-4PGQ3-C8XTP-7CFBY | NW6C2-QMPVW-D7KKK-3GKT6-VCFB2 |
| Windows 10 Education N | 84NGF-MHBT6-FXBX8-QWJK7-DRR8H | 2WH4N-8QGBV-H22JP-CT43Q-MDWWJ |
| Windows 10 Pro Education | 8PTT6-RNW4C-6V7J2-C2D3X-MHBPB | 6TP4R-GNPTD-KYYHQ-7B7DP-J447Y |
| Windows 10 Pro Education N | GJTYN-HDMQY-FRR76-HVGC7-QPF8P | YVWGF-BXNMC-HTQYQ-CPQ99-66QFC |
| | | |
| Windows 10 Enterprise | XGVPP-NMH47-7TTHJ-W3FW7-8HV2C | NPPR9-FWDCX-D2C8J-H872K-2YT43 |
| Windows 10 Enterprise G | | YYVX9-NTFWV-6MDM3-9PT4T-4M68B |
| Windows 10 Enterprise G N | FW7NV-4T673-HF4VX-9X4MM-B4H4T | 44RPN-FTY23-9VTTB-MP9BX-T84FV |
| Windows 10 Enterprise N | WGGHN-J84D6-QYCPR-T7PJ7-X766F | DPH2V-TTNVB-4X9Q3-TJR4H-KHJW4 |
| Windows 10 Enterprise S | NK96Y-D9CD8-W44CQ-R8YTK-DYJWX | FWN7H-PF93Q-4GGP8-M8RF3-MDWWW |
| | | |
| Windows 10 Enterprise 2015 LTSB | | WNMTR-4C88C-JK8YV-HQ7T2-76DF9 |
| Windows 10 Enterprise 2015 LTSB N | | 2F77B-TNFGY-69QQF-B8YKP-D69TJ |
| | | |
| Windows 10 Enterprise LTSB 2016 | | DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ |
| Windows 10 Enterprise N LTSB 2016 | RW7WN-FMT44-KRGBK-G44WK-QV7YK | QFFDN-GRT3P-VKWWX-X7T3R-8B639 |
| | | |
| Windows 10 Enterprise LTSC 2019 | | M7XTQ-FN8P6-TTKYV-9D4CC-J462D |
| Windows 10 Enterprise N LTSC 2019 | | 92NFX-8DJQP-P6BBQ-THF9C-7CG2H |
| | | |
| Windows Server 2016 Datacenter | | CB7KF-BWN84-R7R2Y-793K2-8XDDG |
| Windows Server 2016 Standard | | WC2BQ-8NRM3-FDDYY-2BFGV-KHKQY |
| Windows Server 2016 Essentials | | JCKRF-N37P4-C2D82-9YXRT-4M63B |
| | | |
| Windows Server 2019 Datacenter | | WMDGN-G9PQG-XVVXX-R3X43-63DFG |
| Windows Server 2019 Standard | | N69G4-B89J2-4G8F4-WWYCC-J464C |
| Windows Server 2019 Essentials | | WVDHN-86M7X-466P6-VHXV7-YY726 |
| Windows 10 Edition | Generic product key |
|--------------------+-------------------------------|
| Windows 10 Home | 37GNV-YCQVD-38XP9-T848R-FC2HD |
| Windows 10 Home N | 33CY4-NPKCC-V98JP-42G8W-VH636 |
| Windows 10 Pro | NF6HC-QH89W-F8WYV-WWXV4-WFG6P |
| Windows 10 Pro N | NH7W7-BMC3R-4W9XT-94B6D-TCQG3 |
| Windows 10 SL | NTRHT-XTHTG-GBWCG-4MTMP-HH64C |
| Windows 10 CHN SL | 7B6NC-V3438-TRQG7-8TCCX-H6DDY |
| Windows 10 Edition | Generic product key |
|--------------------+-------------------------------|
| Windows 10 Home N | PGGM7-N77TC-KVR98-D82KJ-DGPHV |
| Windows 10 Pro | RHGJR-N7FVY-Q3B8F-KBQ6V-46YP4 |
| Windows 10 Pro N | 2KMWQ-NRH27-DV92J-J9GGT-TJF9R |
| Windows 10 SL | GH37Y-TNG7X-PP2TK-CMRMT-D3WV4 |
| Windows 10 CHN SL | 68WP7-N2JMW-B676K-WR24Q-9D7YC |
From: https://www.tenforums.com/tutorials/95922-generic-product-keys-install-windows-10-editions.html
- (4014)How to hide specific user accounts from the sign-in screen on Windows 10?
- Get name of account
+ Use the Windows key + R keyboard shortcut to open the Run command, type netplwiz, and click OK to open User Accounts.
+ Select the account you want to hide and click Properties
+ Make note of the User name for the account.
- Hide it
+ Use the Windows key + R keyboard shortcut to open the Run command, type regedit, and click OK to open the Windows Registry.
+ Browse the following path:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
+ Right-click the Winlogon, select New, and click Key.
+ Name the new key SpecialAccounts.
+ Right-click the SpecialAccounts key, select new, and click Key.
+ Name the new key UserList.
+ Inside of UserList, right-click, select New, and click DWORD (32-bit) Value.
+ Name the new DWORD key with the name of the account you're trying to hide.
+ Double-click the new DWORD key and make sure its data value is set to 0.
Sign-out and you'll now notice that the account will no longer be available on the sign-in screen. In fact by doing this, you're also hiding the account from virtually everywhere in the operating system, including the from the switch user menu in the Start menu, from Control Panel, and even from the Settings app.
In order to make a hidden account visible again, you'll have to go back to the registry UserList key using the steps mentioned above, and making sure to change the user name data key value from 0 to 1.
From: https://www.windowscentral.com/how-hide-specific-user-accounts-sign-screen-windows-10
- (4018)How to recover (Ubuntu) Grub from windows?
bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
From: https://askubuntu.com/questions/475241/after-boot-repair-laptop-boots-straight-to-windows-8-without-grub-no-solution#475325
- (4019)How do I connect to Eduroam on Windows 11?
SOLUTION1: Automatic configuration
Many people will be able to connect by using the Windows built-in menus. To access the menus in Windows 11 go to the Start menu > Settings > Network & Internet
- Select Wi-Fi at the right.
- Make sure Wi-Fi is on
- Click Show available networks and select Eduroam from the list of wifi networks.
- Press Connect.
- You will be prompted for a username and password. Enter the full email address of your school. If you are an MIT user, enter your MIT Kerberos account username with "@mit.edu" on the end: username@mit.edu
- (Sometimes) If your computer has not yet encountered the certificate that encrypts the connection, it may show a Windows Security Alert warning that "The connection attempt could not be completed."
+ You can press a button to view Details.
+ You can verify the details against the information listed at Eduroam Certificate Fingerprints
+ Press Connect to go on.
- Your school username and school password will be sent to your school for verification. If they work, your wifi will connect
SOLUTION2: Manual configuration
Some people may need to set up the connection manually:
- Open the list of wireless networks.
- Right click on any listed Eduroam networks and choose "Forget this network". If it is not memorized, you will not have the menu, and can skip this.
- Open the Network and Sharing Center. You can reach it by going to Control Panel > Network and Internet > Network and Sharing Center,
- Click Set up a new connection or network.
- Click Manually connect to a wireless network.
- Click Next.
- Fill in the following information for the new network:
+ Network Name: eduroam
+ Security Type: WPA2-Enterprise
+ Encryption Type: AES
-Click Next.
Result: The screen will say Successfully added Eduroam.
- On the following page, choose to Change connection settings.
- Click the Security tab. Network authentication method should be
Microsoft: Protected EAP (PEAP).
- Click Settings.
- Under Trusted Root Certification Authorities, check the box for
AAA Certificate Services
Select Authentication Method should be:
Secure Password (EAP-MSCHAP v2)
Click Configure.
- Un-check the box labeled Automatically use my Windows logon....
Click OK on all boxes to close out and save the wireless settings.
- Click "Advanced Parameters" -> 802.1X Parameters
Specify authentication -> "user authentication"
Click "Save authentication" and enter Username + Password
- Validate everything
- You should receive a notification asking for additional information. Click this notification anywhere to open the password dialog box.
NOTE: Non-local users should enter their account username with "@xx.yy" on the end. Otherwise they will be rejected by local identification server.
Note: If this process fails, please try to follow it one more time. Occasionally, IS&T has noticed the Windows wireless configuration utility lose the settings after the first setup.
From: https://kb.mit.edu/confluence/pages/viewpage.action?pageId=164078660
https://www.univ-lyon2.fr/medias/fichier/windows-11_1650954874113-pdf
- (4025)How to solve error 0x8000ffff when installing WSL?
Try to run the install command "wsl --install -d ubuntu" from a non-Admin CMD/PowerShell
From: https://github.com/microsoft/WSL/issues/9798#issuecomment-1474183478
- (4027)Typical problems when installing WSL?
- Activate Virutalization in BIOS (sometimes it is in "Security" tab)
+ !! Can have many names: "Intel VT-x", "AMD-V", "SVM Mode", "Secure Virtual Machine Mode"
- Install Windows components:
+ GUI Search for "Windows Features" -> "Install Windows Components"
* Hyper-V
* Virtual Machine Platform
* Windows Hypervisor Platform
* Windows Subsystem for Linux
+ CLI/PowerShell
* Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
* Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
* ...
- Run "wsl --install -d Ubuntu" from Admin/non-Admin CMD/PowerShell?
- "wsl --set-default-version 2"
From: https://github.com/microsoft/WSL/issues/6405
https://github.com/microsoft/WSL/issues/10170
https://ecampus.emse.fr/mod/resource/view.php?id=22806
- (4029)How to change/create a user in WSL?
PROBLEM: when running "wsl --install", WSL asks for the creation of a user. Qtudents often don't understand when password does not echo when they type => they mess up the user creation with a password that is not the one they remember.
I] Hacky solution
- "wsl --unregister ubuntu" # uninstall
- "wsl --install -d ubuntu" # re-install
II] Clean solution
- Login as root (see Tip#4030)
- Create a user (see Tip#4031)
- Define this user as default for WSL (see Tip#4032)
Thanks GM
- (4030)How to login as root in WSL?
wsl ~ -u root
From: https://superuser.com/a/1627461
- (4031)How to create a user in WSL?
NEWUSER=<your_username>
useradd --create-home --shell /usr/bin/bash --user-group --groups adm,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev --password $(read -sp Password: pw ; echo $pw | openssl passwd -1 -stdin) $NEWUSER
From: https://superuser.com/a/1627461
- (4032)How to set default user in WSL?
SOLUTION1: /etc/wsl.conf
The current Microsoft recommended way (https://learn.microsoft.com/en-us/windows/wsl/wsl-config#user-settings) of setting the username in an instance is to create a /etc/wsl.conf in the instance with the following setting:
---
[user]
default=username
---
SOLUTION2: <distro>.exe config --default-user <username>
For instance, if you installed "Ubuntu 22.04" from the Store, you would use:
ubuntu2204.exe config --default-user <username>
SOLUTION3: Registry Key
- Use regedit and navigate to the key:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss
- Examine its subkeys for a distribution that has the right name in the item DistributionName
- Create or modify a DWORD item named DefaultUid and set it to the user-id (uid) of your default user.
Here root user is id 0 while the first user id is 1000 (0x3e8).
From: https://superuser.com/a/1627461
https://superuser.com/questions/1566022/how-to-set-default-user-for-manually-installed-wsl-distro/1566031#1566031
- (4083)How to install WSL in Windows 11?
- Open Start menu
- Search for "Command Prompt"
- Right-click the top result
- Select the "Run as administrator" option.
- Type the following command to install WSL and Ubuntu Linux on Windows 11:
wsl --install
From: https://www.windowscentral.com/software-apps/windows-11/how-to-run-any-linux-distro-alongside-windows-11
- (4085)How to directly restart to "BIOS" from windows (a.k.a. How to restart to "BIOS" when you don't know the boot key or it is not working)?
shutdown /r /t 1 /fw
/fw = "firmware"
/r = rebppt
/t = time delay
From: https://www.youtube.com/shorts/Ky3Uh9dd9bA
- (4096)What is the equivalent of "pkill -f node" on Windows?
> taskkill -f -im "node*"
NOTE: Can't start with a wildcard though
From: https://stackoverflow.com/questions/68975002/possible-pkill-f-node-alternative-on-windows
- (6)File redirection with Bash (thanks to Vroum)
> ou 1> : manages STDOUT
2> : manages STDERR
2>&1 Redirects STDERR to STDOUT
&> Redirects STDERR and STDOUT
- (9)Read line by line instead of token by token in Bash
La bonne manière de faire, dans ce cas précis, est plutôt :
ls | while read f
do
echo "$f"
done
Si la liste est grande, tout est mis en mémoire d'un coup avec une
boucle for, avant même que la boucle ne commence. Avec read, on a
vraiment un traitement ligne par ligne.
- (28)Switch from dir to dir
Sous bash, popd et pushd, permettent de mémoriser des chemins de
répertoires dans une pile, pour se simplifier la vie et éviter de
taper des cd à tout bout de champs. La commande dirs permet de voir
les répertoires actuels du stack.
ca implique qu'on ne peut revenir que dans le sens inverse, pas sauter
au repertoire -2, j'ai bon ?
sinon dans le style y'a "cd -" qui peut être utile
Re: Enchainer les répertoires
Si, on peut aller à n'importe lequel des répertoires (en tous
cas, sous bash) : cd ~n où n est la profondeur dans la
pile. Remarque : ça ne dépile rien, ça remplace juste le top
level.
- (29)Bash security/history
HISTSIZE
The number of commands to remember in the command history (see HISTORY
below). The default value is 500.
HISTFILE
The name of the file in which command history is saved (see HISTORY below).
The default value is ~/.bash_history. If unset, the command history is not
saved when an interactive shell exits.
HISTFILESIZE
The maximum number of lines contained in the history file. When this vari
able is assigned a value, the history file is truncated, if necessary, to
contain no more than that number of lines. The default value is 500. The
history file is also truncated to this size after writing it when an inter
active shell exits.
- (33)Count a word occurences in a file
$ cat fichier | sort | uniq -c
- (71)Get a message repeated until you CTL-C
just type "yes <message>"
- (77)On the use of '*'
- if you ls *, you get all files in the current dir
- if you ls */*, you get all files in all "first-order" subdirs of the current dir
- to list all the files in all the subdirs: ls -R
- with **/* (at least in ant) you get all the files in all the subdirs.
- (81)Reuse arguments from the last command
- for a particular agument, use !:1 !:2 !:3...
e.g., mkdir toto ; cd !:1
- for all arguments, use !:*
- (82)Get number of arguments of a script
- use $#
e.g., if [[ $# != 3 ]]; then ... ;fi
- (83)Doing tests correctly
The [[ ]] construct is the more versatile Bash version of [ ]. This is the extended test command, adopted from ksh88.
No filename expansion or word splitting takes place between [[ and ]], but there is parameter expansion and command substitution.
Using the [[ ... ]] test construct, rather than [ ... ] can prevent many logic errors in scripts. For example, the &&, ||, <, and > operators work within a [[ ]] test, despite giving an error within a [ ] construct.
From the "Advanced Bash Scripting" guide
http://tldp.org/LDP/abs/html/
- (85)Difference between "" and ''
- "" is used to prevent bash from interpreting spaces (therefore grouping words into a single argument), but $ and \ are still a special charaters
e.g.1, in a script, echo "$2" will print the second argument.
e.g.2, "\n" is interpreted as newline
- '' prevents any[1] interpretation, even of the \.
e.g.1, in a script, echo '$2' will print $2, not the content of the second argument.
e.g.2, '\n' is interpreted as the concatenation of '\' and 'n'
Be careful, as '\' is not interpreted, you can have strange results. For instance, '\'' is seen as '+\+'+' since the internal \' is not interpreted, three ' are seen, which leads to an "unbalanced string" error.
[1] The exact truth:
(from the ABS: http://www.tldp.org/LDP/abs/html/quotingvar.html)
DOUBLE QUOTES
When referencing a variable, it is generally advisable to enclose its name in double quotes. This prevents reinterpretation of all special characters within the quoted string -- except $, ` (backquote), and \ (escape) [and !, on the command line]. Keeping $ as a special character within double quotes permits referencing a quoted variable ("$variable"), that is, replacing the variable with its value (see Example 4-1, above).
Use double quotes to prevent word splitting. [2] An argument enclosed in double quotes presents itself as a single word, even if it contains whitespace separators.
SIMPLE QUOTES
Single quotes (' ') operate similarly to double quotes, but do not permit referencing variables, since the special meaning of $ is turned off. Within single quotes, every special character except ' gets interpreted literally. Consider single quotes ("full quoting") to be a stricter method of quoting than double quotes ("partial quoting").
Since even the escape character (\) gets a literal interpretation within single quotes, trying to enclose a single quote within single quotes will not yield the expected result.
- (86)Short script to get a reminder (an xmessage) at a given date & hour
--------------- xrappel
#!/bin/bash
if [[ "$#" -le "1" ]]
then
echo "Usage: $0 [<MM/DD/YY>] <hour:minutes> \"<message>\""
else if [[ "$#" -eq "2" ]]
then
echo 'export DISPLAY=:0.0 ; /usr/bin/xmessage " ************** '$2' ************"' | at "$1"
else
echo 'export DISPLAY=:0.0 ; /usr/bin/xmessage " ************** '$3' ************"' | at "$2" "$1"
fi
fi
- (87)Difference between $* and $@
- $* sees all arguments as single word.
- $@ sees arguments as separate words.
----------------- example script:
index=1
echo "Listing args with \"\$*\":"
for arg in "$*" # Doesn't work properly if "$*" isn't quoted.
do
echo "Arg #$index = $arg"
let "index+=1"
done # $* sees all arguments as single word.
echo "Entire arg list seen as single word."
echo
index=1 # Reset count.
# What happens if you forget to do this?
echo "Listing args with \"\$@\":"
for arg in "$@"
do
echo "Arg #$index = $arg"
let "index+=1"
done # $@ sees arguments as separate words.
echo "Arg list seen as separate words."
from "Advanced Bash Scripting" guide:
http://tldp.org/LDP/abs/html/
- (118)Create a directory hierarchy in one shot
mkdirhier toto/tutu/titi or mkdir -p toto/tutu/titi
It works even if toto and toto/tutu do not exist
- (120)Some useful control keys for the bash
Some commmands from (x)emacs work with bash:
- ESC-t to swap words
- CTL-t to swap characters
- ESC-u to change a word into uppercase
- ESC-l to change a word into lowercase
- ESC-c to capitalize the word
- CTL-r to backwards search in the command history
BE CAREFUL : CTL-S "freeze" xterm (use CTL-q to unfreeze)
- (124)Manage history
- type 'history' to list the last commands
- type '!xxx' to recall the command number xxx
- (175)How to get the user enter a password in a script
echo Enter password:
stty -echo
read passwd
stty echo
mount -t smbfs -ousername=myusername,password=$passwd //192.168.2.5/sharename /mnt/mountname
- (177)How to get the file extension and file name in a script
Using bash there's also ${file%.*} to get the filename without the extension and ${file##*.} to get the extension alone. I.e.
file="thisfile.txt"
echo "filename: ${file%.*}"
echo "extension: ${file##*.}"
outputs:
filename: thisfile
extension: txt
- (195)nohup a running process
Usually nohup is only executed on startup of a command given as argument but cannot attach to a running process.
If you are running your job control in Bash then you could use the built-in disown command like
Code:
$ echo $0
bash
$ sleep 600 &
[1] 5764
$ disown -h %1
Now you should be able to logout without the shell sending a SIGHUP to your disowned sleep job.
May I refer you to man bash:
Code:
disown [-ar] [-h] [jobspec ...]
Without options, each jobspec is removed from the table of
active jobs. If the -h option is given, each jobspec is not
removed from the table, but is marked so that SIGHUP is not sent
to the job if the shell receives a SIGHUP. If no jobspec is
present, and neither the -a nor the -r option is supplied, the
current job is used. If no jobspec is supplied, the -a option
means to remove or mark all jobs; the -r option without a job?
spec argument restricts operation to running jobs. The return
value is 0 unless a jobspec does not specify a valid job.
(from: http://www.unix.com/shell-programming-scripting/79205-stoped-job-using-ctrl-z-now-want-run-nohup.html)
- (204)Getting a random value
Simply use $RANDOM
- (205)Dereferencing a string (a.k.a get the value of a variable for which have the name in a string)
${${var}}
Mixed with arrays, this gives:
A] on the use of @ vs. * to get all args
BAD: ${${tata[1]}[@]}
GOOD: ${${tata[1]}[*]}
B] on the evaluation of the inner string
if ${tata[1]} is in a string $chaine, then we do `eval "expr \"$chaine""`
if tata[1] is in a string $chaine, then we do `eval "expr \"\${$chaine}""`
---
DerefernceVariablePassedToFunction() {
if [ -n "$1" ] ; then
echo "value of [${1}] is: [${!1}]"
else
echo "Null parameter passed to this function"
fi
}
Variable="LinuxJournal"
DerefernceVariablePassedToFunction Variable
The secret here is the "!" used in the variable expansion "${!1}". The bash manual states:
"If the first character of parameter is an exclamation point, a level of variable indirection is introduced. Bash uses the value of the variable formed from the rest of parameter as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of parameter itself. This is known as indirect expansion."
From: http://www.linuxjournal.com/content/tech-tip-dereference-variable-names-inside-bash-functions
- (217)Setting bash-like commands (C-a, C-e, C-_, C-k/C-y, etc) on the editing line of bash
either insert in .inputrc:
set emacs on
(or set editing-mode emacs)
or use
set -o emacs on
- (230)How to manage files with accents in their name when XTerm does not support accentuated characters
If you have a file called 'Régles spatiales', you can move it by typing 'mv R(Ctl-v é)gles spatiales xxx'
It can probably work with characters obtained with the MultiKey too.
- (237)How to transpose an array/matrix stored in a file in bash
awk '
{
for (i=1; i<=NF; i++) {
a[NR,i] = $i
}
}
NF>p { p = NF }
END {
for(j=1; j<=p; j++) {
str=a[1,j]
for(i=2; i<=NR; i++){
str=str" "a[i,j];
}
print str
}
}' file
from : http://stackoverflow.com/questions/1729824/transpose-a-file-in-bash
- (301)How to print an integer variable with always X digits?
Use printf:
for i in 1 2 3 4 5 6 ; do printf "%.4d\n" ${i} ; done
- (302)How to get info about any image format (e.g. image size, etc.) from the commandline?
use ImageMagick::identify
- (308)How to format printing of values? (for instance count integers, printing them with always 4 digits: 0000 0001 0002...)
Use "printf":
printf "Pi to 2 decimal places = %1.2f" $PI
echo
printf "Pi to 9 decimal places = %1.9f" $PI # It even rounds off correctly.
- (336)How to shuffle a playlist in commandline?
commande (notez que vous devez installer avant le paquet coreutils pour utiliser shuf) :
cowsay -f $(ls /usr/share/cows | shuf -n1) hello
- (342)How to configure Zsh key binding like it is done with Bash's .inputrc?
Just make a .zshrc file with the same content as the .inputrc, but with each line preceded by "bindkey "
You can convert /etc/inputrc for Zsh:
# bind special keys according to readline configuration
eval "$(sed -n 's/^/bindkey /; s/: / /p' /etc/inputrc)"
From : https://wiki.archlinux.org/index.php/Zsh
- (388)How to run a process only once (if it is not already running)?
pgrep -f -u <user> -x <prgm> || <prgm>
=> bash function
#!/bin/bash
# A function that runs a process only if it is not already running
function run_only_once()
{
IFS=" " read -a splitted <<< $1
progName=`basename ${splitted[0]}`
if [[ "$progName" =~ "sudo" ]]
then
progName="$(basename "${splitted[1]}")"
fi
# echo "PROG_NAME: $progName"
# out=$(pgrep -f "$progName(\\s+|$)")
# echo -e "PGREP: $out ($?)"
mesg=$(pgrep -f "$progName(\\s+|$)" || eval "${splitted[*]}" 2>&1)
echo -e "${progName}:\n ${mesg}" >> /tmp/mesg_${progName}
}
- (398)How to source the "profile" files?
Try starting a virtual terminal, and then do
"bash -i"
# or
"bash -".
It should start a login shell and it should source the /etc/profile* files.
- (400)How to generate a sequence?
seq <first> <increment> <last>
seq 2 10
seq 10 -1 2
- (401)How to reverse a string/int?
rev 123456 => 654321
- (489)How to run the last command as root?
sudo !!
- (533)How to find file by size (more/less than xMb/xKb) [not specified in the linux man!]?
find . -maxdepth 1 -size -1000k -name '*.pdf'
find . -maxdepth 1 -size +1M -name '*.pdf'
ATTENTION: the second command does not seem to return the files that the 1rst command returns!
- (534)How to simply set the separator in awk?
echo 'a,b,c' | awk -F',' '{ print $1 }'
- (535)How to print the whole read line in awk?
echo 'this is a test' | awk '{ print $0 }'
- (555)How to see the structure of the file tree in console?
install and use "tree"
- (556)How to see the structure of the processes tree in console?
pstree
- (598)How to create a logout script for ksh?
add "trap '$HOME/.logout' 0" in your ~/.profile
make the ~/.logout executable using: chmod +x ~/.logout
e.g., ~/.logout can simply contain "clear" so that nobody know the last command you typed (security!)
- (626)How to prevent bad editing of a long line when using colors in prompt?
set the following variable in "readline"'s config file (~/.inputrc):
set horizontal-scroll-mode On
From: http://www.math.utah.edu/docs/info/features_7.html#SEC49
- (627)How to prevent counting of color escape chars in PS1 prompt?
You need to "escape" the escape sequences - like this:
export PS1="\[^[[33;1m\]\u@\h\[^[[0m^[[1m\]: "
export PS2="\[^[[33;1m\]continue \[^[[0m^[[1m\]> "
Note: the use of \e has the same effect as a ^[
From: http://www.patoche.org/LTT/shell/00000076.html
- (628)
- (629)How to look for several words at a time in a file?
$ egrep 'WORD1|WORD2|WORD3' seekfile.text
- (768)How to print/echo special chars on command line?
echo "$IFS" | cat -vte
- (769)How to split a string based on a delimiter in bash?
-- using read &while loop
IN="bla@some.com;blo@plop.fr;john@home.com"
IFS=';' read -rsa ADDR <<< "$IN" #Â read options : -r (do not interpret '\') -a (create en array var) -s (silent mode)
for i in "${ADDR[@]}"; do
# process "$i"
echo $i
done
IFS=$OIFS
-- using for loop
IN="bla@some.com;blo@plop.fr;john@home.com"
OIFS=$IFS
IFS=';'
for i in $IN #Â do not enquote $IN with "" or it will not be interpreted!
do
# process "$i"
echo $i
done
IFS=$OIFS
-- with no loop
IN='one;two;three' #Â the input string
OIFS=$IFS # saving the current separator
IFS=';' # setting the new separator
spo_array=($IN) # making bash split the var along the new separator
IFS=$OIFS # re-setting the separator to its old value
for i in 0 1 2 ; do echo ${spo_array[$i]} ; done # showing the result!
-- the one-liner:
IN="bla@some.com;blo@plop.fr;john@home.com"
a="(${IN/;/ })";
From : http://stackoverflow.com/questions/918886/split-string-based-on-delimiter-in-bash
- (770)How to send the content of a variable (instead of the content of a file) as a redirection?
use <<< (resp. <<) instead of << (resp. >>)
- (771)How to work with arrays in bash?
${ADDR[@]} => the whole array, elements separated
${ADDR[*]} => the whole array, elements joined
${ADDR[<n>]} => the nth element
${#ADDR[@]} => the size of the array
declare -a
read -a
- (772)How to get specific fields of a file in bash (with no sed/awk/perl tricks!)?
while IFS=":" read -r username passwd uid gid info home shell
do
echo "$username:$info"
done < /etc/passwd
From: http://stackoverflow.com/questions/8884935/bash-script-and-greping-with-command-line
- (774)How to make a bash variable save/show the carriage returns?
$ toto=`cat blob | grep ijk`
$ echo $toto # => no carriage return
$ echo "$toto" # => with carriage return
From: http://www.unix.com/shell-programming-scripting/26010-newlines-shell-variables.html
- (779)How to remove the first/last lines of a file in bash?
head -n -9 => remove last lines
tail -n -9 => remove first lines
Be aware the tail starts at the nth line while head skips n lines of the
input.
From:
http://stackoverflow.com/questions/418467/whats-an-easy-way-to-trim-n-lines-from-the-tail-of-a-file-without-the-use-of
- (780)How to remove last character from a string in bash?
x="foo bar"
echo "${x%?}"
From:
http://www.cyberciti.biz/faq/bash-remove-last-character-from-string-line-word/
- (781)How to remove the last empty line with sed?
${/^$/d;} this will only match an empty line if it is the last line of
the file.
From: http://stackoverflow.com/questions/4448826/removing-last-blank-line
- (944)How to generate sequences of numbers or characters with bash?
$ echo {0..9}
0 1 2 3 4 5 6 7 8 9
echo {0..100}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
$ echo {A..Z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
$ echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
$ seq -s " " 1 10
1 2 3 4 5 6 7 8 9 10
From: http://www.doknowevil.net/2009/08/15/generating-sequences-of-numbers-or-characters-with-bash/
- (958)How to get certain lines from a file in command line?
# gets lines 3 to 6
$ sed -n '3,6p' myfile
$ awk 'NR>=3&&NR<=6 { print }' myfile
# gets lines 3 and 6
$ awk 'NR==3||NR==6 { print }' myfile
From: http://www.unix.com/shell-programming-scripting/26739-get-lines-file.html
# Print lines $x to $y; quit after $y
sed -n "$x,${y}p;${y}q;" myfile
# Print lines 3,6&10 ; quits after reading line 10
sed -n '3p;6p;10p;10q' myfile
From: http://mywiki.wooledge.org/BashFAQ/011
To print odd numbered lines from input.txt:
$ sed -n "1~2 p" input.txt
To print even numbered lines from input.txt:
$ sed -n "2~2 p" input.txt
To print text from a specific line number:
$ sed -n "2 p" input.txt
From: http://viewsby.wordpress.com/2011/12/25/sed-print-lines-with-evenodd-numbers/
- (959)How to add line numbers to a file in command line?
cat -n <file>
or
nl <file>
- (968)How to increment a number in bash?
number=0
let number++
echo $number
From: http://stackoverflow.com/questions/13386223/increment-with-bash
- (969)How to print a message on stderr with bash?
echo "something" >&2
or
echo "something" > /dev/stderr
From: http://stackoverflow.com/questions/2643165/bash-command-that-prints-a-message-on-stderr
- (979)How to convert between upper- and lower-case in shell?
cat myFile | tr '[:upper:]' '[:lower:]'
From: http://www.cyberciti.biz/faq/linux-unix-shell-programming-converting-lowercase-uppercase/
- (1385)How to increment a variable in bash?
var=$((var+1))
((var=var+1))
((var+=1))
((var++))
let "var=var+1"
let "var+=1"
let "var++"
From: http://askubuntu.com/questions/385528/how-to-increment-a-variable-in-bash#385532
See also: http://tldp.org/LDP/abs/html/dblparens.html
- (1386)How to get last element of the line?
- Quick'n'clean awk
echo "/path/to/last/dir/filename" |awk -F"/" '{ print $NF }' # equivalent to basename :)
- With (overcomplex) regular expressions
echo foo bar baz | perl -lpe 's/\s*$//;s/.*\s//'
echo foo bar baz | perl -lane 'print $F[-1]'
sed -E -e 's/.* ([^ ]+)$/\1/'
- With (cpu-intensive) reversing of input
echo hello my friend | tac -s' ' | tr '\n' ' ' | cut -d' ' -f 1
echo 1 2 3 4 5 | rev | cut -f1 -d ' '
- With tail (works on 1 line only?)
echo foo bar baz | tr ' ' '\n' | tail -n1
echo "foo bar baz " | tr ' ' '\n' | grep . | tail -n1
From: http://www.unix.com/unix-for-dummies-questions-and-answers/19937-last-element-cut.html
http://unix.stackexchange.com/questions/70843/print-last-field-from-line-alternative-for-awk
- (1373)Shorten forms for Bash's redirections
1>filename
# Redirect stdout to file "filename."
1>>filename
# Redirect and append stdout to file "filename."
2>filename
# Redirect stderr to file "filename."
2>>filename
# Redirect and append stderr to file "filename."
&>filename
# Redirect both stdout and stderr to file "filename."
# This operator is now functional, as of Bash 4, final release.
From: http://www.tldp.org/LDP/abs/html/io-redirection.html
- (1328)What is the difference between exec/source/.?
$ source <file> # executes content inline (vars are defined) / no execution bit required
$ . <file> # executes content in subshell (vars are lost) / no execution bit required
$ exec <file> # ??? terminates shell when finishes / requires execution bit
- (1306)How to create and move inside a temp directory?
cd `mktemp -d`
From: https://wiki.ubuntu.com/Initramfs
- (1007)How to shorten if/then/else statements in bash?
[ -e myfile ] && echo "then statement" || echo "else statement"
NOTE: ORDER IS IMPORTANT: (&& expr) must be before the (|| expr)
From: http://tldp.org/LDP/abs/html/fto.html (at "-p")
- (1031)How to generate random number in a range [min,max]?
echo $((<min>+RANDOM%<max-min>))
Better solution for {0,1}:
number=$RANDOM
let "number>>=14"
echo $number
From: http://www.tldp.org/LDP/abs/html/randomvar.html
- (1033)How to print a function code/definition in Bash?
Let's say we have, somewhere in our code:
function gpm { ... }
To show the code elsewhere:
$ declare -f gpm
or
$ type gpm
From: http://stackoverflow.com/questions/9894872/how-to-print-a-function-definition-in-bash
- (1036)How to quote singles quotes (') inside a single quoted string?
"You can't nest single quotes, but you can end the single quoted string, include an escaped single quote, and then re-enter the quotes."
e.g., echo 'find [a-z]* -name '\''*.pdf'\'' | cut -d '\''/'\'' -f 2 | sort | uniq -d'
From: http://stackoverflow.com/questions/11404704/how-to-use-single-quotes-inside-awk-statement-that-is-surrounded-by-single-quote#11404858
- (1236)How to write good bash scripts?
A] Start scripts with:
#!/bin/bash
set -o nounset # Prevents referencing undefined variables, instead of returng ""
# equiv: -u
set -o errexit # Prevents ignoring failing commands
# equiv: -e
B] Tips:
- USE $* only when sure! Otherwise use "$@"
- USE [[]] instead of []
- USE $() rather than ``
C] Builtin vars:
- $0 name of the script
- $n positional parameters to script/function
- $$ ID of the script
- $! PID of the last command executed (and run in the background)
- $? exit status of the last command (${PIPESTATUS} for pipelined commands)
- $# number of parameters to script/function
- $@ all parameters to script/function (sees arguments as separate word)
- $* all parameters to script/function (sees arguments as single word)
D] Substitution (f="path1/path2/file.ext"):
- single_subst="${f/path?/x}" # => "x/path2/file.ext"
- global_subst="${f//path?/x}" # => "x/x/file.ext"
- splitted_string=(${f//${DIR_SEP}/ })
E] Deletion (f="path1/path2/file.ext"):
- extension="${f#*.}" # = "ext" # deletion at string beginning
- filename="${f##*/}" # = "file.ext" # greedy deletion at string beginning
- dirname="${f%/*}" # = "path1/path2" # deletion at string end
- root="${f%%/*}" # = "path1" # greedy deletion at end
F] Temp files & redirections
- Avoid Temporary Files: use the <(cmd) operator
# download and diff two webpages
diff <(wget -O - url1) <(wget -O - url2)
- Send multi-lines to a command: use "here documents"
# DELIMITER is an arbitrary string
command << MARKER
...
${var}
$(cmd)
...
MARKER
If parameter substitution is undesirable simply put quotes around the first occurrence of MARKER:
command << 'MARKER'
...
no substitution is happening here.
$ (dollar sign) is passed through verbatim.
...
MARKER
G] Debugging:
- bash -n myscript.sh # perform a syntax check/dry run
- bash -v myscripts.sh # produce a trace of every command executed
- bash -x myscript.sh # produce a trace of the expanded command
From: http://robertmuth.blogspot.fr/2012/08/better-bash-scripting-in-15-minutes.html
- (1239)How to test if a file is sorted?
sort -c
From: https://twitter.com/UnixToolTip/status/455747497240305664
- (1240)How to create an array filled with all possible letters?
typeset -a a=({a..z} {A..Z})
From: http://wiki.bash-hackers.org/snipplets/rndstr
- (1241)How to find the max/min of two integers in bash?
r1=1
r2=2
echo $(( ($r1>$r2)?$r1:$r2 )) # max
echo $(( ($r1<$r2)?$r1:$r2 )) # min
From: http://stackoverflow.com/questions/10415064/how-to-calculate-the-minimum-of-two-variables-simply-in-bash
- (1245)How to print every 10th line from a file?
awk '!(NR % 10)' file
or something like:
sed -n 10p file
From: https://twitter.com/UnixToolTip/status/456109908937936897
- (1265)How to exclude files when listing with ls?
ls !(toexculde)
From: http://stackoverflow.com/questions/10061530/unix-ls-command-exclude-wildcard
- (1270)How to get the line AFTER the one matching a regex in AWK?
awk '/the regex/ { getline;print }' "the file.txt"
From: http://www.pement.org/awk/awk1line.txt
- (1271)How to get/operate on different lines in AWK?
Just provide your various treatments as a sequence, separated by ';'. All the treatments will be applied sequencially on each line, so if there is no overlapping between the matching patterns, you'll get what you expect.
awk '/regex1/ { treatment1 }; /regex2/ { treament2 }; /regex3/ { treament3 }' thefile
e.g.:
awk '/[0-9]/ { print $0 }; /http/ { print $0 }' "file.txt"
Will give you both the lines after those matching at least one number AND those matching "http", in the same order as the original input.
BEWARE that if some lines match both http & numbers, they will be repeated, you have to provide non-overlapping regexes to prevent repetition.
eg:
awk '/^[0-9]+$/ { print $0 }; /http/ { print $0 }' "file.txt"
will do the same as above but with no repetition
From: http://www.pement.org/awk/awk1line.txt
- (1274)How to setup bash prompt (a.k.a PS1 shortcuts)?
\a : an ASCII bell character (07)
\d : the date in "Weekday Month Date" format (e.g., "Tue May 26")
\D{format} : the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation. The braces are required
\e : an ASCII escape character (033)
\h : the hostname up to the first '.'
\H : the hostname
\j : the number of jobs currently managed by the shell
\l : the basename of the shell’s terminal device name
\n : newline
\r : carriage return
\s : the name of the shell, the basename of $0 (the portion following the final slash)
\t : the current time in 24-hour HH:MM:SS format
\T : the current time in 12-hour HH:MM:SS format
\@ : the current time in 12-hour am/pm format
\A : the current time in 24-hour HH:MM format
\u : the username of the current user
\v : the version of bash (e.g., 2.00)
\V : the release of bash, version + patch level (e.g., 2.00.0)
\w : the current working directory, with $HOME abbreviated with a tilde
\W : the basename of the current working directory, with $HOME abbreviated with a tilde
\! : the history number of this command
\# : the command number of this command
\$ : if the effective UID is 0, a #, otherwise a $
\nnn : the character corresponding to the octal number nnn
\\ : a backslash
\[ : begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
\] : end a sequence of non-printing characters
Also See Tip#2854
From: http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
- (1276)How to delete to begining of line in bash (a.k.a what is the inverse of Ctrl+k)?
Ctrl + u (=Delete backward from cursor)
From: http://www.aboutlinux.info/2005/08/bash-shell-shortcuts.html
- (1278)How to do complex sorts?
1) -k option can appear multiple times. Take care though: if you want to sort the file primarily by field 3, and secondarily by field 2 you must use:
sort -k 3,3 -k 2,2 < inputfile
If you use:
sort -k 3 -k 2 < inputfile
you'll sort the file by the string from the beginning of field 3 *to the end of line*!
2) each k option can have its own options (reverse, numeric order, etc.). From the man page: "POS is F[.C][OPTS], where F is the field number and C the character position in the field; both are origin 1."
For instance:
-k 1.4,1.5n -k 3.14,3.15n
would use character positions 4-5 in the first field and sort numerically as the first key. The second key would be characters 14-15 in the third field.
From: http://stackoverflow.com/questions/357560/sorting-multiple-keys-with-unix-sort
- (1281)How to show which lines are repeated in a (sorted?) file?
uniq -d
From: https://twitter.com/UnixToolTip/status/486188049672335360
- (1284)Why should you prefer "for" loops rather than "while" loops in Bash?
PROBLEM: the "|" before "while" makes it executed in a subshell, so not all variable from the parent shell are accessible.
$ plop="plop" ; for i in * ; do echo "$plop: $i" ; done
plop: file1
plop: ...
plop: filen
$ plop="plup" find . -maxdepth 1 | while read i ; do echo "$plop: $i" ; done
plop: file1
plop: ...
plop: filen
From: http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/x13082.html
http://www.linuxtopia.org/online_books/advanced_bash_scripting_guide/subshells.html#PARVIS
- (1287)How to keep stdin "open"/"free to be used" inside a loop that take arguments?
DOES NOT WORK: because both "read line" and "read response" try to read from stdin
while read line
do
echo "get some input from the user"
read response
done < some_file.txt
WORKS:
while read -u 3 line; do
read -p "get some input from the user" response
done 3< some_file.txt
From http://superuser.com/questions/421701/bash-reading-input-within-while-read-loop-doesnt-work
- (1298)How to access the values computed inside a "aaa | while read bbb ; do ccc ; done"?
PROBLEM:
The | makes bash run the content of the loop inside a sub-process, therefore every variable in ccc is local and its content is lost when the loop ends. Exporting the variables will not help since "export" will put the variable in the environment /of the sub-shell/.
SOLUTION1:
replace the "aaa | while read bbb" with "for bbb in aaa"
SOLUTION2:
use tmp file inside the while loop: "while read bbb ; do ccc > tmp-file ; done out=`cat tmp-file`"
THIS IS DANGEROUS IF RUN AS ROOT!!!! (If you do, some enterprising user will create a symlink somewhere named ids.text that points at /etc/passwd (or worse yet, /boot/bzImage), and then you're hosed!).
From: http://forums.justlinux.com/showthread.php?116484-bash-variable-scope-inside-a-loop
- (1230)How to concatenate 2 files vertically (a.k.a. show files side-by-side)?
$ echo file1
a
b
c
d
e
$ echo file2
10
20
30
40
50
$ paste -d"," file1 file2
a,10
b,20
c,30
d,40
e,50
NOTE: pr command can also be used for that purpose.
$ pr -m -t -J --sep-string=',' file1 file2
From: http://www.unix.com/shell-programming-and-scripting/110344-appending-two-files-vertically.html
http://stackoverflow.com/questions/13341832/display-two-files-side-by-side
- (1225)How to group files by extension in CLI?
ls -X
From: https://twitter.com/UnixToolTip
- (1226)How to delete all blank lines?
awk NF
From: https://twitter.com/UnixToolTip
- (1224)Awk one-liners
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
Unix: awk '/pattern/ {print "$1"}' # standard Unix shells
DOS/Win: awk '/pattern/ {print "$1"}' # compiled with DJGPP, Cygwin
awk "/pattern/ {print \"$1\"}" # GnuWin32, UnxUtils, Mingw
Note that the DJGPP compilation (for DOS or Windows-32) permits an awk
script to follow Unix quoting syntax '/like/ {"this"}'. HOWEVER, if the
command interpreter is CMD.EXE or COMMAND.COM, single quotes will not
protect the redirection arrows (<, >) nor do they protect pipes (|).
These are special symbols which require "double quotes" to protect them
from interpretation as operating system directives. If the command
interpreter is bash, ksh or another Unix shell, then single and double
quotes will follow the standard Unix usage.
Users of MS-DOS or Microsoft Windows must remember that the percent
sign (%) is used to indicate environment variables, so this symbol must
be doubled (%%) to yield a single percent sign visible to awk.
If a script will not need to be quoted in Unix, DOS, or CMD, then I
normally omit the quote marks. If an example is peculiar to GNU awk,
the command 'gawk' will be used. Please notify me if you find errors or
new commands to add to this list (total length under 65 characters). I
usually try to put the shortest script first. To conserve space, I
normally use '1' instead of '{print}' to print each line. Either one
will work.
FILE SPACING:
# double space a file
awk '1;{print ""}'
awk 'BEGIN{ORS="\n\n"};1'
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
# NOTE: On Unix systems, DOS lines which have only CRLF (\r\n) are
# often treated as non-blank, and thus 'NF' alone will return TRUE.
awk 'NF{print $0 "\n"}'
# triple space a file
awk '1;{print "\n"}'
NUMBERING AND CALCULATIONS:
# precede each line by its line number FOR THAT FILE (left alignment).
# Using a tab (\t) instead of space will preserve margins.
awk '{print FNR "\t" $0}' files*
# precede each line by its line number FOR ALL FILES TOGETHER, with tab.
awk '{print NR "\t" $0}' files*
# number each line of a file (number on left, right-aligned)
# Double the percent signs if typing from the DOS command prompt.
awk '{printf("%5d : %s\n", NR,$0)}'
# number each line of file, but only print numbers if line is not blank
# Remember caveats about Unix treatment of \r (mentioned above)
awk 'NF{$0=++a " :" $0};1'
awk '{print (NF? ++a " :" :"") $0}'
# count lines (emulates "wc -l")
awk 'END{print NR}'
# print the sums of the fields of every line
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'
# add all fields in all lines and print the sum
awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'
# print every line after replacing each field with its absolute value
awk '{for (i=1; i<=NF; i++) if ($i < 0) $i = -$i; print }'
awk '{for (i=1; i<=NF; i++) $i = ($i < 0) ? -$i : $i; print }'
# print the total number of fields ("words") in all lines
awk '{ total = total + NF }; END {print total}' file
# print the total number of lines that contain "Beth"
awk '/Beth/{n++}; END {print n+0}' file
# print the largest first field and the line that contains it
# Intended for finding the longest string in field #1
awk '$1 > max {max=$1; maxline=$0}; END{ print max, maxline}'
# print the number of fields in each line, followed by the line
awk '{ print NF ":" $0 } '
# print the last field of each line
awk '{ print $NF }'
# print the last field of the last line
awk '{ field = $NF }; END{ print field }'
# print every line with more than 4 fields
awk 'NF > 4'
# print every line where the value of the last field is > 4
awk '$NF > 4'
STRING CREATION:
# create a string of a specific length (e.g., generate 513 spaces)
awk 'BEGIN{while (a++<513) s=s " "; print s}'
# insert a string of specific length at a certain character position
# Example: insert 49 spaces after column #6 of each input line.
gawk --re-interval 'BEGIN{while(a++<49)s=s " "};{sub(/^.{6}/,"&" s)};1'
ARRAY CREATION:
# These next 2 entries are not one-line scripts, but the technique
# is so handy that it merits inclusion here.
# create an array named "month", indexed by numbers, so that month[1]
# is 'Jan', month[2] is 'Feb', month[3] is 'Mar' and so on.
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", month, " ")
# create an array named "mdigit", indexed by strings, so that
# mdigit["Jan"] is 1, mdigit["Feb"] is 2, etc. Requires "month" array
for (i=1; i<=12; i++) mdigit[month[i]] = i
TEXT CONVERSION AND SUBSTITUTION:
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
awk '{sub(/\r$/,"")};1' # assumes EACH line ends with Ctrl-M
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
awk '{sub(/$/,"\r")};1'
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format
awk 1
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
# Cannot be done with DOS versions of awk, other than gawk:
gawk -v BINMODE="w" '1' infile >outfile
# Use "tr" instead.
tr -d \r <infile >outfile # GNU tr version 1.22 or higher
# delete leading whitespace (spaces, tabs) from front of each line
# aligns all text flush left
awk '{sub(/^[ \t]+/, "")};1'
# delete trailing whitespace (spaces, tabs) from end of each line
awk '{sub(/[ \t]+$/, "")};1'
# delete BOTH leading and trailing whitespace from each line
awk '{gsub(/^[ \t]+|[ \t]+$/,"")};1'
awk '{$1=$1};1' # also removes extra space between fields
# insert 5 blank spaces at beginning of each line (make page offset)
awk '{sub(/^/, " ")};1'
# align all text flush right on a 79-column width
awk '{printf "%79s\n", $0}' file*
# center all text on a 79-character width
awk '{l=length();s=int((79-l)/2); printf "%"(s+l)"s\n",$0}' file*
# substitute (find and replace) "foo" with "bar" on each line
awk '{sub(/foo/,"bar")}; 1' # replace only 1st instance
gawk '{$0=gensub(/foo/,"bar",4)}; 1' # replace only 4th instance
awk '{gsub(/foo/,"bar")}; 1' # replace ALL instances in a line
# substitute "foo" with "bar" ONLY for lines which contain "baz"
awk '/baz/{gsub(/foo/, "bar")}; 1'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
awk '!/baz/{gsub(/foo/, "bar")}; 1'
# change "scarlet" or "ruby" or "puce" to "red"
awk '{gsub(/scarlet|ruby|puce/, "red")}; 1'
# reverse order of lines (emulates "tac")
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }' file*
# if a line ends with a backslash, append the next line to it (fails if
# there are multiple lines ending with backslash...)
awk '/\\$/ {sub(/\\$/,""); getline t; print $0 t; next}; 1' file*
# print and sort the login names of all users
awk -F ":" '{print $1 | "sort" }' /etc/passwd
# print the first 2 fields, in opposite order, of every line
awk '{print $2, $1}' file
# switch the first 2 fields of every line
awk '{temp = $1; $1 = $2; $2 = temp}' file
# print every line, deleting the second field of that line
awk '{ $2 = ""; print }'
# print in reverse order the fields of every line
awk '{for (i=NF; i>0; i--) printf("%s ",$i);print ""}' file
# concatenate every 5 lines of input, using a comma separator
# between fields
awk 'ORS=NR%5?",":"\n"' file
SELECTIVE PRINTING OF CERTAIN LINES:
# print first 10 lines of file (emulates behavior of "head")
awk 'NR < 11'
# print first line of file (emulates "head -1")
awk 'NR>1{exit};1'
# print the last 2 lines of a file (emulates "tail -2")
awk '{y=x "\n" $0; x=$0};END{print y}'
# print the last line of a file (emulates "tail -1")
awk 'END{print}'
# print only lines which match regular expression (emulates "grep")
awk '/regex/'
# print only lines which do NOT match regex (emulates "grep -v")
awk '!/regex/'
# print any line where field #5 is equal to "abc123"
awk '$5 == "abc123"'
# print only those lines where field #5 is NOT equal to "abc123"
# This will also print lines which have less than 5 fields.
awk '$5 != "abc123"'
awk '!($5 == "abc123")'
# matching a field against a regular expression
awk '$7 ~ /^[a-f]/' # print line if field #7 matches regex
awk '$7 !~ /^[a-f]/' # print line if field #7 does NOT match regex
# print the line immediately before a regex, but not the line
# containing the regex
awk '/regex/{print x};{x=$0}'
awk '/regex/{print (NR==1 ? "match on line 1" : x)};{x=$0}'
# print the line immediately after a regex, but not the line
# containing the regex
awk '/regex/{getline;print}'
# grep for AAA and BBB and CCC (in any order on the same line)
awk '/AAA/ && /BBB/ && /CCC/'
# grep for AAA and BBB and CCC (in that order)
awk '/AAA.*BBB.*CCC/'
# print only lines of 65 characters or longer
awk 'length > 64'
# print only lines of less than 65 characters
awk 'length < 64'
# print section of file from regular expression to end of file
awk '/regex/,0'
awk '/regex/,EOF'
# print section of file based on line numbers (lines 8-12, inclusive)
awk 'NR==8,NR==12'
# print line number 52
awk 'NR==52'
awk 'NR==52 {print;exit}' # more efficient on large files
# print section of file between two regular expressions (inclusive)
awk '/Iowa/,/Montana/' # case sensitive
SELECTIVE DELETION OF CERTAIN LINES:
# delete ALL blank lines from a file (same as "grep '.' ")
awk NF
awk '/./'
# remove duplicate, consecutive lines (emulates "uniq")
awk 'a !~ $0; {a=$0}'
# remove duplicate, nonconsecutive lines
awk '!a[$0]++' # most concise script
awk '!($0 in a){a[$0];print}' # most efficient script
CREDITS AND THANKS:
Special thanks to the late Peter S. Tillier (U.K.) for helping me with
the first release of this FAQ file, and to Daniel Jana, Yisu Dong, and
others for their suggestions and corrections.
For additional syntax instructions, including the way to apply editing
commands from a disk file instead of the command line, consult:
"sed & awk, 2nd Edition," by Dale Dougherty and Arnold Robbins
(O'Reilly, 1997)
"UNIX Text Processing," by Dale Dougherty and Tim O'Reilly (Hayden
Books, 1987)
"GAWK: Effective awk Programming," 3d edition, by Arnold D. Robbins
(O'Reilly, 2003) or at http://www.gnu.org/software/gawk/manual/
To fully exploit the power of awk, one must understand "regular
expressions." For detailed discussion of regular expressions, see
"Mastering Regular Expressions, 3d edition" by Jeffrey Friedl (O'Reilly,
2006).
The info and manual ("man") pages on Unix systems may be helpful (try
"man awk", "man nawk", "man gawk", "man regexp", or the section on
regular expressions in "man ed").
USE OF '\t' IN awk SCRIPTS: For clarity in documentation, I have used
'\t' to indicate a tab character (0x09) in the scripts. All versions of
awk should recognize this abbreviation.
From: http://www.pement.org/awk/awk1line.txt
- (1191)How to set PS1 colors in a xterm-256color/screen-256color?
colors=$(tput colors)
if (($colors >= 256)); then # Terminal supports 256 colours
color_root='\[\e[38;5;9m\]'
color_user='\[\e[38;5;10m\]'
color_undo='\[\e[0m\]'
elif (($colors >= 8)); then # Terminal supports only eight colours
color_root='\[\e[1;31m\]'
color_user='\[\e[1;32m\]'
color_undo='\[\e[0m\]'
else # Terminal may not support colour at all
color_root=
color_user=
color_undo=
fi
if ((EUID == 0)); then # if we are root
PS1=${color_root}${PS1}${color_undo}
else
PS1=${color_user}${PS1}${color_undo}
fi
From: http://blog.sanctum.geek.nz/tag/xterm-256color/
- (1188)How to select the column to use for "sort"ing elements?
sort -t':' -k1,1 -k3 data.txt
gives:
bast:disp-san-d5-06:piranha
bast:display-san-12:redbird
bast:display-san-07:waverider
bast:display-san-12:waverider
This will sort with the 1st field as primary key, and the 3rd field as secondary key splitting the line into fields by ':'
Details:
- data.txt contains the data to sort
-t: means delimit fields in lines with the ':' character, otherwise blank is used by default
- k1,1 means sort on the first field (start at field 1 and end at field 1, otherwise it would continue using the rest of the line for determining the sort)
- k3 means sort on the 3rd field as secondary key. Since there are no other fields behind it is not necessary to specify -k3,3 but it wouldn't hurt either.
From: http://stackoverflow.com/questions/11006431/sort-by-third-column-leaving-first-and-second-column-intact-in-linux#11006690
- (1117)Sed tips
- use "sed -r" instead of "sed -e" in order to enable extended regexes
- use "sed -n -e/r" in order to prevent sed for printing the input line if no match occurs (this is of great help for debugging as if the regex is wrong nothing gets printed)
From: http://www.grymoire.com/Unix/Sed.html
- (1122)How to reload ~/.inputrc
$ bind -f ~/.inputrc # -f filename : Read key bindings from FILENAME.
$ help bind
Notes: Its bash built in command, it will only work with bash or sh. it won't work with ksh or csh shell, for tcsh or csh shell your need to use bindkey command. for more help bindkey
From: http://stackoverflow.com/questions/15027186/inputrc-file-cannot-be-loaded
- (1110)How to change the position of xargs inputs into to arguments of the command to be executed?
cat complexregex | xargs -I{} grep -E {} *
This will tell xargs to put the content of "complexregex" file into "{}" and use this "variable" as 2nd arg of grep.
From: http://www.unix.com/shell-programming-scripting/153004-grep-awk-one-liner-help.html
- (1087)Handy one-liners for SED
HANDY ONE-LINERS FOR SED (Unix stream editor) Mar. 23, 2001
compiled by Eric Pement <pemente@northpark.edu> version 5.1
Latest version of this file is usually at:
http://www.student.northpark.edu/pemente/sed/sed1line.txt
http://www.cornerstonemag.com/sed/sed1line.txt
This file is also available in Portuguese at:
http://www.lrv.ufsc.br/wmaker/sed_ptBR.html
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
# triple space a file
sed 'G;G'
# undo double-spacing (assumes even-numbered lines are always blank)
sed 'n;d'
NUMBERING:
# number each line of a file (simple left alignment). Using a tab (see
# note on '\t' at end of file) instead of space will preserve margins.
sed = filename | sed 'N;s/\n/\t/'
# number each line of a file (number on left, right-aligned)
sed = filename | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /'
# number each line of file, but only print numbers if line is not blank
sed '/./=' filename | sed '/./N; s/\n/ /'
# count lines (emulates "wc -l")
sed -n '$='
TEXT CONVERSION AND SUBSTITUTION:
# IN UNIX ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
sed 's/.$//' # assumes that all lines end with CR/LF
sed 's/^M$//' # in bash/tcsh, press Ctrl-V then Ctrl-M
sed 's/\x0D$//' # gsed 3.02.80, but top script is easier
# IN UNIX ENVIRONMENT: convert Unix newlines (LF) to DOS format
sed "s/$/`echo -e \\\r`/" # command line under ksh
sed 's/$'"/`echo \\\r`/" # command line under bash
sed "s/$/`echo \\\r`/" # command line under zsh
sed 's/$/\r/' # gsed 3.02.80
# IN DOS ENVIRONMENT: convert Unix newlines (LF) to DOS format
sed "s/$//" # method 1
sed -n p # method 2
# IN DOS ENVIRONMENT: convert DOS newlines (CR/LF) to Unix format
# Cannot be done with DOS versions of sed. Use "tr" instead.
tr -d \r <infile >outfile # GNU tr version 1.22 or higher
# delete leading whitespace (spaces, tabs) from front of each line
# aligns all text flush left
sed 's/^[ \t]*//' # see note on '\t' at end of file
# delete trailing whitespace (spaces, tabs) from end of each line
sed 's/[ \t]*$//' # see note on '\t' at end of file
# delete BOTH leading and trailing whitespace from each line
sed 's/^[ \t]*//;s/[ \t]*$//'
# insert 5 blank spaces at beginning of each line (make page offset)
sed 's/^/ /'
# align all text flush right on a 79-column width
sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space
# center all text in the middle of 79-column width. In method 1,
# spaces at the beginning of the line are significant, and trailing
# spaces are appended at the end of the line. In method 2, spaces at
# the beginning of the line are discarded in centering the line, and
# no trailing spaces appear at the end of lines.
sed -e :a -e 's/^.\{1,77\}$/ & /;ta' # method 1
sed -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\( *\)\1/\1/' # method 2
# substitute (find and replace) "foo" with "bar" on each line
sed 's/foo/bar/' # replaces only 1st instance in a line
sed 's/foo/bar/4' # replaces only 4th instance in a line
sed 's/foo/bar/g' # replaces ALL instances in a line
sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case
sed 's/\(.*\)foo/\1bar/' # replace only the last case
# substitute "foo" with "bar" ONLY for lines which contain "baz"
sed '/baz/s/foo/bar/g'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
sed '/baz/!s/foo/bar/g'
# change "scarlet" or "ruby" or "puce" to "red"
sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds
gsed 's/scarlet\|ruby\|puce/red/g' # GNU sed only
# reverse order of lines (emulates "tac")
# bug/feature in HHsed v1.5 causes blank lines to be deleted
sed '1!G;h;$!d' # method 1
sed -n '1!G;h;$p' # method 2
# reverse each character on the line (emulates "rev")
sed '/\n/!G;s/\(.\)\(.*\n\)/&\2\1/;//D;s/.//'
# join pairs of lines side-by-side (like "paste")
sed '$!N;s/\n/ /'
# if a line ends with a backslash, append the next line to it
sed -e :a -e '/\\$/N; s/\\\n//; ta'
# if a line begins with an equal sign, append it to the previous line
# and replace the "=" with a single space
sed -e :a -e '$!N;s/\n=/ /;ta' -e 'P;D'
# add commas to numeric strings, changing "1234567" to "1,234,567"
gsed ':a;s/\B[0-9]\{3\}\>/,&/;ta' # GNU sed
sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' # other seds
# add commas to numbers with decimal points and minus signs (GNU sed)
gsed ':a;s/\(^\|[^0-9.]\)\([0-9]\+\)\([0-9]\{3\}\)/\1\2,\3/g;ta'
# add a blank line every 5 lines (after lines 5, 10, 15, 20, etc.)
gsed '0~5G' # GNU sed only
sed 'n;n;n;n;G;' # other seds
SELECTIVE PRINTING OF CERTAIN LINES:
# print first 10 lines of file (emulates behavior of "head")
sed 10q
# print first line of file (emulates "head -1")
sed q
# print the last 10 lines of a file (emulates "tail")
sed -e :a -e '$q;N;11,$D;ba'
# print the last 2 lines of a file (emulates "tail -2")
sed '$!N;$!D'
# print the last line of a file (emulates "tail -1")
sed '$!d' # method 1
sed -n '$p' # method 2
# print only lines which match regular expression (emulates "grep")
sed -n '/regexp/p' # method 1
sed '/regexp/!d' # method 2
# print only lines which do NOT match regexp (emulates "grep -v")
sed -n '/regexp/!p' # method 1, corresponds to above
sed '/regexp/d' # method 2, simpler syntax
# print the line immediately before a regexp, but not the line
# containing the regexp
sed -n '/regexp/{g;1!p;};h'
# print the line immediately after a regexp, but not the line
# containing the regexp
sed -n '/regexp/{n;p;}'
# print 1 line of context before and after regexp, with line number
# indicating where the regexp occurred (similar to "grep -A1 -B1")
sed -n -e '/regexp/{=;x;1!p;g;$!N;p;D;}' -e h
# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'
# grep for AAA or BBB or CCC (emulates "egrep")
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d # most seds
gsed '/AAA\|BBB\|CCC/!d' # GNU sed only
# print paragraph if it contains AAA (blank lines separate paragraphs)
# HHsed v1.5 must insert a 'G;' after 'x;' in the next 3 scripts below
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;'
# print paragraph if it contains AAA and BBB and CCC (in any order)
sed -e '/./{H;$!d;}' -e 'x;/AAA/!d;/BBB/!d;/CCC/!d'
# print paragraph if it contains AAA or BBB or CCC
sed -e '/./{H;$!d;}' -e 'x;/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
gsed '/./{H;$!d;};x;/AAA\|BBB\|CCC/b;d' # GNU sed only
# print only lines of 65 characters or longer
sed -n '/^.\{65\}/p'
# print only lines of less than 65 characters
sed -n '/^.\{65\}/!p' # method 1, corresponds to above
sed '/^.\{65\}/d' # method 2, simpler syntax
# print section of file from regular expression to end of file
sed -n '/regexp/,$p'
# print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p' # method 1
sed '8,12!d' # method 2
# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files
# beginning at line 3, print every 7th line
gsed -n '3~7p' # GNU sed only
sed -n '3,${p;n;n;n;n;n;n;}' # other seds
# print section of file between two regular expressions (inclusive)
sed -n '/Iowa/,/Montana/p' # case sensitive
SELECTIVE DELETION OF CERTAIN LINES:
# print all of file EXCEPT section between 2 regular expressions
sed '/Iowa/,/Montana/d'
# delete duplicate, consecutive lines from a file (emulates "uniq").
# First line in a set of duplicate lines is kept, rest are deleted.
sed '$!N; /^\(.*\)\n\1$/!P; D'
# delete duplicate, nonconsecutive lines from a file. Beware not to
# overflow the buffer size of the hold space, or else use GNU sed.
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'
# delete the first 10 lines of a file
sed '1,10d'
# delete the last line of a file
sed '$d'
# delete the last 2 lines of a file
sed 'N;$!P;$!D;$d'
# delete the last 10 lines of a file
sed -e :a -e '$d;N;2,10ba' -e 'P;D' # method 1
sed -n -e :a -e '1,10!{P;N;D;};N;ba' # method 2
# delete every 8th line
gsed '0~8d' # GNU sed only
sed 'n;n;n;n;n;n;n;d;' # other seds
# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2
# delete all CONSECUTIVE blank lines from file except the first; also
# deletes all blank lines from top and end of file (emulates "cat -s")
sed '/./,/^$/!d' # method 1, allows 0 blanks at top, 1 at EOF
sed '/^$/N;/\n$/D' # method 2, allows 1 blank at top, 0 at EOF
# delete all CONSECUTIVE blank lines from file except the first 2:
sed '/^$/N;/\n$/N;//D'
# delete all leading blank lines at top of file
sed '/./,$!d'
# delete all trailing blank lines at end of file
sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' # works on all seds
sed -e :a -e '/^\n*$/N;/\n$/ba' # ditto, except for gsed 3.02*
# delete the last line of each paragraph
sed -n '/^$/{p;h;};/./{x;/./p;}'
SPECIAL APPLICATIONS:
# remove nroff overstrikes (char, backspace) from man pages. The 'echo'
# command may need an -e switch if you use Unix System V or bash shell.
sed "s/.`echo \\\b`//g" # double quotes required for Unix environment
sed 's/.^H//g' # in bash/tcsh, press Ctrl-V and then Ctrl-H
sed 's/.\x08//g' # hex expression for sed v1.5
# get Usenet/e-mail message header
sed '/^$/q' # deletes everything after first blank line
# get Usenet/e-mail message body
sed '1,/^$/d' # deletes everything up to first blank line
# get Subject header, but remove initial "Subject: " portion
sed '/^Subject: */!d; s///;q'
# get return address header
sed '/^Reply-To:/q; /^From:/h; /./d;g;q'
# parse out the address proper. Pulls out the e-mail address by itself
# from the 1-line return address header (see preceding script)
sed 's/ *(.*)//; s/>.*//; s/.*[:<] *//'
# add a leading angle bracket and space to each line (quote a message)
sed 's/^/> /'
# delete leading angle bracket & space from each line (unquote a message)
sed 's/^> //'
# remove most HTML tags (accommodates multiple-line tags)
sed -e :a -e 's/<[^>]*>//g;/</N;//ba'
# extract multi-part uuencoded binaries, removing extraneous header
# info, so that only the uuencoded portion remains. Files passed to
# sed must be passed in the proper order. Version 1 can be entered
# from the command line; version 2 can be made into an executable
# Unix shell script. (Modified from a script by Rahul Dhesi.)
sed '/^end/,/^begin/d' file1 file2 ... fileX | uudecode # vers. 1
sed '/^end/,/^begin/d' "$@" | uudecode # vers. 2
# zip up each .TXT file individually, deleting the source file and
# setting the name of each .ZIP file to the basename of the .TXT file
# (under DOS: the "dir /b" switch returns bare filenames in all caps).
echo @echo off >zipup.bat
dir /b *.txt | sed "s/^\(.*\)\.TXT/pkzip -mo \1 \1.TXT/" >>zipup.bat
TYPICAL USE: Sed takes one or more editing commands and applies all of
them, in sequence, to each line of input. After all the commands have
been applied to the first input line, that line is output and a second
input line is taken for processing, and the cycle repeats. The
preceding examples assume that input comes from the standard input
device (i.e, the console, normally this will be piped input). One or
more filenames can be appended to the command line if the input does
not come from stdin. Output is sent to stdout (the screen). Thus:
cat filename | sed '10q' # uses piped input
sed '10q' filename # same effect, avoids a useless "cat"
sed '10q' filename > newfile # redirects output to disk
For additional syntax instructions, including the way to apply editing
commands from a disk file instead of the command line, consult "sed &
awk, 2nd Edition," by Dale Dougherty and Arnold Robbins (O'Reilly,
1997; http://www.ora.com), "UNIX Text Processing," by Dale Dougherty
and Tim O'Reilly (Hayden Books, 1987) or the tutorials by Mike Arst
distributed in U-SEDIT2.ZIP (many sites). To fully exploit the power
of sed, one must understand "regular expressions." For this, see
"Mastering Regular Expressions" by Jeffrey Friedl (O'Reilly, 1997).
The manual ("man") pages on Unix systems may be helpful (try "man
sed", "man regexp", or the subsection on regular expressions in "man
ed"), but man pages are notoriously difficult. They are not written to
teach sed use or regexps to first-time users, but as a reference text
for those already acquainted with these tools.
QUOTING SYNTAX: The preceding examples use single quotes ('...')
instead of double quotes ("...") to enclose editing commands, since
sed is typically used on a Unix platform. Single quotes prevent the
Unix shell from intrepreting the dollar sign ($) and backquotes
(`...`), which are expanded by the shell if they are enclosed in
double quotes. Users of the "csh" shell and derivatives will also need
to quote the exclamation mark (!) with the backslash (i.e., \!) to
properly run the examples listed above, even within single quotes.
Versions of sed written for DOS invariably require double quotes
("...") instead of single quotes to enclose editing commands.
USE OF '\t' IN SED SCRIPTS: For clarity in documentation, we have used
the expression '\t' to indicate a tab character (0x09) in the scripts.
However, most versions of sed do not recognize the '\t' abbreviation,
so when typing these scripts from the command line, you should press
the TAB key instead. '\t' is supported as a regular expression
metacharacter in awk, perl, and HHsed, sedmod, and GNU sed v3.02.80.
VERSIONS OF SED: Versions of sed do differ, and some slight syntax
variation is to be expected. In particular, most do not support the
use of labels (:name) or branch instructions (b,t) within editing
commands, except at the end of those commands. We have used the syntax
which will be portable to most users of sed, even though the popular
GNU versions of sed allow a more succinct syntax. When the reader sees
a fairly long command such as this:
sed -e '/AAA/b' -e '/BBB/b' -e '/CCC/b' -e d
it is heartening to know that GNU sed will let you reduce it to:
sed '/AAA/b;/BBB/b;/CCC/b;d' # or even
sed '/AAA\|BBB\|CCC/b;d'
In addition, remember that while many versions of sed accept a command
like "/one/ s/RE1/RE2/", some do NOT allow "/one/! s/RE1/RE2/", which
contains space before the 's'. Omit the space when typing the command.
OPTIMIZING FOR SPEED: If execution speed needs to be increased (due to
large input files or slow processors or hard disks), substitution will
be executed more quickly if the "find" expression is specified before
giving the "s/.../.../" instruction. Thus:
sed 's/foo/bar/g' filename # standard replace command
sed '/foo/ s/foo/bar/g' filename # executes more quickly
sed '/foo/ s//bar/g' filename # shorthand sed syntax
On line selection or deletion in which you only need to output lines
from the first part of the file, a "quit" command (q) in the script
will drastically reduce processing time for large files. Thus:
sed -n '45,50p' filename # print line nos. 45-50 of a file
sed -n '51q;45,50p' filename # same, but executes much faster
If you have any additional scripts to contribute or if you find errors
in this document, please send e-mail to the compiler. Indicate the
version of sed you used, the operating system it was compiled for, and
the nature of the problem. Various scripts in this file were written
or contributed by:
Al Aab <af137@freenet.toronto.on.ca> # "seders" list moderator
Edgar Allen <era@sky.net> # various
Yiorgos Adamopoulos <adamo@softlab.ece.ntua.gr>
Dale Dougherty <dale@songline.com> # author of "sed & awk"
Carlos Duarte <cdua@algos.inesc.pt> # author of "do it with sed"
Eric Pement <pemente@northpark.edu> # author of this document
Ken Pizzini <ken@halcyon.com> # author of GNU sed v3.02
S.G. Ravenhall <stew.ravenhall@totalise.co.uk> # great de-html script
Greg Ubben <gsu@romulus.ncsc.mil> # many contributions & much help
From: http://www-rohan.sdsu.edu/doc/sed.html
- (1069)How to remove empty lines with sed?
cat <filename> | sed '/^$/d'
From: http://soft.zoneo.net/Linux/remove_empty_lines.php
- (1059)What is a sed script?
A sed script basically consists of addresses and commands. Addresses specify where, commands specify what.
From: https://twitter.com/UnixToolTip/status/398112856493027328
Addresses in sed specify which lines to act on. They can be line numbers or regular expressions.
From: https://twitter.com/UnixToolTip/status/400287216662220800
- (1058)How to add a (coloured) indication of last command execution status in bash prompt?
##-ANSI-COLOR-CODES-##
ColorOff="\001\033[0m\002"
###-Regular-###
Red="\001\033[0;31m\002"
Green="\001\033[0;32m\002"
Blue="\001\033[0;34m\002"
Purple="\001\033[0;35\002"
####-Bold-####
BRed="\001\033[1;31m\002"
BGreen="\001\033[1;32m\002"
BBlue="\001\033[1;34m\002"
BPurple="\001\033[1;35m\002"
# Status of last command (for prompt)
function __stat() {
if [[ $? -eq 0 ]]; then
echo -en "${Green}[\u2714]${ColorOff}"
else
echo -en "${Red}[\u2718]${ColorOff}"
fi
}
PS1=""
if [[ "$TERM" != "xterm" && "$TERM" != "xterm-color" && "$TERM" != "linux" && "$TERM" != "vt220" && "$TERM" != "wsvt25" && "$TERM" != "xterm-xfree86" ]]
then
PS1+="\u@\h:\W$ "
else
PS1+='$(__stat) '"${BBlue}\u${ColorOff}@\h:\W$ "
fi
export PS1
From: http://www.terminally-incoherent.com/blog/2013/01/14/whats-in-your-bash-prompt/#comment-57271
- (1393)How to create an animated rotating mark in bash (a.k.a. XXXX)?
while(true); do for a in \\ \| \/ -; do echo -n $a; sleep 1 ; echo -n -e \\r ; done; done
From: http://linuxgazette.net/168/misc/lg/two_cent_tip__bash_script_to_create_animated_rotating_mark.html
- (1394)How to append a value to an array in bash?
echo ${a[@]}
36
a+=(18)
echo ${a[@]}
36 18
echo ${a[0]}
36
echo ${a[1]}
18
From: http://stackoverflow.com/questions/4181703/how-can-i-concatenate-string-variables-in-bash
- (1406)How to preserve bash's history inside screen?
shopt -s histappend
PROMPT_COMMAND="$PROMPT_COMMAND;history -a"
NOTE: does not work if PROMPT_COMMAND is not already set...
From: http://stackoverflow.com/questions/5510217/using-screen-command-in-linux-does-not-allow-command-history-to-be-logged
- (1417)How to enable more control characters in bash (and emacs CLI mode) a.k.a. How to enable the sending of C-* in CLI/XTerm/Screen??
A basic VT100 terminal send ^( control character corresponding to (. However, xterm has the so-called "modifyOtherKeys" mode, which does allow to send unique keycodes for combinations like that.
To enable it, set the modifyOtherKeys resource, e.g. in ~/.Xdefaults or ~/.Xressources (then load it with xrdb -override ~/.Xresources):
XTerm*vt100.modifyOtherKeys: 1
With that, Ctrl+( will send the following keycode:
^[[27;6;40~
That's rather long though, so another format for keycodes like that was introduced, which can be enabled by setting the formatOtherKeys resource:
XTerm*vt100.formatOtherKeys: 1
With that, Ctrl+( sends:
^[[40;6u
In both of these keycodes, the 40 is the decimal ASCII code for (, and the 6 represents the Ctrl.
See man xterm and http://invisible-island.net/xterm/ctlseqs/ctlseqs.html for further details. No idea whether Terminal.app supports any of it.
--- With that, you can configure emacs CLI (-nw) to run "Query replace regexp" on Esc-C-%:
;; Requires configuration of .Xdefaults/.Xresources
;;*vt100.modifyOtherKeys: 1
;;*vt100.formatOtherKeys: 1
(global-set-key (kbd "^[[37;6u") 'query-replace-regexp)
From: http://stackoverflow.com/questions/4337837/send-c-to-emacs-in-vt100-xterm-terminal-mac-os-xs-terminal
- (1418)How to canonicalize/normalize a path in bash?
PROBLEM: cd /path/toto/nonexisting/../ does not change directory to /path/toto if "nonexisting" does not exists, because it actually resolves/follow the path!
SOLUTION: use readlink:
-e, --canonicalize-existing
canonicalize by following every symlink in every component of the given name recursively, all components must exist
-m, --canonicalize-missing
canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence
e.g.:
readlink -m /path/here/..
From: http://stackoverflow.com/questions/284662/how-do-you-normalize-a-file-path-in-bash
- (1424)How to unlink the current directory (a.k.a if you are in a dir that is pointed to by a symbolic link, how to go to the original dir)?
You can use either:
cd -P .
or:
cd $(pwd -P)
- (1427)How to count occurrences of a substring in a string with separator char in bash?
needle=","
var="text,text,text,text"
number_of_occurrences=$(grep -o "$needle" <<< "$var" | wc -l)
---
var="text,text,text,text"
res="${var//[^,]}"
echo "$res"
echo "${#res}"
---
tr -dc ',' <<<"$var" | awk '{ print length; }'
---
tr -dc ',' <<<"$var" | wc -c
---
awk -F, '{print NF-1}' <<<"$var"
---
grep -o ',' <<<"$var" | grep -c .
---
x="This is a test"
grep -o "s" <<<"$x" | wc -l
---
perl -nle 'print s/,//g' <<<"$var"
---
y="${x//[^s|S]}"; echo "${#y}"
---
var="text,text,text,text"
num=`echo $var | awk 'BEGIN{FS=","} {print NF}'`
echo "$num"
From: http://stackoverflow.com/questions/16679369/count-occurrences-of-char-in-string-using-bash
- (1432)How to compute an integer division in Awk?
Use the int function to get the integer part of the result, truncated toward 0. This produces the nearest integer to the result, located between the result and 0.
$ awk '{ print int(3/2) }'
1
$ awk '{ print int(-3/2) }'
-1
From: http://stackoverflow.com/questions/14858182/integer-division-in-awk#14858211
- (1434)How to print all but the first X columns with awk (a.k.a how to print the x last columns with awk)?
You can either remove the fields you don't want (dirty but works great :)):
awk '{ $1=""; $2=""; $3=""; print $0 }'
Or do it the actual way:
awk '{for(i=<X>;i<NF;i++)printf "%s",$i OFS; if (NF) printf "%s",$NF; printf ORS}'
From: http://stackoverflow.com/questions/2626274/print-all-but-the-first-three-columns
- (1439)How to execute multiple commands on each line in Sed?
sed [-n] [-r] -e '<command1>' -e '<command2>' ... <file>
- (1440)How to orverridde -i in cp?
PROBLEM:
'cp' behaviour [has changed recently - 2014?]
cp: specifying '-i' (alternatively, '-f') on the command line does not override a previous '-f' (alternatively, '-i). Now, the final '-i' or '-f' in the parameter's sequence will win (for mv, rm).
SOLUTION: You can use '-nf' as an override on 'cp -i'.
From: https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/925876
- (1490)How to merge bash terminal histories?
echo 'export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"' >> .bashrc
From: http://www.commandlinefu.com/commands/view/14090/merge-bash-terminal-histories
- (1492)How to affect multiple vars in one line in Bash?
Use an Here String:
read w1 w2 w3 w4 <<< "one two three four"
From: http://unix.stackexchange.com/questions/11063/how-to-assign-values-to-multiple-variables-in-command-line-with-bars
- (1495)How to shift each letter of a string by a given number of letters? (a.k.a. apply very simple encryption algorithm like "ROT13")
--
#!/usr/bin/bash
dual=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
phrase='hello there'
rotat=13
newphrase=$(echo $phrase | tr "${dual:0:26}" "${dual:${rotat}:26}")
echo ${newphrase}
--
$ alpha=abcdefghijklmnopqrstuvwxyz
$ rot=3
$ sed "y/${alpha}/${alpha:$rot}${alpha::$rot}/" <<< 'foobar'
irredu
--
From: http://stackoverflow.com/questions/6441260/how-to-shift-each-letter-of-the-string-by-a-given-number-of-letters
- (1496)How to rotate/shift letters in a word?
--
#!/bin/bash
string=$1
shift=$2
length=${#string}
echo ${string:$length-$shift:$shift}${string:0:$length-$shift}
--
Another common approach is to "double" the string, which simplifies the substringery:
str=stack
len=${#str}
shift=2
strstr=$str$str
echo ${strstr:$len-$shift:$len}
From: http://stackoverflow.com/questions/7139768/shift-letter-position-in-a-word
- (1533)How to repeat any string or char n times without spaces between?
echo -e ''$_{1..80}'\b+'
From: http://www.commandlinefu.com/commands/view/14209/repeat-any-string-or-char-n-times-without-spaces-between
- (1556)How to test if a JSON file is valid?
cat file.json | python -m json.tool
From: http://stackoverflow.com/questions/3858671/unix-command-line-json-parser
- (1591)How to compare floats in Bash?
Bash can't handle floats. You have to pipe to bc:
if [ $(echo " $test > $k" | bc) -eq 1 ]
It is even better to use (( ... )) since you compare numbers like this:
if (( $(bc <<< "$test > $k") ))
Relational expressions evaluate to 0, if the relation is false, and 1
if the relation is true
(http://www.gnu.org/software/bc/manual/html_mono/bc.html#SEC11). Note
however that is a behavior of GNU bc, and it is not POSIX compiant.
From: http://stackoverflow.com/questions/15224581/floating-point-comparison-with-variable-in-bash
- (1592)How to test a regex against a string in Bash?
To match regexes you need to use the =~ operator.
Try this:
[[ "sed-4.2.2.tar.bz2" =~ tar.bz2$ ]] && echo matched
Alternatively, you can use wildcards (instead of regexes) with the == operator:
[[ "sed-4.2.2.tar.bz2" == *tar.bz2 ]] && echo matched
If portability is not a concern, I recommend using [[ instead of [ or
test as it is safer and more powerful. See What is the difference
between test, [ and [[ ? for details: http://mywiki.wooledge.org/BashFAQ/031
NOTE: The most important thing to note is that the regex string itself MUST NOT be enclosed into quotes (" or ')!!!
From: http://stackoverflow.com/questions/17420994/bash-regex-match-string
- (1602)How to manage CSV files in scripts on command line?
PROBLEM: some of the cells might be strings that contains carriage return, thus using "sed" or "while read" loops, that work line-by-line will not work
SOLUTION: use awk, as you can change the field separator:
awk -F, '{ print $3 }' ### should print the actual 3rd cell/field of a csv file
- (1603)How to convert from HTML-entities to ASCII-characters in bash?
$ echo '<' |recode html..ascii
<
From: http://stackoverflow.com/questions/5929492/bash-script-to-convert-from-html-entities-to-characters
- (1622)How to use recursive globs (star/** syntax) in Bash?
In order to do recursive globs in bash, you need the globstar feature from bash version 4 or higher.
From the bash manpage:
globstar
If set, the pattern ** used in a pathname expansion context will
match all files and zero or more directories and subdirectories.
If the pattern is followed by a /, only directories and
subdirectories match.
For your example pattern:
shopt -s globstar
ls **/*.py
From: http://unix.stackexchange.com/questions/49913/recursive-glob
- (1644)How to generate sequences/combinations of characters?
for car in {0..9} {a..z} ; do echo $car ; done
=> generates 0->9 + a->z
for car in {0..9}{a..z} ; do echo $car ; done
=> generates all combinations of 0->9 with a->z!
- (1654)How to hide a command from the bash command line history?
You may want to do this for different reasons, for instance, when
using plain password as commands argument (this is a bad practice, of
course!).
To hide a command from the bash history, just leave a blank space at
the beginning of the line.
$ mysql -uroot -pMYPASSWORD # This will apear in the bash history.
$ mysql -uroot -pMYPASSWORD # This will NOT apear in the bash history.
From: https://blog.terminal.com/10-unsorted-linux-tricks-volume-3/
- (1655)How to list all files that were modified by a command?
Sometimes you run commands that you don't know entirely and afterwards
you're not sure what was modified in a certain directory of your
system.
To avoid that problem, you can execute your command like this:
D="$(date "+%F %T.%N")"; <COMMAND>; find . -newermt "$D"
Where <command> is what you want to execute.
This simply takes the date (in nanoseconds resolution) and saves its
value in a variable, then it executes the command and search the
directory for the files that were modified since the date stored in
the variable.
Note that this only works on the current directory and its subpaths,
but you can change it by extending the find scope to something
different from ..
From: https://blog.terminal.com/10-unsorted-linux-tricks-volume-3/
- (1688)How to manipulate Strings in Bash?
## LENGTH
${#string} Length
## SUBSTRING
${string:position} Substring from $string at $position
${string:position:length} Substring of $length characters from $string at $position
## DELETION
${string#substring} Deletes shortest match of $substring from front of $string
${string##substring} Deletes longest match of $substring from front of $string
${string%substring} Deletes shortest match of $substring from back of $string
NOTE: used to change of extentions: ${filename%.oldext}.newext
${string%%substring} Deletes longest match of $substring from back of $string
## REPLACEMENT
${string/substring/replace} Replace first match of $substring with $replace
${string//substring/replace} Replace all matches of $substring with $replace
${string/#substring/replace} If $substring matches front end of $string, substitute $replace for $substring
${string/%substring/replace} If $substring matches back end of $string, substitute $replacement for $substring
From: http://tldp.org/LDP/abs/html/string-manipulation.html
- (1689)How to manipulate variables in Bash?
${parameter-default}
${parameter:-default} If parameter not set, use default.
${parameter=default}
${parameter:=default} If parameter not set, set it to default.
${parameter+alt_value}
${parameter:+alt_value} If parameter set, use alt_value, else use null string.
${parameter?err_msg}
${parameter:?err_msg} If parameter set, use it, else print err_msg and abort the script with an exit status of 1.
${#var} String length (number of characters in $var)
For an array, ${#array} is the length of the first element in the array.
${#array[*]} and ${#array[@]} give the number of elements in the array.
${#*} and ${#@} give the number of positional parameters.
${var#Pattern} Remove from $var the shortest part of $Pattern that matches the front end of $var
${var##Pattern} Remove from $var the longest part of $Pattern that matches the front end of $var
${var%Pattern} Remove from $var the shortest part of $Pattern that matches the back end of $var
${var%%Pattern} Remove from $var the longest part of $Pattern that matches the back end of $var
${var:pos} Variable var expanded, starting from offset pos
${var:pos:len} Expansion to a max of len characters of variable var, from offset pos
${var/Pattern/Replace} First match of Pattern, within var replaced with Replace. If Replace is omitted, then it is a deletion
${var//Pattern/Replace} Global replacement. All matches of Pattern, within var replaced with Replacement
${var/#Pattern/Replacement} If prefix of var matches Pattern, then substitute Replacement for Pattern
${var/%Pattern/Replacement} If suffix of var matches Pattern, then substitute Replacement for Pattern
${!varprefix*}, ${!varprefix@} Matches names of all previously declared variables beginning with varprefix
From: http://www.tldp.org/LDP/abs/html/parameter-substitution.html
- (1758)How to replace a token with $(pwd) in sed?
You need to use a different character instead of "/", because "/" appears in the pwd output!
sed 's|var=path/to/be/replaced|var='$(pwd)'|g'
From: https://stackoverflow.com/questions/1186190/how-do-i-replace-a-token-with-the-result-of-pwd-in-sed
- (1850)How to get the biggest files in a dir or list?
du -cksh * | sort -rnh
->du
-c: produces a grand total
-k: bloc size=1k
-s: display total for each arg on command line
-h: displays human-readable sizes
->sort
-r: sorts in reverse order (biggest first)
-n: sorts numerically
-h: accepts human-readable sizes
From: http://stackoverflow.com/questions/1019116/using-ls-to-list-directories-and-their-total-sizes
- (1851)How to get the sum of all file sizes in directory listing?
There's already a UNIX command for this: du. Just do:
du -h
As per convention you can add one or more file or directory paths at
the end of the command. -h is an extension to convert the size into a
human-friendly format.
> Does du work with file filters like *.exe, *.jpg etcetera
Yes, du works fine. You can use the -c option (same as --total) to get
a total at the end of the list
From: http://unix.stackexchange.com/questions/72661/show-sum-of-file-sizes-in-directory-listing
- (1861)How to use the output of a command as input as another without using a temp file (a.k.a. How to perform Bash process substitution)?
Use process substitution:
$ diff <(sort file1) <(sort file2)
This is equivalent to:
$ sort file2 > /tmp/file2.sorted
$ sort file1 | diff - /tmp/file2.sorted
$ rm /tmp/file2.sorted
or:
$ mkfifo /tmp/sort2.fifo
$ sort file2 > /tmp/sort2.fifo &
$ sort file1 | diff - /tmp/sort2.fifo
$ rm /tmp/sort2.fifo
Under the hood, Unix uses the second version, with named pipes. The
special file is often named something like /dev/fd/63 on Unix-like
systems; you can see it with a command like:
$ echo <(true).
Process substitution can also be used to capture output that would
normally go to a file, and redirect it to the input of a process. The
Bash syntax for writing to a process is >(command). Here is an example
using the tee, wc and gzip commands that counts the lines in a file
with wc -l and compresses it with gzip in one pass:
$ tee >(wc -l >&2) < bigfile | gzip > bigfile.gz
LIMITS:
- The "files" created are not seekable, which means the process
reading or writing to the file cannot perform random access; it must
read or write once from start to finish.
- Programs that explicitly check the type of a file before opening it
may refuse to work with process substitution, because the "file"
resulting from process substitution is not a regular file.
- It is not possible to obtain the exit code of a process substitution
command from the shell that created the process substitution.
From: https://twitter.com/UnixToolTip/status/763777224176701440
https://en.wikipedia.org/wiki/Process_substitution
http://www.tldp.org/LDP/abs/html/process-sub.html
https://www.gnu.org/software/bash/manual/bashref.html#Process-Substitution
https://medium.com/@joewalnes/handy-bash-feature-process-substitution-8eb6dce68133
- (1867)How to merge two non-consecutive lines of a file with sed and bash?
sed "2s/$/ $(sed -n '4p' sound.desktop)/" sound.desktop
NOTE: This uses "", which allows bash commands to be interpreted by
sed scripts. A sed script is embedded into another sed script. Here,
the 4th line of the file is concatenated at the end of the second one.
From: http://www.commandlinefu.com/commands/view/17668/merge-two-non-consecutive-lines-of-a-file-with-sed-and-bash
- (1911)How to sum integers, one per line?
paste -s -d+ infile | bc
awk '{s+=$1} END {printf "%.0f", s}' infile
sed 's/^/.+/' infile | bc
From: http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line
- (1950)How to parse JSON file in commandline?
$ cat myfile.json | jq '.name'
NOTE: To manage the namespaces (or, more generaly, access items/fields
with control characters - ":" or "."), there are 2 possibilities:
A] (double-)quote the element name. For e.g.:
cat myfile.json | jq '."namespace:itemname"'
B] Use the longer version of the indexing operator. For e.g.:
cat myfile.json | jq '.["namespace:itemname"]'
From: http://xmodulo.com/how-to-parse-json-string-via-command-line-on-linux.html
- (1964)How to print get the char at a specific position in a String/File in Bash?
filecontent=$(cat </path/to/file>)
echo ${filecontent:<offset>:<length>}
http://unix.stackexchange.com/questions/9468/how-to-get-the-char-at-a-given-position-of-a-string-in-shell-script
- (1965)How to replace extension of a file directly in bash?
mv "$file" "${file%.orig}.dest"
From: http://stackoverflow.com/questions/1224766/how-do-i-rename-the-extension-for-a-batch-of-files
- (2164)Problems with if/then/else in bash/shell scripts
- (()) <=> arithmetic evaluation / [[]] <=> string manipulation
- With [[]] no filename expansion or word splitting takes place, but there
is parameter expansion and command substitution.
- Always test if something is non empty with [[ -z "$var" ]]
- Use [[ ]] rather than [], particularly with multiple tests
- Ensure bash is used instead of sh with #!/bin/bash, particularly
with multiple tests [[]] and if file is ran directly (i.e. is executable & not called with ". <script>")
From: http://tldp.org/LDP/abs/html/testconstructs.html
- (2165)How to execute a sequence of commands and get an exit status that reflects the behaviour of all commands?
PROBLEM:
- if you execute the sequence with { cmd1 ; ... ; cmdn } or ( cmd1 ;
... ; cmdn ) the exit status of the sequence is the exit status of
the last command
- if you execute the sequence with
cmd1 && ... && cmdn
or
cmd1 || ... || cmdn
some commands will not get executed if the previous fails/succeed,
since && and || are lazy operators
SOLUTION1: If by "sequence of commands" you just mean sequential
execution of one command after the other, then just check the exit
status of each command and set a flag if the exit status is not
zero. Have your script return the value of the flag like:
#!/bin/bash
EXIT=0
grep -q A <<< 'ABC' || EXIT=$? # Will exit with 0
grep -q a <<< 'ABC' || EXIT=$? # Will exit with 1
grep -q A <<< 'ABC' || EXIT=$? # Will exit with 0
echo $EXIT # Will print 1
exit $EXIT # Exit status of script will be 1
This uses the logical operator OR || to only set EXIT if the command
fails. Exit status is untouched if the command succeeds. If multiple
commands fail the exit status from the last failed command will be
return by the script.
If you wish to know which command failed, but not neccessarily its
return code you could use:
#!/bin/bash
rc=0;
counter=0;
command1 || let "rc += 1 << $counter"; let counter+=1;
command2 || let "rc += 1 << $counter"; let counter+=1;
command3 || let "rc += 1 << $counter"; let counter+=1;
exit $rc
This uses bit shifting in bash in order to set the bit corresponding
to which command failed.
Hence if the first command failed you'll get an return code of 1
(=2^0), if the third failed you would get a return code of 8 (=2^3),
and if both the first and the third command failed you would get 9 as
the return code.
SOLUTION2: If by "sequence of commands", you mean piping commands into
one another, then you need to set pipefail in your script like set -o
pipefail. From man bash:
The return status of a pipeline is the exit status of the last
command, unless the pipefail option is enabled. If pipefail is
enabled, the pipeline's return status is the value of the last
(rightmost) command to exit with a non-zero status, or zero if all
commands exit successfully. If the reserved word ! precedes a
pipeline, the exit status of that pipeline is the logical negation
of the exit status as described above. The shell waits for all
commands in the pipeline to terminate before returning a value.
From: https://stackoverflow.com/questions/16080716/execute-multiple-commands-in-a-bash-script-sequentially-and-fail-if-at-least-one#16081218
- (2219)How to get info/code of a shell object (alias/function/...)?
$ type <function/alias>
e.g.
$ type rbenv
rbenv is a function
rbenv ()
{ ... }
$ type pdf2imglandscape
pdf2imglandscape is aliased to `...`
$ type date
date is /bin/date
From: https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-ubuntu-16-04
- (2224)What does 'set -- xxx "$@"' do?
Will put the word "xxx" in front of the args ($@=$1 $2 $3...).
Indeed:
# Let's set some CLI arguments
$ set a b c
$ echo $1,$2,$3
a,b,c
$ set -- haproxy "$@"
$ echo $1,$2,$3,$4
haproxy,a,b,c
From: https://unix.stackexchange.com/questions/308260/what-does-set-do-in-this-dockerfile-entrypoint
- (2230)How to get documentation on builtin shell commands?
Instead of wasting time looking for the "INTERNAL BUILTIN COMMANDS" section of "man bash", just type:
help -m set | less
From: https://stackoverflow.com/questions/36273665/what-does-set-x-do
- (2234)How to use comments in multiline bash commands?
SOLUTION1: if you want to put comments between several commands in a sequence
The command ':' is called the "null" command. It does nothing and always returns 0 (== no problem == true). But it can take arguments (that are thus ignored).
As a consequence, you can use this command inside multi-line command sequences to act as comments.
Example:
$ command 1 ; \
: comment 1 ; \
command 2 ; \
: comment 2 - line 1 ; \
: comment 2 - line 2; \
command 3
BEWARE: It is not a true comment. The line is actually parsed by the shell. That may have side effects:
: ${a:=x} ## assigns the value 'x' to the variable, 'a'
: $(command) ## executes 'command'
NOTE: It is convenient to comment out a large section of a script (saves a lot of time over preceding each line with '#'):
: '
while [ $n -ne $x ]
do
: whatever
done
'
SOLUTION2: If you want to put comments between the args of a single command, simply put them into ``
echo CommandName InputFiles `#1st comment` \
--option1 arg1 `#2nd comment` \
--option2 arg2 `#3rd comment`
From: https://unix.stackexchange.com/questions/37411/multiline-shell-script-comments-how-does-this-work
https://stackoverflow.com/questions/9522631/how-to-put-line-comment-for-a-multi-line-command#answer-12797512
- (2299)How to test whether a glob has any matches in bash?
- Method1: hack comparing expanded version versus non-expanded one
if [ "$(echo glob*)" != 'glob*' ]; then...
- Method2: hack consisting in getting size of array after expansion
#shopt -s nullglob
M=(*py)
if [ -e ${M[0]} ]; then...
# Method3: clean method using find
if find $yourGlob -quit &> /dev/null; then...
# Method4: clean method using stat
if stat -t glob* >/dev/null 2>&1; then...
# Method 5: clean method but bash specific
if compgen -G "/tmp/someFiles*" > /dev/null; then...
From: https://stackoverflow.com/questions/2937407/test-whether-a-glob-has-any-matches-in-bash
- (2408)How to make a non-greedy regex match in bash?
PROBLEM: =~ and other regex matches of bash do not support non-greedy matching
SOLUTIO: use perl-regex matching through grep (grep -oP + ".+" -> "\K.+?")
$ string='<span class="circle"> </span>foo</span></span>'
$ grep -oP '<span class="circle"> </span>\K.+?(?=</span>)' <<<"$string"
foo
NOTE: most of the time you can work around the problem by replacing the greedy ".*" with "[^<first char after the capture>]".
Like in the e.g. above:
string='<span class="circle"> </span>foo</span></span>'
regex='<span class="circle"> </span>([^<]+)</span>'
[[ $string =~ $regex ]];
echo "${BASH_REMATCH[1]}"
From: https://unix.stackexchange.com/questions/128362/lazy-regex-using-bash#answer-128365
- (2409)How to get the results of =~ regex matching?
When using =~ in a test in bash some variables are defined:
- BASH_REMATCH[1] -> that part that matched
- BASH_REMATCH[2] -> the remaining string
You can loop on all the matches with:
function find_matches {
MATCHES=()
local STR=$1 RE="($2)(.*)"
while [[ -n $STR && $STR =~ $RE ]]; do
MATCHES+=("${BASH_REMATCH[1]}")
STR=${BASH_REMATCH[2]}
done
}
From: https://stackoverflow.com/questions/18738576/regex-in-bash-expression#answer-18738897
- (2854)What is the syntax of the PS1 prompt in bash?
\$ – # if the effective UID is 0, $ otherwise
\u – Username
\h – Hostname
\w – Full path of the current working directory
\W – the basename of the current working directory, with $HOME abbreviated with a tilde
\t – current time in 24-hour HH:MM:SS format
\T – current time in 12-hour HH:MM:SS format
\@ – current time in 12-hour am/pm format
\A – current time in 24-hour HH:MM format
\D{format} – date in <strftime format>
\! – The history number of the command
\$? – Status of the last command
= COLORS [Note: Replace 0 with 1 for dark color]
\e[ – Indicates the beginning of color prompt
x;ym – Indicates color code. Use the color code values mentioned below.
\e[m – indicates the end of color prompt
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Note: you can also use tput to change the color.
Aslo See Tip#1274
From: https://www.thegeekstuff.com/2008/09/bash-shell-ps1-10-examples-to-make-your-linux-prompt-like-angelina-jolie/
- (2918)How do I replace AND (&&) in a for loop?
The for loop equivalent of:
cmd 1 && cmd 2 && ... && cmd 20
Is:
for i in {1..20}
do
cmd $i || break
done
From: https://unix.stackexchange.com/questions/318266/how-do-i-replace-and-in-a-for-loop/318280#318280
- (2980)BasicBash.sh
#!/bin/bash
set -o nounset # Prevents referencing undefined variables, instead of returng ""
# equiv: -u
set -o errexit # Prevents ignoring failing commands
# equiv: -e
# Tips:
# USE "$@" more often than $*!
# USE [[]] instead of []
# USE $() rather than ``
# Builtin vars:
# $0 name of the script
# $n positional parameters to script/function
# $$ PID of the script
# $! PID of the last command executed (and run in the background)
# $? exit status of the last command (${PIPESTATUS} for pipelined commands)
# $# number of parameters to script/function
# $@ all parameters to script/function (sees arguments as separate word)
# $* all parameters to script/function (sees arguments as single word)
# Substitution:
# f="path1/path2/file.ext"
# single_subst="${f/path?/x}" # = "x/path2/file.ext"
# global_subst="${f//path?/x}" # = "x/x/file.ext"
# # string splitting
# readonly DIR_SEP="/"
# array=(${f//${DIR_SEP}/ })
# second_dir="${arrray[1]}" # = path2
# Deletion:
# f="path1/path2/file.ext"
# # deletion at string beginning
# extension="${f#*.}" # = "ext"
# # greedy deletion at string beginning
# filename="${f##*/}" # = "file.ext"
# # deletion at string end
# dirname="${f%/*}" # = "path1/path2"
# # greedy deletion at end
# root="${f%%/*}" # = "path1"
# Debugging:
# bash -n myscript.sh # perform a syntax check/dry run
# bash -v myscripts.sh # produce a trace of every command executed
# bash -x myscript.sh # produce a trace of the expanded command
- (3285)How to get the documentation about the internal/built-ins commands of bash?
In CentOS, they are in a separate man page (cf link).
In other distributions: "man bash" + search for section "SHELL BUILTIN COMMANDS"
From: https://www.unix.com/man-page/centos/1/compgen/
- (3313)How to detect if the shell is controlled from SSH?
PROBLEM: when running some commands in .bashrc/profile, under an ssh session, the prompt might freeze or become "glitchy"
SOLUTION1: with env vars & ps
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
SESSION_TYPE=remote/ssh
# many other tests omitted
else
case $(ps -o comm= -p $PPID) in
sshd|*/sshd) SESSION_TYPE=remote/ssh;;
esac
fi
SOLUTION2: with who am i (doesn’t work in a remote tmux session)
if [[ $(who am i) =~ \([-a-zA-Z0-9\.]+\)$ ]] ; then echo SSH; else echo no; fi
From: https://unix.stackexchange.com/questions/9605/how-can-i-detect-if-the-shell-is-controlled-from-ssh/9607#9607
- (3314)How to clear bash history?
- Remove single entry
history -d 4
- Clear all history
history -c
rm ~/.bash_history
From: https://linuxhint.com/clear_bash_history/
- (3326)Bash interesting key bindings?
esc-. / esc-_ Insert last word from previous commands
esc-{ Insert filename completion as enclosed names within braces.
esc-= List the possible completions before point
esc-* Insert all completions before point
ctrl-x$ List ENV var completions
esc-$ Insert ENV var completions
ctrl-x@ List hostname completions
esc-@ Insert hostname completions
ctrl-x~ List username completions
esc-~ List username completions
From: https://books.google.fr/books?id=060cAgAAQBAJ&pg=PA521&dq=bash+cookbook%22esc-%7B%22&hl=fr&sa=X&ved=2ahUKEwiekZ_D1oXvAhVRx4UKHQrIBkcQuwUwAHoECAAQCw#v=onepage&q=bash%20cookbook%22esc-%7B%22&f=false
https://ss64.com/bash/syntax-keyboard.html
- (3360)How to exit a Bash script, without quitting the terminal?
Use "return" instead of using "exit"
From: https://stackoverflow.com/questions/9640660/any-way-to-exit-bash-script-but-not-quitting-the-terminal#9640736
- (3378)How to delete history when closing a terminal?
------ ~/.bashrc:
...
clean_hist () {
history -c
history -w # ??
rm ~/.bash_history
}
trap clean_hist EXIT
....
------
From: https://unix.stackexchange.com/questions/25049/how-do-i-close-a-terminal-without-saving-the-history
Thanks Rodo!
- (3399)How to add a command to the Bash history without executing it?
history -s &lt;command&gt;
EXAMPLE: in my .bashrc, I replaced the saving of \&quot;cd &lt;relative path&gt;\&quot; with \&quot;cd &lt;absolute path&gt;\&quot; using:
function cd {
history -s \&quot;cd \&quot;$@\&quot;\&quot;
builtin cd \&quot;$@\&quot;
# pwd
}
From: https://superuser.com/questions/135651/how-can-i-add-a-command-to-the-bash-history-without-executing-it
https://unix.stackexchange.com/questions/20396/make-cd-automatically-ls
- (3412)How to print an ASCII/UTF-8 from their code/integer value in Bash?
If you know the hexadecimal value:
printf \'\\x&lt;hex value&gt;\'
If you know the decimal value:
printf \"\\\\$(printf %o &lt;decimal value&gt;)\"
From: https://unix.stackexchange.com/questions/311904/how-do-i-print-an-ascii-character-by-different-code-points-in-bash/311908#311908
- (3446)How to actually delete directories with "find"? (a.k.a. How to solve "directory not empty" when using "-delete"?) (a.k.a. How to call a single command with all found files as an argument?)
Instead of using:
find /path/ xxx -delete
Use:
find /path/ xxx -exec rm -rv {} + # Executes one single 'rm' with all files as argument
or:
find /path/ xxx -exec rm -rv {} \; # Executes each 'rm' separately
From: https://unix.stackexchange.com/questions/249501/shell-find-delete-directory-not-empty/249503#249503
- (3986)How to prevent overwriting of a file with redirection (>)?
There is the noclobber option:
Prevent output redirection using >, >&, and <> from overwriting existing files.
$ echo foo > bar
$ echo foo > bar
$ set -o noclobber
$ echo foo > bar
bash: bar: cannot overwrite existing file
To undo:
$ set +o noclobber
From: https://unix.stackexchange.com/questions/483122/prevent-overwriting-a-file-with-redirection
https://unix.stackexchange.com/questions/591304/how-do-i-allow-clobber-in-unix#591305
- (4007)How to print multiple array values?
Can be done with xargs. With -n3 xargs will use 3 arguments at same time for the default echo command.
---- Example
$ cat > /tmp/words.lst
one
two
three
four
five
six
seven
eight
nine
ten
$ arr=($(cat /tmp/words.lst))
$ echo "${arr[@]}" | xargs -n3
From: https://superuser.com/questions/1242261/bash-how-to-print-multiple-arrays-values/1242368#1242368
- (4024)How to disable any bash option (e.g. noclobber)?
When you set an option with:
set -o <option>
You can unset it with:
set +o <option>
Example:
set -o noclobber # to prevent overwriting of file with redirections (>)
set +o noclobber # to allow it again
From: https://unix.stackexchange.com/questions/591304/how-do-i-allow-clobber-in-unix#591305
- (4055)How to solve '': command not found' in bash scripts?
Might be due to windows encoding (^M char) in the file => remove them
- (38)Java overloading
Overloading deals with multiple methods in the same class with the same name but different signatures
class test
{
static class A {
A()
{}
}
static void meth1(Object x)
{ System.out.println("meth obj");}
static void meth1(A x)
{ System.out.println("meth A");}
public static void main(String [] args)
{
Object y = new A();
meth1(y); // Affiche "meth obj"
}
}
- (130)Enums / enum
- 'enums Foo { a,b,c }' is implemented by something like 'class Foo extends Enum'
- So we can do something like that (close to inheritance of enums)
class A
{
private Enum type;
public Enum getType() { ... }
public void setType(Enum a) { ... }
}
class B extends A
{
enum LocalEnumeration { a,b,c };
....
{
type = LocalEnumeration.a;
}
}
class C extends A
{
enum LocalEnumeration2 { d,e,f };
....
{
type = LocalEnumeration2.f;
}
public static void main(String args[])
{
C ccc = new C();
cccc.setType(C.LocalEnumeration2.e);
B bbb = new B();
bbb.setType(B.LocalEnumeration.c);
}
}
- (149)Under OpenBSD, when someone runs 'java -XmxYYY' and YYY is greater than the (bash-)allowed data seg size for a process, then java just closes while complaining.
Unfortunately 'ulimit -d' did not help, returning a "operation not permitted". Indeed, I felt that the limitation comes from 'above': it might be limited by some configuration that is set for the current bash at launch-time.
The dialog below indicates a solution: the launch-time configuration of bash is in /etc/login.conf.
> Indeed! Please keep us posted! I'd wager that you're ready to go if
> you can unlimit the data seg size.
I found that the default settings (modifiable in /etc/login.conf) are
a soft limit of 64MB and a hard limit of 256MB.
- (151)How to do profiling
java -agentlib:hprof=heap=sites <class to run>
java -agentlib:hprof=cpu=times <class to run>
- (189)Comparison Java/C#
(A COMPARISON OF MICROSOFT'S C# PROGRAMMING LANGUAGE TO SUN MICROSYSTEMS' JAVA PROGRAMMING LANGUAGE By Dare Obasanjo)
http://www.25hoursaday.com/CsharpVsJava.html
- (303)How to show BIG matrices?
Use UJMP: http://www.ujmp.org/
- (304)How to do genetic programming?
Use ECJ: http://www.cs.gmu.edu/~eclab/projects/ecj/
- (410)What is the difference between OverLoading and OverRiding/OverWriting?
overloaded methods:
appear in the same class or a subclass
have the same name but,
have different parameter lists, and,
can have different return types
overriding methods:
appear in subclasses
have the same name as a superclass method
have the same parameter list as a superclass method
have the same return type as as a superclass method
the access modifier for the overriding method may not be more restrictive than the access modifier of the superclass method
the throws clause of the overriding method may only include exceptions that can be thrown by the superclass method, including it's subclasses
From: http://www.janeg.ca/scjp/overload/poly.html
https://stackoverflow.com/questions/837864/java-overloading-vs-overriding
- (537)How to list currently running Java processes? [OpenJDK only]
In the command line, use:
$ jps
(="Java ps")
- (784)How do I split screens in Eclipse?
Eclipse allows split screen editing on multiple files but I believe you can't open the same file in two editors at the same time.
The split screen is achieved by the following:
1) Open multiple files (e.g. Controller.java, View.java and Model.java). They should now be stacked using tabs and the latest file, say Model.java, being "active".
2) Now left-click (don't release) on a "View.java"'s tab, drag the cursor to the lower edge of the active editor, wait a second so that the cursor changes into a black filled arrow, and release the mouse button. Voila, the two files (Model.java and View.java) should be now vertically split.
3) Now left-click (don't release) on "Controller.java" tab, drag the cursor to the right edge of one of the already open editors, wait a second so that the cursor changes into a black filled arrow, and release the mouse button. Voila, all three files are split into the screen.
From: http://www.coderanch.com/t/101996/vc/Split-screen-editor-Eclipse
- (785)How to set the font size in Eclipse?
- On the eclipse toolbar, select Window -> Preferences
- Set the font size (General -> Appearance -> Colors and Fonts -> Java Editor text font).
- Save the preferences.
From: http://stackoverflow.com/questions/4922305/how-can-i-change-font-size-in-eclipse-for-java-text-editors#4923243
- (786)How to join/apprend/concatenate values from an Array/Collection into a single String?
import org.apache.commons.lang.StringUtils;
List<String> values = ...;
String asString = StringUtils.join(values, ",");
System.out.println("["+asString+"]");
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/StringUtils.html#join%28java.lang.Object[],%20char%29
---
import java.util.Arrays;
String[] values = ...;
String asString = Arrays.toString(values);
System.out.println(asString);
From: http://stackoverflow.com/questions/9868482/what-is-ljava-lang-string
- (823)How to configure the proxy in Eclipse?
Eclipse does not read the system settings for the proxy ;[
So go to General > Network Connections, fill the info for machine/port/auth, then set to Manual/Native/... accordingly
From: http://stackoverflow.com/questions/5857499/how-do-i-have-to-configure-the-proxy-settings-so-eclipse-can-download-new-plugin
- (833)How to read a complete text file into a String in Java?
import org.apache.commons.io.FileUtils;
String str = FileUtils.readFileToString(new File(argv[i]), "utf-8");
From: http://commons.apache.org/io/api-release/index.html?org/apache/commons/io/package-summary.html
- (839)How to associate an editor with a content/file type in Eclipse?
In Window -> Preferences -> General -> Editors -> File Associations, you can associate File Extensions to Editors.
In Window -> Preferences -> General -> Content Types, you can associate Content Types to Editors.
From: http://stackoverflow.com/questions/5859641/eclipse-associate-an-editor-with-a-content-type
- (842)How to set a proxy for Maven 2+?
In settings.xml file (usually ~/.m2/settings.xml)
<settings>
.
.
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<host>proxy.somewhere.com</host>
<port>8080</port>
<username>proxyuser</username>
<password>somepassword</password>
<nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts>
</proxy>
</proxies>
.
.
</settings>
From: https://maven.apache.org/guides/mini/guide-proxies.html
- (844)How to make Eclipse view changes (particularly new files added) to a project when using SVN externally?
Perhaps you want to check Preferences > General > Workspaces > Refresh using native hooks or polling. You can see that the eclipse refreshes the file you edit with external editor (like vi, emacs, etc) when you check the option.
From: http://stackoverflow.com/questions/13470311/eclipse-refresh-files-edited-by-external-editor
- (850)How to set the proxy in Java?
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "3128");
- (851)How to make a .jar file?
jar cvf <jarname>.jar -C <classes dir> <package>
- (852)How to work/read/write with CSV files in Java?
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
--Read
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));
String [] nextLine;
while ((nextLine = reader.readNext()) != null) {
// nextLine[] is an array of values from the line
System.out.println(nextLine[0] + nextLine[1] + "etc...");
}
Or, if you might just want to slurp the whole lot into a List, just call readAll()...
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));
List myEntries = reader.readAll();
--Write
CSVWriter writer = new CSVWriter(new FileWriter("yourfile.csv"), '\t');
// feed in your array (or convert your data to an array)
String[] entries = "first#second#third".split("#");
writer.writeNext(entries);
writer.close();
From: http://opencsv.sourceforge.net/#how-to-read
- (864)How to create a self-signed certificate (for java)?
keytool -genkey -alias <mydomain> -keyalg RSA -keystore <keystore.jks> -keysize 2048
AND GIVE <yourdomain> (e.g., localhost) WHEN ASKED FOR YOUR FIRSTNAME/LASTNAME
From: http://www.sslshopper.com/article-how-to-create-a-self-signed-certificate-using-java-keytool.html
https://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html
- (865)How to list a certificates in java trusted CAs keystore?
$ keytool -v -list -keystore /etc/ssl/certs/java/cacerts
NOTE: Default password for java keystore (/usr/lib/jvm/java-X-openjdk-M/jre/lib/security/cacerts -> /etc/ssl/certs/java/cacerts) is 'changeit'
From: http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html#importCertCmd
http://stackoverflow.com/questions/8640340/java-keystore-password
- (866)How to add a self-signed certificate into java trusted CAs?
# keytool -importcert -alias HeritrixLocal -file /home/guillaume/Work/Code/heritrix-3.1.0/localhost8443.pem -keystore /etc/ssl/certs/java/cacerts
NOTE: Default password for java keystore (/usr/lib/jvm/java-X-openjdk-M/jre/lib/security/cacerts -> /etc/ssl/certs/java/cacerts) is 'changeit'
From: http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/keytool.html#importCertCmd
http://stackoverflow.com/questions/8640340/java-keystore-password
- (871)How to execute some java code live in the console?
use BeanShell:
$ bsh
- (873)How to manage following childs/siblings in XPath?
<root>
<dt>name</dt>
<dd>value</dd>
<dt>name2</dt>
<dt>name3</dt>
<dd>value3</dd>
<dt>name4</dt>
<dt>name5</dt>
<dd>value5</dd>
<dt>name6</dt>
</root>
//dt[not(following-sibling::*[1][self::dd])]
Output is those dt nodes that do not have a dd immediately following them:
<dt>name2</dt>
<dt>name4</dt>
<dt>name6</dt>
What we are doing here is saying:
//dt
All dt nodes, anywhere....
[not(following-sibling::*[1]
....such that it's not the case that their first following sibling (whatever it is called)....
[self::dd]]
...is called dd.
From: http://stackoverflow.com/questions/2092303/xpath-for-choosing-next-sibling
- (874)How to show line numbers in Eclipse?
window -> preference -> general -> editors -> text editors -> show line numbers.
From: http://stackoverflow.com/questions/640884/eclipse-line-numbers
- (875)What to do when Eclipse crashes and shows nothing anymore?
Window -> Show View -> Project Explorer
- (877)How to apply correctly the XPath function 'substring-after'?
! XPath 2.0 only !
/*/*/substring-after(., 'getstringafterthat:')
- (878)How to get xpath consider the whole text() when applying a contains()?
<Home>
<Addr>
<Street>ABC</Street>
<Number>5</Number>
<Comment>BLAH BLAH BLAH <br/><br/>ABC</Comment>
</Addr>
</Home>
//*[contains(text(),'ABC')] => this will search ABC only in "BLAH BLAH BLAH "
//*[text()[contains(.,'ABC')]] => this will actually search ni the whole <comment> text
From: http://stackoverflow.com/questions/3655549/xpath-containstext-some-string-doesnt-work-when-used-with-node-with-more
- (918)How to get the Frontier from a running Heritrix Job?
In the "Scripting console", write the following Groovy script:
//Groovy
appCtx.getBean("frontier").dumpAllPendingToLog()
It will dump the Frontier to the crawl.log file.
From: https://webarchive.jira.com/wiki/display/Heritrix/Heritrix3+Useful+Scripts#Heritrix3UsefulScripts-getalistofseedsfromtheseedsfileondisk
- (928)How do a switch statement with Strings in Java - Before JDK7?
Prior to JDK 7, enum could approximate a String-based switch. This uses the static valueOf method generated by the compiler on every enum type. For example:
Pill p = Pill.valueOf(str);
switch(p) {
case RED: pop(); break;
case BLUE: push(); break;
}
From: http://stackoverflow.com/questions/338206/switch-statement-with-strings-in-java
- (929)How to create an ArrayList from an Array in Java?
use java.util.Arrays:
new ArrayList<Element>(Arrays.asList(array))
Also See Tip#1330
From: http://stackoverflow.com/questions/157944/how-to-create-arraylist-arraylistt-from-array-t-in-java
- (931)How to solve (fatal) Element type "X" must be followed by either attribute specifications, ">" or "/>" in Xerces/SAX xml parsing?
PROBLEM: a form feed is not a legal XML character.
SOLUTION: put everything concerning one tag on a single line!
From: http://www.xml.com/2000/05/10/conformance/reports/report-xerces-val.html
- (932)How to escape HTML/XML/CSV/etc. chars in java?
import static org.apache.commons.lang.StringEscapeUtils.*;
String source = "The less than sign (<) and ampersand (&) must be escaped before using them in HTML";
String escaped = escapeHtml(source);
From: http://stackoverflow.com/questions/5741311/how-to-encode-special-chars-in-html-content
- (936)How to convert an InputStream into a String in Java?
import org.apache.commons.io.IOUtils;
...
StringWriter swriter = new StringWriter();
String encoding = "UTF-8";
IOUtils.copy(is, swriter, encoding);
String content = swriter.toString();
From: http://stackoverflow.com/questions/309424/read-convert-an-inputstream-to-a-string
- (937)How to convert a String into an InputStream in Java?
// convert String into InputStream
InputStream is = new ByteArrayInputStream(str.getBytes());
??? new StringReader(string) ???
From: http://stackoverflow.com/questions/5618262/how-to-skip-well-formed-for-java-dom-parser
From: http://www.mkyong.com/java/how-to-convert-string-to-inputstream-in-java/
- (946)How to ignore namespaces in XPath?
You can use the local-name() XPath function. Instead of selecting a node like
/path/to/x:somenode
you can select all nodes and filter for the one with the correct local name:
/path/to/*[local-name() = 'somenode']
From: http://stackoverflow.com/questions/3931817/xpath-expression-from-xml-with-namespace-prefix
In XPath 2.0, you can simply do:
/path/to/*:somenode
From: http://stackoverflow.com/questions/4402310/how-to-ignore-namespace-when-selecting-xml-nodes-with-xpath
- (947)How to convert an org.w3c.dom.Node into a String?
StringWriter writer = new StringWriter();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(node), new StreamResult(writer));
String xml = writer.toString();
From: http://stackoverflow.com/questions/2223020/convert-an-org-w3c-dom-node-into-a-string
- (951)How to test an XPath expression in commandline?
cat myfile.xml | xmllint --xpath '//text()' /dev/stdin
Also see Tip#1863
- (1340)How to make a non-capturing group in a (Java) regex?
"((capturing2)|(?:non capturing)|(capturing3))" // capturing 1 is the englobing '()'
From: http://www.regular-expressions.info/brackets.html
- (981)How to (quickly) copy an array in Java?
System.arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
From: http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int,%20int%29
- (984)How to Runtime.exec() a command with arguments that contains spaces?
Use the Runtime.exec(String[]) call, in which each argument in its own element of the string array.
Indeed, Runtime.exec(String) appears to just split the input String on spaces, and that misses the point...
From: http://www.jguru.com/faq/view.jsp?EID=529035
- (986)How to manage filenames with spaces in Java?
use file.getPath() instead of file.getCanonicalPath()
- (987)How to do a (foreach) loop on multiple values in Java? [a.k.a how to iterate on an HashMap/Hashtable?]
HashMap<String, Integer> map = ...;
for(Map.Entry<String, Integer> entry: map.entrySet()) {
System.out.println(entry.getKey(), entry.getValue());
}
From: http://stackoverflow.com/questions/1066589/java-iterate-through-hashmap/1066607#1066607
- (993)What is the system-dependant/universal File separator?
File.separator
From: http://docs.oracle.com/javase/1.4.2/docs/api/java/io/File.html#separator
- (996)How to make copies of Strongly-Typed collections in OpenJDK 6/7?
Do not use:
ArrayList<String> newO = oldO.clone();
since it returns Objects.
Prefer
ArrayList<String> newO = new ArrayList<String>(oldO);
- (998)How to globally set the proxy for Java?
There's a file: $JAVA_HOME/lib/net.properties (e.g. /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/net.properties), where you can set the java.net.useSystemProxies to true in order for java to use the system-wide proxy definitions.
From: http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html
- (1382)How to get an InputStream from an URL String?
-- If you have a direct connection to the web
InputStream is = new URL("http://www.somewebsite.com/a.txt").openStream();
-- If you need to set the proxy
String uAgent = ""Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2"";
java.net.URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", uAgent);
InputStream is = conn.getInputStream();
From: http://stackoverflow.com/questions/6932369/inputstream-from-a-file-url#6932394
http://stackoverflow.com/questions/2529682/setting-user-agent-of-a-java-urlconnectio
- (1367)How to set Log4J's configuration file on the command line for execution of Java code?
You can set VM argument : -Dlog4j.configuration='path_to_log4j.xml'
From: http://stackoverflow.com/questions/12579468/how-to-set-log4j-property-file
- (1362)How to build a Path in Java 7?
import java.nio.file.Path;
import java.nio.file.Paths;
//...
Path source = Paths.get("c:/temp/0multipage.tif");
From: http://www.rgagnon.com/javadetails/java-0487.html
--
import java.nio.file.FileSystems;
import java.nio.file.Path;
Path path = FileSystems.getDefault().getPath("logs", "access.log");
From: http://docs.oracle.com/javase/7/docs/api/java/nio/file/Path.html
- (1343)How to get Mime type of a File/byte[] in Java?
1] Basic for images (no PDF, no ZIP, no DOCX, etc.), but works on byte[]
import java.io.ByteArrayInputStream;
import java.net.URLConnection;
import org.apache.commons.io.IOUtils;
// ...
String fname = "~/tmp/myfile";
File file = new File(fname);
// Guess based on the file name/extension
String mime1 = URLConnection.guessContentTypeFromName(fname);
// Guess based on the content
byte[] barray = IOUtils.toByteArray(new FileInputStream(file))
String mime2 = URLConnection.guessContentTypeFromStream(new ByteArrayInputStream(barray));
2] Less basic(??), but requires a File/Path
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
//...
Path source = Paths.get("c:/temp/0multipage.tif");
String mime = Files.probeContentType(source);
From: http://www.rgagnon.com/javadetails/java-0487.html (other ways listed here!)
- (1349)How to make a (Java) regex work on a multiline text?
"(?m)myregex" // multiline matching
"(?s)myregex" // '.' covers ANY character, even '\n'
From: http://www.regular-expressions.info/java.html
- (1350)How to make a (Java) regex case insensitive?
"(?i)myregex" // case insensitive matching
From: http://www.regular-expressions.info/java.html
- (1336)How to write a String to a File in Java/Groovy
import org.apache.commons.io.FileUtils;
String str = FileUtils.writeStringToFile(new File(argv[i]), mystring, "utf-8");
From: http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html
- (1337)How to convert an InputStream into a byte[]?
public static byte[] getBytes(InputStream is) throws IOException {
int len;
int size = 1024;
byte[] buf;
if (is instanceof ByteArrayInputStream) {
size = is.available();
buf = new byte[size];
len = is.read(buf, 0, size);
} else {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
buf = new byte[size];
while ((len = is.read(buf, 0, size)) != -1)
bos.write(buf, 0, len);
buf = bos.toByteArray();
}
return buf;
}
From: http://www.java2s.com/Code/Java/File-Input-Output/GetbytesfromInputStream.htm
- (1329)How to convert an Array of "Object elements" (Integer, Double, Boolean, etc.) into equivalent Array of primitive types (int, double, bool)?
import org.apache.commons.lang.ArrayUtils;
//...
Integer[] myarr = ...;
int[] res = ArrayUtils.toPrimitive(myarr);
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html
- (1330)How to convert an ArrayList of "Object elements" (Integer, Double, Boolean, etc.) into equivalent Array of primitive types (int, double, bool)?
import org.apache.commons.lang.ArrayUtils;
///...
ArrayList<Integer> myArr = ...;
Integer[] myarr = myArr.toArray(new Integer[0]/*for typing*/);
int[] res = ArrayUtils.toPrimitive(myarr);
Also See Tip#929
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html
- (1313)How to encode/decode Base64 in Java?
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.StringUtils;
public String decode(String s) {
return StringUtils.newStringUtf8(Base64.decodeBase64(s));
}
public String encode(String s) {
return Base64.encodeBase64String(StringUtils.getBytesUtf8(s));
}
NOTE: OK with commons-codecs-1.9, NOT OK with commons-codecs-1.3
From: http://stackoverflow.com/questions/469695/decode-base64-data-in-java
- (1309)How to get Mime type of a file in Java 7?
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Test {
public static void main(String[] args) throws IOException {
Path source = Paths.get(args[0]);
System.out.println(Files.probeContentType(source));
// output : image/tiff
}
}
From: http://www.rgagnon.com/javadetails/java-0487.html
- (1001)How to enable multiple reads from InputStream?
To create two readers that read independently from the same source, you'll have to make sure they don't consume data from the same stream.
This can be achieved by combining TeeInputStream from Apache Commons and a PipedInputStream and PipedOutputStream as follows:
import java.io.*;
import org.apache.commons.io.input.TeeInputStream;
class Test {
public static void main(String[] args) throws IOException {
// Create the source input stream.
InputStream is = new FileInputStream("filename.txt");
// Create a piped input stream for one of the readers.
PipedInputStream in = new PipedInputStream();
// Create a tee-splitter for the other reader.
TeeInputStream tee = new TeeInputStream(is, new PipedOutputStream(in));
// Create the two buffered readers.
BufferedReader br1 = new BufferedReader(new InputStreamReader(tee));
BufferedReader br2 = new BufferedReader(new InputStreamReader(in));
// Do some interleaved reads from them.
System.out.println("One line from br1:");
System.out.println(br1.readLine());
System.out.println();
System.out.println("Two lines from br2:");
System.out.println(br2.readLine());
System.out.println(br2.readLine());
System.out.println();
System.out.println("One line from br1:");
System.out.println(br1.readLine());
System.out.println();
}
}
From: http://stackoverflow.com/questions/5034311/multiple-readers-for-inputstream-in-java#comments-link-5035111
- (1002)How to use (Static) Initialization Blocks Java?
Initializing Fields
As you have seen, you can often provide an initial value for a field in its declaration:
public class BedAndBreakfast {
// initialize to 10
public static int capacity = 10;
// initialize to false
private boolean full = false;
}
This works well when the initialization value is available and the initialization can be put on one line. However, this form of initialization has limitations because of its simplicity. If initialization requires some logic (for example, error handling or a for loop to fill a complex array), simple assignment is inadequate. Instance variables can be initialized in constructors, where error handling or other logic can be used. To provide the same capability for class variables, the Java programming language includes static initialization blocks.
Note: It is not necessary to declare fields at the beginning of the class definition, although this is the most common practice. It is only necessary that they be declared and initialized before they are used.
Static Initialization Blocks
A static initialization block is a normal block of code enclosed in braces, { }, and preceded by the static keyword. Here is an example:
static {
// whatever code is needed for initialization goes here
}
A class can have any number of static initialization blocks, and they can appear anywhere in the class body. The runtime system guarantees that static initialization blocks are called in the order that they appear in the source code.
There is an alternative to static blocks — you can write a private static method:
class Whatever {
public static varType myVar = initializeClassVariable();
private static varType initializeClassVariable() {
// initialization code goes here
}
}
The advantage of private static methods is that they can be reused later if you need to reinitialize the class variable.
Initializing Instance Members
Normally, you would put code to initialize an instance variable in a constructor. There are two alternatives to using a constructor to initialize instance variables: initializer blocks and final methods.
Initializer blocks for instance variables look just like static initializer blocks, but without the static keyword:
{
// whatever code is needed for initialization goes here
}
The Java compiler copies initializer blocks into every constructor. Therefore, this approach can be used to share a block of code between multiple constructors.
A final method cannot be overridden in a subclass. This is discussed in the lesson on interfaces and inheritance. Here is an example of using a final method for initializing an instance variable:
class Whatever {
private varType myVar = initializeInstanceVariable();
protected final varType initializeInstanceVariable() {
// initialization code goes here
}
}
This is especially useful if subclasses might want to reuse the initialization method. The method is final because calling non-final methods during instance initialization can cause problems.
From: http://docs.oracle.com/javase/tutorial/java/javaOO/initial.html
- (1003)How to make java.util.logging print ALL messages?
Editing the handler level
1. Using the Configuration file
The java.util.logging properties file (by default, this is the logging.properties file in JRE_HOME/lib) can be modified to change the default level of the ConsoleHandler:
java.util.logging.ConsoleHandler.level = FINER
2. Creating handlers at runtime
This is not recommended, for it would result in overriding the global configuration. Using this throughout your code base will result in a possibly unmanageable logger configuration.
Handler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.FINER);
Logger.getAnonymousLogger().addHandler(consoleHandler);
From: http://stackoverflow.com/questions/6315699/why-are-my-level-fine-logging-messages-not-showing
- (1026)How to set the Look&Feel of Java?
$ cat /etc/java-7-openjdk/swing.properties
# uncomment to set the default look and feel to GTK
# swing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
# GM
swing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel
From: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- (1027)How to make Java GUIs (swing) behave correctly under AwesomeWM/i3?
1. Install suckless-tools
$ sudo apt-get install suckless-tools
2. Fake another WM
$ wmname LG3D
3. Run your software again
java -jar weka.jar
4. Enjoy :)
From: https://awesome.naquadah.org/wiki/Problems_with_Java
- (1035)How to match div by class/id in XPath?
Strangely, //div[@id=<name>] or //div[@class=<name>] often do not work (at least in my setup, where I parse HTML files using Tidy)
But it can be worked-around using:
//div[contains(concat(' ', @class, ' '),' <name> ')]
- (1039)How to work with symlinks in Java?
Be carefull myfile.isDirectory() and myfile.isFile() as they BOTH return false for symlinks!
See:
java.nio.file.Files::isSymbolicLink()
org.apache.commons.io.FileUtils
From: http://stackoverflow.com/questions/813710/java-1-6-determine-symbolic-links
- (1042)How to catch multiple exception at once in Java 7?
The following example, which is valid in Java SE 7 and later, eliminates the duplicated code:
catch (IOException|SQLException ex) {
logger.log(ex);
throw ex;
}
From: http://docs.oracle.com/javase/7/docs/technotes/guides/language/catch-multiple.html
- (1043)How to run Eclipse's code formatter in command-line?
eclipse \
-vm `which java` \
-application org.eclipse.jdt.core.JavaCodeFormatter \
-verbose \
-nosplash \
-config /home/guillaume/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs \
$*
For a slightly faster version, you can use -quiet instead of -verbose
From: http://blogs.operationaldynamics.com/andrew/software/java-gnome/eclipse-code-format-from-command-line
http://liviutudor.com/2012/03/02/batch-source-formatting-in-eclipse-indigo/
http://superuser.com/questions/325378/how-to-disable-eclipse-splash-screen
- (1044)How to convert an OutputStream into a String?
BufferedOutputStream bos = new BufferedOutputStream(...);
String encoding = "UTF-8";
String content = new String(bos.toByteArray(), encoding);
From: http://stackoverflow.com/questions/216894/get-an-outputstream-into-a-string
- (1045)How to detect the running OS in Java?
List of possible OS names: http://lopica.sourceforge.net/os.html
SOLUTION 1:
// Use the os.name proterty
if (System.getProperty("os.name").startsWith("Windows")) {
// includes: Windows 2000, Windows 95, Windows 98, Windows NT, Windows Vista, Windows XP
} else {
// everything else
}
SOLUTION 2:
// Use the separator char
if (File.separatorChar == '/') {
// UNIX-like (Linux/BSD/MacOS)
} else {
// Probably Windows
}
SOLUTION 3:
Use the org.apache.commons.lang.SystemUtils utility class from Commons Lang, it has a nice IS_OS_UNIX constant.
if (SystemUtils.IS_OS_UNIX) {
// UNIX-like (Linux/BSD/MacOS)
} else {
// Probably Windows
}
SOLUTION 4:
File.listRoots() will give you an array of the file system root directories. If you are on a Unix-like system, then the array should contain a single entry "/" and on Windows systems you'll get something like ["C:", "D:", ...]
if (Arrays.asList(File.listRoots()).contains("C:")) { // contains() exists?
// Windows
} else {
// Probably UNIX-like
}
From: http://stackoverflow.com/questions/3282498/how-can-i-detect-a-unix-like-os-in-java
- (1047)How to add readline-like capabilities to bsh?
java -cp /path/to/jline.jar:/path/to/bsh-x.x.x.jar jline.ConsoleRunner bsh.Interpreter
Voila! Beanshell with readline capabilities ;-)
From: http://code.google.com/p/beanshell2/issues/detail?id=52
Get jline: http://jline.sourceforge.net/index.html
- (1048)How to quote/protect special/control characters RegExp in Java?
You have to surround the special char with \Q & \E. For instance, use \Q[\E (instead of \[ in bash). Beware that you might have to double the '\' if you use it in a String.
Example:
import import java.util.regex.*;
...
Pattern datePattern = Pattern.compile("\\Q[\\E(19|20)[0-9]{2}\\Q]\\E");
Matcher dateMatcher = datePattern.matcher(query);
System.out.println(dateMatcher.matches());
From: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html
- (1252)How to list files with a certain extension in a given directory in Java 7?
Path dir = new File("/path/to/dir/").toPath(); // Is there a simpler way?
DirectoryStream<Path> stream = null;
try {
stream = Files.newDirectoryStream(dir, "*.ext");
} catch (java.io.IOException e) {
// Manage error...
}
for (Path entry: stream) {
// Manage each file
}
From: http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#newDirectoryStream%28java.nio.file.Path,%20java.lang.String%29
- (1253)How to redirect verbose garbage collection output to a file?
From the output of java -X:
-Xloggc:<filename> log GC status to a file with time stamps
From Sun's doc (http://java.sun.com/javase/6/docs/technotes/tools/windows/java.html):
"-Xloggc:<filename> Report on each garbage collection event, as with -verbose:gc, but log this data to file. In addition to the information -verbose:gc gives, each reported event will be preceeded by the time (in seconds) since the first garbage-collection event."
-XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamp
From: http://stackoverflow.com/questions/1161647/how-to-redirect-verbose-garbage-collection-output-to-a-file
- (1254)How to defeat java.lang.OutOfMemoryError: Java heap space?
- In most of the cases, the code is not optimized:
=> Release those objects which you think shall not be needed further.
=> Avoid creation of objects in your loop each time.
- You can increase the 'HeapSpace' using -Xmx option.
- Local variables are located on the stack. Heap space is occupied by objects.
- Basically heap space is used up everytime you allocate a new object with 'new' and freed some time after the object is no longer referenced. So make sure that you don't keep references to objects that you no longer need.
You can get your heap memory size through the following program:
public class GetHeapSize {
public static void main(String[] args) {
long curHeapSize = java.lang.Runtime.getRuntime().totalMemory();
long maxHeapSize = java.lang.Runtime.getRuntime().maxMemory();
System.out.println("heapsize is currently:"+curHeapSize+" with max of "+maxHeapSize);
}
}
From: http://stackoverflow.com/questions/1596009/java-lang-outofmemoryerror-java-heap-space
- (1256)How to list only files of a certain type from a directory in Java?
import org.apache.commons.io.filefilter.WildcardFileFilter;
// ...
File dir = new File(fileDir);
FileFilter fileFilter = new WildcardFileFilter("*.txt");
File[] files = dir.listFiles(fileFilter);
From: http://stackoverflow.com/questions/1384947/java-find-txt-files-in-specified-folder
- (1257)How to interpret Java verbose GC output?
Most of it is explained in the GC Tuning Guide (which you would do well to read anyway): http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html
The command line option -verbose:gc causes information about the heap and garbage collection to be printed at each collection. For example, here is output from a large server application:
[GC 325407K->83000K(776768K), 0.2300771 secs]
[GC 325816K->83372K(776768K), 0.2454258 secs]
[Full GC 267628K->83769K(776768K), 1.8479984 secs]
Here we see two minor collections followed by one major collection. The numbers before and after the arrow (e.g., 325407K->83000K from the first line) indicate the combined size of live objects before and after garbage collection, respectively. After minor collections the size includes some objects that are garbage (no longer alive) but that cannot be reclaimed. These objects are either contained in the tenured generation, or referenced from the tenured or permanent generations.
The next number in parentheses (e.g., (776768K) again from the first line) is the committed size of the heap: the amount of space usable for java objects without requesting more memory from the operating system. Note that this number does not include one of the survivor spaces, since only one can be used at any given time, and also does not include the permanent generation, which holds metadata used by the virtual machine.
The last item on the line (e.g., 0.2300771 secs) indicates the time taken to perform the collection; in this case approximately a quarter of a second.
The format for the major collection in the third line is similar.
The format of the output produced by -verbose:gc is subject to change in future releases.
---
- PSYoungGen refers to the garbage collector in use for the minor collection. PS stands for Parallel Scavenge.
- The first set of numbers are the before/after sizes of the young generation and the second set are for the entire heap. (Diagnosing a Garbage Collection problem details the format: http://reins.altervista.org/java/gc1.4.2_example.html)
- The name indicates the generation and collector in question, the second set are for the entire heap.
From: http://stackoverflow.com/questions/895444/java-garbage-collection-log-messages
- (1266)How to analyze a Java Heap space OpenJDK JVM crash?
Also, the 'jmap' tool, especially as 'jmap -histo JVM_PID', shows the
distribution of live objects, and so might suggest what's gone wrong by
what objects are overrepresented (compared to other runs where the crawl
progresses indefinitely). So if the JVM is still alive, please forward
the first ~30 lines of 'jmap -histo' output.
From: https://groups.yahoo.com/neo/groups/archive-crawler/conversations/messages/5595
- (1267)What are the [B [C [I in jmap's output meaning?
Character | Type | Interpretation
========================================
B | byte | signed byte
C | char | Unicode character code point in the Basic Multilingual Plane, encoded with UTF-16
D | double | double-precision floating-point value
F | float | single-precision floating-point value
I | int | integer
J | long | long integer
LClassName | reference | an instance of class ClassName
S | short | signed short
Z | boolean | true or false
[ | reference | one dimensional array
From: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2
- (1269)How to optimize GC in Java?
Run System.runFinalization() (== Runtime.getRuntime().runFinalization() ) before asking/forcing the JVM to do a GC.
From: http://stackoverflow.com/questions/11368650/java-xml-dom-memory-intensive
http://docs.oracle.com/javase/7/docs/api/java/lang/System.html#runFinalization%28%29
- (1280)How to solve error "No appenders" for log4j in java/Grails?
PROBLEM: java/grails logs show the following error:
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
SOLUTION:
add a log4j.properties file into your classpath
For instance, I copied /usr/local/grails-2.3.0/src/war/WEB-INF/log4j.properties in <grailsapplication>/src/java
If you already have a log4j.properties file, ensure that the rootLogger as a appenders assigned:
If you have:
log4j.rootLogger=WARN
Change it to:
log4j.rootLogger=WARN, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.conversionPattern=%5p [%t] (%F:%L) - %m%n
From: http://stackoverflow.com/questions/1266139/log4jwarn-no-appenders-could-be-found-for-logger-in-web-xml
- (1289)How to pause a java program?
Use Thread.sleep(<# ms>);
From: http://docs.oracle.com/javase/tutorial/essential/concurrency/sleep.html
- (1292)How to set the timeout of a connection in Java?
URL url = new URL(urlPath);
URLConnection con = url.openConnection();
con.setConnectTimeout(connectTimeout);
con.setReadTimeout(readTimeout);
InputStream in = con.getInputStream();
From: http://stackoverflow.com/questions/5351689/alternative-to-java-net-url-for-custom-timeout-setting
- (1210)How to set the expiration date when generating a Java keystore certificate?
keytool -genkey -alias <mydomain> -keyalg RSA -keystore <keystore.jks> -keysize 2048 -validity <nbdays from today>
From: http://www.sitepoint.com/forums/showthread.php?602621-keytool-selfcert-specifying-validity-more-than-365-days-how
- (1212)How to remove a certificate from a Java keystore?
keytool -delete -alias <alias: mydomain> -keystore file.keystore
From: http://stackoverflow.com/questions/16688873/how-to-delete-2-alias-entries-from-keystore
- (1217)How to lower/upper case a single char (non-object/primitive type) in Java?
char a = Character.toLowerCase('A')
char b = Character.toUpperCase('b')
Thanks FC
- (1204)What is Lucene's query syntax?
Search for phrase "foo bar" in the title field.
title:"foo bar"
Search for phrase "foo bar" in the title field AND the phrase "quick fox" in the body field.
title:"foo bar" AND body:"quick fox"
Search for either the phrase "foo bar" in the title field AND the phrase "quick fox" in the body field, or the word "fox" in the title field.
(title:"foo bar" AND body:"quick fox") OR title:fox
Search for word "foo" and not "bar" in the title field.
title:foo -title:bar
Search for any word that starts with "foo" in the title field.
title:foo*
Search for any word that starts with "foo" and ends with bar in the title field.
title:foo*bar
Note that Lucene doesn't support using a * symbol as the first character of a search.
Search for "foo bar" within 4 words from each other.
"foo bar"~4
Note that for proximity searches, exact matches are proximity zero, and word transpositions (bar foo) are proximity 1.
A query such as "foo bar"~10000000 is an interesting alternative to foo AND bar. Whilst both queries are effectively equivalent with respect to the documents that are returned, the proximity query assigns a higher score to documents for which the terms foo and bar are closer together.
Range Queries allow one to match documents whose field(s) values are between the lower and upper bound specified by the Range Query. Range Queries can be inclusive or exclusive of the upper and lower bounds. Sorting is done lexicographically.
mod_date:[20020101 TO 20030101]
Specify which terms/clauses are "more important" (boosting):
(title:foo OR title:bar)^1.5 (body:foo OR body:bar)
From: http://www.lucenetutorial.com/lucene-query-syntax.html
- (1203)How to compute the intersection of 2 Maps in Java?
Map map1 = ...;
Map map2 = ...;
Map result = new ...(map1);
result.keySet().retainAll(map2.keySet());
or:
Map map1 = ...;
Map map2 = ...;
Set result = new ...(map1.keySet());
result.retainAll(map2.keySet());
From: http://stackoverflow.com/questions/13180488/intersection-of-java-util-map-in-java
- (1202)How to sort a Map (by values) in Java?
/**
* Note that returning a LinkedHashMap is import, since with other
* types of Maps the ordering is not guaranteed.
*
* Be aware that this might not give you what is expected:
*
* Louis Wasserman (yes, one of the Google Guava guys), actually
* dislikes this answer quite a bit: "It breaks in several really
* confusing ways if you even look at it funny. If the backing map
* changes, it will break. If multiple keys map to the same value, it
* will break. If you call get on a key that isn't in the backing
* map, it will break. If you do anything whatsoever that would cause
* a lookup to happen on a key that isn't in the map -- a Map.equals
* call, containsKey, anything -- it will break with really weird
* stack traces."
* plus.google.com/102216152814616302326/posts/bEQLDK712MJ
*
* From: http://stackoverflow.com/questions/109383/how-to-sort-a-mapkey-value-on-the-values-in-java
*/
static Map sortByValue(Map map) {
List list = new LinkedList(map.entrySet());
Collections.sort(list, new Comparator() {
public int compare(Object o1, Object o2) {
return ((Comparable) ((Map.Entry) (o1)).getValue())
.compareTo(((Map.Entry) (o2)).getValue());
}
});
Map result = new LinkedHashMap();
for (Iterator it = list.iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry)it.next();
result.put(entry.getKey(), entry.getValue());
}
return result;
}
From: http://www.programmersheaven.com/download/49349/download.aspx
http://stackoverflow.com/questions/109383/how-to-sort-a-mapkey-value-on-the-values-in-java
- (1201)How to get class instance of generics type T?
QUESTION:
I have a generics class Foo<T>. In a method of Foo, i want to get the class instance of type T. But i just can't call T.class
Please tell me your preferred way to get around with the T.class ?
ANSWER:
The short answer is, that there is no way to find out the runtime type of generic type parameters in Java. I suggest reading the chapter about type erasure in the Java Tutorial for more details.
A popular solution to this is to pass the Class of the type parameter into the constructor of the generic type, e.g.
class Foo<T> {
final Class<T> typeParameterClass;
public Foo(Class<T> typeParameterClass) {
this.typeParameterClass = typeParameterClass;
}
public void bar() {
// you can access the typeParameterClass here and do whatever you like
}
}
From: http://stackoverflow.com/questions/3437897/how-to-get-class-instance-of-generics-type-t
- (1198)How to do a logical OR in an XPath?
Please help to use the logical OR operator in XPATH and select one request from these two:
1) .//span[@class=\'fob12\']
2) .//p[@class=\'fob12\']
They differ in tag only.
One more (with the OR as requested):
".//*[(self::p or self::span) and @class = 'fob12']"
From: http://stackoverflow.com/questions/6864399/xpath-logical-or
- (1190)How to merge 2 Lists in Java?
List<String, Integer> map1 = new ArrayList<String, Integer>();
List<String, Integer> map2 = new ArrayList<String, Integer>();
List<String, Integer> map3;
// code that fills map1 & map2
map3 = new ArrayList<String, Integer>();
map3.addAll(map1);
map3.addAll(map2);
From: http://docs.oracle.com/javase/7/docs/api/java/util/List.html#addAll%28java.util.Collection%29
- (1189)How to merge 2 Maps in Java?
Map<String, Integer> map1 = new HashMap<String, Integer>();
Map<String, Integer> map2 = new HashMap<String, Integer>();
Map<String, Integer> map3;
// code that fills map1 & map2
map3 = new HashMap<String, Integer>();
map3.putAll(map1);
map3.putAll(map2);
From: http://stackoverflow.com/questions/4299728/how-can-i-combine-two-hashmap-objects-of-same-type-in-java
- (1184)How to copy files with wildcards in a process from Java/Groovy?
You must call the version of exec() that takes a String[] as argument and pass the whole command you want to execute as a single argument of sh, so that it gets extended.
The generic line is:
Runtime.exec(new String[] { "sh", "-c", <your command> });
e.g.:
Runtime.exec(new String[] { "sh", "-c", "rm /tmp/ABC*" }); // Java
Runtime.exec([ "sh", "-c", "rm /tmp/ABC*" ] as String[]); // Groovy
From: http://stackoverflow.com/questions/2111983/java-runtime-getruntime-exec-wildcards
- (1180)How to "force" a Garbage Collection in Java?
System.gc()
NOTE: this will no force a GC, but tell the system that it can do one if the GC algorithm allows it now.
From: http://www.java-tips.org/java-se-tips/java.lang/how-can-i-force-garbage-collection-to-take-place.html
- (1052)A very inefficient, but useable implementation of SortedArrayList<E> in Java
package fr.presans.commons.util.collections;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class SortedArrayList<T extends Comparable<? super T>> extends ArrayList<T> {
/**
* Overrides the normal "add" method of ArrayList with one that
* keeps the list ordered.
*/
public boolean add(T elt) {
super.add(elt);
Collections.sort((List<T>) this);
return true;
}
}
From: GM
Another solution:
class SortedArrayList<T> extends ArrayList<T> {
@SuppressWarnings("unchecked")
public void insertSorted(T value) {
add(value);
Comparable<T> cmp = (Comparable<T>) value;
for (int i = size()-1; i > 0 && cmp.compareTo(get(i-1)) < 0; i--)
Collections.swap(this, i, i-1);
}
}
From: http://stackoverflow.com/questions/4031572/sorted-array-list-in-java
- (1053)How to access Superclass Members from methods of the Subclass?
If your method overrides one of its superclass's methods, you can invoke the overridden method through the use of the keyword super. You can also use super to refer to a hidden field (although hiding fields is discouraged). Consider this class, Superclass:
public class Superclass {
public void printMethod() {
System.out.println("Printed in Superclass.");
}
}
Here is a subclass, called Subclass, that overrides printMethod():
public class Subclass extends Superclass {
// overrides printMethod in Superclass
public void printMethod() {
super.printMethod();
System.out.println("Printed in Subclass");
}
public static void main(String[] args) {
Subclass s = new Subclass();
s.printMethod();
}
}
Within Subclass, the simple name printMethod() refers to the one declared in Subclass, which overrides the one in Superclass. So, to refer to printMethod() inherited from Superclass, Subclass must use a qualified name, using super as shown. Compiling and executing Subclass prints the following:
Printed in Superclass.
Printed in Subclass
From: http://docs.oracle.com/javase/tutorial/java/IandI/super.html
- (1155)How to get a date in a simple format in Java (like with the command "date" in linux)?
import java.text.DateFormat;
import java.text.SimpleDateFormat;
//...
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
String date = dateFormatter.format(new Date()); // today
Also see Tip#1864
From: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
http://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html
- (1147)How to initialize an [Array]List with a list of predefined values?
import java.util.Arrays;
/* You can do it directly (Java 8 only?)*/
List<String> places = Arrays.asList("Buenos Aires", "Córdoba", "La Plata");
/* Or you can combine initialization of a basic array with transformation of a basic array into an [Array]List */
List<String> myList = new ArrayList<String>(Arrays.asList(new String[] {"val1","val2", "val3"}));
Also see Tip#929
From: http://stackoverflow.com/questions/1005073/initialization-of-an-arraylist-in-one-line#1005089
- (1148)How to increment the Integer values stored in a Map?
You cannot increments Integers, they are immutable...
This DOES NOT work:
Map myMap = new Map<String, Integer>();
for (String word: map.keySet()) {
myMap.get(word)++; // DOES NOT WORK!!!
}
You MUST do like that:
Map myMap = new Map<String, Integer>();
for (String word: map.keySet()) {
myMap.put(word, myMap.get(word)+1);
}
---
You can also use MutableInt from Apache-commons
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/mutable/MutableInt.html
- (1153)How to create/manage a java array with more than 4G elements?
Java array indices are of type 'int' (4 bytes or 32 bits), so I'm afraid you're limited to 2^31-1 or 2147483647 slots in your array. I'd read the data into another data structure, like a 2D array.
--
If necessary, you can load the data into an array of arrays, which will give you a maximum of int.maxValue squared bytes, more than even the beefiest machine would hold well in memory.
From: http://stackoverflow.com/questions/878309/java-array-with-more-than-4gb-elements
- (1124)How to fine tune the GC with some JVMs switches?
-Xms32m - this setting tells the Java virtual machine to set its initial heap size to 32 megabytes. By telling the JVM how much memory it should initially allocate for the heap, we save it growing the heap as NetBeans consumes more memory. This switch improves startup time. It is used by default in NetBeans, so you do not need to specify it.
-Xmx256m - this settings tells the Java virtual machine the maximum amount of memory it should use for the heap. Placing a hard upper limit on this number means that the Java process cannot consume more memory than physical RAM available. This limit can be raised on systems with more memory. Current default value is 128MB. Note: Do not set this value to near or greater than the amount of physical RAM in your system or it will cause severe swapping during runtime.
-XX:+UseConcMarkSweepGC or -J-XX:+UseParNewGC - try these switches if you are having problems with intrusive garbage collection pauses. This switch causes the JVM to use different algorithms for major garbage collection events (also for minor collections, if run on a multiprocessor workstation), ones which do no.t "stop the world" for the entire garbage collection process. You should also add the line -XX:+CMSClassUnloadingEnabled and -XX:+CMSPermGenSweepingEnabled to your netbeans.conf file so that class unloading is enabled (it isn't by default when using this collector).
-XX:+UseAdaptiveSizePolicy - this switch may help improve garbage collector throughput and memory footprint. It is part of garbage collector ergonomics implemented in JDK5.0.
-XX:+UseParallelGC - some tests have shown that, at least on systems fairly well equipped with memory, the durations of minor garbage collections is halved when using this collection algorithm, on uniprocessor systems. Note that this is paradoxical - this collector is designed to work best on multiprocessor systems with gigabyte heaps. No data is available on its effect on major garbage collections. Note: this collector is mutually exclusive with -XX:+UseConcMarkSweepGC. The measurements supporting the use of this algorithm can be found on the performance website.
-XX:+PrintGCDetails - this is similar switches (like -verbose:gc) do not improve performance but provide diagnostic data showing information about memory management that are useful source of input for performance tuning. Another way how to obtain these data is to use monitoring tools or (NetBeans) profiler.
-XX:CompileThreshold=100 - this switch will make startup time slower, by HotSpot to compile many more methods down to native code sooner than it otherwise would. The reported result is snappier performance once the IDE is running, since more of the UI code will be compiled rather than interpreted. This value represents the number of times a method must be called before it will be compiled.
-Djava.net.preferIPv4Stack=true - this switch will suppress use of IPv6 stack in networking code and it can avoid small delay during startup when inet address is being resolved. It will be usefull only on a system where IPv6 is installed but not actually configured. Note: there can be another problems related to IPv6 - see for example discussion on interaction between fwbuilder and Java apps
From: https://performance.netbeans.org/howto/jvmswitches/index.html
On server-class machines running the server VM, the garbage collector (GC) has changed from the previous serial collector (-XX:+UseSerialGC) to a parallel collector (-XX:+UseParallelGC). You can override this default by using the -XX:+UseSerialGC command-line option to the java command.
The parallel garbage collector (UseParallelGC) throws an out-of-memory exception if an excessive amount of time is being spent collecting a small amount of the heap. To avoid this exception, you can increase the size of the heap. You can also set the parameters -XX:GCTimeLimit=time-limit and -XX:GCHeapFreeLimit=space-limit where:
time-limit:
The upper limit on the amount of time spent in garbage collection in percent of total time (default is 98).
space-limit:
The lower limit on the amount of space freed during a garbage collection in percent of the maximum heap (default is 2).
-XX:+UseAdaptiveSizePolicy used by default with the -XX:+UseParallelGC
-XX:MaxGCPauseMillis=nnn
A hint to the virtual machine that pause times of nnn milliseconds or less are desired. The VM will adjust the java heap size and other GC-related parameters in an attempt to keep GC-induced pauses shorter than nnn milliseconds. Note that this may cause the VM to reduce overall throughput, and in some cases the VM will not be able to meet the desired pause time goal.
By default there is no pause time goal. There are definite limitations on how well a pause time goal can be met. The pause time for a GC depends on the amount of live data in the heap. The minor and major collections depend in different ways on the amount of live data. This parameter should be used with caution. A value that is too small will cause the system to spend an excessive amount of time doing garbage collection.
-XX:GCTimeRatio=nnn
A hint to the virtual machine that it's desirable that not more than 1 / (1 + nnn) of the application execution time be spent in the collector.
For example -XX:GCTimeRatio=19 sets a goal of 5% of the total time for GC and throughput goal of 95%. That is, the application should get 19 times as much time as the collector.
By default the value is 99, meaning the application should get at least 99 times as much time as the collector. That is, the collector should run for not more than 1% of the total time. This was selected as a good choice for server applications. A value that is too high will cause the size of the heap to grow to its maximum.
Suggested strategy
Do not choose a maximum value for the heap unless you know that the heap is greater than the default maximum heap size. Choose a throughput goal that is sufficient for your application.
In an ideal situation the heap will grow to a value (less than the maximum) that will support the chosen throughput goal.
If the heap grows to its maximum, the throughput cannot be met within that maximum. Set the maximum heap as large as you can, but no larger than the size of physical memory on the platform, and execute the application again. If the throughput goal can still not be met, then it is too high for the available memory on the platform.
If the throughput goal can be met but there are pauses that are too long, select a pause time goal. This will likely mean that your throughput goal will not be met, so choose values that are an acceptable compromise for the application.
From: http://docs.oracle.com/javase/1.5.0/docs/guide/vm/gc-ergonomics.html
- (1127)How to define default options for java?
If you want to define default options to java as can be done in Grails, the trick is to add the following lines to ~/.bashrc:
export JAVA_OPTS="-Xmx2G -server -XX:MaxPermSize=128M"
alias java='java $JAVA_OPTS'
From: http://stackoverflow.com/questions/2011311/running-java-with-java-opts-env-variable
- (1128)What is the difference between a Set and a List in Java/Groovy?
- Set has no repetition and is not ordered (i.e. storing the result of a sort in a Set is useless)
- List can contain multiple instance of the same element and is ordered
From: http://docs.oracle.com/javase/6/docs/api/java/util/List.html
http://docs.oracle.com/javase/6/docs/api/java/util/Set.html (not so clear on the lack of order...)
- (1107)Difference between HashMap and HashTable in Java?
- HashTable is a legacy class that came along with the first version of java development kit (JDK), while HashMap was introduced in java version 1.2, as part of java collections framework.
- HashTable is synchronized (Thread safe), but HashMap not synchronized. All the new implementations of java collection framework is not synchronized.
- As HashTable is synchronized (Thread safe), so in general, executing a "synchronized" method results in costly performance than a unsynchronized method. So HashTable is relatively slower in performance than HashMap. If thread safety in not concerned, HashMap always perform better than HashTable.
- HashMap can be synchronized using the java collections framework utility class. Or you can use ConcurrentHashMap in case of multi-threaded environment.
- HashTable doesn't allow Null key however HashMap allows Null key and values.
From: http://naeemgik.blogspot.fr/2013/11/difference-between-hashmap-and.html
See also: http://volodial.blogspot.fr/2013/07/internal-life-of-hashmap-in-java.html
- (1090)How to create a temp File in Java?
import java.nio.file.Files;
Path p = Files.createTempFile(<prefix>, <suffix>/*can be null*/, <FileAttributes>/*can be null*/);
File f = p.toFile();
From: http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#createTempFile(java.lang.String, java.lang.String, java.nio.file.attribute.FileAttribute...)
- (1072)How to solve "No editor descriptor for id org.eclipse.ui.internal.emptyEditorTab" in Eclipse 4?
Closing eclipse and removing
.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi solved it!
From: https://bugs.eclipse.org/bugs/show_bug.cgi?id=386648
- (1060)How to authenticate a running heritrix with external Java code (Sofia)?
Sofia contacts heritrix to send crawl jobs. This part is only useful for the crawl admin section.
Heritrix is using https only, and for heritrix to be reachable, we have to authorize heritrix ssl certificate. (ask heritrix devs why).
In the following, the executable keytool may not be reachable straightforward. For instance, on verspertine, it's /usr/java/jdk1.7.0_10/bin/keytool
Generate a self-signed certificate in the form of a JKS file
On the machine using heritrix :
keytool -genkey -alias <mydomain> -keyalg RSA -keystore <keystore.jks> -keysize 2048
where <mydomain> is the domain name of the heritrix machine, e.g. xtec.polytechnique.fr
Provide a password for the keystore file, say tototo
AND GIVE <mydomain> (e.g., xtec.polytechnique.fr) WHEN ASKED FOR YOUR FIRSTNAME/LASTNAME
This generates file <keystore.jks>
Give it to heritrix
In the heritrix launch command line :
heritrix -s <keystore.jks>,<kstorepass>,<keypass> -a <user:pass>
where <kstorepass> and <keypass> are the password you chose at last step. (tototo)
Get the certificate public key as a PEM file
Go to the heritrix web interface using chromium. Click on the little padlock at the left of the url. Go to certificate information > Details > Export, and save it in the Base64 single certificate format (that's the PEM file).
Alternative way, if you don't like the chromium
On the heritrix machine,
keytool -importkeystore -srckeystore <keystore.jsk> -destkeystore heritrix.p12 -srcstoretype jks -deststoretype pkcs12
openssl pkcs12 -in heritrix.p12 -out heritrix.bag
You'll be asked for passwords, and to provide new passwords for new files. You may want to make it easy by using always the same like 'tototo'.
Then open heritrix.bag, take the text between -----BEGIN CERTIFICATE----- and -----END CERTIFICATE----- (included), and put it in heritrix.pem. That's the PEM file.
Give it to Sofia
On the machine running Sofia,
keytool -importcert -alias <mydomain> -file <pemfile> -keystore /etc/ssl/certs/java/cacerts
When asked for the password of cacerts, type 'changeit'.
Where <pemfile> is the file you exported from chromium.
- (1056)How to convert an UTF-8/ISO-8859-1 String into an ASCII String in Java/Groovy (a.k.a getting rid of accents and converting them to regular letters)?
import java.text.Normalizer;
String convertedString =
Normalizer
.normalize(input, Normalizer.Form.NFD)
.replaceAll("[^\\p{ASCII}]", ""); // also removes russian/chinese/... (non-ASCII) chars
You can also use:
"\\p{InCombiningDiacriticalMarks} // removes only accentuated chars
From: http://stackoverflow.com/questions/3707977/converting-java-string-to-ascii
---
import net.sf.junidecode.Junidecode;
...
return Junidecode.unidecode(in);
Returns the transliterated string (i.e. from
Cyrillic/Chinese/... characters to ASCII-7 characters). Diatrics are
removed. No need to replace accents after that.
- (1410)How to know your current Heap/Stack/Thread Stack Size?
java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
From: http://www.mkyong.com/java/find-out-your-java-heap-memory-size/
- (1412)How to compute size of Array/ArrayList/String Objects in Java?
- ArrayList<String> arraylist
arraylist.size();
- String[] array;
array.length;
- String string;
string.length();
- (1413)How to debug a Java program in CLI (Old-School)?
First you start the remote program you want to debug on myserver.com with something like:
java -agentlib:jdwp=transport=dt_socket,server=y,address=8787 myClass
Then on your local machine, run:
jdb -connect com.sun.jdi.SocketAttach:hostname=myserver.com,port=8787
Here's a quick cheat-sheet to get you started with the obvious stuff:
stop in pkg.class.method[args] # Set breakpoint on method entry
stop at pkg.class:line_nb # Set breakpoint at line
clear # List (no args) or clear (with args) breakpoints
use /path/to/srccode # Set source code path
list # Show source code lines
next # Steps OVER method calls
step # Steps INTO method calls
step up # Run until current method returns
cont # Continue exection after breakpoint
locals # List local variables
print somevar # Show current value of somevar
classpath # Print JVM's classpath
disablegc (expr) # Prevent garbage collection of an object
classes # List all currently loaded classes
class org.package.class # Show details of named class
methods com.this.class # List a class's methods
fields com.that.class # List a class's fields
eval (java expression) # Run arbitrary java code, alter program state at will
redefine path.to.newcode.class # Load new .class file to redefine an existing class
From: http://mackys.livejournal.com/983296.html
- (1421)How to get the JVM CLI arguments in Java?
Some of it is available from the RuntimeMXBean, obtained by calling ManagementFactory.getRuntimeMXBean()
You can then, for example call getInputArguments()
The javadocs for which say:
Returns the input arguments passed to the Java virtual machine which does not include the arguments to the main method. This method returns an empty list if there is no input argument to the Java virtual machine.
Some Java virtual machine implementations may take input arguments from multiple different sources: for examples, arguments passed from the application that launches the Java virtual machine such as the 'java' command, environment variables, configuration files, etc.
Typically, not all command-line options to the 'java' command are passed to the Java virtual machine. Thus, the returned input arguments may not include all command-line options.
From: http://stackoverflow.com/questions/2541627/how-do-i-get-the-commandline-that-started-the-process
- (1438)How to get performance information/tuning in Java?
opensource tools are noted by *
- NetBeans Profiler
- JProfiler
- GC Viewer
- VisualVM *
- Java Performance Analysis Tool (Patty) *Beta
- JRockit - Mission Control
- Eclipse Memory Analyzer
- Java Interactive Profiler
- Profiler4J
- JVM Monitor *
- JMap * (see also tips #1266 & #1257)
- BTrace *
- EurekaJ *
From: https://blog.idrsolutions.com/2014/06/java-performance-tuning-tools/
https://code.google.com/a/eclipselabs.org/p/jvmmonitor/
http://www.infoq.com/articles/java-profiling-with-open-source/
http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jmap.html
https://kenai.com/projects/btrace
http://eurekaj.haagen.name/documentation/btrace_script_concepts_1.2.html
- (1449)How to convert from Any language to ASCII with ICU in Java?
The converter "Any-ASCII" dooes not exist. You must combine converters and use: "Any-Latin; Latin-ASCII".
From the online docs:
"Converts non-ASCII-range punctuation, symbols, and Latin letters in an approximate ASCII-range equivalent. For example: « -> '<<', © -> '(C)', Æ -> AE. Can be combined with Any-Latin to produce a transform that will convert as much as possible to an ASCII-range representation: “Any-Latin; Latin-ASCII”."
From: http://userguide.icu-project.org/transforms/general
- (1483)How to format an integer in Java (a.k.a. How to print ints with a predifined number of digits)?
// %0 = pad with 0s, 3 = use 3 digits
String.format("%03d", 1); // => "001"
From: http://stackoverflow.com/questions/6034523/format-an-integer-using-java-string-format
- (1494)How to easily pretty print a Map in Java?
import java.lang.Arrays;
Arrays.toString(map.entrySet().toArray());
From: http://stackoverflow.com/questions/10120273/pretty-print-a-map-in-java
- (1500)How to generate a random char (in a given alphabet) in Java?
NOTE: is it seems java.lang.Math.Random has been moved to java.util.Random?
--- To generate a random char in a-z:
private String randomCharAZ() {
return((char)(Math.Random.nextInt(26) + 'a'));
}
--- To generate in an alphabet:
private String randomChar(String alphabet) {
return(alphabet.charAt(Math.Random.nextInt(alphabet.length())));
}
From: http://stackoverflow.com/questions/2626835/is-there-functionality-to-generate-a-random-character-in-java
- (1509)How to run a method every x (milli-)seconds in Java?
class SayHello extends TimerTask {
public void run() {
System.out.println("Hello World!");
}
}
// And From your main() method or any other method
Timer timer = new Timer();
timer.schedule(new SayHello(), 0, 5000);
See also:
1) other methods
void schedule(TimerTask task, Date time)
void schedule(TimerTask task, Date firstTime, long period)
void schedule(TimerTask task, long delay)
void schedule(TimerTask task, long delay, long period)
void scheduleAtFixedRate(TimerTask task, Date firstTime, long period)
void scheduleAtFixedRate(TimerTask task, long delay, long period)
2) other class
ExecutorService
From: http://stackoverflow.com/questions/12908412/print-hello-world-every-x-seconds
- (1519)How to convert a Set to a List in Java?
Set set = ...;
List list = new ArrayList().addAll(set);
From: http://stackoverflow.com/questions/8892360/convert-set-to-list-without-creating-new-list
- (1526)How to concatenate XPath results?
concat(string(/path/to/elmt1),
string(/path/to/elmt2))
From: http://www.coderanch.com/t/125982/XML/Concatenate-xpath-results
- (1532)How to lowercase a text in XPath?
translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')
From: http://stackoverflow.com/questions/13801669/xpath-translate-to-lower-case-not-working
- (1537)How to get elements that contains at least one non-empty child?
Accurate, simple and efficient:
/path/to/target/*[text()]
If you want to exclude any element that has only whitespace-only text children, use:
/path/to/target/*[normalize-space()]
From: http://stackoverflow.com/questions/13703478/xsl-xpath-expression-to-check-if-a-node-contains-at-least-one-non-empty-child
- (1538)How to combine multiple XPath?
Simply use: "xpath1 | xpath2"
From: http://stackoverflow.com/questions/10402613/how-do-i-combine-these-xpath-expressions
- (1549)How to do a case insensitive xpath contains() in XPath?
/html/body//text()[
contains(
translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),
'test'
)
]
From: http://stackoverflow.com/questions/8474031/case-insensitive-xpath-contains-possible
- (1563)How to convert a String into its hexadecimal representation in Java?
public String toHex(String arg) {
return String.format("%x", new BigInteger(1, arg.getBytes(/*charset*/)));
}
From: http://stackoverflow.com/questions/923863/converting-a-string-to-hexadecimal-in-java
- (2142)How to create a crawler with Norconex Http-collector
* The config file is composed of several parts (default values inside parenthesis)
** Full documentation
https://www.norconex.com/collectors/collector-http/configuration
** Basic collector config
*** You can always use =#parse("<file>")= to include external xml config
https://github.com/Norconex/collector-http/issues/98
*** You can use the XML parameter <tag xml:space="preserve"></tag> to indicate not trim spaces (useful for regexes)
#+BEGIN_SRC nxml
<numThreads>2</numThreads>
<sitemapResolverFactory ignore="true"/>
<robotsTxt ignore="true"/>
<keepDownloads>false</keepDownloads>
<maxDepth>-1</maxDepth> (based on explicitely procided startURLs => if an Extractor used, might require to set a large nb)
<delay default="5000"/>
<userAgent>...</userAgent>
#+END_SRC
** HTTP connection config (how to request the webpages)
#+BEGIN_SRC nxml
<httpClientFactory>
<maxConnections>10</maxConnection>
<connectionTimeout>???(ms)<connectionTimeout>
<socketTimeout>???(ms)</socketTimeout>
<maxConnectionIdleTime>???(ms)</maxConnectionIdleTime>
<maxConnectionInactiveTime>???(ms)</maxConnectionInactiveTime>
</httpClientFactory>
#+END_SRC
** Fetcher (how to download the webpages)
#+BEGIN_SRC nxml
<fetcher class="com.norconex.collector.http.fetch.impl.GenericDocumentFetcher">
...
</fetcher>
#+END_SRC
*** Overloading of =createUriRequest()= required to send requests as POST instead GET
*** Overloading of =fetchDocument()= required get/add an OAuth AccessToken (see EPOOAuthFetcher)
*** See https://www.norconex.com/how-to-crawl-facebook/ for an (old) example
** Select seeds (starting pages)
#+BEGIN_SRC nxml
<startURLs stayOnDomain="true" stayOnPort="true" stayOnProtocol="true">
<url>...</url>
<!-- <urlsFile>...</urlsFile> -->
</startURLs>
#+END_SRC
** ReferenceFilter (how to determine webpages to be treated/skipped)
#+BEGIN_SRC nxml
<referenceFilters>
<filter class="com.norconex.collector.core.filter.impl.RegexReferenceFilter" onMatch="include">
...
</filter>
</referenceFilters>
#+END_SRC
** Extractor (how to extract links to other webpages to be crawled from the content of fetched webpages)
#+BEGIN_SRC nxml
<extractor class="...">
...
</extractor>
#+END_SRC
**** Overloading of =accepts()= to extract only on certain webpages
** How to normalize/modify on the fly the to-be-crawled urls (e.g. replacing "&type=summary" with "&type=full")?
#+BEGIN_SRC nxml
<urlNormalizer class="com.norconex.collector.http.url.impl.GenericURLNormalizer">
<normalizations>
removeFragment, lowerCaseSchemeHost, upperCaseEscapeSequence,
decodeUnreservedCharacters, removeDefaultPort,
encodeNonURICharacters, addWWW
</normalizations>
<replacements>
<replace>
<match>(&type=)(summary)</match>
<replacement>$1full</replacement>
</replace>
</replacements>
</urlNormalizer>
#+END_SRC
From: https://github.com/Norconex/collector-http/issues/361#issuecomment-334045648
https://www.norconex.com/collectors/collector-http/latest/apidocs/com/norconex/collector/http/url/impl/GenericURLNormalizer.html
** Importer (what to extract from the webpages content)
*** Filter (various pages might be treated differently => select those to treat as follows)
#+BEGIN_SRC nxml
<filter class="com.norconex.importer.handler.filter.impl.RegexMetadataFilter"
field="document.reference"
onMatch="include">
https?://www\.myregex\.com/.*
</filter>
#+END_SRC
*** Splitter (=splits the page )
**** TIP =overwrite= *must* be set to =true= for all the values that are *shared* amongst the splits (e.g. constants TYPE=PUBLICATION/NAME_ORIENTATION/..., Copy CURRENT_URL, etc.) to prevent multiple instances from being generated
*** Tagger (=an extractor)
**** Extracted data is stored in the metadata fields of the webpage
#+BEGIN_SRC nxml
<tagger class="com.norconex.importer.handler.tagger.impl.ConstantTagger">... (adds a constant field)
<tagger class="com.norconex.importer.handler.tagger.impl.CopyTagger">... (copies a field to another)
<tagger class="com.norconex.importer.handler.tagger.impl.ReplaceTagger" regex="true" replaceAll="true">... (replaces all occurrences of a field's value by another, possibly using a regex)
<tagger class="com.norconex.importer.handler.tagger.impl.TextPatternTagger">... (extracts all text values that match the regex)
<tagger class="com.norconex.importer.handler.tagger.impl.DOMTagger" fromField="..." defaultValue="..." parser="xml">... (uses a CSS selector to extract elements, parser option prevents JSoup from cleaning the HTML, particularly important if working on Splitted rows of a table - that would be cleaned if <table> if not kept - introduced in 2.8.0)
<dom selector="<CSS selector>" toField="..."
overwrite="true"
extract="ownText"/>
<tagger class="com.norconex.importer.handler.tagger.impl.KeepOnlyTagger">... (keep only listed metadata elements)
#+END_SRC
**** DOMTagger can "extract":
***** text: Default option when extract is blank. The text of the element, including combined children.
***** html: Extracts an element inner HTML (including children).
***** outerHtml: Extracts an element outer HTML (like "html", but includes the "current" tag).
***** ownText: Extracts the text owned by this element only; does not get the combined text of all children.
***** data: Extracts the combined data of a data-element (e.g. <script>).
***** id: Extracts the ID attribute of the element (if any).
***** tagName: Extract the name of the tag of the element.
***** val: Extracts the value of a form element (input, textarea, etc).
***** className: Extracts the literal value of the element's "class" attribute, which may include multiple class names, space separated.
***** cssSelector: Extracts a CSS selector that will uniquely select (identify) this element.
***** attr(attributeKey): Extracts the value of the element attribute matching your replacement for "attributeKey" (e.g. "attr(title)" will extract the "title" attribute).
**** New Options
***** TIP =matchBlanks= can be set to =true= to make DOMTagger extract elements with blank values. You will always get an empty string in cases where you have spaces only (but *at least you'll have a match returned* as opposed to none). The handling of the =defaultValue= attribute has been modified to support empty strings and spaces (but =null= is still used when no default values are specified).
***** TIP we *must* set a defaultValue for *each* field of the authors' attributes to ensure same number of values are generated, thus they'll not be dropped later
***** TIP it's generally a good idea to extract each XML/HTML element separately in multiple tags (e.g. EXP_XXX-AUX), then Merge/SingleValue them later. This ensures we have the same number of values for each attributes of authors, thus they'll not be dropped later.
** Committer (Where to send the extracted (meta-)data)
*** A MultiCommitter is almost always necessary, at least to add a FileSystemCommitter for debugging purposes
#+BEGIN_SRC nXML
<committer class="com.norconex.committer.core.impl.MultiCommitter"> (allows multiple outputs)
<committer class="com.norconex.committer.core.impl.FileSystemCommitter>...
<committer class="com.norconex.committer.core.impl.FoafCommitter>...
#+END_SRC
* If you need to overload Norconex's code
*** Implementation Extractor
#+BEGIN_SRC java
public class XXXLinkExtractor implements ILinkExtractor, InxmlConfigurable {
public Set<Link> extractLinks(InputStream content, String reference, ContentType contentType) throws IOException {...}
public boolean accepts(String reference, ContentType contentType) {...}
}
#+END_SRC
*** Fetcher
#+BEGIN_SRC java
public class XXXFetcher extends GenericDocumentFetcher {
public HttpFetchResponse fetchDocument(HttpClient httpClient, HttpDocument doc) {...}
protected HttpRequestBase createUriRequest(HttpDocument doc) {...}
}
#+END_SRC
*** Tagger
#+BEGIN_SRC java
public class XXXTagger implements IDocumentTagger, InxmlConfigurable {
public void tagDocument(String reference, InputStream document, ImporterMetadata metadata, boolean parsed) {...}
}
#+END_SRC
*** Committer
#+BEGIN_SRC java
public class XXXCommitter implements ICommitter, InxmlConfigurable {
public void add(String reference, InputStream content, com.norconex.commons.lang.map.Properties metadata) {...}
public void commit() {...}
public void remove(String reference, com.norconex.commons.lang.map.Properties metadata) {...}
}
#+END_SRC
*** IXMLConfigurable (to allow parameterization of any element from the crawlers' XML configuration file)
#+BEGIN_SRC java
@Override
public void loadFromXML(Reader in) {
XMLConfiguration xml = ConfigurationUtil.new XMLConfiguration(in);
this.setParamX(xml.getString("paramX"));
this.setParamY(xml.getString("paramY"));
//...
}
@Override
public void saveToXML(Writer out) throws IOException {
XMLOutputFactory factory = XMLOutputFactory.newInstance();
try {
XMLStreamWriter writer = factory.createXMLStreamWriter(out);
writer.writeStartElement("<entity>"); // entity = extractor, fetcher...
writer.writeAttribute("class", getClass().getCanonicalName());
writer.writeStartElement("paramX");
writer.writeCharacters(this.getParamX());
writer.writeEndElement();
writer.writeStartElement("paramY");
writer.writeCharacters(this.getParamY());
writer.writeEndElement();
writer.writeEndElement(); // entity
writer.flush();
writer.close();
} catch (XMLStreamException e) {
throw new IOException("Cannot save as nxml.", e);
}
}
#+END_SRC
From: https://www.norconex.com/collectors/collector-http/configuration
https://github.com/Norconex/importer/issues/56
https://github.com/Norconex/importer/issues/57
- (1571)How to find the position of a node in XPath 1.0?
count(/path/to/target/node/preceding-sibling::*)+1
From: http://stackoverflow.com/questions/226405/find-position-of-a-node-using-xpath
- (1588)How to extract exact (1rst level) domain name from URL in Java?
PROBLEM: URL might look like:
- (https?://)?(<2nd/3rd/...level domain>)?.example.com or
- (https?://)?(<2nd/3rd/...level domain>)?.example.co.uk
This means that both on the left (presence or absence of
2nd/3rd/...level domains) and on the right (com vs co.uk) the position
of "example" is variable, so using regexes is not easy.
SOLUTION1:
import com.google.common.net.InternetDomainName;
//...
public class splitDomain {
public static void main(String[] args) {
// With simple 2nd/3rd levels
it = InternetDomainName.from("www.vinay.co.in");
System.out.println(it.publicSuffix().name());
// With subdomains
String url = "firstsubdomain.developer.vinay.co.in";
url = InternetDomainName.from(url).topPrivateDomain().name();
it = InternetDomainName.from(url);
String domainname = it.publicSuffix().name();
System.out.println(domainname);
String temp = url.replaceAll("."+domainname, "");
System.out.println(temp);
}
}
SOLUTION2:
URI uri = new URI("http://www.mydomain.ltd.uk/blah/some/page.html");
String host = uri.getHost();
System.out.println(host);
SOLUTION3:
Apache Http Component (HttpClient 4) comes with classes to handle this,
org.apache.http.impl.cookie.PublicSuffixFilter
org.apache.http.impl.cookie.PublicSuffixListParser
You need to download the public suffix list from here,
http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1
From: http://stackoverflow.com/questions/32181588/in-java-how-to-extract-exact-domain-name-from-url
- (1590)How to correct "java.lang.UnsatisfiedLinkError: ...: failed to map segment from shared object: Operation not permitted"?
The problem is that the (temporary) directory in use is located on the
filesystem mounted with "noexec" option.
From: https://netbeans.org/bugzilla/show_bug.cgi?id=163806
- (1621)How to override the log4j configuration on the commandline?
java -Dlog4j.debug -Dlog4j.configuration=file:/path/to/file
From: https://logging.apache.org/log4j/1.2/manual.html
http://stackoverflow.com/questions/2594689/external-log4j-xml-file
- (1677)How to make DocumentBuilder actually ignore validation in Java?
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setNamespaceAware(true);
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
DocumentBuilder db = dbf.newDocumentBuilder();
From: http://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references
- (1678)What is the difference between File.separator and File.pathSeparator in Java::File?
- File.pathSeparator is used to separate individual file paths in a list of file paths. Consider on windows, the PATH environment variable. You use a ; to separate the file paths so on Windows File.pathSeparator would be ;.
- File.separator is either / or \ that is used to split up the path to a specific file. For example on Windows it is \ or C:\Documents\Test
From: http://stackoverflow.com/questions/5971964/file-separator-or-file-pathseparator#5972020
- (1681)How to optimize a comparison between two sets?
It should not be difficult; the procedure is to load both arff files
as Instances objects, and for every attribute in the test file, check
if you have an attribute with the same name in the training
dataset. In that case, keep it, other wise delete it. It will will
take some time (O(n^2))
Unless you want to make it more efficient
getting all the attribute names in the training dataset and storing
them in a hash table; that way it will take only O(n) where n = number
of attributes.
From: http://weka.8497.n7.nabble.com/how-to-map-word-dictionary-of-test-and-train-data-td35905.html (around 9th response)
- (1698)How to convert an array of primitive type (ex: double) to an array of sub-Object type (ex: Double)?
Double[] objs = org.apache.commons.lang.ArrayUtils.toObject(new double[] {0.0,0.1,0.2,0.3});
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html#toObject%28double[]%29
- (1699)How to convert an array of sub-Object type (ex: Double) into an arry of primitive type (ex: double)?
double[] objs = org.apache.commons.lang.ArrayUtils.toPrimitive(new Double[] {0.0,0.1,0.2,0.3});
From: https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/org/apache/commons/lang/ArrayUtils.html#toPrimitive%28java.lang.Double[]%29
- (1704)How to make heritrix go depth-first (crawls first seed fully) instead of breadth-first (crawling all seeds)?
<property name="preferenceDepthHops" value="-1" />
Number of hops (of any sort) from a seed up to which a URI has higher priority scheduling than any remaining seed.
If set to -1, no preferencing will occur, and a breadth-first search with seeds processed before discovered links will proceed.
If set to 0, a purely depth-first search will proceed, with all discovered links processed before remaining seeds. Seed redirects are treated as one hop from a seed.
!!! You probably DO NOT WANT to set the value to 0, otherwise Heritrix may run in into an endless loop !!!
If set to 1, items one hop (link, embed, redirect, etc.) away from a seed will be scheduled with HIGH priority.
From: https://webarchive.jira.com/wiki/display/Heritrix/Processor+Settings
- (1713)How to correct Java error "Unmappable character for encoding ASCII"?
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
From: https://stackoverflow.com/questions/26067350/unmappable-character-for-encoding-ascii-but-my-files-are-in-utf-8
- (1724)How to solve the font problem of Java/OpenJDK7 that make no text appear in the menus/etc.?
PROBLEM: no text appears in the menus, etc. with java/OpenJDK7
SOLUTION: Use the system's anti-aliased fonts.
export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=on -Dswing.aatext=true'
For definitive resolution, add this line in "/etc/profile.d/jre.sh" or "~/.bashrc"
From: https://unix.stackexchange.com/questions/137896/java-doesnt-show-menu-text
https://wiki.archlinux.org/index.php/java#Tips_and_tricks
- (1728)How to get the name of the command ran (a.k.a how to write a USAGE String in Java)?
if (args.length != 2) {
System.err.println("USAGE: "+System.getProperty("sun.java.command")+" <args>");
System.exit(1);
} else {
...
}
From: https://stackoverflow.com/questions/13958318/is-it-possible-to-get-the-command-used-to-launch-the-jvm-in-java
- (1729)How to get several nodes by index/position in XPath?
//path/to/element[position()=1 or position()=2...]
From: https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/position
- (1742)How to read a Java .properties file in Tomcat?
The simple way to instantiate the DataSource would be include a properties file in the war's classpath (in WEB-INF/classes), which would allow you to do the following (note the DataSource instantiation will be database specific):
Properties properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream("config.properties"))
DataSource dataSource = new PGSimpleDataSource();
dataSource.setServerName(properties.get("database.server.name"));
PROBLEM: So this gets you to the point where you're loading a properties file from within your war. However as I stated, this makes the war environment specific.
---
The best way I know to solve this is to use an exploded war with a symlink to the environment configuration. To do this, you use a context file which you would place in [Tomcat root]/conf/Catalina/localhost.
For example, the given context file:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/my-app" docBase="/local/apps/my-app/war" distributable="false" allowLinking="true">
<WatchedResource>WEB-INF/web.xml</WatchedResource>
</Context>
You would have a directory structure like this:
local
+ apps
+ my-app
+ war
+ WEB-INF
+ classes
+ env -> /local/apps/my-app/env
+ env
Where /local/apps/my-app/war/WEB-INF/classes/env is a symlink to /local/apps/my-app/env.
Your properties would now be loaded like this:
Properties properties = new Properties();
properties.load(getClass().getClassLoader().getResourceAsStream("env/config.properties"));
From: https://stackoverflow.com/questions/31068574/how-to-get-property-file-in-tomcat#31070962
- (1744)How to get the (currently-running) Thread ID?
Thread.currentThread().getId();
From: https://stackoverflow.com/questions/11224394/obtaining-the-thread-id-for-java-threads-in-linux
- (1745)How to convert JSON to XML and conversly in Java? [VERY SLOW?]
- JSON to XML
/** Converts a String containing JSON code into XML. */
public static String JsonToXml(String content) {
net.sf.json.JSONObject json = net.sf.json.JSONObject.fromObject(uncomment(content));
String cvtd = new XMLSerializer().write(json);
return(cvtd);
}
/** Converts a String containing JSON code into XML. */
// NOTE: this version does not work on JSON code from http://startup-genome.co
public static String JsonToXmlOLD(String content) {
try {
org.json.JSONObject jo = new org.json.JSONObject(uncomment(content));
String cvtd = XML.toString(jo, "root");
return(cvtd);
} catch(org.json.JSONException e) {
ExceptionUtilities.manageException("Failed to interpret JSON: ", e, logger);
return("");
}
}
- XML to JSON
XML.toJSONObject(java.lang.String string)
From: https://stackoverflow.com/questions/19977979/converting-json-to-xml-in-java
- (1750)How to solve Heritrix..."Cannot create SymbolicLink"..."this platform does not support this operation"... org/archive/util/CLibrary?
PROBLEM: Java is unable to find the JNA library.
SOLUTION: You -Djava.library.path=
SOLUTION Presans-spécific: I had to add this line to the to Makefile
export JAVA_OPTS="$${JAVA_OPTIONS} -Djava.library.path=/usr/share/java/jna-4.2.0.jar:/usr/share/java/jna-platform-4.2.0.jar"
From: http://stackoverflow.com/questions/21679004/jna-unsatisfiedlinkerror-works-when-i-set-java-library-path-to-a-bogus-value
- (1754)How to solve Heritrix's "java.lang.NoSuchMethodError: org.apache.commons.httpclient.HttpState.setCookiesMap(Ljava/util/SortedMap;)V"?
PROBLEM: Heritrix has its own http-client, so commons-httpclient MUST NOT be in the CLASSPATH for running heritrix (or at least, be loaded AFTER hertrix's own lib: ia-web-commons). However, Sofia REQUIRES commons-httpclient.
SOLUTION: commons-httpclient.jar MUST be put in sofia2/lib/, so that Grails/Sofia finds it when it automatically builds its own CLASSPATH (see BuildConfig). However, the manual CLASSPATH (~/Softs/classpath) MUST NOT load all presans-lib/jars nor sofia2/lib/, but only heritrix/lib!
- (1757)What are the various Java Map/Collection types and when to use them? (a.k.a Java Collection Cheat Sheet)
Will it contain key/value pair or values only?
1) If it contains pairs, the choice is a map. Is order important?
1-1) If yes, follow insertion order or sort by keys?
1-1-1) If ordered, LinkedHashMap
1-1-2) If sorted, TreeMap
2) If order is not important, HashMap
3) If it stores only values, the choice is a collection. Will it contain duplicates?
3-1) If yes, ArrayList
3-2) If it will not contain duplicates, is primary task searching for elements (contains/remove)?
3-2-1) If no, ArrayList
3-2-2) If yes, is order important?
3-2-2-1) If order is not important, HashSet
3-2-2-2) If yes, follow insertion order or sort by values?
3-2-2-2-1) if ordered, LinkedHashSet
3-2-2-2-2) if sorted, TreeSet
From: https://stackoverflow.com/questions/13863506/why-doesnt-java-util-hashset-have-a-getobject-o-method
http://www.sergiy.ca/guide-to-selecting-appropriate-map-collection-in-java/
https://stackoverflow.com/questions/21974361/what-java-collection-should-i-use
https://docs.oracle.com/javase/tutorial/collections/implementations/index.html
- (1777)How to get time in milliseconds from Epoch (a.k.a How to compare 2 Dates) in Java?
long currDate = new Date().getTime(); // Get time in milliseconds from Epoch
// ... Perform some timely operation ...
if (currDate - new Date().getTime() > 20*60*1000) { // if operation lasted more than 20 minutes
// ...
}
From: https://docs.oracle.com/javase/8/docs/api/java/util/Date.html#getTime--
- (1787)How to manage/change Immutable Objects in Java?
In the case where an Object is Immutable, instead of creating a method
that changes the current instance value, you should create methods
that return a new instance with the modified value.
E.g.:
String replaced = original.replaceAll("regex", "replacement");
GraphEdge edge4 = edge2.changeName("new_name");
This may be useful for instance in Sets, where you **MUST NOT** change
the value of an entry once inserted into the Set, otherwise you might
get doubles in your Set!!!
From: https://stackoverflow.com/questions/13114043/java-hashset-contains-duplicates-if-contained-element-is-modified
- (1788)How to correctly use Sets in Java?
When you insert an Object in a Sets, some checks are made so that
there is no duplicates.
However, if you modify an Object inside the Set, no check is made
(indeed, that would require the Set to subscribe to events from each
inserted Objects).
As a consequence, you **MUST NOT** change the value of an entry once
inserted into the Set, otherwise you might get doubles in your Set!!!
From: https://stackoverflow.com/questions/13114043/java-hashset-contains-duplicates-if-contained-element-is-modified
- (1802)How to increase the stack size from within a Java code (for Android)?
THERE IS a way to increase your stack size, although you might not be
able to do it in the main UI Thread(which is understandable because
you're supposed to do as few things as possible here), by making use
of the Thread object parameters you can:
ThreadGroup group = new ThreadGroup("threadGroup");
new Thread(group, runnableObject, "YourThreadName", 2000000).start();
With this example I increased my stack size from 8k (around 260 calls)
to 2M (enough for not to get the StackOverFlowException, of course you
can add as much as you want as long as the memory can take it), so in
the end, for further readers, this is the way you can increase your
stack size,although is not recommended, in some cases it's actually
necessary for example an algorithm with extensive recursive calls and
of course by doing all the hard work in a worker thread(as you're
supposed to) with your specified stack size and just "posting" changes
in UIs using the main UI Thread with Handlers or whatever mechanism
you would like to use to interact with it...
From: https://stackoverflow.com/questions/8857602/android-increase-call-stack-size
- (1803)How to make DNS/Host lookup from Java?
// Print out a sorted list of mail exchange servers for a network domain name
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.InitialDirContext;
import javax.naming.NamingException;
import java.util.Arrays;
import java.util.Comparator;
public class MailHostsLookup
{
public static void main(String args[])
{
// explain what program does and how to use it
if (args.length != 1)
{
System.err.println("Print out a sorted list of mail exchange servers ");
System.err.println(" for a network domain name");
System.err.println("USAGE: java MailHostsLookup domainName");
System.exit(-1);
}
try
{ // print the sorted mail exhchange servers
for (String mailHost: lookupMailHosts(args[0]))
{
System.out.println(mailHost);
}
}
catch (NamingException e)
{
System.err.println("ERROR: No DNS record for '" + args[0] + "'");
System.exit(-2);
}
}
// returns a String array of mail exchange servers (mail hosts)
// sorted from most preferred to least preferred
static String[] lookupMailHosts(String domainName) throws NamingException
{
// see: RFC 974 - Mail routing and the domain system
// see: RFC 1034 - Domain names - concepts and facilities
// see: http://java.sun.com/j2se/1.5.0/docs/guide/jndi/jndi-dns.html
// - DNS Service Provider for the Java Naming Directory Interface (JNDI)
// get the default initial Directory Context
InitialDirContext iDirC = new InitialDirContext();
// get the MX records from the default DNS directory service provider
// NamingException thrown if no DNS record found for domainName
Attributes attributes = iDirC.getAttributes("dns:/" + domainName, new String[] {"MX"});
// attributeMX is an attribute ('list') of the Mail Exchange(MX) Resource Records(RR)
Attribute attributeMX = attributes.get("MX");
// if there are no MX RRs then default to domainName (see: RFC 974)
if (attributeMX == null)
{
return (new String[] {domainName});
}
// split MX RRs into Preference Values(pvhn[0]) and Host Names(pvhn[1])
String[][] pvhn = new String[attributeMX.size()][2];
for (int i = 0; i < attributeMX.size(); i++)
{
pvhn[i] = ("" + attributeMX.get(i)).split("\\s+");
}
// sort the MX RRs by RR value (lower is preferred)
Arrays.sort(pvhn, new Comparator<String[]>()
{
public int compare(String[] o1, String[] o2)
{
return (Integer.parseInt(o1[0]) - Integer.parseInt(o2[0]));
}
});
// put sorted host names in an array, get rid of any trailing '.'
String[] sortedHostNames = new String[pvhn.length];
for (int i = 0; i < pvhn.length; i++)
{
sortedHostNames[i] = pvhn[i][1].endsWith(".") ?
pvhn[i][1].substring(0, pvhn[i][1].length() - 1) : pvhn[i][1];
}
return sortedHostNames;
}
From: https://stackoverflow.com/questions/15240952/java-dnslookup-mx-record-list-like-mxtoolbox
- (1820)How to set max upload size in tomcat8?
In server.xml:
<Connector ...
maxPostSize="<size in bytes>"
... />
From: http://tomcat.10.x6.nabble.com/Setting-max-file-upload-size-td2010633.html
- (1844)How to prevent Tomcat (8) from leaking too much info in case of error?
To prevent Tomcat's error message to leak too much info about the
error & installation, add the following lin in the server.xml:
<Valve className="org.apache.catalina.valves.ErrorReportValve" showReport="false" showServerInfo="false"/>
To ensure that URLs to locations outside of your hosts/contexts are
not shown the error messages compiled into Tomcat you need to make
sure this <Valve/> is added your default <Host/>
From: http://stackoverflow.com/questions/794329/disable-all-default-http-error-response-content-in-tomcat
- (1848)How to make a "resources/" directory accessible to your application in Tomcat?
-- In the code:
// As a URL
URL webinfClassesResource = Thread.currentThread().getContextClassLoader().getResource("resources/myfile.text");
String content = FileUtils.readFileToString(webinfClassesResource, "UTF-8");
// As a Stream
InputStream webinfClassesPath = Thread.currentThread().getContextClassLoader().getResourceAsStream("resources/myfile.text");
// NOTE: By default, the getResource() looks into "[webapps/<your_app>]/WEBINF/classes/"
// Since Tomcat(8) seems not to allow ".." when trying to access the
// resources, if you want to access a resource in
// "[webapps/<your_app>]/" instead of
// "[webapps/<your_app>]/WEBINF/classes/" you cannot do:
URL webinfClassesPath = Thread.currentThread().getContextClassLoader().getResource("/");
String content = FileUtils.readFileToString(webinfClassesPath+"../../"+"resources/myfile.text", "UTF-8");
// Instead you should do:
URL webappDir = Thread.currentThread().getContextClassLoader().getResource("../../");
String content = FileUtils.readFileToString(webappDir+"resources/myfile.text", "UTF-8");
-- In Tomcat's configuration file $CATALINA_BASE/conf/catalina.policy (or /etc/tomcat8/policy.d/04webapps.policy)
// Was not required in my case...
permission java.util.PropertyPermission "${catalina.base}${file.separator}webapps${file.separator}sofia${file.separator}resources", "read";
From: https://tomcat.apache.org/tomcat-8.0-doc/security-manager-howto.html
https://stackoverflow.com/questions/5007481/tomcat-correct-way-to-find-a-resource#5007727
- (1852)How to resolve a URL in Java (a.k.a. How to make a relative URL into an absolute one)?
/** resolves relUrl against baseURL, i.e. make relURL abslute based on
* assumption we are surfing on baseURL website
* returns a normilized & ASCII'd URL. */
public String makeAbsolute(String relURL, String baseURL) {
if ((relURL==null)||(baseURL==null)) {
throw new URIException("URLs provided as input cannot be null!");
}
if (baseURL.length<=10) { // 'http://x.y' is the min URL
throw new URIException("baseURL URL is too small!");
}
if (relURL.indexOf('#')>=0) {
throw new URIException("Cannot use an anchor for reference!");
}
URI rel = new URI(relURL);
if (rel.isAbsolute()) {
return(rel.normalize().toASCIIString());
} else {
URI orig = new URI(baseURL);
return(orig.resolve(relURL).normalize().toASCIIString());
}
}
From: http://docs.oracle.com/javase/8/docs/api/java/net/URI.html
http://stackoverflow.com/questions/4390800/determine-if-a-string-is-absolute-url-or-relative-url-in-java#12840255
- (1854)How to use wildcard in "java -cp" / java command-line CLASSPATH?
Using Java 6 or later, the classpath option supports wildcards. Note the following:
* Use straight quotes (")
* Use *, not *.jar
Example:
java -cp "Test.jar:lib/*" my.package.MainClass
From: http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath#219801
- (1864)How to create a Date based on a String in Java7+?
import java.text.SimpleDateFormat;
Date date = new SimpleDateFormat("YYYY-MM-DD").parse("1970-01-01");
Also see Tip#1155
From: https://docs.oracle.com/javase/7/docs/api/java/text/DateFormat.html#parse(java.lang.String)
- (1900)How to solve "Missing JavaFX application class XXX" in Java8?
If you call:
$ java mypackage/mysubpackage/MyApp
You'll get:
Missing JavaFX application class mypackage/MyApp
That is because you are calling your application with a *directory
path* instead of a *fully qualified classname*. The fully qualified
classname is composed from the package name and the class name,
separated by dots, not slashes.
You should have called:
$ java mypackage.mysubpackage.MyApp
From: http://stackoverflow.com/questions/39308480/missing-javafx-application-class#39308517
- (1902)How to format numbers in Java's output?
System.out.format("The value of " + "the float variable is " +
"%f, while the value of the " + "integer variable is %d, " +
"and the string is %s", floatVar, intVar, stringVar);
From: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html
- (1903)How to get user input in Java7+?
import java.util.Scanner;
...
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter a number: ");
int n = reader.nextInt(); // Scans the next token of the input as an int.
From: http://stackoverflow.com/questions/5287538/how-can-i-get-the-user-input-in-java#5287561
- (1906)How to solve error "REJECTED_ROBOTS_META_NOINDEX" in Norconex crawler?
Add these two line in your crawler's XML configuration file:
<robotsTxt ignore="true" />
<robotsMeta ignore="true" />
From: https://github.com/Norconex/collector-http/issues/114
- (1916)How to test a CSS/JSoup selector on a File/URL?
How to test a CSS/JSoup selector on a File/URL?
-- JSoupTester.java
import java.io.File;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
/**
* Based on:
* https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/examples/HtmlToPlainText.java
* https://jsoup.org/apidocs/org/jsoup/nodes/Document.html
* https://jsoup.org/apidocs/org/jsoup/nodes/Element.html
* https://jsoup.org/apidocs/org/jsoup/select/Elements.html
*/
public class JSoupTester {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("USAGE: "+System.getProperty("sun.java.command")+"<html/xml file> <jsoup/css selector>");
System.exit(1);
}
try {
Document doc = null;
if (args[0].startsWith("http")) {
doc = Jsoup.parse(new File(args[0]), "UTF-8");
} else {
doc = Jsoup.connect(args[0]).timeout(60000).get();
}
Elements elts = doc.select(args[1]);
for (Element e: elts) {
System.out.println(e.text());
}
} catch(Exception e) {
e.printStackTrace();
}
}
}
-- test_css_selector.sh
if [[ $# != 2 ]]
then
echo "USAGE: $0 <filename> <CSS selector>"
else
java -cp /path/to/jsouptester/class/:/path/to/jsoupjar/jsoup.jar:. JSoupTester "$1" "$2"
fi
From: https://github.com/jhy/jsoup/blob/master/src/main/java/org/jsoup/examples/HtmlToPlainText.java
- (1918)How to fake a mouse/key event in JavaFX (e.g. load a page - HTML+CSS+JS - with WebKit and fake/simulate a scrolldown)? [DOES NOT WORK?]
/**
* Goal of the class was to fetch a page, execute the JS in it, then
* return (or display/save) the resulting HTML/JS page so that norconex's
* crawler can extract infos from http://500.co
*/
package fr.presans.crawling.norconex.fetchers;
import java.io.*;
import java.util.logging.*;
import java.nio.charset.Charset;
import javafx.application.*;
import javafx.beans.value.*;
import javafx.concurrent.Worker.State;
import javafx.event.*;
import javafx.scene.Scene;
import javafx.scene.input.*
import javafx.scene.web.*;
import javafx.stage.Stage;
import org.apache.xml.serialize.*;
import org.w3c.dom.Document;
import fr.presans.commons.util.ExceptionUtilities;
public class WebLauncher extends Application {
//// Another way to listen to the page-loading even is:
// webEngine.getLoadWorker().workDoneProperty().addListener(new ChangeListener<Number>() {
// @Override
// public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
// if (newValue.intValue() == 100 /*percents*/) {
// }
// }});
class MyChangeStateListener<K> implements ChangeListener<K> {
private WebLauncher parentApp = null;
private boolean display = false;
MyChangeStateListener(WebLauncher argApp, boolean argDisplay) {
this.parentApp = argApp;
this.display = argDisplay;
}
@Override
public void changed(ObservableValue<? extends K> ov, K oldState, K newState) {
if ((newState instanceof State) &&
(newState == State.SUCCEEDED)) {
// Optional: display the page in a window
if (display) { parentApp.displayPage(); }
// Inject code for loading more content + Load page
injectAnchorToNextPage();
// Save the resulting page
parentApp.savePageAfterJSExecution();
// Optional: Quit the platform
if (!display) { Platform.exit(); }
}
}
}
class MyInjectionThread extends Thread {
WebView webView;
Stage stage;
int nbInjections;
public MyInjectionThread(WebView argWebView, Stage argStage, int argNbInjections) {
this.webView = argWebView;
this.stage = argStage;
this.nbInjections = argNbInjections;
}
private void sleep(int sec) {
try {
Thread.sleep(sec*1000);
} catch (InterruptedException e) {}
}
public void run() {
sleep(5);
//webEngine.executeScript("window.wheel()");
for(int i=0 ; i<this.nbInjections ; i++) {
webView.fireEvent(largeScrollEvent);
stage.fireEvent(largeScrollEvent);
sleep(2);
webView.fireEvent(pageDownEvent);
stage.fireEvent(pageDownEvent);
sleep(2);
}
}
}
private static Logger logger = Logger.getLogger(WebLauncher.class.getCanonicalName());
static { logger.setLevel(Level.INFO); }
private static int WAIT_MS_FOR_PAGE = 3000; // default ms waiting for page to be ready
private String URL = "https://app.dealroom.co/companies?keyword=plasma";
private String outFilename = null;
private int nbInjections = 0;
private Stage stage = null;
private Scene scene = null;
private WebView webView = null;
private WebEngine webEngine = null;
private int scrollSize = 1; // #pages of fake scroll
private ScrollEvent largeScrollEvent = null; // Fake scrolling event/Mouse
private KeyEvent pageDownEvent = null; // Fake scrolling event/Keyboard
public void start(Stage argStage) {
this.stage = argStage;
// Create a fake page scrolling event
largeScrollEvent = new ScrollEvent(ScrollEvent.SCROLL,
0, 0, 0, 0, // x,y , screenX,screenY
false, false, false, false, // <key>Down?
false, false, // direct,inertia
0, 1, 0, 0, // deltaX,deltaY , totalDeltaX,totalDeltaY
ScrollEvent.HorizontalTextScrollUnits.NONE,
0, // textDeltaX
ScrollEvent.VerticalTextScrollUnits.PAGES,
1, // textDeltaY
0, null); // touchCount, pickResult
//Create a fake keypress
pageDownEvent = new KeyEvent(KeyEvent.KEY_TYPED,
KeyCode.PAGE_DOWN.toString(),
KeyCode.PAGE_DOWN.toString(),
KeyCode.PAGE_DOWN, false, false, false, false);
// Get app parameters
setURL(getParameters().getRaw().get(0));
logger.finer("URL set to: "+this.getURL());
setOutputFilename(getParameters().getRaw().get(1));
logger.finer("outputFilename set to: "+this.getOutputFilename());
setNbInjections(Integer.parseInt(getParameters().getRaw().get(2)));
logger.finer("nbInjections set to: "+this.getNbInjections());
// Init Webkit engine
webView = new WebView();
webEngine = webView.getEngine();
// Register callback for when page is fully loaded
MyChangeStateListener<State> listnr = new MyChangeStateListener<State>(this, Boolean.parseBoolean(getParameters().getRaw().get(3)));
webEngine.getLoadWorker().stateProperty().addListener(listnr);
loadPage();
}
public String getURL() {
return(URL);
}
public void setURL(String argURL) {
this.URL = argURL;
}
public String getOutputFilename() {
return(outFilename);
}
public void setOutputFilename(String argOutFile) {
this.outFilename = argOutFile;
}
public int getNbInjections() {
return(nbInjections);
}
public void setNbInjections(int argNbInjections) {
this.nbInjections = argNbInjections;
}
// BOF 1. Wrong Event ?
// TODO! 2. Wrong target (get a Node?) ?
// NOPE 3. Wrong moment for injection (=> wait in other Thread?) ?
// 4. Do not use event, but inject JS code (=> correct method is n()?) ?
public void injectAnchorToNextPage() {
MyInjectionThread it = new MyInjectionThread(webView, stage, nbInjections);
it.start();
}
public void loadPage() {
webEngine.load(this.URL);
}
public void displayPage() {
this.scene = new Scene(webView);
this.stage.setScene(this.scene);
this.stage.show();
}
public String getPageAfterJSExecution() {
OutputStream os = new ByteArrayOutputStream();
try {
Document doc = webEngine.getDocument();
logger.finer("***** doc= "+doc);
new XMLSerializer(os, new OutputFormat(doc, "UTF-8", true)).serialize(doc);
} catch(IOException e) {
ExceptionUtilities.manageException("ERROR: serialization interrupted", e, logger);
}
return(os.toString());
}
public void savePageAfterJSExecution() {
OutputStream os = null;
try {
if (this.outFilename==null) {
os = System.out;
} else {
os = new FileOutputStream(this.outFilename);
}
os.write(getPageAfterJSExecution().getBytes(Charset.forName("UTF-8")));
} catch (IOException e) {
ExceptionUtilities.manageException("ERROR: storage interrupted", e, logger);
} finally {
try {
if (os!=null) { os.close(); }
} catch (IOException e) {
ExceptionUtilities.manageException("ERROR: storage interrupted", e, logger);
}
}
}
public static void main(String[] args) {
WebLauncher wl = new WebLauncher();
if (args.length != 4) {
System.err.println("USAGE: $0 <url> <outfile> <nb injections> <display?>");
Platform.exit();
} else {
wl.launch(args[0], args[1], args[2], args[3]);
}
}
}
From: http://stackoverflow.com/questions/26537548/javafx-listview-with-touch-events-for-scrolling-up-and-down
http://stackoverflow.com/questions/36069049/programmatically-fireevent-in-textfield-javafx#36069360
- (1920)What does "() ->" means in Java8?
That's part of the syntax of the new lambda expressions of Java 8.
There are a couple of online tutorials to get the hang of it, here's a
link to one
(http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html).
Basically, the -> separates the parameters (left-side) from the actual
expression (right side).
e.g.
(Person p) -> p.getGender() == Person.Sex.MALE
&& p.getAge() >= 18
&& p.getAge() <= 25
When applied to a Collection, will select only the MALEs with ages in range [18,25].
This is called a "functional interface", it is equivalent to an
interface that contains only one abstract method.
From: http://stackoverflow.com/questions/15146052/what-does-the-arrow-operator-do-in-java#15146099
- (1942)How do the levels in org.apache.log4j and java.util.logging compare?
org.apache.log4j.Level.TRACE => java.util.logging.Level.FINER;
org.apache.log4j.Level.DEBUG => java.util.logging.Level.FINE;
org.apache.log4j.Level.INFO => java.util.logging.Level.INFO;
org.apache.log4j.Level.WARN => java.util.logging.Level.WARNING;
org.apache.log4j.Level.ERROR => java.util.logging.Level.SEVERE;
org.apache.log4j.Level.FATAL => java.util.logging.Level.SEVERE;
From: https://blogs.oracle.com/bondolo/entry/log4j_to_java_util_logging
- (2005)How to estimate InMemory/Serialized Java Object size?
The size in memory will be usually between half and double the
serializable size. The most extreme example might be the Byte which is
more than 80 bytes Serialized can be 16 bytes in memory.
You can use a profiler to tell you how much memory an object uses.
Another way is to use a tool based on
Instrumentation.getObjectSize(object)
From: http://stackoverflow.com/questions/7146559/serialized-object-size-vs-in-memory-object-size-in-java#7146941
http://vanillajava.blogspot.fr/2011/07/java-getting-size-of-object.html
- (2007)How to stop crashing your brain with multiple escaping levels when using Regexes inside Java Strings?
String escapedString = java.util.regex.Pattern.quote(myStringWithSlashesAndDolars)
This will automagically escape all special regex characters in a given string!
From: http://stackoverflow.com/questions/3853726/java-regular-expressions-and-dollar-sign
- (2009)How to efficiently convert a char into a String in Java?
PROBLEM: using ""+char is inefficient!! Indeed:
String s = "" + 's';
is compiled to:
String s = new StringBuilder().append("").append('s').toString();
which is not efficient because the StringBuilder is backed by a char[]
(over-allocated by StringBuilder() to 16), only for that array to be
defensively copied by the resulting String.
SOLUTION: You can use:
String.valueOf(char) // or
Character.toString(char) // calls above method!
This is more efficient since it wraps the char in a single-element
array and passing it to the package private constructor String(char[],
boolean), which avoids the array copy.
ATTENTION: above methods do not work with null input.
// Below are less efficient and longer methods, for the sake of completeness
String s = new String(new char[]{'s'});
String s = String.valueOf(new char[]{'s'});
String s = new Character('s').toString();
From: http://stackoverflow.com/questions/8172420/how-to-convert-a-char-to-a-string-in-java
- (2033)How to make a main application wait for (a) thread(s) before terminating in Java?
SOLUTION1: for a single Thread
Thread outputDrainThread = new Thread(new Runnable() {
public void run() {
// ...
}
}).start();
// ...
// ***HERE IS WHERE I NEED TO WAIT FOR THE THREAD TO FINISH ***
outputDrainThread.join();
SOLUTION2: for a multiple Threads
static private Object monitorMain = new Object();
//...
private static synchronized void decRunningThreads() {
nRunningThreads--;
if (nRunningThreads <= 0) {
synchronized (monitorMain) {
monitorMain.notify(); // No more sub-threads. Notify main thread to exit.
}
}
}
// ...
public static void main(String[] args) {
// ...
try {
synchronized (monitorMain) {
monitorMain.wait();
}
} catch(InterruptedException ex) {}
}
From: Thanks FC
https://www.safaribooksonline.com/library/view/java-threads-second/1565924185/ch04s03.html
http://stackoverflow.com/questions/7126550/java-wait-and-notify-illegalmonitorstateexception#7126587
http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#wait%28%29
- (2085)How to remove credentials in Jenkins (a.k.a how to solve "No valid crumb was included in the request")?
To manage saved credentials, go to Jenkins[Home] > Credentials
If you get error "No valid crumb was included in the request" when attempting to delete a credential: YOU NEED TO CLEAR YOUR COOKIES or you'll hit this.
From: https://issues.jenkins-ci.org/browse/JENKINS-12875
- (2089)How to enable sending of notification emails through Gmail with Jenkins 2?
Run jenkins with:
$ java -Dmail.smtp.starttls.enable="true" -jar jenkins.war
Or add this line at the top of /etc/init.d/jenkins
JAVA_ARGS=${JAVA_ARGS} -Dmail.smtp.starttls.enable="true"
From: https://issues.jenkins-ci.org/browse/JENKINS-2206
- (2112)How to get the IP of the computer through Java?
private static InetAddress getFirstNonLoopbackAddress(boolean getIPv6) throws SocketException {
Enumeration en = NetworkInterface.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface i = (NetworkInterface) en.nextElement();
for (Enumeration en2 = i.getInetAddresses(); en2.hasMoreElements();) {
InetAddress addr = (InetAddress) en2.nextElement();
if (!addr.isLoopbackAddress()) {
if (addr instanceof Inet4Address) {
if (getIPv6) {
continue;
}
return addr;
}
if (addr instanceof Inet6Address) {
if (!getIPv6) {
continue;
}
return addr;
}
}
}
}
return null;
}
From: https://stackoverflow.com/questions/901755/how-to-get-the-ip-of-the-computer-on-linux-through-java#901943
- (2114)How to apply a reverseDNS query on an IP in Java?
-- Simple solution, which can take very long (~5sec) to return
InetAddress addr = InetAddress.getByName("192.168.4.1");
System.out.println(addr.getCanonicalHostName());
-- More complex solution, a lot faster (requires http://www.xbill.org/dnsjava/)
import org.xbill.DNS.*;
import java.io.IOException;
public class ReverseDnsTest {
public static String reverseDns(String hostIp) throws IOException {
Record opt = null;
Resolver res = new ExtendedResolver();
Name name = ReverseMap.fromAddress(hostIp);
int type = Type.PTR;
int dclass = DClass.IN;
Record rec = Record.newRecord(name, type, dclass);
Message query = Message.newQuery(rec);
Message response = res.send(query);
Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0)
{ return hostIp; }
else
{ return answers[0].rdataToString(); }
}
public static void main(String args[]) throws IOException {
long now = System.currentTimeMillis();
System.out.println(reverseDns("192.222.1.13"));
System.out.println(reverseDns("208.201.239.36"));
long after = System.currentTimeMillis();
System.out.println((after - now) + " ms");
}
}
From: http://archive.oreilly.com/pub/post/reverse_dns_lookup_and_java.html
- (2133)How to instantiate a logger in Java?
How to create a logger in Java?
It is NOT recommended to use:
private static final <LogClass> logger = Logger.getLogger(this.getClass());
As in this case, if you create a subclass, the log messages will get
logged to the subclass's logger (See EXPLANATION below).
It's probably the same with all generic attempts, like:
private static final <LogClass> logger = Logger.getLogger(MethodHandles.lookup().lookupClass());
== SOLUTION
It's best to use either:
private static final <LogClass> logger = Logger.getLogger(<YourClassName>.class);
private static final <LogClass> logger = Logger.getLogger(<YourClassName>.class.getCannonicalName());
== EXPLANATION
If you create a subclass, the log messages will get logged to the subclass's logger.
package pkgone;
public class SuperType {
private Logger log = Logger.getLogger(this.getClass());
public void someAction() {
log.info("Doing something");
}
}
package pkgtwo;
import pkgone.SuperType;
public class SubType extends SuperType {
// for instances of SubType, the log object in SuperType
// will get initialized with SubType's class object
}
// some code somewhere that uses SubType
SubType obj = new SubType();
obj.someAction();
In the above example, "Doing something" will get logged to the pkgtwo.SubType logger instead of pkgone.SuperType logger, which may or may not be what you want.
From: https://stackoverflow.com/questions/10725402/generic-way-of-getlogger-from-log4j-logger
- (2135)What is a good ticketing system for Git (+code review +CI +wiki)?
GitLab is a on-premise or hosted Git repository management tool. It
also includes code reviews, issue tracking, wikis, and continuous
integration.
From: http://alternativeto.net/software/bitbucket/
- (2156)How to prevent an XML parser (e.g. norconex collector config file reader) from trimming spaces?
FYI, the xml:space attribute is defined in the XML Standard so it is
not specific to the Importer XML configuration. This means you should
be able to use this attribute anywhere in your config.
e.g.:
<replace fromField="EXP_POSITION" regex="true" replaceAll="true">
<fromValue>\s*</fromValue>
<toValue xml:space="preserve"> </toValue>
</replace>
From: https://github.com/Norconex/importer/issues/56
- (2162)How to actually edit an issue in Redmine (instead of adding notes)?
NOTE: In order to edit an existing issue, your role has to have the
Issue Tracking > Edit Issues right in the the roles and permissions
configuration.
1. Open the issue
2. Click Update/Edit link (having a *pencil icon*) at the top or the bottom
of the issue page.
The description of the issue has *pencil icon* right next to it that you
can click to change the description.
From: http://www.redmine.org/projects/redmine/wiki/RedmineIssues#Editing-an-existing-issues-Subject-or-Description
- (2169)How to get the current/working directory in Java?
public class Test {
public static void main(final String[] args) {
final String dir = System.getProperty("user.dir");
System.out.println("current dir = " + dir);
}
}
From: https://stackoverflow.com/questions/3153337/get-current-working-directory-in-java#3153440
- (2183)When to use pre/postParseHandler with Norconex collector?
"Parsing" in this context means extracting the raw text and metadata
from a document, regardless of its content type.
That is, the text is extracted from binaries such as PDFs, MS Word,
etc., or in the case of markup-based documents such as HTML, tags are
stripped so you get only the content. Extracted Metadata depends on
each document. They range from document properties to <meta> tags in
HTML pages.
So preParseHandler takes place before text and metadata are extracted
while postParseHandler executes after.
So if you need to deal with documents in their original form (e.g.,
you want to reference HTML tags using DOMTagger or else), you would
use pre.... Otherwise, if you want to act on obtained metadata or the
text only (without formatting or else), use ``post...```.
Using a handler that is meant to work on text only as a pre-parse
handler can produce errors since many documents could be binaries. You
can use the restrictTo configuration that is available to all handlers
to make sure your handler only applies to a specific content type.
From: https://github.com/Norconex/collector-http/issues/385#issuecomment-327320238
- (2220)WikiBook: Software Design Principles
== Software design principles ==
=== Software Philosophy ===
* Mostly based on:
:[[List of eponymous laws]]
** https://haacked.com/archive/2007/07/17/the-eponymous-laws-of-software-development.aspx/
** http://www.itexico.com/blog/bid/99765/software-development-kiss-yagni-dry-3-principles-to-simplify-your-life
** https://www.javacodegeeks.com/2017/06/coderdojo-whats-point.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+JavaCodeGeeks+%28Java+Code+Geeks%29
** https://thefullstack.xyz/dry-yagni-kiss-tdd-soc-bdfu/
** https://thefullstack.xyz/solid-javascript/
:[[Roy_Amara#Amara.27s_law]]
:[[Three_Laws_of_Robotics]]
:[[Augustine%27s_laws]]
:[[Bergmann%27s_rule]]
:[[Betteridge%27s_law_of_headlines]]
:[[Bullshit#Bullshit_asymmetry_principle]]
:[[Brooks%27s_law]]
:[[Conway%27s_law]]
:[[Hick%27s_law]]
:[[Hofstadter%27s_law]]
:[[Jamie_Zawinski#Principles]]
:[[Kerckhoffs%27s_principle]]
:[[Linus%27s_Law]]
:[[Moore%27s_law]]
:[[Murphy%27s_law]]
:[[Pareto_principle]]
:[[Parkinson%27s_law]]
:[[Peter_principle]]
:[[Postel%27s_law]]
:[[Reed%27s_law]]
:[[Sturgeon%27s_law]]
:[[Wirth%27s_law]]
:[[Dunning%E2%80%93Kruger_effect]]
:[[Peter_principle]]
:[[Murphy%27s_law]]
:[[Muphry%27s_law]]
:[[Godwin%27s_law]]
- dev principles]]
:[[KISS_principle]]
:[[Don%27t_repeat_yourself]]
:[[You_aren%27t_gonna_need_it]]
:[[Occam%27s_razor]]
:[[Worse_is_better]]
:[[Rule_of_least_power]]
:[[Single_responsibility_principle]]
:[[Open/closed_principle]]
:[[Liskov_substitution_principle]]
:[[Interface_segregation_principle]]
:[[Dependency_inversion_principle]]
:[[GRASP_(object-oriented_design)]]
:[[Design_Patterns]]
:[[Package_principles]]
:[[Muntzing]]
*:[[Muda_(Japanese_term)]]
:[[Conway%27s_law]]
:[[IDEF6]]
:[[Client–server_model]]
:[[Model–view–controller]]
:[[Convention_over_configuration]]
:[[SOLID_(object-oriented_design)]]
:[[Unix_philosophy#Do_One_Thing_and_Do_It_Well]]
:[[Unix_philosophy#Eric_Raymond.E2.80.99s_17_Unix_Rules]]
:[[Model-driven_application]]
:[[Behavior-driven_development]]
:[[Story-driven_modeling]]
:[[Responsibility-driven_design]]
:[[Domain-driven_design]]
:[[Test-driven_development]]
https://en.wikipedia.org/w/index.php?search=oriented+programming&title=Special:Search&go=Go&searchToken=ftz20d2ii0dmu13biawbvi8y
- (2247)Principes des Design Patterns
"Imaginer ce qui pourrait être amené à changer"
Thanks P Jourdat Astree
- (2266)How to accelerate algorithms?
1. Design a first *non-optimized* proto + define some metrics before any optimization
2. *Simple* algorithms are *easier to maintain*
Complex algorithms are optimized on most cases but often have a (few) case(s) for which they are very bad and *these cases always occur IRL (Murphy's law!)!
3. Be careful that choosing an good *algorithm* does not mean it will be *implemented* correctly
* For instance, never use sqrt(), as it is computationally intensive
* Avoid calling too many functions (prefer /iterative loops/ over recursion)
4. In Python & R work on vectors/matrices (apply()/map()/...) not loops
From: https://www.kdnuggets.com/2017/12/accelerating-algorithms-design-choice-implementation.html
- (2302)What is immutable in Java and how to use it?
- immutable = Not changeable (ex: String/wrapper classes like Integer/Long...)
- Creation:
* final keyword
* private variable with no public accessor
* Collections.unmodifiable*()
* Iterator with a dummy remove() method.
- Advantages:
* Thread safe
* Persistence safe
* RAM efficiency
immutable != unmodifiable: for instance an immutable List cannot not received more elements (it is /structurally/ unmodifiable), but its elements can change (since their are, in fact, pointers)
From: http://mindprod.com/jgloss/immutable.html
- (2337)How to ensure that your Class' Comparator/Equals/HashCode methods return coherent values?
Use org.apache.commons.lang3.builder.comparetobuilder!
public int compareTo(MyClass other) {
return new CompareToBuilder()
.append(this.attribute1, other.attribute1) // attribute comparison must be
.append(this.attribute2, other.attribute2) // in order of preference
.toComparison();
}
From: https://stackoverflow.com/questions/9161370/what-exactly-does-org-apache-commons-lang-builder-comparetobuilder-do#24040873
- (2338)How to generate Pastel colors palette (in Java)?
Random rand = new Random();
float r = rand.nextFloat() / 2f + 0.5f;
float g = rand.nextFloat() / 2f + 0.5f;
float b = rand.nextFloat() / 2f + 0.5f;
this.colors.put(ofGroup, new Color(r, g, b));
Thx JC
- (2340)Explanation of JVM memory Options -Xmx/etc
<----------- -Xmx ------------><- -XX:PermSize -><--- -Xss * N -----><------->
Young | Old | Perm | Stack | MISC |
<-- -Xmn -->
<------------------------------ process memory ------------------------------>
From: https://stackoverflow.com/questions/13489469/how-to-increase-intellij-32bit-xmx-more-than-1gb?answertab=active#tab-top
https://i.stack.imgur.com/bjrmw.png
- (2345)How to directly initialize a Map in Java?
- With 3rd party libs (Guava's ImmutableMap)
Map<String, String> test = ImmutableMap.of("k1", "v1", "k2", "v2");
- Java 7 + varargs
public static HashMap<String, String> build(String... data){
HashMap<String, String> result = new HashMap<String, String>();
if(data.length % 2 != 0)
throw new IllegalArgumentException("Odd number of arguments");
String key = null;
Integer step = -1;
for(String value : data){
step++;
switch(step % 2){
case 0:
if(value == null)
throw new IllegalArgumentException("Null key value");
key = value;
continue;
case 1:
result.put(key, value);
break;
}
}
return result;
}
HashMap<String,String> data = HashMapBuilder.build("key1","value1","key2","value2");
- Java < 9
private static final Map<String, String> myMap;
static
{
myMap = new HashMap<String, String>();
myMap.put("a", "b");
myMap.put("c", "d");
}
HashMap<String, String> h = new HashMap<String, String>() {{
put("a","b");
}}; // be careful and make sure that you understand the above code (it creates a new class that inherits from HashMap). Read more here: http://www.c2.com/cgi/wiki?DoubleBraceInitialization
- Java 9
private static final Map<String, String> test2 = Map.ofEntries(
entry("a", "b"),
entry("c", "d")
);
private static final Map<String, String> test = Map.of("a", "b", "c", "d");
From: https://stackoverflow.com/questions/6802483/how-to-directly-initialize-a-hashmap-in-a-literal-way
- (2346)How to use Lambda Expression to Sort a List in Java 8?
// Pre-Java8 we needed to use an Anonymous Inner class:
Collections.sort(personList, new Comparator<Person>(){
public int compare(Person p1, Person p2){
return p1.firstName.compareTo(p2.firstName);
}
});
// Java8 with Lambda expression:
Collections.sort(personList, (Person p1, Person p2) -> p1.firstName.compareTo(p2.firstName));
// Java8 with type information removed:
Collections.sort(personList, (p1, p2) -> p1.firstName.compareTo(p2.firstName));
From: https://dzone.com/articles/using-lambda-expression-sort
- (2347)How to try snippets of code?
- Pre-Java9, use BeanShell
bsh
- Java 9, use
jshell
- Online, use
https://tryjshell.org/
- with IDEA, use Scratches
Press Ctrl+Shift+Alt+Insert and select type Scratch
From: https://stackoverflow.com/questions/5682618/shortcuts-for-testing-out-small-code-snippets-in-intellij-idea#32330477
- (2349)How to build a Map from a Java9 stream?
items = List<...>
Map<...,...> map = items.stream().collect(Collectors.toMap(i -> ..., i -> ...));
From: https://stackoverflow.com/questions/32859038/java-8-list-to-map-with-stream#answer-32863263
- (2352)How to model a Tree structure in Hibernate?
@Entity
class Node {
@ManyToOne
@JoinColumn(name = "<parent_id>")
private Node parent; //each Domain with parent==null is a root domain, all others are subdomains
@OneToMany
@JoinColumn(name = "<parent_id>")
private List<Node> subdomains;
}
From: https://stackoverflow.com/questions/7064691/how-to-model-a-tree-with-hibernate#7064777
- (2354)How to convert a String to Double while respecting the locale?
NumberFormat nf = NumberFormat.getInstance(Locale.FRENCH);
myNumber = nf.parse(myString);
double myNumber = nf.parse(myString).doubleValue();
BEWARE that this method may not use the entire text of the given string. It is designed to parse text only from the beginning of the given string to produce a number. This might result in stange behaviours. For example:
if str="a10" then is thrown a ParseException
if str="10a" then no exception thrown and number=10
To raise an Exception in all the cases the String is in a bad format (in the same manner as Double.parse()), do:
public static double parse(String str) throws ParseException {
NumberFormat formatter = NumberFormat.getInstance();
ParsePosition position = new ParsePosition(0);
Number number = formatter.parse(str, position);
if (position.getIndex() != str.length()) { // If the whole String has not been parsed, raise the Exception
throw new ParseException("failed to parse entire string: " + str, position.getIndex());
}
return number.doubleValue();
}
From: https://stackoverflow.com/questions/888088/how-do-i-convert-a-string-to-double-in-java-using-a-specific-locale#888105
https://stackoverflow.com/questions/2266020/strange-behaviour-of-numberformat-java#answer-2266069
- (2362)What is the difference between Objects.equals(object1,object2) and object1.equals(object2)?
The difference is the Objects.equals() considers two nulls to be "equal". The pseudo code is:
if both parameters are null or the same object, return true
if the first parameter is null return false
return the result of passing the second parameter to the equals() method of the first parameter
This means it is "null safe" (non null safe implementation of the first parameter’s equals() method notwithstanding).
From: https://stackoverflow.com/questions/34486832/objects-equals-and-object-equals#34486950
- (2363)What is Java 8's Optional Class?
Optional is a container object used to contain not-null objects. Optional object is used to represent null with absent value. This class has various utility methods to facilitate code to handle values as ‘available’ or ‘not available’ instead of checking null values.
From: https://www.tutorialspoint.com/java8/java8_optional_class.htm
- (2364)How do I test a private method with JUnit?
If you have somewhat of a legacy Java application, and you're not allowed to change the visibility of your methods, the best way to test private methods is to use reflection.
Internally we're using helpers to get/set private and private static variables as well as invoke private and private static methods. The following patterns will let you do pretty much anything related to the private methods and fields. Of course you can't change private static final variables through reflection.
Method method = targetClass.getDeclaredMethod(methodName, argClasses);
method.setAccessible(true);
return method.invoke(targetObject, argObjects);
And for fields:
Field field = targetClass.getDeclaredField(fieldName);
field.setAccessible(true);
field.set(object, value);
Notes:
1. targetClass.getDeclaredMethod(methodName, argClasses) lets you look into private methods. The same thing applies for getDeclaredField.
2. The setAccessible(true) is required to play around with privates.
From: https://stackoverflow.com/questions/34571/how-do-i-test-a-private-function-or-a-class-that-has-private-methods-fields-or#34658
- (2366)What are the differences between ceil/floor/round/rint?
There is no inconsistency: the methods are simply designed to follow different specifications.
long round(double a)
https://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#round%28double%29
Returns the closest long to the argument.
double floor(double a)
https://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#floor%28double%29
Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer.
Compare with double ceil(double a)
https://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#ceil%28double%29
double rint(double a)
https://docs.oracle.com/javase/6/docs/api/java/lang/Math.html#rint%28double%29
Returns the double value that is closest in value to the argument and is equal to a mathematical integer
So by design round rounds to a long and rint rounds to a double. This has always been the case since JDK 1.0.
From: https://stackoverflow.com/questions/3412449/why-does-math-round-return-a-long-but-math-floor-return-a-double#3412759
- (2368)How do you assert that a certain exception is thrown in JUnit 4 tests?
The simplest way is:
@Test
public void testFooThrowsIndexOutOfBoundsException() {
boolean thrown = false;
try {
foo.doStuff();
} catch (IndexOutOfBoundsException e) {
thrown = true;
}
assertTrue(thrown);
}
For more advanced uses, see the links
From: https://stackoverflow.com/questions/156503/how-do-you-assert-that-a-certain-exception-is-thrown-in-junit-4-tests
https://github.com/junit-team/junit4/wiki/Exception-testing
- (2369)How to write a number while preserving the Locale?
String.format(Locale.GERMAN, "%d", 1234567890);
String.format(Locale.FRENCH, "%f", 1234567890.12345);
From: https://stackoverflow.com/questions/13763700/java-string-format-numbers-with-localization#13763815
- (2377)How to launch tasks regularly with Java (a.k.a. What is a good Java (cron-like) scheduler)?
http://www.quartz-scheduler.org/
Thanks PhM
- (2384)How to create a memory leak in Java?
Here's a good way to create a true memory leak (objects inaccessible by running code but still stored in memory) in pure Java:
The application creates a long-running thread (or use a thread pool to leak even faster).
The thread loads a class via an (optionally custom) ClassLoader.
The class allocates a large chunk of memory (e.g. new byte[1000000]), stores a strong reference to it in a static field, and then stores a reference to itself in a ThreadLocal. Allocating the extra memory is optional (leaking the Class instance is enough), but it will make the leak work that much faster.
The thread clears all references to the custom class or the ClassLoader it was loaded from.
Repeat.
This works because the ThreadLocal keeps a reference to the object, which keeps a reference to its Class, which in turn keeps a reference to its ClassLoader. The ClassLoader, in turn, keeps a reference to all the Classes it has loaded.
(It was worse in many JVM implementations, especially prior to Java 7, because Classes and ClassLoaders were allocated straight into permgen and were never GC'd at all. However, regardless of how the JVM handles class unloading, a ThreadLocal will still prevent a Class object from being reclaimed.)
A variation on this pattern is why application containers (like Tomcat) can leak memory like a sieve if you frequently redeploy applications that happen to use ThreadLocals in any way. (Since the application container uses Threads as described, and each time you redeploy the application a new ClassLoader is used.)
Update: Since lots of people keep asking for it, here's some example code that shows this behavior in action: https://gist.github.com/dpryden/b2bb29ee2d146901b4ae
From: https://stackoverflow.com/questions/6470651/creating-a-memory-leak-with-java#answer-6471947
https://frankkieviet.blogspot.com/2006/10/classloader-leaks-dreaded-permgen-space.html
https://wiki.apache.org/tomcat/MemoryLeakProtection
- (2385)How are FIFO/LIFO implemented in Java?
- FIFO
https://docs.oracle.com/javase/8/docs/api/java/util/Queue.html
In fact List<> implements Queue<> you can just use a List with add() [at
last pos] and removeFirst()
https://stackoverflow.com/questions/9580457/fifo-class-in-java#9580485
- LIFO
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Stack.html
https://stackoverflow.com/questions/302460/java-collections-lifo-structure#302474
Thanks BC
- (2386)How to flatten a Map of Lists?
someMap.values().forEach(someList::addAll); // requires to create/initialize the someList first
or:
List<String> someList = map.values().stream().flatMap(c -> c.stream()).collect(Collectors.toList());
From: https://stackoverflow.com/questions/18290935/flattening-a-collection
- (2388)How to instantiate an object of type parameter (a.k.a I created a class Template<Alias extends YYY>, how do I instantiate an object of type Alias)?
PROBLEM:
class MyClass<T>
{
T field;
public void myMethod()
{
field = new T(); // gives compiler error
}
}
SOLUTION1: with reflection (is it what's used by Java internally for Collection::toArray(Class)?)
class MyClass<T> {
private final Constructor<? extends T> ctor;
private T field;
MyClass(Class<? extends T> impl) throws NoSuchMethodException {
this.ctor = impl.getConstructor();
}
public void myMethod() throws Exception {
field = ctor.newInstance();
}
}
SOLUTION2: with a supplier
class MyClass<T> {
private final Supplier<? extends T> ctor;
private T field;
MyClass(Supplier<? extends T> ctor) {
this.ctor = Objects.requireNonNull(ctor);
}
public void myMethod() {
field = ctor.get();
}
}
...
MyClass<StringBuilder> it = new MyClass<>(StringBuilder::new);
From: https://stackoverflow.com/questions/299998/instantiating-object-of-type-parameter
- (2390)How to find Set difference with custom Comparator or equals method?
The easiest way to do it, is to simple use a TreeSet (with your custom Comparato: e.e. the GenusComparator in the code below).
NOTE: *You have to convert both sets to TreeSet(GenusComparator) for the retainAll() to work correctly.*
I fixed equals() and added hashCode() and toString().
public class Test {
public static void main(String[] args) {
Set<Animal> set1 = new HashSet<>(Arrays.asList(new Animal("Jaguar", "Panthera"),
new Animal("Margay", "Leopardus"),
new Animal("Tiger", "Panthera")));
Set<Animal> set2 = new HashSet<>(Arrays.asList(new Animal("Bobcat", "Lynx"),
new Animal("Cougar", "Puma"),
new Animal("Leopard", "Panthera")));
TreeSet<Animal> treeSet1 = new TreeSet<>(new GenusComparator());
treeSet1.addAll(set1);
TreeSet<Animal> treeSet2 = new TreeSet<>(new GenusComparator());
treeSet2.addAll(set2);
treeSet1.retainAll(treeSet2);
System.out.println(treeSet1);
}
}
class Animal {
public String species;
public String genus;
public Animal(String species, String genus) {
this.species = species;
this.genus = genus;
}
@Override
public boolean equals(Object obj) {
return obj instanceof Animal && this.species.equals(((Animal)obj).species);
}
@Override
public int hashCode() {
return this.species.hashCode();
}
@Override
public String toString() {
return this.species + "/" + this.genus;
}
}
class GenusComparator implements Comparator<Animal> {
@Override
public int compare(Animal animal1, Animal animal2) {
return String.CASE_INSENSITIVE_ORDER.compare(animal1.genus, animal2.genus);
}
}
Output:
[Jaguar/Panthera]
From: https://stackoverflow.com/questions/37956655/how-to-find-set-difference-with-custom-comparator-or-equals-method#37957011
- (2414)How to cast List<Object> to List<MyClass>
You can always cast any object to any type by up-casting it to Object first. in your case:
(List<Customer>)(Object)list;
NOTE: this is dangerous!
From: https://stackoverflow.com/questions/1917844/how-to-cast-listobject-to-listmyclass#1920865
- (2444)How to convert Eclipse project type from general to Java?
Under Project Properties -> Project Facets -> Convert to faceted form... you can select Java - this will add the Java functionalities to your project. There you can also add other facets like Dynamic Web Module if necessary.
From: https://stackoverflow.com/questions/9592081/convert-eclipse-project-type-from-general-to-java
- (2445)How to solve "Class model.XXX” is listed in the persistence.xml file but not mapped?
This is an Eclipse quirk. I recently had exactly this problem when I created a new JPA project with the JPA library configuration disabled, but didn't manually configure the JPA libraries before I created the entities by the Eclipse New JPA Entity wizard. After creating the entities I configured the JPA libraries in project's Build Path (just by adding target Java EE server runtime in Libraries), but the validation error still remains. I could solve it in at least one of following ways:
Rightclick persistence.xml file, JPA Tools -> Synchronize Class List.
Or, rightclick project, Validate.
Or, close/reopen project.
This is consistently reproducible. I was using Eclipse Indigo SR1. When I create the entities after configuring the JPA libraries, this validation error doesn't occur.
From: https://stackoverflow.com/questions/2242637/class-model-address-is-listed-in-the-persistence-xml-file-but-not-mapped#8288446
- (2448)How to catch splitted Strings within java Stream?
SOLUTION1
Using flatMap is not the right tool for the job. What you apparently want to do is
strings.map(string -> string.split(" ", 2))
.map(array -> new MyClass(array[0], array[1]))
You may process the stream further by using .collect(Collectors.toList()) to get a List<MyClass> or .findAny() to get a single MyClass instance (if any).
Generally, streaming an array is only useful if you want to treat all elements uniformly, i.e. not if their position has a special meaning which has to be preserved for subsequent operations.
SOLUTION2
And if you really want to create a flat stream of words or tokens, you shouldn’t use the combination of String.split and Arrays.stream as that will create and fill an unnecessary intermediate array. In this case use
strings.flatMap(Pattern.compile(" ")::splitAsStream)
see Pattern.splitAsStream
From: https://stackoverflow.com/questions/29807947/how-to-catch-splitted-string-in-java-stream#29825120
- (2466)How to hidde the Tab part of a JTabbedPane?
NOTE: this is a bad idea to divert a component from its intended use!
The solution consists in overriding the method that draws the tabs.
JTabbedPane tp = new JTabbedPane();
...
tp.setUI(new javax.swing.plaf.metal.MetalTabbedPaneUI(){
protected void paintTabArea(Graphics g,int tabPlacement,int selectedIndex){}
});
...
From: https://coderanch.com/t/344299/java/Hide-tabs-JTabbedPane#1512562
- (2467)How to generate Javadoc comments in Eclipse?
You can either use
/**<NEWLINE>
or
Shift-Alt-J
Auto-generated Javadoc comments in source code that have not been filled/updated with relevant content are both a waste of space on the screen and waste of time for the dev that will read/be fooled by them.
It is much much better to generate the Javadoc comment skeletons one by one as you are about to fill in the details.
From: https://stackoverflow.com/questions/1777175/how-can-i-generate-javadoc-comments-in-eclipse
- (2468)How to pause and resume a thread from another thread in Java?
You have to use a "monitor" Object:
class MyThread extends Thread {
JTextArea area;
private final Object GUI_INITIALIZATION_MONITOR = new Object();
private boolean pauseThreadFlag = false;
public MyThread(JTextArea area) {
super();
this.area = area;
}
@Override
public void run() {
for(int i=0 ; ; i++) {
checkForPaused();
area.setText(i+"");
}
}
private void checkForPaused() {
synchronized (GUI_INITIALIZATION_MONITOR) {
while (pauseThreadFlag) {
try {
GUI_INITIALIZATION_MONITOR.wait();
} catch (Exception e) {}
}
}
}
public void pauseThread() throws InterruptedException {
pauseThreadFlag = true;
}
public void resumeThread() {
synchronized(GUI_INITIALIZATION_MONITOR) {
pauseThreadFlag = false;
GUI_INITIALIZATION_MONITOR.notify();
}
}
}
NOTES:
1) From the OOP design pattern point of view, it is the responsibility of the "to be paused" Thread to manage its own status: it is the one that has to store/manage a boolean that represents its pause/not pause state.
2) A Thread cannot directly control the state of another. Particularly, a Thread cannot call wait() on another Thread (when thinking about it, it is logical: as only one single Thread can be in the "running" state at a single time step, if the second thread is running, then the ther one is asleep. Therefore, it is not possible to put it asleep a second time!)
3) To prevent an active waiting in the "paused" Thread, which would be very inefficient, the "paused" Thread uses wait(), which lets the OS manage Thread sleeping efficiently, without waiting too many CPU cycles.
4) Finally, we need to apply the wait()/notify() methods on another Object (the famous monitor) than the "paused" Thread itself for the simple and obvious reason that if the Thread would pause itself it would then be asleep and never able to wake itself up (and, as we've seen above, no other Thread has the right to wake it up...)
From: https://stackoverflow.com/questions/11989589/how-to-pause-and-resume-a-thread-in-java-from-another-thread#11990012
- (2471)How to get the short filename (MSDOS/8.3-format) using Java?
Use JNA (Java Native Access).
NOTE: THIS IS VERY DIRTY AS IT MAKES YOUR CODE NON-PORTABLE!!!!
import com.sun.jna.platform.win32.Kernel32;
//...
public class MyClass {
//...
private static Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
//...
public static String convertToWindowsShortName(String longFilename) {
char result[] = new char[longFilename.length()];
kernel32.GetShortPathName(longFilename, result, longFilename.length());
return new String(result).trim();
}
}
From: https://stackoverflow.com/questions/24101134/jna-windows-get-process-path
- (2472)How to increase the line width/color when drawing on a Granphics[2D]?
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.RED);
g2.setStroke(new BasicStroke(10));
g2.draw(new Line2D.Float(30, 20, 80, 90));
}
From: https://stackoverflow.com/questions/2839508/java2d-increase-the-line-width
- (2473)How to draw basic figures (lines, circles, rectangles) on a "canvas" in Swing?
BufferedImage surface = new BufferedImage(600,400,BufferedImage.TYPE_INT_RGB);
JLabel view = new JLabel(new ImageIcon(surface));
Graphics g = surface.getGraphics();
g.setColor(Color.ORANGE);
g.fillRect(0,0,600,400);
g.setColor(Color.BLACK);
g.drawLine(10, 20, 350, 380);
g.dispose();
From: https://stackoverflow.com/questions/10628492/dynamic-graphics-object-painting/10628553#10628553
- (2478)How to concatenate text in Thymleaf (MVC/GUI for SpringBoot)?
<p th:text="${bean.field1 + ' fixed string ' + bean.field2}">demo content</p>
or
<p th:text="${bean.field1} + ' fixed string ' + ${bean.field2}">demo content</p>
From: https://stackoverflow.com/questions/16119421/thymeleaf-concatenation-could-not-parse-as-expression
- (2479)What is the default Maven directory structure?
- src
- main
- java Main code
- resources Main resources (accessible through getClass().getResource("/"))
- test
- java Code for the test
- resources Resources for the tests
- assembly
- LICENSE.txt Project's LICENCE
- NOTICE.txt Notices and attributions required by dependencies
- README.txt Project's README
From: https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html
- (2480)Where to put Thymleaf (MVC/GUI for SpringBoot) template files?
Using Maven it is in:
src/resources/templates
From: https://stackoverflow.com/questions/41318005/how-to-locate-thymeleaf-template-from-spring-boot
- (2482)How to convert a Java Swing Image into a JavaFX Image?
BufferedImage bImage = ...;
Image image = SwingFXUtils.toFXImage(bImage, null); // JavaFX's Image!
From: https://stackoverflow.com/questions/30970005/bufferedimage-to-javafx-image#30970114
- (2483)How to make Maven "see" Eclispe's "Referenced Libraries"?
<dependency>
<groupId>com.package</groupId>
<artifactId>library</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}/src/lib/library.jar</systemPath>
</dependency>
From: https://stackoverflow.com/questions/24439580/maven-and-referenced-libraries
- (2500)How to use Java varargs?
NOTE: varargs must be last arguments of the method.
static int sum(int... args) {
int sum = 0;
for(int arg : args) {
sum += arg;
}
return sum;
}
BEWARE: using varargs passes references, contrarilly to separate args, thus values might be modified.
From: https://studiofreya.com/java/how-to-use-java-varargs/
- (2573)How to correctly benchmark code in Java?
Use jmh
From: http://openjdk.java.net/projects/code-tools/jmh/
https://www.baeldung.com/java-microbenchmark-harness
https://shipilev.net/blog/2014/nanotrusting-nanotime/
- (2614)What's the difference between "final" and "immutable" in JAva?
The keyword "final" represents "const", consider:
final Person someone = new Person();
This means someone can NEVER refer to another Person object. But, you can still change details of the person being referred. E.g. someone.setMonthlySalary(10000);
But, if someone was an "Immutable" object, one of the following would be true: (a) You would not have a method named setMonthlySalary (b) Calling setMonthlySalary would always throw an exception such as UnsupportedOperationException
From: https://softwareengineering.stackexchange.com/questions/149555/difference-between-immutable-and-const#answer-149567
- (2631)How to solve "An error has occurred. See the log file null" when opening Eclipse@Windows10?
Try to launch it from the console like:
C:\path\to\eclipse\eclipse -clean
Also you try to can delete the file to fix the problem permanently as suggested at https://www.metod.si/job-found-still-running-after-platform-shutdown-eclipse/. Command would be something like below for windows.
del YOUR_WORKSPACE/.metadata/.plugins/org.eclipse.core.resources/.snap
From: https://stackoverflow.com/questions/32944658/display-error-message-when-open-the-eclipse-an-error-has-occurred-see-the-log#answer-32944784
- (2634)How to run a quick code test/snippet in Eclipse?
You can use the Scrapbook:
Main Menu > New > Java Run/Debug > Scrapbook Page
You need to explicitly reference all class files using a full package name, but you can get around this by importing all the libraries (including the JRE libraries) you need onto the runtime classpath.
From: https://stackoverflow.com/questions/4861722/running-a-quick-code-test-in-eclipse
- (2635)How to add an external lib (e.g. Guava) to an Eclipse project?
To add a lib to the Eclipse build path simply right click on your project -> build path -> configure build path -> libraries tab -> add external jars -> locate you .jar file -> OK/OPEN
NOTE: It's generally better to create a Maven/Gradle/... project and use the version from the repositories
From: https://stackoverflow.com/questions/4648911/how-to-add-guava-to-eclipse-project#answer-4648947
https://stackoverflow.com/questions/4256988/the-very-basics-for-using-guava#answer-4257318
- (2705)How to create a Jar (UberJar&OneJar included) from Eclipse?
There are plenty of possibilities to generate a jar from Eclipse:
I] Via Eclipse (easy, but requires to redo the configuration at each jar generation)
- Menu "File>Export>Java> JarFile": creates only an archive with your own classes, not the project dependencies, nor the MANIFEST.MF with the main class
- Menu "File>Export>Java> Runnable JarFile": adds the project dependencies (quite brutally: decompresses them then adds them at the final UberJar root & creates a MANIFEST.MF with the main class name provided duringconfiguration
More details at: https://stackoverflow.com/questions/12811618/eclipse-manually-select-main-class-for-executable-jar-file/12811630#12811630
- Via Maven (more complicated, but configured only once => then it becomes part of the projet generation toolset)
- Without any maven plugin => creates a simple jar simple (archive without dependencies nor MANIFEST.MF)
=> use maven target "mvn package"
- maven-jar-plugin => also generates a MANIFEST.MF (main class & CLASSPATH where to find dependencies), BUT does not copy dependencies into the final UberJar
https://maven.apache.org/plugins/maven-jar-plugin/
https://stackoverflow.com/questions/10019549/how-to-eclipse-maven-install-build-jar-with-dependencies#10019803 (point3)
=> use maven target "mvn jar:jar"
- maven-assembly-plugin => includes a MANIFEST.MF (main class) & dependencies (brutally copied at the root of the final UberJar)
https://maven.apache.org/plugins/maven-assembly-plugin/
https://stackoverflow.com/questions/574594/how-can-i-create-an-executable-jar-with-dependencies-using-maven#574650
=> use maven targets mvn "clean compile assembly:single"
- maven-shade-plugin => includes a MANIFEST.MF (main class) & dependencies (copied brutally at the root of the final UberJar)
https://maven.apache.org/plugins/maven-shade-plugin/
https://stackoverflow.com/questions/10019549/how-to-eclipse-maven-install-build-jar-with-dependencies#10019803 (point1)
=> use maven target "mvn install"
- one-jar => includes MANIFEST.MF (main class) & dependencies (copied cleanly as "jars in the jar"... BUT the plugin needs to modify our code to inject a jars-in-UberJar-aware Classloader, might not work with all projects (e.g. infinite loop with "nu"/"openpnp" OpenCV-3 version...)
https://www.baeldung.com/executable-jar-with-maven#thymeleaf-3
=> utiliser les cibles maven "clean compile package onejar:one-jar"
- (2713)How to change Java-Project/Maven "execution environment" (=JDK version used)?
- Right-click on your project
- Click Properties
- Click the "Java Compiler" option on the left menu
- Under JDK compliance section on the right, change it to desired version
- Run a Maven clean and then Maven build.
From: https://stackoverflow.com/questions/14804945/maven-build-path-specifies-execution-environment-j2se-1-5-even-though-i-chang/14805111#14805111
- (2761)Why are Observable/Observer deprecated and what to used instead?
Observer and Obervable shouldn't be implement anymore.
- Why were they deprecated?
They didn't provide a rich enough event model for applications. For example, they could support only the notion that something has changed, but didn't convey any information about what has changed.
Alex's answer puts it nicely upfront that Observer has a weakness: all Observables are the same. You have to implement the logic that is based on instanceof and cast object to concrete type into Observable.update() method.
To add to it there were bugs like one could not serialize the Observable class because as it didn't implement Serializable interface and all of its members were private.
- What is a better alternative to that?
On the other hand Listeners have a lot of types and they have callback methods and don't require casting. As pointed by @Ravi in his answer you can make use of PropertyChangeListener and PropertyChangeSupport instead.
From: https://stackoverflow.com/questions/46380073/observer-is-deprecated-in-java-9-what-should-we-use-instead-of-it#46381645
- (2763)How to deep copy/clone a Buffered image (Swing/OpenCV)?
static BufferedImage deepCopy(BufferedImage bi) {
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(null);
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
From: https://stackoverflow.com/questions/3514158/how-do-you-clone-a-bufferedimage/3514297#3514297
- (2764)When using System.out.println() on an Integer, is unboxing or toString() used to convert the Integer to a String?
PROBLEM: In the code below, is unboxing or toString() called to convert "integer" arg to String?
Integer integer = new Integer(42);
System.out.println(integer);
ANSWER:
From JLS#15.12.2 (https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2.2) we know that, to determine the signature of the method to use, the JVM first tries NOT to use unboxing.
In our example, there exists a method System.out.println(Object), thus it will be used.
This method invokes Integer's toString() method for the conversion to String.
From: https://stackoverflow.com/questions/36594948/integer-in-system-out-println-unboxing-or-tostring
- (2765)How to decompile a class?
javap -c/-v <file.class>
From: https://stackoverflow.com/questions/36594948/integer-in-system-out-println-unboxing-or-tostring
- (2776)How to make maven read/compile for Java 8+?
SOLUTION1:
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
The Maven compiler accepts this command with -target and -source versions. If we want to use the Java 8 language features the -source should be set to 1.8.
Also, for the compiled classes to be compatible with JVM 1.8, the -target value should be 1.8.
The default value for both of them is 1.6 version.
SOLUTION2:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
SOLUTION3a: Java 9 and Beyond
Starting from JDK 9 version, we can use a new -release command-line option. This new argument will automatically configure the compiler to produce class files that will link against the implementation of the given platform version.
By default, the -source and -target options don't guarantee a cross-compilation.
This means that we cannot run our application on older versions of the platform. Additionally, to compile and run the programs for older Java versions, we also need to specify -bootclasspath option.
To cross-compile correctly, the new -release option replaces three flags: -source, -target and -bootclasspath.
After transforming our examples, for the plugin properties we can declare:
<properties>
<maven.compiler.release>7</maven.compiler.release>
</properties>
SOLUTION3b: Java 9 and Beyond
And for the maven-compiler-plugin starting from the 3.6 version we can write:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>7</release>
</configuration>
</plugin>
From: https://www.baeldung.com/maven-java-version
- (2792)How to place windows side-by-side / at relative positions? [TO VERIFY]
A] When placing JDialog position according to the parent JFrame
Just use setLocationRelativeTo() method for your JDialog.
JDialog d = new JDialog();
d.pack();
d.setLocationRelativeTo(COMPONENT);
//d.setLocationByPlatform(true);
here COMPONENT is parent frame.
From: https://stackoverflow.com/questions/21228932/how-to-set-jdialog-position-according-to-the-parent-jframe
B] When using two JFrames
[NOTE: this is a bad coding practice to have multiple "main" windows/JFrame]
setLocationRelativeTo() does not work in this case
Just position them yourself manually:
public class Test
{
public static void main (String[] args)
{
JFrame f1 = new JFrame();
f1. setSize(100, 100);
f1.setLocationRelativeTo(null);
f1.setVisible(true);
JFrame f2 = new JFrame();
f2.setSize(100, 100);
f2.setLocation(f1.getX() + f1.getWidth(), f1.getY());
f2.setVisible(true);
}
}
From: https://stackoverflow.com/questions/23039600/how-to-set-a-jframe-location-beside-another-jframe
- (2796)What does ClassName.this mean (a.k.a. How to access outer class attributes using anonymous Listeners)?
ClassName.this is a mean to tell the Java compiler we want to refer to the "outer" class' attributes/methods when inside a nested class.
This can be very useful when using anonymous Listener classes, like in:
class MyClass {
Integer counter = 0;
JButton button = new JButton("Increase Counter");
// ...
public static final void main(String args[]) {
// ...
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MyClass.this.counter += 1; // a simple "this" here would refer to the anonymous ActionListener, which does not have a "counter" attribute, thus will raise a compilation error
}
});
// ...
}
}
From: https://stackoverflow.com/questions/45637427/what-is-classname-this/45637841#45637841
https://stackoverflow.com/questions/4080868/using-this-with-class-name
- (2812)What's the difference between Float.POSITIVE_INFINITY and Float.MAX_VALUE?
- Float.MAX_VALUE is the largest finite value that can be represented in a float. You won't find any value greater than that, other than infinity. But you can perform all kinds of other operations on it.
- Float.POSITIVE_INFINITY is, well, infinity. Most operations involving an infinity will end up with infinity (either positive or negative).
From: https://stackoverflow.com/questions/9743487/whats-the-difference-between-float-positive-infinity-and-float-max-value/9743510#9743510
- (2815)How to modifying external variables inside lambdas?
PROBLEM: Any local variable, formal parameter, or exception parameter used but not declared in a lambda expression must either be declared final or be effectively final (§4.12.4), or a compile-time error occurs where the use is attempted.
https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.27.2
E.g.
int count = 0;
myIntStream.map(x -> { count++; return count; }).collect(Collectors.toList());
SOLUTION:
1. Making the variable static // DOES NOT WORK in a multi-threaded environment
2. Use Array // Trick: only the external variable inside lamdba must be final
3. Atomic Integer
From: https://dzone.com/articles/modifying-variable-inside-lambda
- (2851)How to read a file line by line with Java (Streams, BufferredReader, Scanner...)?
SOLUTION1:
package com.mkyong.java8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
public class TestReadFile {
public static void main(String args[]) {
String fileName = "lines.txt";
//read file into stream, try-with-resources
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
stream.forEach(System.out::println);
} catch (IOException e) {
e.printStackTrace();
}
}
}
SOLUTION2:
package com.mkyong.java8;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class TestReadFile2 {
public static void main(String args[]) {
String fileName = "lines.txt";
List<String> list = new ArrayList<>();
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
//1. filter line 3
//2. convert all content to upper case
//3. convert it into a List
list = stream.
filter(line -> !line.startsWith("line3")).
map(String::toUpperCase).
collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();
}
list.forEach(System.out::println);
}
}
SOLUTION3:
package com.mkyong.java8;
import java.io.BufferedReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class TestReadFile3 {
public static void main(String args[]) {
String fileName = "lines.txt";
List<String> list = new ArrayList<>();
try (BufferedReader br = Files.newBufferedReader(Paths.get(fileName))) {
//br returns as stream and convert it into a List
list = br.lines().collect(Collectors.toList());
} catch (IOException e) {
e.printStackTrace();
}
list.forEach(System.out::println);
}
}
SOLUTION4: BufferedReader
package com.mkyong.core;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class TestReadFile4 {
public static void main(String args[]) {
String fileName = "lines.txt";
try (BufferedReader br = new BufferedReader(new FileReader(fileName))) {
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
SOLUTION5: Scanner
package com.mkyong.core;
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class TestReadFile5 {
public static void main(String args[]) {
String fileName = "lines.txt";
try (Scanner scanner = new Scanner(new File(fileName))) {
while (scanner.hasNext()){
System.out.println(scanner.nextLine());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
From: https://mkyong.com/java8/java-8-stream-read-a-file-line-by-line/
- (2852)What is the difference between Comparator and Comparable in Java?
PROBLEM: How to compare objects that aren't directly comparable?
SOLUTION1: implement Comparable
public class Player implements Comparable<Player> {
//...
@Override
public int compareTo(Player otherPlayer) {
return (this.getRanking() - otherPlayer.getRanking());
}
}
The problem with this solution is that you can define only one single order (e.g. name OR age, but not both)
SOLUTION2: use an external Comparator
public class PlayerRankingComparator implements Comparator<Player> {
@Override
public int compare(Player firstPlayer, Player secondPlayer) {
return (firstPlayer.getRanking() - secondPlayer.getRanking());
}
}
PlayerRankingComparator playerComparator = new PlayerRankingComparator();
Collections.sort(footballTeam, playerComparator);
Note: with this solution you can define&use multiple external comparators along various attributes of the initial Objects
SOLUTION3: use lambdas
Comparator<Player> byRanking = (Player player1, Player player2) -> player1.getRanking() - player2.getRanking();
Or, more simple for basic data types:
Comparator<Player> byRanking = Comparator.comparing(Player::getRanking);
From: https://www.baeldung.com/java-comparator-comparable
- (2853)How to use Generics with multiple types?
Example: create a list of Objects that are either Lovable and Buyable
// We need to parametrize the method with a type that is both Lovable&Buyable!!!!
public static <E extends Lovable&Buyable> List<String> urlsOfLovableStuff(List<E> list, int threshold) {
return (list.stream().
filter(car -> car.lovability()>threshold)).
map( (E x) -> x.whereToBuy() ).
collect(Collectors.toList());
}
From: http://www.angelikalanger.com/GenericsFAQ/FAQSections/TypeParameters.html#What%20is%20a%20type%20parameter%20bound
- (2855)How to call a (e.g. more specific) constructor from another one (more generic)
public class Foo {
private int x;
public Foo() {
this(1);
}
public Foo(int x) {
this.x = x;
}
}
From: https://stackoverflow.com/questions/285177/how-do-i-call-one-constructor-from-another-in-java#285184
- (2856)What are the differences between StringBuffer and StringBuilder?
- StringBuffer is synchronized, StringBuilder is not.
- StringBuilder is faster than StringBuffer because it's not synchronized.
Good mnemonic for those who mix these two: BuFFer was First, older and therefore synchronized implementation. Newer Builder class uses Builder pattern and is asynchronous.
From: https://stackoverflow.com/questions/355089/difference-between-stringbuilder-and-stringbuffer/355092#355092
- (2857)How to use Rectangular Selection in Eclipse?
Pressing Shift + Alt + A toggles Block or Column selection mode
https://stackoverflow.com/questions/2665429/rectangular-select-in-eclipse-editor-as-in-any-microsoft-tools#2665448
- (2860)How to add comments and Javadocs in Eclipse with a single keystroke?
Shortcut Command Description
Ctrl+/ Toggle Comment Add/remove line comments (//…) from the current line. The position of the cursor can be anywhere on the line. Works with multiple selected lines as well.Alternatively, you can also use Ctrl+Shift+C, which probably works better on a QWERTZ keyboard (eg. German layout), or Ctrl+7.
Ctrl+Shift+/ Add Block Comment Wrap the selected lines in a block comment (/*… */).
Ctrl+Shift+/ Remove Block Comment Remove a block comment (/*… */) surrounding the selected lines.
Alt+Shift+J Add Javadoc Comment Add a Javadoc comment to the active field/method/class. See the notes below for more details on where to position the cursor.
Bear the following in mind when using Add Javadoc comment (Alt+Shift+J):
- To add a comment to a field, position the cursor on the field declaration.
- To add a comment to a method, position the cursor anywhere in the method or on its declaration.
- To add a comment to a class, the easiest is to position the cursor on the class declaration. Also works if you’re in the class, but not in a method, field or nested type.
- The Javadoc comment inserted is based on the Code Templates defined under Window > Preferences > Java > Code Style > Code Templates. If you expand the Comments section, you can change the default for Fields, Methods, Types (eg. classes), etc.
From: http://www.eclipseonetips.com/2010/05/05/add-comments-and-javadocs-in-eclipse-with-a-single-keystroke/
- (2880)How to edit a class with the GUI Designer in Eclipse?
1. You need to install the WindowBuilder extension (which requires SWT Designer)
2. Right click on the class -> Open With -> WindowBuilder Editor
If it does not work, this might be that your project's JVM version (13/14?) is not compatible with Window Builder's.
=> Try lowering it. Right Click on Project > Properties > Java Compiler > JDK Compliance. Set it to 1.8 for instance.
From: https://www.eclipse.org/forums/index.php?t=msg&th=237691&goto=720647&#msg_720647
- (2881)How to make Eclipse use Spaces instead of Tabs?
Java Editor
Click Window » Preferences
Expand Java » Code Style
Click Formatter
Click the Edit button
Click the Indentation tab
Under General Settings, set Tab policy to: Spaces only
Click OK ad nauseam to apply the changes.
[Note: If necessary save profile with a new name as the default profile cannot be overwritten.]
Default Text Editor
Click Window » Preferences
Expand General » Editors
Click Text Editors
Check Insert spaces for tabs
Click OK ad nauseam to apply the changes.
Note that the default text editor is used as the basis for many non-Java editors in Eclipse.
From: https://stackoverflow.com/questions/407929/how-do-i-change-eclipse-to-use-spaces-instead-of-tabs/408449#408449
- (2893)How to find the index of the min/max value of a list the Java8 way (i.e. using Stream/Lambdas)
The "trick" is to loop over the list indexes not the list content (exactly like a for loop would do) and use get("curent_pos") to access the value to be compared.
SOLUTION1:
import static java.util.Comparator.comparingInt;
int minIndex = IntStream.range(0,list.size()).boxed()
.min(comparingInt(list::get))
.get(); // or throw if empty list
SOLUTION2:
int minIdx = IntStream.range(0,list.size())
.reduce((i,j) -> list.get(i) > list.get(j) ? j : i)
.getAsInt(); // or throw
From: https://stackoverflow.com/questions/31116190/java-8-find-index-of-minimum-value-from-a-list/31116474#31116474
- (2934)How to force the creation of a Maven directory structure on a project (e.g. created as Java, then switched to Maven)?
1. Right click on the Project
2. Goto "Build Path" > "Configure Build Path"
3. In "Order and Export tab", you can see the message like '2 build path entries are missing'
4. Now select 'JRE System Library' and 'Maven Dependencies' checkbox
5. Click OK
--
- Open Properties > Java Build Path for the project
- Select the Source tab
- Add Folders to add source folders.
From: https://stackoverflow.com/questions/22914927/creating-a-src-main-java-folder-structure-in-eclipse-without-maven/37846753#37846753
- (2935)How do I enable index downloads in Eclipse for Maven dependency search?
- Windows > Preferences
- Maven in the left side
- Check the box "Download repository index updates on startup".
Optionally, check the boxes "Download Artifact Sources" and "Download Artifact JavaDoc".
- Click OK
- Restart Eclipse.
BEWARE that your Eclipse might freeze at startup later on while the indexes are being downloaded :{
Also see Tip#2936
From: https://stackoverflow.com/questions/24252256/how-do-i-enable-index-downloads-in-eclipse-for-maven-dependency-search/24494049#24494049
- (2936)How do I (graphically) add a Maven dependency in Eclipse?
Once indexing is complete (see below):
7. Right-click on the Project
8. Maven > "Add Dependency"
9. Start typing the name of the project you want to import (such as "hibernate")
NOTE: for this, you need the indexes to be downloaded:
1. Window > "Show View" > Other
2. "Show View" window > "Maven" > "Maven Repositories"
3. Right-click on "Global Repositories"
4. Select "Go Into"
5. Right-click on "central (http://repo.maven.apache.org/maven2)"
6. Select "Rebuild Index"
NOTE: it will take a while to complete the download :{{{
Also see Tip#2935
From: https://stackoverflow.com/questions/9164893/how-do-i-add-a-maven-dependency-in-eclipse#26350902
- (3042)How to import a Git(Lab) projet in Eclispe?
1. Install the Git extension
- Open Menu "Help" > "Install New Software"
- Search for "Git Integration for Eclipse"
- Check the box (it might ask for installing "Java implementation of Git", accept it)
- Click Finish & Accept licences to Install
2. Set up the local copy of the git repository
- Switch to Git view
+ Windows > Show View > Other
+ Search for Git
+ Select "Git repositories"
- Setup a Git repo (in the "Git repositories" view)
+ Click the button/icon that correspond to your situation (Add an Existing Local Repo / *Clone a repo* / Create a repo)
+ Follow the instructions
3. Import a given branch of the repo as a project
- Go to the "Git repositories" view
- Right click on the repository from which you want to import code into an Eclipse project
- Select "Import Projects"
- Follow the instructions
You can then switch branches, the project will sync with the local copy of the git repo
From: https://www.youtube.com/watch?v=WSdIbqw7Kz4
https://www.youtube.com/watch?v=Fv_5KEN6Ix4
- (3043)How to solve Eclipse's error: "Some projects cannot be imported because they already exist in the workspace error"?
Depending on how you import the project, one of the following might work:
- Uncheck the "copy projects into workspace" checkbox, and then click "refresh" button, you will be able to import the project
- Go to .project file in your project and change the name of the project in name tag
- Go to your workspace directory and remove/rename the directory that already exists
- Do not "import a project into your workspace" but "import a project from existing files"
- (3097)How to find out what plug-ins are installed in Eclipse (2020-06+)?
Help > About Eclipse IDE > Installation Details
From: https://wiki.eclipse.org/FAQ_How_do_I_find_out_what_plug-ins_have_been_installed%3F
- (3098)How to Uninstall an Eclipse Plugin?
- Run Help > About Eclipse > Installation Details
- Select the software you no longer want and click Uninstall.
From: https://wiki.eclipse.org/FAQ_How_do_I_remove_a_plug-in%3F
- (3109)Howto remove the welcome/startup splash screen in Eclipse?
Open it, at the bottom right, there's a checkbox with "Always show Welcome at start up". Uncheck it!
You can also access it at Preferences > IDE > General > "Show Welcome View"
From: https://mcuoneclipse.files.wordpress.com/2017/05/option-to-control-welcome-at-startup.png
https://mcuoneclipse.files.wordpress.com/2017/05/show-welcome-view.png
https://mcuoneclipse.com/2017/05/13/customizing-welcome-view-and-splash-screen-in-eclipse-neon/
- (3117)How to configure Maven to execute/run the compiled code?
Use the "exec" plugin
mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"] ...
From: https://www.mojohaus.org/exec-maven-plugin/usage.html
https://metamug.com/article/java/build-run-java-maven-project-command-line.html#maven-run-command
- (3125)How to format numbers *in the source code*?
You can use _ as a thousands separator! This makes large number more readable!
public static void main(String[] args) {
System.out.println("Underscore allowed as seperator", 10_000);
}
NOTE: works in other languages too!
From: https://rosettacode.org/wiki/Numeric_separator_syntax#Java
- (3133)How to convert a Map to a List in Java 8?
// Java 8, Convert all Map values to a List
List<String> result4 = map.values().stream()
.collect(Collectors.toList());
// Java 8, seem a bit long, but you can enjoy the Stream features like filter and etc.
List<String> result5 = map.values().stream()
.filter(x -> !"apple".equalsIgnoreCase(x))
.collect(Collectors.toList());
NOTE: You need
1) To transform the initial collection into a .stream() to get access to Java 8 stream/lambdas facilities
2) To collect the results into a List with .collect(Collectors.toList());
From: https://mkyong.com/java8/java-8-convert-map-to-list/
- (3173)What is the basic Maven archetype for a Java project?
maven-archetype-quickstart
From: https://maven.apache.org/guides/introduction/introduction-to-archetypes.html
- (3214)What is the difference between the Java Access Modifiers - Public, Private, Protected & Default?
- public class member: can be accessed from *any other class* regardless of the package boundary.
- private class member: cannot be accessed from outside the class; only members of the *same class* can access these private members.
- protected class member: only accessible by the classes of the *same package* and the *subclasses of any package*.
- default class member: the scope of this modifier is limited to the *package only*.
From: https://www.javaguides.net/2018/10/java-access-modifiers-public-private-protected-default.html
- (3729)How to use the Maven version that is embedded in Eclipse directly from the command line?
It is possible to use Embedded Maven
- Add de installation-path\bin in variable PATH
- Define M2_HOME=installation-path
- Define JAVA_HOME
Installation path could be something like
~/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3/bin
From: https://stackoverflow.com/questions/33414625/how-to-use-eclipse-embedded-maven-installation-from-the-command-line/60497882#60497882
- (3791)How to zoom in/out in IntelliJ?
- Go to Preferences > Keymap
- Look for "Increase Font Size" and "Decrease Font Size"
From: https://stackoverflow.com/a/26436771
- (366)Basic R commands
* Général :
on est en fonctionnel, donc quand on donne une commande, comme order(x), ça renvoie le x trié, il faut le récupérer. De même, quand on donne juste le nom d'une fonction, ça affiche son code.
* Chercher de l'aide sur une commande
help("<command name>")
* Afficher le contenu d'un objet
<nom de l'objet>
print(<nom de l'objet>)
* Spécifier l'encoding à utiliser
encoding("latin1")
encoding("utf8")
* Charger un fichier
read.csv("/path/to/file")
* Fusionner des vecteurs/matrices
cbind(mat,vectcol) : coller vectcol comme dernière? colonne de mat
rbind(mat,vectligne) : coller vectcol comme dernière? ligne de mat
merge(mat,mat) : équivalent d'un join en BD : fusionne deux dataframes en fonction d'une ou plusieurs lignes (resp. colonnes) si fusion pas possible (ex: pas de valeur commune?) renvoie toutes les combinaisons des valeurs présentes.
* Connaître les dimensions d'un objet
dim(objet) <-> dimension 2 (matrice, table, dataframe)
length(objet) <-> dimension 1 (vecteur)
* Connaître les noms des colonnes d'un objet
dimnames(objet) <-> tables
colnames(objet) <-> matrices?
names(objet) <-> dataframes?
* Différence entre vecteur/liste/table/matrice/dataframe, etc.
- Vecteur = ensemble d'object basique de dimension 1
- Liste = ensemble d'objets nommés de dimension 1 (<=> hashtable dans d'autres langages)
- Table = résultat de table(), composé d'une ligne de names et une ligne de valeurs
- Matrice = que des nombres ?
- dataframe = dimension 2, avec éléments de types différents, infos supplémentaires (colnames, etc.)
* Récupérer des infos sur un objet
summary(objet) : renvoie qq analyses stats sur le dataframe
head(objet) : affiche les premières ligne d'un objet
* Compter les occurence d'élements
table(objet)
* Supprimer les doublons / récupérer la liste des éléments qui apparaîssent dans l'ensemble des données
unique(dataframe$colonnes)
* Chercher les éléments communs entre deux vercteurs/etc.
match(a,b) : si trouve a dans b, retourne les indices des a dans b
intersect(a,b) : renvoie les éléments communs à a et b (l'intersection des ensembles)
* Trier un vecteur/matrice
sort(vector) : renvoie le vecteur trié
order(x) : renvoie un vecteur donnant la liste de permutations à opérer pour trier l'objet (vecteur d'indices des éléments dans l'objet original)
* Concaténer des chaînes de caractères
paste(deb,fin)
* Faire des itérations
for (x in <vector>) { ... }
ATTENTION en R on peut éviter des boucles en faisant une utilisation intelligente des [] : <dataframe>[order()]
* Récupérer des sous-éléments d'un dataframe
data[<contraintes sur les ligne>,<contraintes sur les colonnes>]
<dataframe>$ColName == <dataframe>["ColName"]
X[-1,] récupère tout sauf la première ligne
X[,-1] récupère tout sauf la première colonne
ATTENTION en dimension 2, utiliser <dataframe>["ColName",] pour récupérer un élément de dimension 2 et non un vecteur
X[[1]] renvoie le premier élément d'une liste.
* Enlever les NA / remplacer les NA par des 0 (="not available")
data[is.na(data),] <- 0
* Do a logical AND or OR between vector values: BE CAREFUL!!! The && will generally not do what you want:
'&' and '&&' indicate logical AND and '|' and '||' indicate
logical OR. The shorter form performs elementwise comparisons in
much the same way as arithmetic operators. The longer form
evaluates left to right examining only the first element of each
vector. Evaluation proceeds only until the result is determined.
The longer form is appropriate for programming control-flow and
typically preferred in 'if' clauses.
* Parcourir un répertoire
fileNames = system("ls <dirname>",intern=T) # or fileNames = list.files() ;
for (i in fileNames) { ... }
* Appliquer une fonction sur un ensemble de données (équiv. bcl for)
base::apply(X, [1|2], FUN) # exécute FUN sur les lignes(1)/cols(2) de df et retourne un array (si FUN retourne un vector) ou un vector (si FUN retourne un seul élement)
base::lapply(X, FUN) # exécute FUN sur chaque élément de la list et retourne une liste de même taille
base::sapply(X, FUN) # exécute FUN sur chaque élément de X et retourne un vector
base::replicate(n, expr) # exécute n fois expr
base::Filter(f, X) # ne conserve que les éléments pour lesquels la fonction (booléenne) renvoie TRUE
base::Map(f, X) # applique f indépendemment sur chaque élément
base::Reduce(f, X) # applique une fonction binaire (de 2 arguments, ex: intersect) successivement sur les éléments de X [à la façon d'une fenêtre glissante] en combinant les résultats pour faire comme si on avait appliqué f directement sur l'ensemble des éléments.
plyr::ldply(.data=lst, .fun) # exécute .fun (qui renvoit des vector) sur les éléments de lst et combine le résultat en une df
plyr::llply(.data=lst, .fun) # exécute .fun successivement sur chaque éléments de la liste
* Dessiner / Plotter les données
plot(A$Col1, B$Col2) # plot(x, y) : met des points à (x=Col1 de A, y=Col2 de B)
* Mettre plusieurs dessins les uns à côté des autres
oldpar <- par(mfcol=c(2,2),cex=.5) # 1. saves plot config / 2. configures a 2*2 matrix of independent plots
plot(...) # first plot
plot(...) # second plot
plot(...) # ...
par <- oldpar
* Mettre plusieurs dessins les uns sur les autres
points()
plot(A$Col1 ~ B$Col2) # plot("y en fonction de x") : plot Col1 de A (y) en fonction de Col2 de B (x)
* Get the length of a string
nchar(str)
* From: http://www.childrensmercy.org/stats/weblog2005/StringsR.asp
* paste() combines several strings together into a single string.
* substr() selects substrings.
* format() makes a set of numbers print out more nicely (also see sprintf! Tip#374/659).
* chartr() converts specific characters in a string to different characters.
* tolower() converts all the letters in a string to lower case.
* toupper() converts all the letters in a string to upper case.
* casefold() will perform either of the two conversions shown above.
* a %in% b returns a logical value of TRUE for each value of a which can be found somewhere in list b and FALSE if that value cannot be found.
* pmatch(), match(), charmatch() work similarly but with subtle variations (e.g. returns indexes instead of T/F).
* grep() searches for matches to a pattern.
* strsplit() splits a string into several pieces.
* makeUnique() is found in the limma package and adds numbers to the ends of duplicate strings to give each one a unique name.
* trimWhiteSpace() is found in the limma package and removes leading and trailing blanks from a string.
* Manipulation de fichiers
help(dir) => dir.create()
help(file) => basename()/dirname() pour manipuler les noms de fichiers
* Comment faire retourner deux valeurs à une fonction ?
le plus sûr est d'utiliser une list; si on utilise des vectors, le resultat est *un unique* vector plutôt qu'une collection de
deux vectors. Generic pattern :
maFonction <- function() {
a <- 1
b <- 3
list(un=a,trois=b)
}
nombres=maFonction()
nombres$un
nombres$trois
* Comment mettre en forme des entiers (ex: imprimer des zeros devant pour avoir toujours le même nombre de caractères)
olddata$NUMFUA <- sprintf("%019.0f",olddata$NUMFUA)
* Comment dessiner un scatterplot (groupe de plot comparant des attributs 2 à 2)
pairs(<dataframe>)
* Comment sortir les graphiques dans des fichiers pdf ou png?
pdf("<nomfichier>.pdf") ;
<instructions graphiques>
dev.off() ;
* Comment libérer de la mémoire
delete.all <- function() { rm(list=ls(pos=.GlobalEnv), pos=.GlobalEnv) }
delete.all()
graphics.off()
From: http://snipplr.com/view/4013/r-clean-workspace
- (373)Functions to work on Strings
nchar(unqoldnumvol) : nb chars.
http://www.childrensmercy.org/stats/weblog2005/StringsR.asp
As part of my efforts to analyze microarray data, I am finding that I need to do simple string manipulations in R. Here is a list of functions that might help.
* paste() combines several strings together into a single string.
* substr() selects substrings.
* format() makes a set of numbers print out more nicely.
There are several functions that will convert one string into another string.
* chartr() converts specific characters in a string to different characters.
* tolower() converts all the letters in a string to lower case.
* toupper() converts all the letters in a string to upper case.
* casefold() will perform either of the two conversions shown above.
Several functions help find matches between two lists.
* a %in% b returns a logical value of TRUE for each value of a which can be found somewhere in list b and FALSE if that value cannot be found.
* pmatch(), match(), charmatch() work similarly but with subtle variations.
Several functions will use regular expressions.
* grep() searches for matches to a pattern.
* strsplit() splits a string into several pieces.
A nice tutorial, by the way, on regular expressions is at:
* en.wikibooks.org/wiki/Programming:Perl_Regular_expressions
There are several string manipulation functions found in the limma package, including
* makeUnique() is found in the limma package and adds numbers to the ends of duplicate strings to give each one a unique name.
* trimWhiteSpace() is found in the limma package and removes leading and trailing blanks from a string.
- (374)How to print ints with a predifined number of digits?
olddata$NUMFUA <- sprintf("%019.0f",olddata$NUMFUA)
print ints with leading 0's
- (375)Funtions to work on files/directories
help(dir) => dir.create()
help(file) => basename/dirname pour les noms de fichiers
- (376)How can I return two values in a function?
safer to wrap the results into a list; if both foo and bar are vectors,
the returned result would be *one* vector rather that a collection of
two vectors. so the generic pattern would be:
<function> = function(<args>) {
<body>
list(<values>)
}
?return
- (424)How to change the range of the plots?
xlim, ylim
- (425)How to search for the position of a value in a vector?
- match()
- which()
- (a)grep()
- (426)How to remove doubles in a vector? [Hack]
unique(match(v,v)) ;
- (427)How to know how to use a given function? Get examples of use?
example(<funname>) ;
- (428)Beware of the recycling rule of R
When two vector of the same size are expected and R gets 2 vectors of different sizes, it concatenates the shortest one several time until it gets the same size as the longest one. E.g.:
> c(1,2,3) + c(1,2,3,4,5)
[1] 2 4 6 5 7
which is indeed:
> c(1,2,3,1,2) + c(1,2,3,4,5)
- (429)How to select all elements that are above 95% or below 5%?
v[(v<quantile(v,.05))|(v>quantile(v,0.95))]
- (430)How to select all elements that are within mean+/-2*sd?
v[abs(v-mean(v))>2*sd(v)]
- (431)How to know if a vector contains a certain value?
- any(v==TRUE)
- all(v==TRUE)
- %in%
- (432)How to create sequences?
use 'rep()' or 'seq()' or ':' if appropriate
- (433)How to know the class/type of an object?
- use class() or mode()
- For Gtk objects (that can be polymorphic, i.e. belong to several classes),
DO NOT use:
if (class(obj)==GtkXXX) {}
but
if (is(obj,"GtkXXX")) {}
- (434)How to access Hidden variables?
- Hidden variables are those that start with a "."
- to list them, use ls(all.names=TRUE) ;
- (435)How to get informations on the currently defined variables?
ls.str() ;
- (436)What is the difference between print/cat?
- 'print()' can print almost any element (even composed ones)
- 'print()' cannot print several elements at once (=> need to use 'paste()')
- 'cat()' can print only basic object types
- 'cat()' can print several elements in a continuous output
- (437)On the use of &/&& and |/||
~&~ and ~&&~ indicate logical AND and ~|~ and ~||~ indicate logical
OR.
The shorter form performs elementwise comparisons in much the same way
as arithmetic operators.
The longer form evaluates left to right examining only the first
element of each vector. Evaluation proceeds only until the result is
determined.
The longer form is appropriate for programming control-flow and
typically preferred in ~if~ clauses.
- (438)How to access list elements?
mylist[i:j] returns a list of several elements, the ones from positions i to j
mylist[[i]] returns /the element/ at position i
mylist$name returns /the element/ named "name"
- (439)How to get an ascii representation of your data?
dump() ;
- (440)How to find a suitable package for a certain task?
- List of packages by domain: http://cran.r-project.org/web/views/
- List of packages ordered alphabetically: http://cran.r-project.org/web/packages/
- (441)How to get help on a function/package in R?
To know what libs are loaded:
library()
.libPaths()
If you know or have loaded the package that defines the function:
- ?'some.function' <=> help("some.function")
- ??'some.function' <=> help.search("some.function")
- apropos("some.function")
- vignette(package="packagename")
Otherwise:
- find("some.function")
- getAnywhere("some.function")
To get examples of usage:
- example("some.function")
- demo("some.function")
If you have no clue about the package:
- sos::findFn("some.function")
- RSiteSearch("some.function")
- http://rseek.org/
- http://crantastic.org/
- https://cran.r-project.org/web/packages/<packagename>/index.html
If you look for infos about the package itself:
- View(available.packages())
- View(installed.packages())
- search() # which packages are loaded
- packageDescription()
- news(package="")
From: http://stackoverflow.com/questions/7027288/error-could-not-find-function-in-r
http://stackoverflow.com/questions/15289995/how-to-get-help-in-r#15290370
- (442)How to make Java/rJava not circumvent R's environment variables? [Linux only]
Create a ~/.Renviron file with the following lines:
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
- (443)How to get line numbers from a data.frame?
data$NUMBER <- row.names(data) ;
- (444)How to compare objects in if/while statements in R?
From "?identical":
A call to ~identical~ is the way to test exact equality in ~if~
and ~while~ statements, as well as in logical expressions that use
~&&~ or ~||~. In all these applications you need to be assured of
getting a single logical value.
Users often use the comparison operators, such as ~==~ or ~!=~, in
these situations. It looks natural, but it is not what these
operators are designed to do in R.
- (445)How to print the elements of a vector/list in a sigle line?
print(paste("value=",vector,collapse=',')) ;
- (446)Remove elements from a vector (!! probably also removes doubles !!!)
# Returns vector cols, with elements of vector "colsToRemove" removed
removeElements <- function(eltsToRemove, elts)
{
return(setdiff(elts, eltsToRemove)) ;
}
- (447)How to connect to an oracle DB?
library(RJDBC);
drv <- JDBC("oracle.jdbc.OracleDriver",
"/path/to/ojdbc14.jar",
identifier.quote="`");
conn <- dbConnect(drv, "jdbc:oracle:thin:@<db server ip>:1521:<sid>", "<username>", "<password>");
dbGetQuery(conn, "SELECT * from BD_NAME") ;
- (448)Pièges classiques
-> Variables "XXX" définie dans l'environnement global et utilisée par erreur à la place d'une variable locale "XXXs" à l'intérieur d'une function
-> Boucle for(i in 1:ncol(X)-1) [le -1 s'applique à tout le vecteur 1:Y ! Ce dernier commence donc à 0!] au lieu de for(i in 1:(ncol(X)-1))
-> colnames(varThatDoNotExist) => c() au lieu d'une erreur dans une function ???
-> Use mydata[mydata$X=="Y"] (returns a vector) instead of mydata[mydata$X=="Y",] (returns a data.frame)
-> ifelse(TRUE,c(1,2,3),5) returns only 1, because ifelse(c(x,y,z),c(1,2,3),c(-1,-2,-3)) returns 1/-1 if x==TRUE/FALSE , 2/-2 if y==TRUE/FALSE and 3/-3 if x==TRUE/FALSE
-> x < - y+1 (with a space between '<' and '-') => computes "x is inferior to -y+1" instead of "affecting y+1 to x"
- DO NOT use: if (class(obj)==GtkXXX) {} (particularly with Gtk objects, since they can be polymorphic, i.e. belong to several classes), rather use if (is(obj,"GtkXXX")) {}
- (449)Coding style
-> When writing on several lines, it's better to write them like that:
plop <- a+b+c+
d+e+f
rather than:
plop <- a+b+c
+d+e+f
because in the first case R is forced to see that the line is not terminated. In the second case, it could happen that R considers the first line terminated, so the computation is erroneous AND the second line is erroneous
- (450)How to make a GUI? - 1
1. use library("Rgtk2")
2. make the gui with glade and save it in the GtkBuilder format
3. load the GUI in R with
# Initializes an GLOBAL object to load a GUI built with Glade
myGUI <- gtkBuilderNew() ;
# Load the XML file generated by Glade
gtkBuilderAddFromFile(myGUI, "path/to/glade/xml/file") ;
# Connect the signals listed in the builder XML file
gtkBuilderConnectSignals(myGUI) ;
4. you can access the various object composing the GUI with
obj1 <- gtkBuilderGetObject(guiObject, "component ID/name") ; # NOTE: Gave names/ids to the objects in glade!
- (451)How to make a GUI? - 2 [EASIER!]
install.packages("gWidgetsRGtk2", dep=TRUE) ;
require("gWidgets") ;
options("guiToolkit"="RGtk2") ;
And then have a look at:
http://cran.r-project.org/web/packages/gWidgets/vignettes/gWidgets.pdf
to understand how to use it
- (452)How to make a GUI? - 3
- Je conçois l'interface avec glade (apparemment il marche sur windows
aussi, reste "juste" à connecter les signaux, mais c'est très facile en
R puisqu'il suffit de donner le nom de la fonction de CallBack) :
http://glade.gnome.org/
Le fichier XML résultant de l'utilisation de Glade décrit la GUI et
peut être chargé grâce à un objet GtkBuilder de RGtk2.
- Je code le reste en RGtk2 :
http://www.ggobi.org/rgtk2/ (c'est le site de base, mais il n'y a pas
beaucoup de documentation, juste quelques exemples...)
http://www.jstatsoft.org/v37/i08/paper (un papier avec quelques
exemples, très clair mais pas très complet)
http://rss.acs.unt.edu/Rdoc/library/RGtk2/html/ (j'utilise cette doc
HTML plutôt que la version locale incluse dans R, car les liens
hypertexte sont bien pratique pour se balader dans la structure assez
complexe des types de Gtk)
- J'utilise pas mal la doc de pyGTk, qui est beaucoup plus complète que
celle de RGtk2 :
http://www.pygtk.org/pygtk2tutorial/ (il faut jongler un peu avec le
langage qui est assez différent, mais au moins ça donne les principes à
suivre, des fonctions à appeler et des événements à intercepter. Par
exemple, pour récupérer la valeur selectionnée dans une combobox, je
n'ai trouvé que dans cette doc)
Il y a aussi le code de RGtk2gWidgets qui peut aider à comprendre les
différentes fonction/events
Pour info, RGtk2 utilise les principes de Programmation Orientée Objet
(POO) en R, mais avec le package OOP, pas les S3 et S4 de base du
langage [les docs pour S3 et S4 sont accessibles à ?Classes et
?Method]. Une très bonne doc sur la POO en R se trouve dans le
chapitre 10 de "R in a Nutshell". Et pour le package OOP plus
particulièrement l'appendix E de "Using R for introductory
Statistics".
Sinon, en cherchant comment faire des interfaces graphiques en R,
j'avais aussi vu Tcl/Tk et gWidgets. Si je devais recommencer une
interface de zéro, je pense que c'est gWidgets que j'utiliserais, car
l'API est super simple (malheureusement on ne peut pas utiliser glade
avec cette API).
Sinon mes bouquins de référence sont :
- "The R book"
- "R in a Nutshell"
- "R Cookbook"
- (453)How to use a GtkSpinButton?
A RGtk2::SpinButton does work only if a GtkAdjustment is associated to it (RTFM !!!)
- (454)How to change a global variable from within a function?
To store a value into a global variable, even from within a function, you have to use "<<-" instead of "<-"
- (455)If you get the following error in R:
"Error in asCairoDevice(graphics) : Graphics API version mismatch"
Then remove any Gtk2/cairoDevice package installed and install them /directly within R/, using:
> install.package("RGtk2") ;
> install.package("cairoDevice") ;
- (456)If you get the following error using RGtk2+cairoDevice:
"Error in plot.new() : figure margins too large "
Just make so that your GtkDrawingArea is of squared dimensions (e.g. 800x800). Eventually, put it inside a GtkScrolledWindow (and therefore, you'll need to put a GtkViewPort inside the GtkScrolledWindow before adding the GtkDrawingArea :))
- (457)How to get an object by name?
use:
> get("objectname") ;
- (458)How to get the signature of a function?
use:
> args(<function>) ;
- (459)How to see the code a a hidden function?
use getAnywhere(...) ;
- (460)How to do OOP in R?
- ?Methods
- list classes : getClasses(...)
- definition (S4) : setClass(...)/setMethod(...)/setValidity(...)/
- creation of an instance : new() ;
- list methods : methods("classname") ; / getMethods(...)
- access slots : object@slot
- inheritance : use the 'contains=' argument in setClass(...)
also see the "OOP" package
- (461)Dirty way to force an rbind on 2 dataframes with != colnames
> t(dataframe(t(a),t(b))) ;
Indeed, on some cases, I got this strange error:
> rbind(myDataFrame,matrix(ncol=6,nrow=3))
Error in match.names(clabs, names(xi)) :
names do not match previous names
- (462)How to know the RAM size used by an object?
object.size(a) ;
- (463)How to clean (all) the objects created by the user?
rm(list=ls()) ;
- (464)How to initialize a data.frame?
> df <- data.frame(matrix(ncol = 300, nrow = 100))
> dim(df)
[1] 100 300
From: http://stackoverflow.com/questions/4868903/r-initializing-data-frames
- (465)How to make GUIs in R?
library(RGtk2) or library(RGtkGen)
- (466)How to load a library?
library("<library name>")
- (467)How to debug a function in R (a.k.a. How to get more information on a method after crashed)?
1) Simplest way: Post-mortem analysis
Once a function has crashed, run:
> traceback()
2) More complex way: Run the function step-by-step
?debug
?browser
?trace
From: http://r.789695.n4.nabble.com/Package-mice-Error-in-if-meth-j-quot-quot-argument-is-of-length-zero-td3437515.html
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/
- (468)"Error in if (...) { : argument is of length zero"
The 'if' returns a vector of length zero when it does not match => do not test with NULL, but if the length is 0:
if (length(...) != 0)
or use is.null()
From: http://r.789695.n4.nabble.com/argument-is-of-length-zero-td1589995.html
- (469)How to correct the body of a funtion after defining the function?
> fix(<funciton name>)
> edit(<funciton name>)
=> will edit the function body in the default $EDITOR
- (503)How to work with switches and strings?
y <- "fruit" ;
switch(y, fruit = "banana", vegetable = "broccoli", "Neither") ;
[1] "banana"
BUT:
To choose from a list of alternatives that already exists switch may
not be the best way to select one for evaluation. It is often better
to use eval and the subset operator, [[, directly via
eval(x[[condition]]).
- (504)How to recover string values from a list of factors numbers?
> levels(<column of factors>)[<list of indices>]
> df <- data.frame(c=c("a","b","b","a"))
> df
c
1 a
2 b
3 b
4 a
> df$c
[1] a b b a
Levels: a b
> levels(df$c)
[1] "a" "b"
> levels(df$c)[df]
Error in levels(df$c)[df] : invalid subscript type 'list'
> levels(df$c)[df$c]
[1] "a" "b" "b" "a"
- (505)How to list last typed commands?
history(100) ;
history(Inf) ;
- (506)How to save the whole workspace?
save.image() ;
- (507)"Error in nchar(ID) : invalid multibyte string ...")
Use
Sys.setlocale()
to fix this.
From: http://www.mail-archive.com/r-help@r-project.org/msg100579.html
- (508)Where does the Warning message: "In ... : Coercing LHS to a list" come from?
LHS = left hand side
- (509)Another way to get the args list passed to a method (particularly useful when using '...' - ellipsed args)
~match.call~ returns a call in which all of the specified arguments are specified by their full names.
- (510)How to compute modulo and quotient of integers?
> 19%%5 % modulo
[1] 4
> 19%/%5 % quotient
[1] 3
- (511)How to remove columns from a dataframe using their name, not their number?
dataEngine=dataEngine[,-match(c(<colnames to remove>),colnames(dataEngine))]
- (512)How to save the content of a gtkDrawable into a file?
see RGtk2::gdk-Pixbufs and RGtk2::gdkPixbufGetFromDrawable
From: http://stackoverflow.com/questions/3254499/save-gtk-drawingarea-to-file
def get_picture(self, event, data):
drawable = self.movie_window.window
colormap = drawable.get_colormap()
pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, 0, 8, *drawable.get_size())
pixbuf = pixbuf.get_from_drawable(drawable, colormap, 0,0,0,0, *drawable.get_size())
pixbuf.save(r'somefile.png', 'png')
pixbuf.save(r'somefile.jpeg', 'jpeg')
(see also tip 540)
- (513)How to call a function passing it a list as its args instead of the args directly?
?do.call
https://webcache.googleusercontent.com/search?q=cache:uvtZzcrg8-IJ:https://stat.ethz.ch/pipermail/r-help/2002-November/027004.html+&cd=2&hl=en&ct=clnk
- (514)How to pretty-print a list?
noquote(unlist(format(.Machine)))
- (515)How to change float precision? How to resolve (some) errors with float precision?
> abs(1-1.1)<=1
[1] FALSE
> ?as.single
> ?writeBin
> .changePrecision()?
http://r.789695.n4.nabble.com/floating-point-in-single-precision-td2269833.html
--- also see .Machine$double.eps (which is an equivalent of MatLab
eps()) and represents "Machine epsilon mach , i.e. difference between
1 and the next largest double-precision floating-point number.
- (516)Error: "Attempt to apply non-function"?
Happens when object$funName() where object == NULL
- (517)How to activate a Gtk2::SpinButton?
set a GtkAdjument AND set a default value
- (518)RGtk2 callback functions
The callback funtions MUST return FLASE/TRUE (why???when???)
- (519)How to catch an error?
use error <- try() + stop() to intercept the error
E.g.:
x <- 1:100
y <- sqrt(1:100)
postscript("filename", horizontal=FALSE, onefile=FALSE, paper="special",bg="white", family="ComputerModern", pointsize=10);
par(mar=c(5, 4, 0, 0) + 0.1);
err <- try(plot(x, y)) ;
class(err) ;
if (is(err,"try-error")) { stop(paste(err)) } ; # use inherits(err,"try-error")?
dev.off() ;
=> Error in plot.new() : figure margins too large
----
Correct catch of a try-error?
err <- try ( XXX )
if (!is.null(err$error))
{ stop(err$error) ; }
- (520)How to get the result/value of last expression?
x <- .Last.value
but be careful, any new command will re-set its value!
- (521)How to know which packages are currently loaded? How to know where R seeks for functions?
search() ;
- (522)How to list all installed packages?
library() ;
rownames(installed.packages()) ;
- (523)How to install a package?
install.packages("<package name>") ;
- (524)How to unload/detach a package?
detach(package:MASS) ;
- (525)How to list built-in datasets?
data() ;
- (526)How to load built-in datasets?
data(<data set name>, package=<package name>) ;
- (527)How to fix the CRAN mirror to use?
add:
options(repos="URL of the repository")
in your ~/.Rprofile
To get the URL, use chooseCRANmirror() ; options("repos")[[1]][1]
- (528)How to mix R and C?
$ R CMD SHLIB myfile.c
<creates a myfile.so>
$ R
> dyn.load("myfile.so") ;
- (529)How to skip the splash-screen/banner?
run:
$ R --quiet
instead of:
$ R
or make an alias
- (539)How to change the # of columns of the text of the terminal used by R?
wideScreen <- function(howWide=Sys.getenv("COLUMNS")) {
options(width=as.integer(howWide))
}
--- or better:
wideScreen <- function(howWide=system("stty -a | head -n 1 | awk '{print $7}' | sed 's/;//'", intern=T)) # Sys.getenv("COLUMNS")
{
print(paste("Setting column width to ",howWide)) ;
options(width=as.integer(howWide))
} ;
wideScreen() ; # remove this line to make install.packages() work again
From: http://stackoverflow.com/questions/1172485/how-to-increase-the-number-of-columns-using-r-in-linux
- (540)How to save a plot even if the function to draw it is lost?
dev.copy(<format:png,pdf,...>,file="<filename>") ;
dev.off() ;
(see also tip 512)
- (541)How to create an empty data.frame with names for columns?
nbCols <- 20
df <- data.frame(matrix(nrow=0,ncol=nbCols)) ;
colnames(df) <- rep("toto", nbCols) ;
- (542)How to load only some cols in a csv file?
read.csv("rec05784.csv", colClasses=c(rep(NA,30),rep('NULL',200))))
NA => Column is Kept ?
NULL => Column is NOT Kept ?
Possible values are ~NA~ (the default, when ~type.convert~ is
used), ~"NULL"~ (when the column is skipped), one of the
atomic vector classes (logical, integer, numeric, complex,
character, raw), or ~"factor"~, ~"Date"~ or ~"POSIXct"~.
Otherwise there needs to be an ~as~ method (from package
~methods~) for conversion from ~"character"~ to the specified
formal class.
Note that ~colClasses~ is specified per column (not per
variable) and so includes the column of row names (if any).
- (543)How to skip a lines at the start of a CSV?
read.csv("filename", skip=5)
- (544)How to skip a lines at the end of a CSV?
tip: read only X first lines <=> read n-X lines where n is the total number of lines of the file
read.csv("filename", nrows=5) # read only the 5 first lines of the file
- (545)How to run scripts in batch mode?
$ R CMD BATCH myscript.R myscript.Rout
- CMD BATCH automatically captures warnings and errors
- CMD BATCH automatically adds a call to proc.time() at the end of the session, to document how long the script took to run.
From: http://blog.revolutionanalytics.com/2009/06/running-scripts-with-r-cmd-batch.html
- (546)How to concatenate rows/cols quickly (typical use: load multiple csv file to make only one)?
df <- do.call("rbind", listOfDataFrames)
df <- rbind.fill(listOfDataFrames)
df <- ldply(listOfDataFrames, data.frame)
My guess is that using do.call("rbind", ...) is going to be the fastest approach that you will find unless you can do something like (a) use a matrices instead of a data.frames and (b) preallocate the final matrix and assign to it rather than growing it.
From: http://stackoverflow.com/questions/2851327/r-converting-a-list-of-data-frames-into-one-data-frame
- (547)How to get the int value of a factor?
Use as.numeric()
R> df <- data.frame(plop=c("a","a","a","b","b","c"))
R> class(df$plop)
[1] "factor"
R> as.numeric(df$plop)
[1] 1 1 1 2 2 3
- (548)How to get the string value of a factor?
Use paste() or levels()
R> df <- data.frame(plop=c("a","a","a","b","b","c"))
R> class(df$plop)
[1] "factor"
R> levels(df$plop)
[1] "a" "b" "c"
R> paste(df$plop[1]) # When you have the factor itself
[1] "a"
R> levels(df$plop)[1] # When you know the factor value
[1] "a"
- (557)How to make interactive graphics?
use package "Rgoobi" or "iplots" (needs rJava)
http://www.rforge.net/doc/packages/iplots/html/00Index.html
http://www.statmethods.net/advgraphs/interactive.html
- (558)How to generate color palettes?
use package "grDevices"
?heat.colors
?rainbow
?terrain.colors
?cm.colors
?topo.colors
?gray.colors
Define your own palette:
rgb.palette <- colorRampPalette(c("red", "orange", "blue"), space = "rgb")
filled.contour(m, col = rgb.palette(20))
- (559)How to make a (text/tk/win) progress bar
total <- 20
# create progress bar
pb <- txtProgressBar(min = 0, max = total, style = 3)
for(i in 1:total){
Sys.sleep(0.1)
# update progress bar
setTxtProgressBar(pb, i)
}
close(pb)
- (560)A gui for R?
R --gui=<GNOME,tk,X11>
- (657)How to get user input?
cat("\n","Enter x","\n") # prompt
y<-scan(n=1)
prompts for user imput and scans 1 line from console.
~readChar~ and ~readBin~ to read fixed or variable length
character strings or binary representations of numbers a few at a
time from a connection.
readline(), readLines() and scan()
- (638)How to make a plotting window of a specified size?
plot(1:10)
dev.new(width=5, height=4)
plot(1:20)
- (639)How to make formulae work inside functions?
plop <- function(mydata)
{
model <- as.formula("mydata$y ~ mydata$x", env=new.env()) ;
}
- (640)Useful packages
- reshape2
- datatable
- (641)How to find the *index* of the min/max of a vector (in 1 pass)?
which.min(x)
which.max(x)
Determines the location, i.e., index of the (first) minimum or maximum of a numeric vector.
- (642)Roxygen parameters
#' @param
#' @return
#' @keywords
#' @seealso \code{\link{<funcname>}}
#' @export
#' @examples
- (643)How to generate datasets for clustering/classification?
fpc::rFace()
From: https://www.rdocumentation.org/packages/fpc/versions/2.2-8
https://www.rdocumentation.org/packages/fpc/versions/2.2-8/topics/rFace
- (644)How to prevent a small dataframe to be converted to another type?
oneSetParam <- as.list(allCombiParam[i,,drop=FALSE]) ;
- (645)How to transform numeric values into chars/strings?
R > as.character(list(1,2,3))
[1] "1" "2" "3"
R > paste(list(1,2,3), collapse=" ")
[1] "1 2 3"
- (646)How to access private/hidden functions of packages?
Use ':::'
e.g.,
RWeka:::Weka_packages_loaded()
- (647)How to install rJava?
- make sure you don't have JAVA_HOME set in your environment or set it to the correct JVM.
- set the correct default JVM for your OS: update-alternatives --config java
- run R CMD javareconf
- set correct file permissions:
# chmod a+r /usr/lib/R/etc/Makeconf
# chmod a+r /usr/lib/R/etc/ldpaths
- run R & install.packages("rJava")
- (648)How to know if a variable exists?
exists("<var name>") ;
- (649)How to draw line segments?
use segments()
- (650)How to draw a dotted/dashed line?
use lty=3 resp. lty=2 (see ?par)
- (651)How to make the GUI/core of the program work asynchronously/work in another thread?
Release control to the GUI from the core of the program using:
while (gtkEventsPending()>0)
{ gtkMainIteration() ; }
- (652)How to check if an argument has been provided?
Clean way: use the missing() function:
test <- function(a,b)
{
if (missing(b))
{ return(a) ; }
else
{ return(b) ; }
}
R> test(a=1,b=NULL)
NULL
R> test(a=1,b=2)
[1] 2
R> test(a=1)
[1] 1
Dirty way: set the default value of the argument to NULL and check if it is NULL:
test <- function(a,b=NULL)
{
if (is.null(b))
{ return(a) ; }
else
{ return(b) ; }
}
R> test(a=1,b=NULL)
[1] 1
R> test(a=1,b=2)
[1] 2
R> test(a=1)
[1] 1
- (653)How to load/source a file that itself loads/sources files? [irrelevant for packages]
source('../../other_path/file.R', chdir=TRUE) ; # where file.R loads files in its own directory
or
oldpath <- getwd() ;
setwd("path_to_other_code") ;
source("the_file_to_load") ;
setwd(oldpath) ;
- (654)How to make R/rJava be able to load libjvm?
- set $JAVA_HOME to where your libjvm.so is:
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.10
- reconfigure R's way to find java (as root?)
# R CMD javareconf
- (655)rJava works for root but not for user sean?
Make sure you don't have JAVA_HOME set in your environment for user sean.
From: https://stat.ethz.ch/pipermail/r-sig-debian/2010-March/001066.html
i.e. the root (the installer of the package) and user (the user of the package) must have the same Java configuration
Also have a look at [How to make R/rJava be able to load libjvm?]
- (656)How to store/load in binary format (a.k.a. accelarate loading of data)?
Use readRDS/saveRDS
or dput/dget or save/load or serialize/unserialize
- (658)How to get user input with no echo (a.k.a. how to read a password)?
get_password <- function()
{
cat("Password: ") ;
system("stty -echo") ;
a <- readline() ;
system("stty echo") ;
cat("\n") ;
return(a) ;
}
> a <- get_password()
Password:
> a
[1] "sdfs"
- (659)How to print formatted doubles/integers?
R> sprintf("%.4d", 2)
[1] "0002"
- (660)How to plot on top of an older plot rather than redrawing?
plot(...) ;
par(new=TRUE) ;
plot(...) ;
Be careful to have the same limits on the axes. Use xlim/ylim
- (661)How to do a rbind more quickly?
Use plyr::rbind.fill
- (662)How to decompose the phases of a plot?
plot.new() ; # creation of the window?
plot.window(xlim=c(minX,maxX),ylim=c(minY,maxY)) ; # Cretation of the drawing canevas?
axis(1) ; # Below axis
axis(2) ; # Left axis
lines(X, Y, col="blue", type="points") ;
- (663)How to print a contingency table of the counts at each combination of factor levels? (a.k.a. matrice de confusion)
table(prediction,iris$Species)
- (664)How to generate all combinations of parameters?
expand.grid(list(A=1:2,B=2:5))
A B
1 1 2
2 2 2
3 1 3
4 2 3
5 1 4
6 2 4
7 1 5
8 2 5
- (665)How to build a dataframe that shows statistics on subsets of an original dataframe?
?aggregate
Splits the data into subsets, computes summary statistics for
each, and returns the result in a convenient form.
e.g., we have a dataframe that lists performance evaluations of the
application of several clustering algos on various test files and we
want the means of the performance of each algorithm on the overall set
of test files
- (666)How to manage lists of lists?
clusters <- list(......) ;
clust <- list(......) ;
clusters <- c(clusters, list(clust)) ;
# Note: clust is already a list but you might have to create a list of one element that contains it, so that its the whole list that is appended to the list "clusters", not its elements :)
- (667)How to remove annoying outputs (a.k.a. redirect error messages)?
?invisible
or
sink("/dev/null") ;
a <- list_Weka_interfaces()[[category]] ;
sink() ;
or
?capture.output
- (668)How to compute all the combinations/permutations of elements of a vector?
R> ?gtools::combinations
R> library(gtools)
R> combinations(3,2,letters[1:3])
[,1] [,2]
[1,] "a" "b"
[2,] "a" "c"
[3,] "b" "c"
R> permutations(3,2,letters[1:3])
[,1] [,2]
[1,] "a" "b"
[2,] "a" "c"
[3,] "b" "a"
[4,] "b" "c"
[5,] "c" "a"
[6,] "c" "b"
- (669)How to show all the possible graphical point types? (pch)
In ?points, there are examples like the following:
pchShow <-
function(extras = c("*",".", "o","O","0","+","-","|","%","#"),
cex = 3, ## good for both .Device=="postscript" and "x11"
col = "red3", bg = "gold", coltext = "brown", cextext = 1.2,
main = paste("plot symbols : points (... pch = *, cex =",
cex,")"))
{
nex <- length(extras)
np <- 26 + nex
ipch <- 0:(np-1)
k <- floor(sqrt(np))
dd <- c(-1,1)/2
rx <- dd + range(ix <- ipch %/% k)
ry <- dd + range(iy <- 3 + (k-1)- ipch %% k)
pch <- as.list(ipch) # list with integers & strings
if(nex > 0) pch[26+ 1:nex] <- as.list(extras)
plot(rx, ry, type="n", axes = FALSE, xlab = "", ylab = "",
main = main)
abline(v = ix, h = iy, col = "lightgray", lty = "dotted")
for(i in 1:np) {
pc <- pch[[i]]
## 'col' symbols with a 'bg'-colored interior (where available) :
points(ix[i], iy[i], pch = pc, col = col, bg = bg, cex = cex)
if(cextext > 0)
text(ix[i] - 0.3, iy[i], pc, col = coltext, cex = cextext)
}
}
pchShow()
- (670)How to show all the possible graphical colors?
?rainbow has some examples, like:
require(graphics)
# A Color Wheel
pie(rep(1,12), col=rainbow(12))
##------ Some palettes ------------
demo.pal <-
function(n, border = if (n<32) "light gray" else NA,
main = paste("color palettes; n=",n),
ch.col = c("rainbow(n, start=.7, end=.1)", "heat.colors(n)",
"terrain.colors(n)", "topo.colors(n)",
"cm.colors(n)"))
{
nt <- length(ch.col)
i <- 1:n; j <- n / nt; d <- j/6; dy <- 2*d
plot(i,i+d, type="n", yaxt="n", ylab="", main=main)
for (k in 1:nt) {
rect(i-.5, (k-1)*j+ dy, i+.4, k*j,
col = eval(parse(text=ch.col[k])), border = border)
text(2*j, k * j +dy/4, ch.col[k])
}
}
n <- if(.Device == "postscript") 64 else 16
# Since for screen, larger n may give color allocation problem
demo.pal(n)
- (671)How to get points with transparency/alpha channel color?
R> palet <- cm.colors(10, apha=.3) ;
or
R> palet <- cm.colors(10) ;
R> colos <- adjustcolor(palet, alpha.f = 0.3) ;
- (672)How to get the matlab color map?
R> install.packages("matlab") ;
R> library("matlab") ;
R> pie(x, col = jet.colors(length(x))) ;
- (673)How to install packages in RWeka?
library(RWeka)
make_Weka_clusterer("weka.clusterers.EM") ;
list_Weka_interfaces() ;
#Available actions and respective additional arguments are as follows:
#"refresh-cache" Refresh the cached copy of the package meta data from the central package repository.
#"list-packages" print information (version numbers and short descriptions) about packages as specified by an additional keyword which must be one of "all" (all packages the system knows about), "installed" (all packages installed locally$
#"package-info" print information (metadata) about a package. Requires two additional character string arguments: a keyword and the package name. The keyword must be one of "repository" (print info from the repository) or "installed" (pri$
#"install-package" install a package as specified by an additional character string giving its name. (In principle, one could also provide a file path or URL to a zip file.)
#"remove-package" remove a given (installed) package.
#"load-package" load a given package by adding its jars to the Java classpath.
WPM("refresh-cache") ;
WPM("list-packages", "installed") ;
WPM("list-packages", "available") ;
WPM("package-info", "repository", "XMeans") ;
WPM("install-package", "LVQ") ;
WPM("load-package", "LVQ") ;
list_Weka_interfaces() ;
make_Weka_clusterer("weka.clusterers.LVQ") ;
list_Weka_interfaces() ;
- (674)How to concatenate several dataframe saved in a list?
R> library(plyr)
R> df2 <- data.frame(A=c(10,20,30),B=c(20,30,40))
R> li <- list(TOTO=df,TITI=df2)
R> ldply(li,rbind)
- (675)Introspection functions
eval
expression
parse/deparse
get
quote/enquote
call/do.call/.Call
substitute
- (676)How to set the number of cores/process R can use?
mc.cores: a integer giving the maximum allowed number of
_additional_ R processes allowed to be run in parallel to the
current R process. Defaults to the setting of the
environment variable \342\200\230MC_CORES\342\200\231 if set. Most applications
which use this assume a limit of \342\200\2302\342\200\231 if it is unset.
To be set using options(), for instance in ~/.Rprofile
- (677)How to set # of columns?
cols <- Sys.getenv("COLUMNS")
if(nzchar(cols)) options(width = as.integer(cols))
From: ?Startup
- (678)How to get colors in prompt without messing up readline?
From: https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14800
This appears to be a matter of not understanding the cause of the problem.
Can't say that I do entirely either, but a bit of further googling led to this,
from a Ruby forum:
# readline.h
/* Definitions available for use by readline clients. */
#define RL_PROMPT_START_IGNORE '\001'
#define RL_PROMPT_END_IGNORE '\002'
Bash handles this issue by mapping `\[' and `\]' to
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE inside of `PS*' prompt variables.
So trying to get "\[" into the prompt string is unlikely to work in R, and it
wasn't done right anyway -- read up on R's mechanisms for escaping special
characters in strings; see help("Quotes").
This appears to work for me (had I actually wanted a bright green "R>" in a
"Red Sands" terminal window!):
options(prompt="\001\033[01;32m\002R> \001\033[00m\002")
- (679)How to get nrow/ncol whathever the type of collection (vector/data.frame/etc.) used?
use: NCOL/NROW
see: ?NCOL
- (680)How to draw a smoothing of a chaotic curve (polynomial regression)?
see ?lowess / ?loess
- (681)How to force garbage collection?
see ?gc:
gc(verbose = getOption("verbose"), reset=FALSE)
gcinfo(verbose)
- (682)How to evaluate only partially a part of code?
Use bquote()
Example: do a function B that returns a function A with some
parameters fixed from the parameters of B.
R> B <- function(param=1)
{
return(A=bquote(function(x) { return(.(param)) ; })) ;
}
R> B(12)
function(x) {
return(12)
}
R> B(15)
function(x) {
return(15)
}
- (683)A shortened & functional version of if/then/else?
R > ifelse(cond,ifcond,elsecond) ;
- (684)How to serialize a Java (e.g. Weka) object from R?
library(rJava) ;
write(.jserialize(model$classifier), "/tmp/model_classifier.out") ;
- (685)Useful functions for timeseries
R> ?window
R> ?lag
R> ?diff
- (686)How to draw a function?
see ?curve
- (687)How to compare if 2 objects have identical values?
see ?identical or ?all.equal
or package "compare" [manages precision errors???]
> identical(0.3 - 0.2, 0.1)
[1] FALSE
> all.equal(0.3 - 0.2, 0.1)
[1] TRUE
- (688)How to create/call R code directly in Java?
RCaller caller = new RCaller();
caller.setRscriptExecutable("/usr/bin/Rscript");
RCode code = new RCode();
double[] numbers = new double[] {1, 4, 3, 5, 6, 10};
code.addDoubleArray("x", numbers);
File file = code.startPlot();
System.out.println("Plot will be saved to : " + file);
code.addRCode("plot.ts(x)");
code.endPlot();
caller.setRCode(code);
caller.runOnly();
code.showPlot(file);
- (689)How to compute an AND or an OR on a vector of Booleans?
any <-> or
all <-> and
- (690)How to rotate a plot [Does not work with a base::plot() but grid::xyplot(), etc.]?
library(lattice)
library(grid)
grid.newpage()
pushViewport(viewport(angle = 90, name = "VP")) ;
upViewport();
x <- 1:10
print(xyplot(x ~ x, groups = gl(2, 5), auto.key = TRUE), draw.in = "VP") ;
---
grid.newpage()
pushViewport(viewport(angle = 90))
x <- 1:10
print(xyplot(x ~ x, groups = gl(2, 5), auto.key = TRUE), newpage = FALSE) ;
upViewport()
From: http://tolstoy.newcastle.edu.au/R/e2/help/06/09/0447.html
---
myhist <- hist(rnorm(50))
# Make two square regions side by side
pushViewport(viewport(layout=grid.layout(1, 2, respect=TRUE)))
# Go to the left region
pushViewport(viewport(layout.pos.col=1))
# Draw the histogram in normal orientation
print(myhist, newpage=FALSE)
popViewport()
# Go to the right region then rotate 90 degrees
pushViewport(viewport(layout.pos.col=2), viewport(angle=90))
# Draw the histogram (rotated 90 degrees)
print(myhist, newpage=FALSE)
popViewport(3)
From: https://stat.ethz.ch/pipermail/r-help/2003-October/040356.html
- (1371)How to get informations on an RWeka package?
WOW(AS)
From: http://permalink.gmane.org/gmane.comp.ai.weka/35251
- (1361)How to automatically save & restore command history?
SOLUTION1:
use R --save (or alias it with alias R='R --save' in your .bashrc)
SOLUTION2:
Put those lines into ~/.Rprofile :
.First<- function() {
library(utils);
loadhistory("~/.Rhistory"); #To get the file from the envrnmt: Sys.getenv("R_HISTFILE")
}
# ...
.Last <- function() {
if(!any(commandArgs()=='--no-readline') && interactive()) {
try(savehistory("~/.Rhistory"));
}
}
From: http://akh1.blogspot.fr/2010/04/rprofile.html?_escaped_fragment_#!
http://stackoverflow.com/questions/14757743/automatically-saving-history-in-r-across-sessions
- (1334)How to detect/remove a constant column in R?
Tips: constant <=> sdev == 0
y <- x[,sd(x)!=0]
From: http://stackoverflow.com/questions/15068981/removal-of-constant-columns-in-r
- (1310)What are R's configuration files?
.Renviron
.Rprofile
- (1311)How to prevent R from asking to save?
SOLUTION1:
use R --save/--no-save
SOLUTION2:
Add to your ~/.Rprofile:
# Override q() to not save by default.
# Same as saying q("no")
q <- function (save="no", ...) {
quit(save=save, ...)
}
From: http://stackoverflow.com/questions/1189759/expert-r-users-whats-in-your-rprofile
- (1024)How to get last result in R?
a <- .Last.value
- (1290)How to read .arff file with R?
"read.arff" in package "foreign" reads data from Weka Attribute-Relation File Format (ARFF) files.
Looking through the "R Data Import/Export Manual", which also comes with your system, is generally useful but would not have found the answer to this question...
It might be useful to know about the RWeka version on the off chance that the version in foreign (which you should try first) fails for some reason.
From: http://stackoverflow.com/questions/7548216/how-to-read-arff-file-with-r
- (1291)How to find the package that does XXX in R?
In general the answer to questions like this can be found via the "sos" package, which accesses a full-text search of all the packages on CRAN.
install.packages("sos")
library("sos")
findFn("arff")
finds functions in the foreign (as noted above) and RWeka packages. Since foreign is a recommended package, it will be installed on your system by default.
Hence you would have found the answer with
help.search("arff")
in the first place, without installing the "sos" package.
"sos" is still worth having for times when the string you are searching for isn't in the metadata (title, keywords, alias, etc.), which is all that "help.search" searches, or not in a package you already have installed on your system (ditto).
From: http://stackoverflow.com/questions/7548216/how-to-read-arff-file-with-r
- (2821)How to open all files from a project (dir) in RStudio?
files <- list.files("R", full.names = TRUE)
file.edit(files)
From: https://github.com/rstudio/rstudio/issues/3248#issuecomment-410011339
- (1442)How to debug a function in R?
1. Set the debug flag on the function:
debug(<function name>)
2. Execute the function:
<function name>(<args>)
To quit, use: Q
- (1443)How to exit the debug/browser mode in R?
use:
> Q
From: http://stackoverflow.com/questions/13663043/exit-current-browser-return-one-level
- (1451)How to correctly redirect output in a file with sink()?
Surround the stuff you want to print with print()
From: http://stackoverflow.com/questions/16575172/how-can-i-output-the-processes-within-a-function-to-a-textfile-in-r-sink-doesn
- (1452)How to remove an element from a vector in R?
x <- x[!which(x==remove.value)]
x <- x[-which(x=="bobo")] # Does not work if the searched term does not appear in x!
x <- x[which(x!="bobo")]
x <- x[!x == remove.value]
x <- x[x!="bobo"] # Can be read as "xx such that xx is not 'bobo'"
x <- x[!match(remove.value,x)]
From: http://r.789695.n4.nabble.com/Remove-a-number-from-a-vector-td851865.html
- (1460)How to benchmark/compare execution time of various functions in R?
Use the "benchmark" function.
Example for comparing replicate vs. for loop:
repl_function = function(no_rep) {
means <- replicate(no_rep, mean(rnorm(50)))
}
for_loop = function(no_rep) {
means <- c()
for(i in 1:no_rep) {
means <- c(means, mean(rnorm(50)))
}
means
}
for_loop_prealloc = function(no_rep) {
means <- vector(mode = "numeric", length = no_rep)
for(i in 1:no_rep) {
means[i] <- mean(rnorm(50))
}
means
}
no_loops = 50e3
benchmark(repl_function(no_loops),
for_loop(no_loops),
for_loop_prealloc(no_loops),
replications = 3)
From: http://stackoverflow.com/questions/13412312/replicate-verses-a-for-loop
- (1461)How to compute function designed for 2 args (intersect, union, etc) on more than 2 elements?
R> Reduce(<function>, list(...))
e.g. compute the intersection of more than 2 sets:
R> Reduce(intersect,
list(v1 = c("a","b","c","d"),
v2 = c("a","b","e"),
v3 = c("a","f","g")))
Also see:
- Filter(f, x) extracts the elements of a vector for which a predicate
(logical) function gives true
- Find(f, x, right=F, nomatch=NULL) give the first such element and
its position in the vector
- Position(f, x, right=F, nomatch=NA_integer_) give the last such
element and its position in the vector.
- Map(f, ...) applies a function to the corresponding elements of
given vectors. [similar to sapply?]
- Negate(f) creates the negation of a given function.
From: http://r.789695.n4.nabble.com/How-to-get-intersection-of-multiple-vectors-td4350731.html
- (1462)How to remove row/col names of a matrix/data.frame in R?
For dropping the row names of a matrix x, it may be easier to use rownames(x) <- NULL, similarly for column names.
From: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f
- (1463)How to set components of a list to NULL?
You can use:
x[i] <- list(NULL)
to set component i of the list x to NULL, similarly for named components. Do not set x[i] or x[[i]] to NULL, because this will remove the corresponding component from the list.
From: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f
- (1464)How to remove an element from a list in R?
myList[[5]] <- NULL
This will remove the 5th element and then "close up" the hole caused by deletion of that element. That suffles the index values, so be careful in dropping elements.
--
For deleting an element of a list, see R FAQ 7.1
Setting x[i] or x[[i]] to NULL, will remove the corresponding component from the list.
From: http://stackoverflow.com/questions/652136/how-can-i-remove-an-element-from-a-list
http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-set-components-of-a-list-to-NULL_003f
- (1465)How to apply a function to multiple values (a.k.a avoid usage of 'for' loops and speed-up code)?
- base::apply(X, MARGIN, FUN, ...) returns a vector or array or list
of values obtained by applying a function to margins (rows/cols)
of an array or matrix. (e.g. compute the "sum" for each row of a
matrix).
- base::*l*apply(X, FUN, ...) returns a *list* of the same length as
‘X’, each element of which is the result of applying ‘FUN’ to the
corresponding element of ‘X’. (e.g. compute "the class" of each
column of a data.frame).
- base::[*v*|*s*]apply(X, FUN, ..., simplify=T, USE.NAMES=T) is a
user-friendly version of ‘lapply’ by default returning a
*vector*.
- base::replicate(n, expr, simplify = "array") is a user-friendly
version of ‘sapply’ for repeated evaluation of an
expression. (e.g. call 1000 time the same function)?
- base::Reduce applies a function (created for two arguments)
successively on the elements of a given vector to combine them
(e.g. compute the intersection of more than 2 sets - on a list of
sets).
- plyr::*l*~d~ply(.data, .fun=NULL, ...) applies .fun on each element
of a *list*, then combine results into a ~data.frame~.
- plyr::*l*~l~ply(.data, .fun = NULL, ...) applies .fun on each element of a
*list*, keeping results as a ~list~.
From: ?apply and ?lapply and ?Reduce and ??ldply and ??llply
- (1466)How to partially apply a function in R (a.k.a How to use apply/sapply/vapply/lapply/Reduce/ldply/etc. with a method that has more than two arguments, varying only one of them, the others being fixed)?
It's simple: create a(n) (anonymous) function that takes only the arguments that are not fixed and calls the actual function with both these non-fixed args and the fixed ones.
Example: you want to compute the intesection of the set A=c("a","c") with several other sets, stored in the list L=list(B=c("a","e","i"),C=c("o","u"),D=c("a","b","c", "d"))
A <- c("a","c")
L <- list(B=c("a","e","i"),C=c("o","u"),D=c("a","b","c", "d"))
lapply(X=L, FUN=function(p) { intersect(x=A, y=p) })
$B
[1] "a"
$C
character(0)
$D
[1] "a" "c"
NOTE: With this trick, it is even possible to transform any "for" loop into a call to <x>apply: just create a function which argument is the argument of the loop (typically the "counter", or a list of files) and the body is the body of the for loop, then call <x>apply with this function and the list of possible values as arguments.
From: http://r.789695.n4.nabble.com/Partial-function-application-in-R-td886216.html
A more generic/complete solution can be found here:
http://rosettacode.org/wiki/Partial_function_application#R
- (1467)How to interlace 2 (character) vectors in R?
paste0(letters[1:10], LETTERS[1:10], collapse = " ")
[1] "aA bB cC dD eE fF gG hH iI jJ"
From: http://stackoverflow.com/questions/23001548/dealing-with-readlines-function-in-r
- (1468)How to convert a file-"regular expression" (a.k.a "glob") into an actual regular expression in R?
If you're struggling with regexps but know the wildcard-pattern, function glob2rx() is often helpful
From: http://stackoverflow.com/questions/4876813/using-r-to-list-all-files-with-a-specified-extension
- (1469)How to list all files with a specified extension in R?
files <- list.files(pattern = "\\.<extension>$")
filenames <- Sys.glob("*.<extension>")
- Dirty hack:
files <- list.files()
myfiles <- files[-grep(".<extension>", files, fixed=T)]
From: http://stackoverflow.com/questions/4876813/using-r-to-list-all-files-with-a-specified-extension#4876869
- (1472)How to shuffle elements from a vector in R?
myset <- c(1,2,3,4,5,6)
sample(x=myset, size=length(myset), replace=F)
- (1473)How to set the seed for random generation (of sample()s) in R?
R> sample(LETTERS, 5)
[1] "K" "N" "R" "Z" "G"
R> sample(LETTERS, 5)
[1] "L" "P" "J" "E" "D"
These two, however, are identical because I set the seed:
R> set.seed(42); sample(LETTERS, 5)
[1] "X" "Z" "G" "T" "O"
R> set.seed(42); sample(LETTERS, 5)
[1] "X" "Z" "G" "T" "O"
R>
From: http://stackoverflow.com/questions/13605271/reasons-for-using-the-set-seed-function
- (1474)How to safely save/load an RWeka model?
SOLUTION1: To save models for re-use in R:
The RWeka objects are just a references to the Java objects used by
Weka under the hood. As a consequence, you have to manually ask R
(rJava) to cache the Java object, in order to be able to save
it. Otherwise, when you load the R object in a new R session, it only
contains an empty reference to a Java object that does no longer exist
and you hit the error "RcallMethod: attempt to call a method of a NULL
object".
## Allows to safely save the model for reloading in R
saveClassifierR <- function(wekaClassifier, filename) {
rJava::.jcache(wekaClassifier$classifier)
save(wekaClassifier, file=filename)
}
From: http://one-line-it.blogspot.fr/2013/03/r-store-rweka-model-to-file.html
http://cran.r-project.org/web/packages/RWeka/vignettes/RWeka.pdf
SOLUTION2: To save models for re-use in Java (requires Weka 3.5.5++)
library("rJava")
## Allows to safely save the model for reloading in Java
saveClassifierJava <- function(wekaClassifier, filename) {
rJava::.jcache(wekaClassifier$classifier)
J("weka.core.SerializationHelper")$write(filename, wekaClassifier$classifier)
}
From: http://weka.wikispaces.com/Serialization + rJava doc (run static methods)...
- (1475)How to find the position of the max in a vector in R?
v<- c(1,4,2,3)
which.max(v)
From: ?max -> section"See Also"
---
More complicated manual version:
k <- c(1,2,3,4,5,1000, 6,7,8)
which(Reduce(max, k) == k) # computes max of a vector by applying the binary max function successively over the original vector (using Reduce), then looks for its position in the original vector
- (1477)How to compute a confusion matrix in R (in the same way as Weka)?
Use table(actualClasses, predictions, dnn=c("isActually v","-> classifiedAs"))
E.g.:
iris.lda = lda(Species ~ . , data = iris)
table(iris$Species, predict(iris.lda, type="class")$class)
From: http://stackoverflow.com/questions/13375908/how-to-compute-confusion-matrix-on-iris-dataset
- (1484)How to re-factor levels of a data.frame in R (a.k.a How to actually remove/drop factor levels in a subsetted data.frame)?
PROBLEM: when removing all elements with a given level value in a vector/data.frame column of class "factor", the list of levels remains intact.
e.g.
> df <- data.frame(letters=letters[1:5], numbers=seq(1:5))
> levels(df$letters)
## [1] "a" "b" "c" "d" "e"
> subdf <- subset(df, numbers <= 3)
## letters numbers
## 1 a 1
## 2 b 2
## 3 c 3
## but the levels are still there!
levels(subdf$letters)
## [1] "a" "b" "c" "d" "e"
SOLUTION: you need to update / re-assign the factor levels manually (i.e. re-factor the data) by calling "factor()"
e.g.
> subdf$letters <- factor(subdf$letters)
From: http://stackoverflow.com/questions/1195826/dropping-factor-levels-in-a-subsetted-data-frame-in-r
- (1511)Be careful with implicit type conversion in R!
## I] Adding a string to a number vector results in a string vector!
a <- c(1,2,3)
a <- c(a, "hi")
a
#[1] "1" "2" "3" "hi"
## II] Some functions, like apply implicitely convert an input data.frame (heterogeneous type container) into matrix (homogenous type container). In the process, everything is converted to a "common" data type, generally "string". Thus, computations are not possible anymore.
n <- 5
#make some dummy data
df <- data.frame(cbind(rbinom(n, 1, 0.5), rnorm(n, 10, 5), rnorm(n, 20, 10)))
#make the first column a factor
df[,1] <- as.factor(df[,1])
head(df)
# X1 X2 X3
#1 1 8.911567 27.28325
#2 1 9.933021 13.74879
#3 0 10.177231 20.65490
#4 0 6.368177 27.10183
#5 1 12.084135 14.54369
apply(df, 1, function(x) x[2] + x[3]) # sum the two numeric columns
#Error in x[2] + x[3] : non-numeric argument to binary operator
# Above line does not work because apply() converts to a matrix of strings:
apply(df, 1, function(x) mode(x))
#[1] "character" "character" "character" "character" "character"
# However, the initial matrix is not changed:
df[,2] + df[,3]
#[1] 36.19481 23.68181 30.83213 33.47001 26.62783
# The solution is to call apply() on numeric values only (the
# sub-data.frame df[,2:3]), so that the implicit consersion of apply()
# results into a numeric matrix
apply(df[,2:3], 1, function(x) x[1] + x[2])
#[1] 36.19481 23.68181 30.83213 33.47001 26.62783
Beware that this can also happen with cbind(), notably with everything being converted to factors:
df <- data.frame(cbind(paste("subject", 1:n, sep=''), rnorm(n, 10, 5), rnorm(n, 20, 10)))
# X1 X2 X3
#1 subject1 14.6619839711866 6.94472759446703
#2 subject2 11.603910222178 27.6225162121889
#3 subject3 5.21881004622993 20.3409476386206
#4 subject4 16.3574724782284 39.0904723579448
#5 subject5 9.35407053787977 23.8568796326835
apply(df[,2:3], 1, function(x) x[1] + x[2])
#Error in x[1] + x[2] : non-numeric argument to binary operator
a <- df[,2:3]
mode(a[,1])
#[1] "numeric" # Uh Oh! mode is wrong!...
as.matrix(a) # ... as.matrix() converts as strings
# X2 X3
#[1,] "-3.89274205212847" "12.7336046818466"
#[2,] "12.3494043977024" "17.9329667214396"
#[3,] "4.7419241278816" "16.0664073330786"
#[4,] "8.50784944656814" "8.65139145569206"
#[5,] "9.56191506080518" "21.2114650777001"
a[,1] #... because they are factors
#[1] -3.89274205212847 12.3494043977024 4.7419241278816 8.50784944656814 9.56191506080518
#Levels: -3.89274205212847 12.3494043977024 4.7419241278816 8.50784944656814 9.56191506080518
From: http://www.r-bloggers.com/type-conversion-and-you-or-and-r/
- (1518)How to (pretty) print a data.frame with cat() in R?
Use capture.output()!
prettyPrintDF <- function(myDF) {
asString <- capture.output(myDF)
asString2 <- paste(asString, "\n", sep="")
cat(asString2, "\n")
}
From: http://r.789695.n4.nabble.com/print-data-frame-to-string-td4631989.html
- (1521)How to cleanly remove columns/rows by name in R?
Beware that using a simple df[,-match(cols,colnames(df))] will lead to a vicious error if "cols" is empty, as df[, -c()] == df[, c()] == a valid data.frame but with no lines.
removeColumns <- function(dataFrame, colNames) {
stopifnot(is.data.frame(dataFrame),
is.character(colNames))
if (length(colNames) == 0) {
return(dataFrame)
} else {
return(dataFrame[,-match(colNames, colnames(dataFrame))])
}
}
removeRows <- function(dataFrame, rowNames) {
stopifnot(is.data.frame(dataFrame),
is.character(rowNames))
if (length(rowNames) == 0) {
return(dataFrame)
} else {
return(dataFrame[-match(rowNames, rownames(dataFrame)),])
}
}
- (1706)How to solve "Cannot find JRI native library" / "java.lang.UnsatisfiedLinkError" when running R code inside Java using JRI?
You must add JRI's libs (and their deps) to Java's lib path:
export LD_LIBRARY_PATH=~/.R/amd64-portbld-freebsd10.1-library/3.2.2/rJava/jri/:/usr/local/lib/R/lib:/usr/local/openjdk7/jre/lib/amd64/server/:/usr/local/lib/gcc48/:$LD_LIBRARY_PATH
From: https://stackoverflow.com/questions/19100875/java-r-interface-jri-setup
https://lists.freebsd.org/pipermail/freebsd-toolchain/2014-April/001150.html
- (1945)How to solve "package 'xxx' is not available (for R version x.y.z)" in R?
In Ubuntu 16+, with R>3.0, the default "internal" download method
cannot to get data/packages from HTTPs servers, you need to use an
external method, like "lynx" or "wget". Add the following line to your
.Rprofile:
options(download.file.method="wget")
From: http://stackoverflow.com/questions/25721884/how-should-i-deal-with-package-xxx-is-not-available-for-r-version-x-y-z-wa
- (1946)How can I see what data sets are available?
- Globally:
data()
- For a particular package:
data(package="caret")
From: http://statistics.ats.ucla.edu/stat/r/faq/data_sets_avaiable_R.htm
- (1973)How to "flatten" a data.frame in R?
SOLUTION I: if what you want is simply concatenate line contents one after the another:
c(test[["seq"]], recursive = TRUE) # fast
do.call("c", test[["seq"]]) # fast
unlist(test[["seq"]]) # very slow
SOLUTION II: if what you want is to combine the various combinations of line/col values into line only
see reshape2::melt()
From: https://stackoverflow.com/questions/9467321/flatten-a-data-frame
https://cran.r-project.org/web/packages/reshape2/index.html
- (2016)How to calculate the euclidean norm of a vector in R?
normL2 <- function(x) { sqrt(sum(x^2)); }
normL2 <- function(x) { norm(x, type="2"); }
From https://stackoverflow.com/questions/10933945/how-to-calculate-the-euclidean-norm-of-a-vector-in-r#10934119
- (2029)How to solve lacking system lib failure when installing R packages (eg: EBImage, mgcv)?
R > install.packages("mgcv")
Installing package into ‘/~/.R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.univ-paris1.fr/src/contrib/mgcv_1.8-17.tar.gz'
Content type 'application/x-gzip' length 849787 bytes (829 KB)
==================================================
downloaded 829 KB
* installing *source* package ‘mgcv’ ...
** package ‘mgcv’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fopenmp -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c coxph.c -o coxph.o
gcc -std=gnu99 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o mgcv.so coxph.o discrete.o gdi.o init.o magic.o mat.o matrix.o mgcv.o misc.o mvn.o qp.o soap.o sparse-smooth.o tprs.o -llapack -lblas -lgfortran -lm -lquadmath -fopenmp -L/usr/lib/R/lib -lR
[...]
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'mgcv.so' failed
make: *** [mgcv.so] Error 1
ERROR: compilation failed for package ‘mgcv’
* removing ‘/home/guillaume/.R/x86_64-pc-linux-gnu-library/3.2/mgcv’
The downloaded source packages are in
‘/tmp/RtmpC34Fi2/downloaded_packages’
Warning message:
In install.packages("mgcv") :
installation of package ‘mgcv’ had non-zero exit status
SOLUTION: You must install the system lib packages, but more importantly their companion header poackages (xxx-dev packages) :
=> sudo apt-get install libblas3 libblas3-dev liblapack3 liblapack3-dev
From: own experience
- (2031)How to resolve stack limit error in R (a.k.a How to solve "Error: memory exhausted (limit reached?)" or "Error: C stack usage 7970548 is too close to the limit")?
Just increase the size of the stack for all processes of the current shell before running R:
$ ulimit -s # print default
8192
$ R --slave -e 'Cstack_info()["size"]'
size
8388608
8388608 = 1024 * 8192; R is printing the same value as ulimit -s, but in bytes instead of kilobytes.
$ ulimit -s 16384 # enlarge stack limit to 16 megs
$ R --slave -e 'Cstack_info()["size"]'
size
16777216
From: http://stackoverflow.com/questions/14719349/error-c-stack-usage-is-too-close-to-the-limit#14719448
- (2062)How to resolve "Error creating thread: Resource temporarily unavailable" (a.k.a. How to make so that rattle 4+ can run)?
PROBLEM:
$ R
14:22:48 R > library("rattle") ; rattle();
(R:9689): GLib-ERROR **: creating thread 'gdbus': Error creating thread: Resource temporarily unavailable
SOLUTION:
$ ulimit -s 16000
From: https://unix.stackexchange.com/questions/253903/creating-threads-fails-with-resource-temporarily-unavailable-with-4-3-kernel
- (2068)Basic Shiny App
This App just draws a 2D plot from "iris" dataset, allowing you to
select which columns to use as xAxis, yAxis and colors.
---- server.R
library("shiny");
function(input, output) {
output$title <- renderText({
paste("Plotting ", strong(input$xAxis), " versus ", strong(input$yAxis), "with colors=", strong(input$color));
} );
output$plot <- renderPlot( {
data <- iris[, c(input$xAxis, input$yAxis)];
colors <- iris[, input$color];
plot(data, col=colors)
} );
}
---- ui.R
library("shiny");
last <- length(names(iris));
fluidPage(
titlePanel(title = "This is a basic Shiny app"), # Title of the webpage
sidebarLayout(
position = "right",
sidebarPanel(
h3("Select the variables to manipulate"),
#textInput("unused","Unused Name", "default name"),
selectInput("xAxis", "X-axis", names(iris), names(iris)[1]),
selectInput("yAxis", "Y-axis", names(iris), names(iris)[2]),
selectInput("color", "Color", names(iris), names(iris)[last])
),
mainPanel(
htmlOutput("title"),
plotOutput("plot") # do not use "output$" here, it is assumed!
)
)
)
From: http://shiny.rstudio.com/tutorial/
https://www.youtube.com/playlist?list=PL6wLL_RojB5xNOhe2OTSd-DPkMLVY9DfB
- (2095)How to check if a column exists in R?
"colnametocheck" %in% colnames(df)
From: https://stackoverflow.com/questions/10276092/to-find-whether-a-column-exists-in-data-frame-or-not
- (2226)How to time methods in R?
1) Sys.time()
start_time = Sys.time()
Sys.sleep(0.5)
end_time = Sys.time()
end_time - start_time
2) The tictoc package
library("tictoc")
tic("mark1")
tic("mark2")
Sys.sleep(2)
toc(log = TRUE) # ends mark2 timer
Sys.sleep(3)
toc(log = TRUE) # ends mark1 timer
3) system.time()
system.time(replicate(10, Sys.sleep(0.1)))
4) The microbenchmark package
library("microbenchmark")
microbenchmark(Sys.sleep(0.1), times = 10, unit = "s") # times=#repetitions, unit="s"= in secs
# Commands can even been named
sleep = microbenchmark(sleepy = Sys.sleep(0.1),
sleepier = Sys.sleep(0.2),
sleepiest = Sys.sleep(0.3),
times = 10,
unit = "s")
# Results can be plotted
microbenchmark:::autoplot.microbenchmark(sleep)
microbenchmark:::boxplot.microbenchmark(sleep)
From: https://www.r-bloggers.com/timing-in-r/
- (2285)How to choose a random number in R?
> x1 <- runif(<number_of_values>, <min>, <max>)
> x3 <- sample(<min>:<max>, <number_of_values>[, replace=T]) # use "replace" if repetitions are allowed
> ?runif
> ?sample
> ?.Random.seed
From: http://blog.revolutionanalytics.com/2009/02/how-to-choose-a-random-number-in-r.html
- (2308)R Tip: Use qc() For Fast Legible Quoting
library("wrapr") # get qc() definition
head(mtcars[, qc(mpg, cyl, wt)]) # <- here no need to add many quotes
From: https://www.r-bloggers.com/r-tip-use-qc-for-fast-legible-quoting/
- (2426)How to easily quote multiple elements in R (alternative to paste(...sep="")?)?
Need to quote a lot of names at once? Use qc().
This is particularly useful in selecting columns from data.frames:
library("wrapr") # get qc() definition
head(mtcars[, qc(mpg, cyl, wt)])
# shorter than the alternative:
# head(mtcars[, c("mpg", "cyl", "wt")])
Or even to install many packages at once:
install.packages(qc(vtreat, cdata, WVPlots))
# shorter than the alternative:
# install.packages(c("vtreat", "cdata", "WVPlots"))
From: https://www.r-bloggers.com/r-tip-use-qc-for-fast-legible-quoting/
- (2556)My typical .Rprofile (with date + color in the prompt + setting of terminal width)
# Skip banner/splash screen
options(quiet=TRUE);
# Prevent the printing of "+" when R waits for new input => allows copy/paste
# from R to $EDITOR
options(continue=" ");
# Set the default repository to be Lyon1
options(repos=c("http://cran.univ-lyon1.fr"));
# Set the user directory for libraries
Rplatform <- paste(R.version['platform'],"library", sep='-')
Rversion <- paste(R.version['major'], substring(R.version['minor'],1,1), sep=".")
.libPaths(paste("~/.R", Rplatform, Rversion, sep="/"))
getWidth <- function() {
howWide <- system("stty -a | head -n 1 | awk '{print $7}' | sed 's/;//'", intern=T)
##howWide <- Sys.getenv("COLUMNS") # This method does not adapt to dynamic changes in window size :[
return(howWide)
}
# Set width and add date+color to the prompt
updatePrompt <- function(...)
{
runsFromRStudio <- Sys.getenv("RSTUDIO") == "1" # or: "tools:rstudio" %in% search()
if (interactive() && !runsFromRStudio) {
# Add Time + Colors
options(menu.graphics=FALSE,
prompt=paste("\001\033[01;32m\002", format(Sys.time(),"%H:%M:%S"), "R > \001\033[00m\002"));
# Get current # of columns in the term
options(width=getWidth());
} else {
options(menu.graphics=FALSE,
prompt=paste(format(Sys.time(),"%H:%M:%S"), "R > "));
}
return(invisible(TRUE));
}
updatePrompt() ;
invisible(addTaskCallback(updatePrompt));
#### Using --save on commandline/in alias renders everything below useless
## .First<- function() {
## library(utils);
## loadhistory("~/.Rhistory"); #To get the file from the envrnmt: Sys.getenv("R_HISTFILE")
## }
## .Last <- function() {
## if(!any(commandArgs()=='--no-readline') && interactive()) {
## try(savehistory("~/.Rhistory"));
## }
## }
## # From: https://stackoverflow.com/questions/13043146/how-to-make-qyes-the-default-quitting-behavior-in-r-using-rprofile/60043504#60043504
## # Override q() to not save by default.
## # !!! using alias R='R --vanilla' in .bashrc works better !!!
## #q <- function(save = "yes", status = 0, runLast = TRUE){
## #.Internal(quit(save, status, runLast))
## # #<environment: namespace:base>
## #}
- (2704)How to upgrade all packages at once with R?
# 1) Get R version info for 2)
Rplatform <- paste(R.version['platform'],"library", sep='-')
Rversion <- paste(R.version['major'], substring(R.version['minor'],1,1), sep=".")
# 2) Set the user directory for libraries
.libPaths(paste("~/.R", Rplatform, Rversion, sep="/"))
# 3) Set the downloading repo
options(repos=c("http://cran.univ-lyon1.fr"));
# 4) Actually make the update while enforcing the libPath otherwise some packages will try install their deps in the default (system) location :[
update.packages(ask=FALSE, lib.loc=.libPaths()[1])
# update.packages(rownames(installed.packages()), lib.loc=.libPaths()[1], ask=F)
- (2747)How to resolve the following error while opening rattle "Error in .RGtkCall(”S_gtk_file_chooser_dialog_new_with_backend"?
Install previous version of RGtk2
install.packages("https://cran.r-project.org/src/contrib/Archive/RGtk2/RGtk2_2.20.35.tar.gz", repos=NULL)
- (2752)How to find indices of duplicated rows in R?
This returns a logical index vector:
duplicated(df) | duplicated(df[nrow(df):1, ])[nrow(df):1]
Here's an example:
df <- data.frame(a = c(1,2,3,4,1,5,6,4,2,1))
duplicated(df) | duplicated(df[nrow(df):1, ])[nrow(df):1]
#[1] TRUE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
which(duplicated(df) | duplicated(df[nrow(df):1, ])[nrow(df):1])
#[1] 1 2 4 5 8 9 10
The complexity of the command can be reduced if fromLast = TRUE is used as function argument. This is easier than creating two reversed vectors.
duplicated(df) | duplicated(df, fromLast = TRUE)
duplicated(df) | duplicated(df, fromLast = TRUE)
#[1] TRUE TRUE FALSE TRUE TRUE FALSE FALSE TRUE TRUE TRUE
How it works?
The function duplicated is applied to both the original data frame and the data frame with reversed order of rows. The output of the latter is reversed again. Note that the first occurrences of duplicated values in the original data are the last occurrences in the reversed version. Afterwards, both vectors are combined using | since a TRUE in at least one of them indicates a duplicated value.
From: https://stackoverflow.com/questions/12495345/find-indices-of-duplicated-rows
- (2757)How to read & write Excel sheets from R?
There exist several packages, but the ones below are more complete.
install.packages("readxl")
# writexl is not currently on CRAN, so install it from GitHub
devtools::install_github("ropensci/writexl")
library(readxl)
library(writexl)
data <- read_excel("data/climate_change_download_0.xls", sheet = "Data")
data
From: https://tutorials.methodsconsultants.com/posts/reading-and-writing-excel-files-with-r-using-readxl-and-writexl/
- (2803)How to "simulate" passing by reference in R?
By default, R passes function args *by value*, i.e. it copies the value to a new structure.
If you want to lighten data transfer, you can simulate a passage *by reference*, by passing list()s as arguments.
This is probably due to the fact that list()s are ~ pointers to their first element, thus the pointer is the only thing copied.
Thanks Benjamin Charlier & Ghislain Durif for their Presentation of KeOps @ SciDoLySE
- (2823)How to "deselect" a column by name?
You can do this using vector subsetting. First, create a dummy data set:
R> dd = data.frame(A = 1:3, B = 1:3, C=1:3, D=1:3)
Then use the ! operator to reverse the selection:
R> dd[ ,!(colnames(dd) == "A")]
B C D
1 1 1 1
2 2 2 2
3 3 3 3
Alternatively, you could have:
A slightly shorter version (courtesy of @Tomas):
dd[ , names(dd) != "A"]
To cope with multiple columns (courtesy of @Tyler)
dd[ ,!(colnames(dd) %in% c("A", "B"))]
From: https://stackoverflow.com/questions/9805507/deselecting-a-column-by-name#9805544
- (2826)What's the difference between `=` and `<-` in R?
From http://stat.ethz.ch/R-manual/R-patched/library/base/html/assignOps.html :
"The operators <- and = assign into the environment in which they are evaluated. The operator <- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions."
---
Reading from "Introducing Monte Carlo Methods with R", by Robert and Casella:
"The assignment operator is =, not to be confused with ==, which is the Boolean operator for equality. An older assignment operator is <- and, for compatibility reasons, it still remains functional, but it should be ignored to ensure cleaner programming. (As pointed out by Spector, P. (2009). 'Data Manipulation with R' - Section 8.7., an exception is when using system.time, since = is then used to identify keywords)
A misleading feature of the assignment operator <- is found in Boolean expressions such as
> if (x[1]<-2) ...
which is supposed to test whether or not x[1] is less than -2 but ends up allocating 2 to x[1], erasing its current value! Note also that using
> if (x[1]=-2) ...
mistakenly instead of (x[1]==-2) has the same consequence."
From: https://stackoverflow.com/questions/2271575/whats-the-difference-between-and-in-r
- (2827)How to compute the density (distribution?) of a vector, e.g. to plot an histogram?
density(x, …)
From: https://www.rdocumentation.org/packages/stats/versions/3.6.2/topics/density
- (2828)How to correct "Error in py_get_attr_impl(x, name, silent) : AttributeError: 'Sequential' object has no attribute 'metrics'" in Keras?
When you compile your model, specify the metrics using string, and not array. Like this:
modelo %>% compile(
loss = 'categorical_crossentropy',
optimizer = optimizer_rmsprop(),
metrics = 'accuracy'
)
If you do something like this: metrics = c('accuracy') it will not work.
NOTE GM: But apparently c("accuracy") works?
From: https://stackoverflow.com/questions/48888752/error-in-py-get-attr-implx-name-silent-attributeerror-sequential-object/49068173#49068173
- (2829)How to convert categorical data to one-hot encoding, for ML algorithms that do not like categorical values?
varhandle::to.dummy()
From: https://rdrr.io/cran/varhandle/man/to.dummy.html
-- or
keras.utils::to_categorical()
From: https://keras.io/utils/#to_categorical
- (2830)How to solve "Keras: ValueError: No data provided for “input_1”. Need data for each key"?
This error generally occurs in 3 cases (In R):
- The input data does not have the same dimension as was declared in the first layer
- The input data includes missing values
- The input data is not a matrix (for example, a data frame)
Maybe this code in R can help:
library(keras)
#The network should identify the rule that a row sum greater than 1.5 should yield an output of 1
my_x=matrix(data=runif(30000), nrow=10000, ncol=3)
my_y=ifelse(rowSums(my_x)>1.5,1,0)
my_y=to_categorical(my_y, 2)
model = keras_model_sequential()
layer_dense(model,units = 2000, activation = "relu", input_shape = c(3))
layer_dropout(model,rate = 0.4)
layer_dense(model,units = 50, activation = "relu")
layer_dropout(model,rate = 0.3)
layer_dense(model,units = 2, activation = "softmax")
compile(model,loss = "categorical_crossentropy",optimizer = optimizer_rmsprop(),metrics = c("accuracy"))
history <- fit(model, my_x, my_y, epochs = 5, batch_size = 128, validation_split = 0.2)
evaluate(model,my_x, my_y,verbose = 0)
predict_classes(model,my_x)
From: https://stackoverflow.com/questions/42379138/keras-valueerror-no-data-provided-for-input-1-need-data-for-each-key/50666476#50666476
- (2837)How to customize key binding in RStudio (a.k.a. How to enable switching between code panel and R shell with keyboard)?
- Open Tools > Modify Keyboard Shortcuts
- Set a key from "Switch focus between Source/Console", e.g. CTRL-Tab
From: https://support.rstudio.com/hc/en-us/articles/206382178-Customizing-Keyboard-Shortcuts
- (2835)How to convert R objects to/from Python objects (a.k.a. How to get the layers of a Keras model as an R list)?
Use reticulate::r_to_py() and reticulate::py_to_r()
E.g.
library("keras")
library("reticulate")
...
model %>% compile(...)
model %>% fit(...)
layers <- py_to_r(model)$layers
Also see Tips#2836
From: https://www.r-bloggers.com/what-r-you-r-list-in-python/
- (2836)How to access the complete architecture of a Keras model (a.k.a. How to access the configuration of the NN including the input and output layers' shapes)?
keras::get_config(<keras model>)
> model_config <- py_to_r(get_config(model))
> model_config$layers[[1]]$config$batch_input_shape
output: nb of unit on the input layer
> model_config$layers[[1]]$config$units
output: nb of unit on the 1rst hidden layer
-- another way:
layers <- py_to_r(model)$layers
layers[[1]]$input
Also see Tips#2835
From: https://keras.rstudio.com/reference/get_config.html
- (2900)How to convert factors (of numerical values) to (their actual values as) integers?
PROBLEM: if you use as.numeric() on a factor, it returns the numeric value for the internal representation of the factor. The problem is is you factor represents numerical values, how to get these as returned values?
> numbers <- factor(c(9, 8, 10, 8, 9))
> as.numeric(numbers)
[1] 2 1 3 1 2 <- here we would like 8/9/10...
> as.character(numbers)
[1] "9" "8" "10" "8" "9" <- ...like we get here
SOLUTION: See help page for factor, use double conversion:
as.numeric(levels(f))[f] is recommended
as.numeric(as.character(f)) is slightly less efficient
From: https://stackoverflow.com/questions/4798343/convert-factor-to-integer/4798794#4798794
- (2901)How to Convert factors in R?
== To string
Use as.character() to convert a factor to a character vector:
> directions <- factor(c("North", "East", "South", "South"))
> as.character(directions)
[1] "North" "East" "South" "South"
== To numerical values
Use as.numeric() to convert a factor to a numeric vector. Note that this will return the numeric codes that correspond to the factor levels.
> directions <- factor(c("North", "East", "South", "South"))
> as.numeric(directions)
[1] 2 1 3 3
From: https://www.dummies.com/programming/r/how-to-convert-a-factor-in-r/
- (3012)How to plot an image (raster) using base graphics in R?
img <- data.frame(<2D array>)
rasterImage(img, 0, 0, dim(img)[1], dim(img)[2])
From: https://stackoverflow.com/questions/9543343/plot-a-jpg-image-using-base-graphics-in-r#28729601
- (3017)How to detect if R is running from RStudio (a.k.a. How to prevent redefinition of some variables, like line width, in .Rprofile if running from RStudio)?
SOLUTION1: no package, based on env vars, works in any condition
# Test whether running under RStudio
isRStudio <- Sys.getenv("RSTUDIO") == "1"
SOLUTION1b: (similar but more general than SOLUTION1)
any(grepl("rstudio",Sys.getenv(),ignore.case=TRUE))
SOLUTION1c:
Sys.getenv("RSTUDIO_USER_IDENTITY")!= ""
SOLUTION2a: no package, based on libs, does not work if .libPaths is also modified in .Rprofile
any(grepl("RStudio", .libPaths()))
SOLUTION2b:
"tools:rstudio" %in% search()
SOLUTION3a: no packages, based on RStudio vars, very dependent on RStudio version
is.rstudio = function(){
.Platform$GUI == "RStudio"
}
SOLUTION3b:
is.RStudio <- function(){
if(!exists("RStudio.version"))return(FALSE)
if(!is.function(RStudio.version))return(FALSE)
return(TRUE)
}
SOLUTION4: with packages
rstudioapi::isAvailable()
assertive::is_rstudio()
startup:::is_rstudio_console()
From: https://stackoverflow.com/questions/12389158/check-if-r-is-running-in-rstudio
- (3031)How to do Data Wrangling in R?
set.seed : fixes the random seed, for repeatable experiments
sample : selects subset elements from a set. Can select with/without replacement. With a single number "x" as input, returns a permutation of 1:x
table: displays a correlation matrix
prop.table: same as table but provides proportions
ifelse: helps replace values conditionally
expand.grid: generates all the combinations of input values
From: https://clayford.github.io/dwir/dwr_12_generating_data.html
- (3032)How to code cleanly and check function arguments values (a.k.a What is the equivalent of 'assert()' in R)?
!ATTENTION!
stopifnot() : validity testing = test that code does what expected (~Unit Test)
For *input* testing, rather use :
if (blahdiblah) stop("error message")
Or use the assertthat::assertthat() method.
From: https://stackoverflow.com/questions/2233584/does-r-have-an-assert-statement-as-in-python#2233599
- (3035)How do I extract a single column from a data.frame as a data.frame?
Use drop=FALSE
> df <- data.frame(A=c(10,20,30),B=c(11,22,33), C=c(111,222,333))
A B C
1 10 11 111
2 20 22 222
3 30 33 333
> x <- df[,1, drop=FALSE]
> x
A
1 10
2 20
3 30
From: https://stackoverflow.com/questions/21025609/how-do-i-extract-a-single-column-from-a-data-frame-as-a-data-frame#21025639
- (3047)What are the R equivalents of np.sum and np.reshape?
# Equivalent of reshape/ravel/flatten (NOTE: unfortunately R matrices only store objects of same type)
mat <- matrix(c(0,5,0,1), nrow=2, ncol=2)
# Equivalent of np.sum
rowSums(mat) / colSums(mat)
or *apply(FUN=sum)
From: https://stackoverflow.com/questions/53375385/r-and-pandas-r-equivalent-of-np-sum-and-np-reshape/53375678#53375678
- (3187)How to configure reticulate to use an existing Python install, rather than an internal minicoda (and thus gain HD space + coherence within 1-Python envs, 2-R&Python envs)?
use_python("/usr/bin/python3")
use_virtualenv("/path/to/venv-topdir/", TRUE)
Then you can test it (for instance if WordCloud is installed in Python venv)
library(reticulate)
wc <- import("wordcloud")
p <- wc$WordCloud()
p$generate(text="ceci est un long long long texte")
i <- p$to_image()
i$show()
From: https://blog.rstudio.com/2019/12/20/reticulate-1-14/
https://github.com/rstudio/reticulate
- (3251)How to install R 4.0 in Linux Mint20?
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/'
sudo apt update
From: https://rtask.thinkr.fr/installation-of-r-4-0-on-ubuntu-20-04-lts-and-tips-for-spatial-packages/
- (3372)How to solve \"ERROR: dependency \'xxx\' is not available for package \'yyy\'? (a.k.a. \"Error: package or namespace load failed for ‘xxx’ ... there is no package called ‘yyy’)?
SOLUTION1: Disable your config files (if they load some libs with library(yyy) & fail, this will prevent update of yy and possibly of its deps)
mv ~/.Rprofile{,.backup}
mv ~/.Renv{,.backup}
SOLUTION2: Change the repository
options(repos = c(CRAN = \"https://cran.rstudio.com\"))
SOLUTION3: try installing the \'xxx\' package manually
install.packages(\"config\", dep=T, ask=F, lib=\"/path/to/your/local/packages\")
From: https://www.stat.math.ethz.ch/pipermail/r-help/2019-August/463668.html
https://github.com/sparklyr/sparklyr/issues/230#issuecomment-249642711
https://stackoverflow.com/questions/47263330/error-while-installing-dplyr-in-r/47263384
- (3445)How to upgrade all packages by script?
----- upgrade_all_R_packages.sh
#!/usr/bin/env bash
FIFO=/tmp/Rupg
mkfifo $FIFO
R < $FIFO &
# Upgrade the packages
echo "update.packages(ask=F, l='.R/x86_64-pc-linux-gnu-library/4.0/')" > $FIFO
# Save a list of the packages & vesrions
echo "write.csv(file='~/.R/"$(date --iso-8601 | sed 's/-/_/g')"_packages.list', x=installed.packages())" > $FIFO
echo "quit()" > $FIFO
fg
\rm $FIFO
-----
- (3496)How to (re)select the (default) CRAN mirror with a GUI?
chooseCRANmirror(graphics = getOption("menu.graphics"), ind = NULL, local.only = FALSE)
From: https://stat.ethz.ch/R-manual/R-patched/library/utils/html/chooseCRANmirror.html
- (3558)How to solve error "there is no packages called xxx"?
In my case the problem was that the .libPaths() did not pointed to the correct directory (~/.R/x86_64-pc-linux-gnu-library/<major>.<minor>/)
- (3661)How to install packages binaries instead of compiling from sources?
Use repositories from RStudio:
https://packagemanager.rstudio.com/client/#/repos/1/overview
e.g.
options(repos = c("https://packagemanager.rstudio.com/all/__linux__/focal/latest"))
From: https://github.com/mlverse/torch/issues/724#issuecomment-955205615
- (3662)How to install "torch" in R (a.k.a. How to solve error "as: out of memory allocating xxx bytes after a total of yyy bytes)?
PROBLEM
For some probably obscure security reason, there was a low ulimit on several memory-related entries:
$ ulimit -a
...
max locked memory (kbytes, -l) 1519764
max memory size (kbytes, -m) 2097152
...
SOLUTION
Go root (as users can only decrease the values):
# ulimit -l $(($(ulimit -l)*1024))
Then fake a "login" as user and run the R pkg upgrade:
# su - <user>
$ R
> install.packages("torch", ask=F, repos="https://packagemanager.rstudio.com/all/__linux__/focal/latest")
From: https://github.com/mlverse/torch/issues/724#issuecomment-1003773083
- (3664)How to install R-package prophet (a.k.a. How to solve "ERROR: configuration failed for package ‘V8’")?
Step 1: install.packages("matrixStats")
Step 2: install.packages("loo")
Step 3: Sys.setenv(DOWNLOAD_STATIC_LIBV8=1) ### <- Here is the trick!!!
Step 4: install.packages("V8")
Step 5: install.packages("rstan")
Step 6: install.packages("prophet")
From: https://community.rstudio.com/t/unable-to-install-r-package-prophet/81428/12
- (3943)How do I save a wordcloud as a .png using the wordcloud2 package in R?
NOTE: DOES NOT WORK WITH ALL WordCloud shapes => use wordcloud package instead (less configurable but directly exports to png)
library(wordcloud2)
library(webshot)
library(htmlwidgets)
Bcloud <- wordcloud2(wordFreq,
size = 1,
color = colorVec)
Bcloud
#
saveWidget(Bcloud, "tmp.html", selfcontained = F)
webshot("tmp.html", "wordcloud.png", delay = 120, vwidth = 2000, vheight = 2000)
From: https://stackoverflow.com/questions/62539150/how-do-i-save-a-wordcloud-as-a-png-using-the-wordcloud2-package-in-r
- (4105)How to solve "Error in library(rlang) : there is no package called ‘rlang’" when installing tidyverse?
SOLUTION1:
install.packages("stringi", dependencies=TRUE, INSTALL_opts = c('--no-lock'))
install.packages("stringr", dependencies=TRUE, INSTALL_opts = c('--no-lock'))
install.packages("tidyverse")
SOLUTION2:
Look for an old version of rlang hidden on your computer. Delete them all.
From: https://stackoverflow.com/questions/49721356/trouble-downloading-rlang-with-tidyverse
- (1784)How to convert a set into a string in Python3?
s=set([1,2,3,4,5,6])
", ".join(str(e) for e in s)
This can be useful to concatenate string in a print:
print("Values in the set: "+", ".join(str(e) for e in s))
From: https://stackoverflow.com/questions/17750099/python-print-list-of-sets-without-brackets
- (1804)How to get the path/name of the script currently being executed?
Use __file__.
If you want to omit the directory part (which might be present), you can use:
import os
os.path.basename(__file__)
or:
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
From: https://stackoverflow.com/questions/4152963/get-the-name-of-current-script-with-python#4152986
http://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory#5137509
- (1805)How to create class/instance attributes in Python?
- class (or static) variables: variables declared inside the class definition, but not inside a method. They can be accessed by *prefixing with the class name*:
>>> class MyClass:
... i = 3
...
>>> MyClass.i
3
- instance-level variables: they can be created / accessed by *prefixing with an instance* name:
>>> m = MyClass()
>>> m.i = 4
>>> MyClass.i, m.i
>>> (3, 4)
From: https://stackoverflow.com/questions/68645/static-class-variables-in-python
- (3864)How do I check if PyTorch is using the GPU?
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.device_count()
1
>>> torch.cuda.current_device()
0
>>> torch.cuda.device(0)
<torch.cuda.device at 0x7efce0b03be0>
>>> torch.cuda.get_device_name(0)
'GeForce GTX 950M'
From: https://stackoverflow.com/questions/48152674/how-do-i-check-if-pytorch-is-using-the-gpu#48152675
- (2296)How to pass an argument to a GUI/button callback funtion in Python/TKInter?
button = Tk.Button(master=frame, text='press', command= lambda:action(someNumber))
From: https://stackoverflow.com/questions/6920302/how-to-pass-arguments-to-a-button-command-in-tkinter#6921225
- (2310)How to replace multiple values in a list at the same time?
You can replace multiple values in a list at the same time:
data[1:2] = ["toto","tutu"]
From: Snake Wrangling For Kids
- (2311)How to properly copy a list?
x= ['a','b','c']
y = x # copies the pointer to abc
y[1] = 'z'
print(x)
>['a','z','c'] # x is also modified :)
To actually copy a list:
y=list(x)
y=x[:]
- (2312)How to import packages?
import <pkg>
import <pkg>.<method> # pkg name will be required at method call
import <pkg> as <alias>
from <pkg> import <method> # pkg name NOT required at method call
- (2351)How to convert a number range to another range, maintaining ratio?
OldRange = (OldMax - OldMin)
NewRange = (NewMax - NewMin)
NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
From: https://stackoverflow.com/questions/929103/convert-a-number-range-to-another-range-maintaining-ratio
- (2428)Tips Python
- Various ways of importing a package
import <pkg>
import <pkg> as <alias>
from <pkg> import <method> # Python3 only?
- Copying lists
x= ['a','b','c']
y = x # copies the *pointer to* abc
y[1] = 'z'
print(x)
['a','z','c'] # x is also modified :)
To actually copy a list:
y=list(x)
y=x[:]
- List replacements
You can replace multiple values in a list at the same time:
data[1:2] = ["toto","tutu"]
- (2486)What is the equivalent of the ternary conditional operator in Python ((cond)?then_code:else_code)
<then_code> if condition else <else_code>
From: https://stackoverflow.com/questions/394809/does-python-have-a-ternary-conditional-operator#394814
- (2487)How to get a sublist of a list, based on the given indices in Python?
You can use list comprehension to get that list:
c = [a[index] for index in b]
print c
This is equivalent to:
c= []
for index in b:
c.append(a[index])
print c
From: https://stackoverflow.com/questions/22412509/getting-a-sublist-of-a-python-list-with-the-given-indices#22412533
- (2488)How to have a main() method in a Python class?
Use:
if __name__== "__main__":
<your code>
From: https://www.guru99.com/learn-python-main-function-with-examples-understand-main.html
- (2489)How to reshape a pandas series?
You can call reshape on the values array of the Series:
In [4]: a.values.reshape(2,2)
Out[4]:
array([[1, 2],
[3, 4]], dtype=int64)
From: https://stackoverflow.com/questions/14390224/reshape-of-pandas-series#14390487
- (2490)How to find the maximum of each row in a numpy array and the corresponding element in another array of the same size?
b[np.arange(len(a)), np.argmax(a, axis=1)]
For example:
>>> a = np.array([
[1, 2, 0],
[2, 1, 0],
[0, 1, 2]
])
>>> b = np.array([
[1, 2, 3],
[1, 2, 3],
[1, 2, 3]
])
>>> b[np.arange(len(a)), np.argmax(a, axis=1)]
array([2, 1, 3])
From: https://stackoverflow.com/questions/31733605/find-maximum-of-each-row-in-a-numpy-array-and-the-corresponding-element-in-anoth
- (2491)How do I check whether a file exists without exceptions?
If the reason you're checking is so you can do something like if file_exists: open_it(), it's safer to use a try around the attempt to open it. Checking and then opening risks the file being deleted or moved or something between when you check and when you try to open it.
If you're not planning to open the file immediately, you can use os.path.isfile
Return True if path is an existing regular file. This follows symbolic links, so both islink() and isfile() can be true for the same path.
import os.path
os.path.isfile(fname)
if you need to be sure it's a file.
Starting with Python 3.4, the pathlib module offers an object-oriented approach (backported to pathlib2 in Python 2.7):
from pathlib import Path
my_file = Path("/path/to/file")
if my_file.is_file():
# file exists
To check a directory, do:
if my_file.is_dir():
# directory exists
To check whether a Path object exists independently of whether is it a file or directory, use exists():
if my_file.exists():
# path exists
You can also use resolve(strict=True) in a try block:
try:
my_abs_path = my_file.resolve(strict=True)
except FileNotFoundError:
# doesn't exist
else:
# exists
From: https://stackoverflow.com/questions/82831/how-do-i-check-whether-a-file-exists-without-exceptions#82852
- (2492)How can I get the inspect/source code of a Python function?
If the function is from a source file available on the filesystem, then inspect.getsource(foo) might be of help:
If foo is defined as:
def foo(arg1,arg2):
#do something with args
a = arg1 + arg2
return a
Then:
import inspect
lines = inspect.getsource(foo)
print(lines)
Returns:
def foo(arg1,arg2):
#do something with args
a = arg1 + arg2
return a
But I believe that if the function is compiled from a string, stream or imported from a compiled file, then you cannot retrieve its source code.
From: https://stackoverflow.com/questions/427453/how-can-i-get-the-source-code-of-a-python-function#427533
- (2493)How to define a static/class variables/methods in Python?
Variables declared inside the class definition, but not inside a method are class or static variables:
>>> class MyClass:
... i = 3
...
>>> MyClass.i
3
As @millerdev points out, this creates a class-level i variable, but this is distinct from any instance-level i variable, so you could have
>>> m = MyClass()
>>> m.i = 4
>>> MyClass.i, m.i
>>> (3, 4)
This is different from C++ and Java, but not so different from C#, where a static member can't be accessed using a reference to an instance.
See what the Python tutorial has to say on the subject of classes and class objects: https://docs.python.org/2/tutorial/classes.html#class-objects
@Steve Johnson has already answered regarding static methods (http://web.archive.org/web/20090214211613/http://pyref.infogami.com/staticmethod), also documented under "Built-in Functions" in the Python Library Reference (https://docs.python.org/2/library/functions.html#staticmethod).
class C:
@staticmethod
def f(arg1, arg2, ...): ...
@beidy recommends classmethods (https://docs.python.org/2/library/functions.html#classmethod) over staticmethod, as the method then receives the class type as the first argument, but I'm still a little fuzzy on the advantages of this approach over staticmethod. If you are too, then it probably doesn't matter.
From: https://stackoverflow.com/questions/68645/are-static-class-variables-possible#68672
http://web.archive.org/web/20090214211613/http://pyref.infogami.com/staticmethod
- (2494)How to create "private" variables in Python's classes?
It's cultural. In Python, you don't write to other classes' instance or class variables. In Java, nothing prevents you from doing the same if you really want to - after all, you can always edit the source of the class itself to achieve the same effect. Python drops that pretence of security and encourages programmers to be responsible. In practice, this works very nicely.
If you want to emulate private variables for some reason, you can always use the __ prefix from PEP 8. Python mangles the names of variables like __foo so that they're not easily visible to code outside the class that contains them (although you can get around it if you're determined enough, just like you can get around Java's protections if you work at it).
By the same convention, the _ prefix means stay away even if you're not technically prevented from doing so. You don't play around with another class's variables that look like __foo or _bar.
You can also define/use properties, where getters/setters are eventually disabled:
https://docs.python.org/3/library/functions.html#property
From: https://stackoverflow.com/questions/1641219/does-python-have-private-variables-in-classes#1641236
- (2495)How to (programmatically) check which version of scikit-learn is installed?
import sklearn
print('The scikit-learn version is {}.'.format(sklearn.__version__))
From: https://stackoverflow.com/questions/28501072/how-to-check-which-version-of-nltk-scikit-learn-installed#28501150
- (2496)How to write data in HD5 files from Python?
===== Write
import h5py
import numpy as np
arr = np.random.randn(1000)
with h5py.File('random.hdf5', 'w') as f:
dset = f.create_dataset("default", data=arr)
===== Read
with h5py.File('random.hdf5', 'r') as f:
data = f['default']
print(min(data))
print(max(data))
print(data[:15])
From: https://www.pythonforthelab.com/blog/how-to-use-hdf5-files-in-python/#basic-saving-and-reading-data
- (2497)How to flatten a pandas dataframe to a list?
SOLUTION1:
You can just use .flatten() on the DataFrame:
df.values.flatten()
and you can also add .tolist() if you want the result to be a Python list.
SOLUTION2:
You can try with numpy:
import numpy as np
np.reshape(df.values, (1,df.shape[0]*df.shape[1]))
From: https://stackoverflow.com/questions/25440008/python-pandas-flatten-a-dataframe-to-a-list#25440505
- (2512)How to read/write CSV files in Python?
I] Reading
import csv
with open('eggs.csv', 'r') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',', quotechar='"')
for row in spamreader:
print ', '.join(row)
II] Writing
import csv
with open('eggs.csv', 'w') as csvfile:
spamwriter = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
From: https://docs.python.org/2/library/csv.html
- (2513)How to read/write a CSV file with NumPy/Pandas?
import numpy
a = numpy.asarray([ [1,2,3], [4,5,6], [7,8,9] ])
numpy.savetxt("foo.csv", a, delimiter=",")
----
out = pd.DataFrame(data=[...], columns=...)
out.to_csv("/path/to/file.csv")
From: https://stackoverflow.com/questions/6081008/dump-a-numpy-array-into-a-csv-file#41096943
- (2514)How to walk through files/dirs in Python?
import os
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
print(os.path.join(root, name))
for name in dirs:
print(os.path.join(root, name))
From: https://www.tutorialspoint.com/python/os_walk.htm
- (2515)How to create a directory in Python?
import os
if not os.path.exists(directory):
os.makedirs(directory)
From: https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory-in-python#273227
- (2516)How to specify the column and row(index) names when creating a Pandas DataFrame from a NumPy array?
You need to specify data, index and columns to DataFrame constructor, as in:
Let's say you have the following NumPy array:
data = array([['','Col1','Col2'],['Row1',1,2],['Row2',3,4]])
To get an equivalent pandas DataFrame:
pd.DataFrame(data=data[1:,1:], # values
index=data[1:,0], # 1st column as index
columns=data[0,1:]) # 1st row as the column names
From: https://stackoverflow.com/questions/20763012/creating-a-pandas-dataframe-from-a-numpy-array-how-do-i-specify-the-index-colum#20763459
- (2517)How to create an empty DataFrame with only index/column names?
You can create an empty DataFrame with either column names or an Index:
In [4]: import pandas as pd
In [5]: df = pd.DataFrame(columns=['A','B','C','D','E','F','G'])
In [6]: df
Out[6]:
Empty DataFrame
Columns: [A, B, C, D, E, F, G]
Index: []
Or
In [7]: df = pd.DataFrame(index=range(1,10))
In [8]: df
Out[8]:
Empty DataFrame
Columns: []
Index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
From: https://stackoverflow.com/questions/44513738/pandas-create-empty-dataframe-with-only-column-names#44514187
- (2521)How to upgrade all packages at once with pip?
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
pip freeze | cut -d '=' -f1> requirements.txt && pip install -r requirements.txt --upgrade
- (2652)How to make IPython display matplotlib figures inline?
Use
%matplotlib inline
in the first cell of the notebook.
From: https://stackoverflow.com/questions/19410042/how-to-make-ipython-notebook-matplotlib-plot-inline
- (2664)How to find the location of the JSON connection file created by ipython kernel?
from CLI:
jupyter --runtime-dir
From Python code:
jupyter_core.paths.jupyter_runtime_dir()
From: https://stackoverflow.com/questions/36413531/cannot-locate-json-connection-file-created-by-ipython-kernel/36433438#36433438
- (2665)How to Raise Exceptions in Python?
try:
raise ValueError("My message")
except ValueError as e:
print("ValueError Exception:"+e.args[0])
From: https://www.dummies.com/programming/python/how-to-raise-exceptions-in-python/
- (2666)How to get the dimensions of a np.array?
import numpy as np
a = np.array([[1,2],[3,4]])
a.shape
- (2667)How to use map/reduce in Python (a.k.a change python2->3)?
* map() and filter() return iterators. If you really need a list, a quick fix is e.g. list(map(...)), but a better fix is often to use a list comprehension (especially when the original code uses lambda), or rewriting the code so it doesn’t need a list at all. Particularly tricky is map() invoked for the side effects of the function; the correct transformation is to use a regular for loop (since creating a list would just be wasteful).
* Removed reduce(). Use functools.reduce() if you really need it; however, 99 percent of the time an explicit for loop is more readable.
From: https://stackoverflow.com/questions/13638898/how-to-use-filter-map-and-reduce-in-python-3#13638960
https://docs.python.org/3.0/whatsnew/3.0.html#views-and-iterators-instead-of-lists
https://docs.python.org/3.0/whatsnew/3.0.html#builtins
From: https://stackoverflow.com/questions/13638898/how-to-use-filter-map-and-reduce-in-python-3#13638960
- (2668)How to flatten a structure (list of lists, array/list of arrays)?
With a (map)/reduce function:
functools.reduce(operator.iconcat, the_list_of_lists, [])
With a list-comprehension:
flatten = lambda l: [item for sublist in l for item in sublist]
With monoids (inefficient!)
>>> sum(l, [])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
This just sums the elements of iterable passed in the first argument, treating second argument as the initial value of the sum (if not given, 0 is used instead and this case will give you an error).
Because you are summing nested lists, you actually get [1,3]+[2,4] as a result of sum([[1,3],[2,4]],[]), which is equal to [1,3,2,4].
Note that only works on lists of lists. For lists of lists of lists, you'll need another solution.
From: https://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-list-of-lists/45323085#45323085
- (2693)What does the “yield” keyword do?
To understand what yield does, you must understand what generators are. And before you can understand generators, you must understand iterables.
Iterables
When you create a list, you can read its items one by one. Reading its items one by one is called iteration:
>>> mylist = [1, 2, 3]
>>> for i in mylist:
... print(i)
1
2
3
mylist is an iterable. When you use a list comprehension, you create a list, and so an iterable:
>>> mylist = [x*x for x in range(3)]
>>> for i in mylist:
... print(i)
0
1
4
Everything you can use "for... in..." on is an iterable; lists, strings, files...
These iterables are handy because you can read them as much as you wish, but you store all the values in memory and this is not always what you want when you have a lot of values.
Generators
Generators are iterators, a kind of iterable you can only iterate over once. Generators do not store all the values in memory, they generate the values on the fly:
>>> mygenerator = (x*x for x in range(3))
>>> for i in mygenerator:
... print(i)
0
1
4
It is just the same except you used () instead of []. BUT, you cannot perform for i in mygenerator a second time since generators can only be used once: they calculate 0, then forget about it and calculate 1, and end calculating 4, one by one.
Yield
yield is a keyword that is used like return, except the function will return a generator.
>>> def createGenerator():
... mylist = range(3)
... for i in mylist:
... yield i*i
...
>>> mygenerator = createGenerator() # create a generator
>>> print(mygenerator) # mygenerator is an object!
<generator object createGenerator at 0xb7555c34>
>>> for i in mygenerator:
... print(i)
0
1
4
Here it's a useless example, but it's handy when you know your function will return a huge set of values that you will only need to read once.
To master yield, you must understand that when you call the function, the code you have written in the function body does not run. The function only returns the generator object, this is a bit tricky :-)
Then, your code will continue from where it left off each time for uses the generator.
Now the hard part:
The first time the for calls the generator object created from your function, it will run the code in your function from the beginning until it hits yield, then it'll return the first value of the loop. Then, each other call will run the loop you have written in the function one more time, and return the next value until there is no value to return.
The generator is considered empty once the function runs, but does not hit yield anymore. It can be because the loop had come to an end, or because you do not satisfy an "if/else" anymore.
From: https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do
- (2703)How to correct bug "RuntimeError: Please check Spyder installation requirements:
spyder-kernels < 1.0 is required (found 1.0.1)." when upgrading spyder from pip --upgrade?
When using Tip#2521 to upgrade all packages, spyder-kernel is wrongly updated.
To correct:
pip install -U spyder
From: https://github.com/spyder-ide/spyder/issues/7395
- (2721)How to plot a density map (thus a spectrogram) in python?
I] Solution with plt.imshow()
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from matplotlib.colors import LogNorm
import numpy as np
x, y, z = np.loadtxt('data.txt', unpack=True)
N = int(len(z)**.5)
z = z.reshape(N, N)
plt.imshow(z+10, extent=(np.amin(x), np.amax(x), np.amin(y), np.amax(y)),
cmap=cm.hot, norm=LogNorm())
plt.colorbar()
plt.show()
II] Solution with plt.colormesh
import pylab as plt
import numpy as np
# Sample data
side = np.linspace(-2,2,15)
X,Y = np.meshgrid(side,side)
Z = np.exp(-((X-1)**2+Y**2))
# Plot the density map using nearest-neighbor interpolation
plt.pcolormesh(X,Y,Z)
plt.show()
From: https://stackoverflow.com/questions/24119920/how-to-plot-a-density-map-in-python
- (2740)How to create/initialize a venv?
python3 -m venv /path/to/new/virtual/environment
From: https://docs.python.org/3/library/venv.html
- (2799)How to transform b'...' strings to u'...' strings (a.k.a. How to get paramiko's stdout/stderr in a correct string format)?
You need to decode the bytes object to produce a string:
>>> b"abcde"
b'abcde'
# utf-8 is used here because it is a very common encoding, but you
# need to use the encoding your data is actually in.
>>> b"abcde".decode("utf-8")
'abcde'
This can be very useful to convert paramiko's output (stdout/stderr) from b'...' into a string you can use regexes on!
From: https://stackoverflow.com/questions/606191/convert-bytes-to-a-string/606199#606199
- (2807)How to ignore certain returned values when called a function that has multiple returns?
One common convention is to use a "_" as a variable name for the elements of the tuple you wish to ignore. For instance:
def f():
return 1, 2, 3
_, _, x = f()
From: https://stackoverflow.com/questions/431866/ignore-python-multiple-return-value/431871#431871
- (2831)How to compute precision and recall and F1-score for a Keras model?
These metrics have been removed from Keras core. You need to calculate them manually. They removed them on 2.0 version. Those metrics are all global metrics, but Keras works in batches. As a result, it might be more misleading than helpful.
However, if you really need them, you can do it like this:
from keras import backend as K
def recall_m(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
recall = true_positives / (possible_positives + K.epsilon())
return recall
def precision_m(y_true, y_pred):
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
precision = true_positives / (predicted_positives + K.epsilon())
return precision
def f1_m(y_true, y_pred):
precision = precision_m(y_true, y_pred)
recall = recall_m(y_true, y_pred)
return 2*((precision*recall)/(precision+recall+K.epsilon()))
# compile the model
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['acc',f1_m,precision_m, recall_m])
# fit the model
history = model.fit(Xtrain, ytrain, validation_split=0.3, epochs=10, verbose=0)
# evaluate the model
loss, accuracy, f1_score, precision, recall = model.evaluate(Xtest, ytest, verbose=0)
-- or
You can also try as mentioned below.
from sklearn.metrics import f1_score, precision_score, recall_score, confusion_matrix
y_pred1 = model.predict(X_test)
y_pred = np.argmax(y_pred1, axis=1)
# Print f1, precision, and recall scores
print(precision_score(y_test, y_pred , average="macro"))
print(recall_score(y_test, y_pred , average="macro"))
print(f1_score(y_test, y_pred , average="macro"))
From: https://datascience.stackexchange.com/questions/45165/how-to-get-accuracy-f1-precision-and-recall-for-a-keras-model/55120#55120
- (2890)How to add your VEnV environment as a Python Kernel for Jupyter or Spyder?
1. Activate the virtualenv
source your-venv/bin/activate
2. Install jupyter in the virtualenv
python - m pip install jupyter
3. Add the virtualenv as a jupyter kernel
ipython kernel install --name "local-venv" --user
You can now select the created kernel "local-venv" in Jupyter or Spyder
From: http://queirozf.com/entries/jupyter-kernels-how-to-add-change-remove
- (2891)How to solve "ModuleNotFoundError: No module named 'tensorflow.examples.tutorials'"?
import tensorflow_datasets as tfds
# Construct a tf.data.Dataset
dataset = tfds.load(name="mnist", split=tfds.Split.TRAIN)
From: https://github.com/tensorflow/tensorflow/issues/32790
- (2908)How to exit/deactivate a Python venv?
deactivate
From: https://stackoverflow.com/questions/990754/how-to-leave-exit-deactivate-a-python-virtualenv/990779#990779
- (2932)How to convert 2 lists (keys, values) to a dictionary?
>>> keys = ['a', 'b', 'c']
>>> values = [1, 2, 3]
>>> dictionary = dict(zip(keys, values))
>>> print(dictionary)
{'a': 1, 'b': 2, 'c': 3}
From: https://stackoverflow.com/questions/209840/convert-two-lists-into-a-dictionary/209854#209854
- (2971)How to repair a Python venv after an upgrade to a never Python version?
For instance, upgrading to Ubuntu 20.04, remplaces Python 3.7 with Python 3.8. venvs refuse to work (can't remember the exact error, but was about lacking pip/ensurepip and terminted by a fatal "Core dump")
- Activate your venv
- Run: python3 -m venv --upgrade <venv_dir>
- Deactivate venv
- Reactivate it
- Update packages [see Tip#2521]
NOTE: I also had to replace the exec venv/bin/python with a link to venv/bin/python3
Based on a response I had submitted to SO, but has never been published :{
https://stackoverflow.com/questions/61541281/python-3-7-venv-broken-after-upgrade-to-ubuntu-20-04/61682997#61682997
- (2979)BasicPython.py
#!/usr/bin/env python3
# Most of it comes from: https://www.tutorialsteacher.com
import os # CurrPath manipulation
import sys # Args
import random # To get random values
from tkinter import * # Simple GUIs
# DataScience
import scipy as sp # computations
import numpy as np # arrays
import pandas as pd # dataframes
from sklearn import * # ML
from keras import * # DeepL
import matplotlib.pyplot as plt # Plotting
import bokeh as bk # Gfx
import collections # OrderedDicts
class MyClass:
""" This is my class comment """
static_field = random.randint(0,10) # Both values included
@classmethod
def class_method(classs): # receives the class as arg
print(classs.static_field)
@staticmethod
def static_method(): # receives the class as arg
print("Value:" + str(MyClass.static_field))
def non_static_method(self, otherarg="default value"):
""" This is my method comment """
self.non_static_field = 10
self._protected_field = "Only a convention"
self.__private_field = "Only a convention" # NOTE: field name is mangled to _object._class__variable=> not that easily accessible, but still accessible
def THIS_IS_A_CONSTANT():
return(100);
def multi_returns():
return((1,2,3))
def multi_get():
a1, a2, a3 = multi_returns()
def __init__(self):
print("the constructor")
def __str__(self):
print("the toString() method")
def __add/sub/mult/div__(self, other):
print("Operator overloading")
def file_access():
# Read
f = open("./myfile.text","r")
# line = f.readline()
for line in f:
print(line)
f.close()
# Write
lines = ["Hello", "World", "!"]
f = open("./myfile.text","w")
f.write("Hello World!")
f.writelines(lines)
f.close()
def plotting():
plt.plot(x, y, linewidth=2.)
plt.show()
def data_science():
a = np.random.random((2,2))
a.shape ; a.reshape(1,4)
np.save('my_array', a)
np.load('my_array.npy')
np.add/mult(a,b) # Value by value
np.dot(a,b) # Dot product
a.sum/min/max(axis=0)/mean()
b = np.copy(a) # Deep Copy
a.sort(axis=0)
a[0:10,:] # Subsetting
a.T # Transpose
np.append(a,b) ; np.vstack((a,b)) ; np.hstack((a,b))
df = pd.read_csv("filename.csv")
df.loc[:,1:2]
df.any/all()
df.filter(values)
df.isin(df2)
df.select(lambda)
df.unique()/duplicated(col_name)
df.groupby(by=col_list)
df.fillna(df.mean())/replace("a", "f")
df.merge/join/append/concat(axis)/pivot/melt
def other_stuff():
# Asking using input
num = int(input('Enter a number: '))
# Asserting stuff
assert num>=0
# Raising Exceptions
raise TypeException
# Managing Exceptions
try:
stuff_to_try()
except:
recover_from_error()
# List comprehension
[x for x in iterable if expression]
# Lambdas
square = lambda x: x*x
# Map (applies function on each value)
squared_list = map(square, [1, 2, 3, 4, 5])
# Reduce (applies func on consecutive values until all of them are reduced)
fact=functools.reduce(mult, range(1, 4))
# Filter
only_primes_up100 = filter(is_prime, range(100))
# Property decorator
# (transforms fields into properties, accessible using "instance.filed=val" instead of "instance.setField(val)")
## A decorator is a function that receives another function as argument. The behaviour of th1e argument function is extended by the decorator without actually modifying it.
class Person:
def __init__(self):
self.__name=''
@property
def name(self):
return self.__name
@name.setter
def name(self, value):
self.__name=value
@name.deleter
def name(self, value):
print('Deleting..')
del self.__name
if __name__ == "__main__":
print("Hello "+sys.argv[1]+"! Your PYTHON_PATH is: "+sys.path)
os.getcwd() ; os.mkdir("./tempdir/") ; os.chdir("./tempdir/")
files = os.listdir("./tempdir/")
# GUI
window=Tk()
window.title('Hello Python')
window.mainloop()
sys.exit(0)
- (2982)How to convert date/time to/from epoch timestamp?
Convert a timestamp to a datetime object:
from datetime import datetime
print datetime.fromtimestamp(1346236702)
#2012-08-29 11:38:22
Convert a datetime object to a timestamp
from datetime import datetime
import time
dt = datetime.fromtimestamp(1346236702)
print time.mktime(dt.timetuple())
#1346236702.0
From: http://blog.jmoz.co.uk/python-convert-datetime-to-timestamp/
- (2984)How to create private/protected/public attributes/methods in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
= PUBLIC: just use "self.xxx" to mark them as members of the class, but use them normally
class employee:
def __init__(self, name, sal):
self.name=name
self.salary=sal
= PROTECTED: use "self._xxx" (prefixing with 1 '_') to mark them as protected
class employee:
def __init__(self, name, sal):
self._name=name # protected attribute
self._salary=sal # protected attribute
= PRIVATE: use the "self.__xxx" (prefixing with 2 '_') to mark them as private
class employee:
def __init__(self, name, sal):
self.__name=name # private attribute
self.__salary=sal # private attribute
NOTE: Python performs *name mangling* of private variables. Every member with double underscore will be changed to _object._class__variable. So accessing them through obj.__name will not work. However, they can still be accessed from outside the class using the complicated & longer name.
From: https://www.tutorialsteacher.com/python/private-and-protected-access-modifiers-in-python
- (2985)How do I create a constant in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
= BASICS
CONST_NAME = "Name" # const is just a convention => just put name in maj
= MORE REASONABLE (truly not modifyable) hack:use a function
def CONST_NAME():
return <const_val>
= ADVANCED: use properties with only a getter
def constant(f):
def fset(self, value):
raise TypeError
def fget(self):
return f()
return property(fget, fset)
class _Const(object):
@constant
def FOO():
return 0xBAADFACE
@constant
def BAR():
return 0xDEADBEEF
CONST = _Const()
print CONST.FOO
##3131964110
CONST.FOO = 0
##Traceback (most recent call last):
## ...
## CONST.FOO = 0
##TypeError: None
From: https://stackoverflow.com/questions/2682745/how-do-i-create-a-constant-in-python/2688086#2688086
- (2986)How to make a class in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
class MyClass:
"""A simple example class"""
c = 12345 # class attribute
def f(self): # public method
return 'hello world'
def __init__(self, ival) # constructor
self.i=ival # public attribute
def __str__(self) # toString method [you might need __repr__ if inside a list]
return str(self.i)
From: https://docs.python.org/3/tutorial/classes.html#class-objects
- (2987)How to create a toString() method in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
Use __str__() and __repr__() (for when inside a list)
class MyClass:
def __str__(self) # toString method [you might need __repr__ if inside a list]
return str(self.i)
From: https://stackoverflow.com/questions/12448175/confused-about-str-on-list-in-python
- (2988)How to create a constructor in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
class MyClass:
def __init__(self, ival) # constructor
...
From: https://docs.python.org/3/tutorial/classes.html#class-objects
- (2989)How to create a static/class attribute in Python?
NOTE: Python is a *scripting* language, NOT an *object* language. Object constructs are only eye-candy/notations/conventions, not truly enforced by the interpreter!
class MyClass:
"""A simple example class"""
c = 12345 # class/static attribute
def __init__(self, ival)
self.i=ival # public attribute
From: https://docs.python.org/3/tutorial/classes.html#class-objects
- (3046)How to store the "ranges" of indices to access a numpy array in a variable?
Use np.s_ . It create slices objects:
> indices = np.s_[1:5:2,::3]
(slice(1, 5, 2), slice(None, None, 3))
> np.arange(2*10*4).reshape(2,10,4)[indices]
array([[[40, 41, 42, 43],
[52, 53, 54, 55],
[64, 65, 66, 67],
[76, 77, 78, 79]]])
From: https://stackoverflow.com/questions/29476182/store-numpy-array-index-in-variable
- (3055)What is the difference between flatten(), ravel() and reshape(-1) functions in numpy?
numpy.ndarray.flatten
- always returns a copy.
numpy.ravel
- returns a view of the original array whenever possible.
reshape((-1,))
- gets a view whenever the strides of the array allow it even if that means you don't always get a contiguous array.
From: https://stackoverflow.com/questions/28930465/what-is-the-difference-between-flatten-and-ravel-functions-in-numpy/54313275#54313275
- (3056)How to check if an array is a copy?
Use the .base attribute of the ndarray.
- If it's a view, the base will be the original array.
- If it is a copy, the base will be None.
From: https://stackoverflow.com/questions/28930465/what-is-the-difference-between-flatten-and-ravel-functions-in-numpy/54313275#54313275
- (3102)How to create memory efficient iterators (a.k.a. how to use the yield keyword, a.k.a. what is lazyness, a.k.a. infinite data structure)?
E.g. for Eratosthene sieve
def nats(n):
yield n
yield from nats(n+1)
def sieve(s):
n = next(s)
yield n
yield from sieve(i for i in s if i%n!=0)
From: https://www.youtube.com/watch?v=5jwV3zxXc8E
- (3142)How to install large package in Python (a.k.a. how to solve "No space left on device" when installing TensorFlow/PyTorch with pip)?
If you get an error like:
"**Could not install packages due to an EnvironmentError: [Errno 28] No space left on device**"
Change the downloading/compiling directories with:
TMPDIR=/path/to/compilation/dir/ pip install --cache-dir=/path/to/download/dir --build /path/to/compilation/dir/ tensorflow
From: https://github.com/pypa/pip/issues/5816#issuecomment-425205365
- (3169)What is the for/else construct?
for loops also have an else clause which most of us are unfamiliar with. The else clause executes after the loop completes normally. This means that the loop did not encounter a break statement. They are really useful once you understand where to use them. I, myself, came to know about them a lot later.
The common construct is to run a loop and search for an item. If the item is found, we break out of the loop using the break statement. There are two scenarios in which the loop may end. The first one is when the item is found and break is encountered. The second scenario is that the loop ends without encountering a break statement. Now we may want to know which one of these is the reason for a loop’s completion. One method is to set a flag and then check it once the loop ends. Another is to use the else clause.
This is the basic structure of a for/else loop:
for item in container:
if search_something(item):
# Found it!
process(item)
break
else:
# Didn't find anything..
not_found_in_container()
From: https://book.pythontips.com/en/latest/for_-_else.html
- (3190)How to define the alternatives for python in Ubuntu?
# update-alternatives --install /usr/local/bin/python python /usr/bin/python2.xxx 2
# update-alternatives --install /usr/local/bin/python python /usr/bin/python3.xxx 3
# update-alternatives --config python # to define the default one
From: https://stackoverflow.com/questions/43062608/how-to-update-alternatives-to-python-3-without-breaking-apt#46335142
- (3219)How to solve annoying opening of a DialogBox for unlocking keyring/wallet when installing Python packages with pip 20+?
Define PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring in the environment
NOTE: Might also work for Emacs-AIChat?
From: https://pypi.org/project/keyring/#disabling-keyring
- (3247)How to solve "Memory Error" during pip install (occurs mostly with PyTorch)?
pip install packagename --no-cache-dir
Also see Tip#3142
From: https://chirale.org/2017/01/15/memory-error-on-pip-install-solved/
- (3248)How to rename a Python venv directory?
1. Rename your directory
2. Rerun the venv initialisation script
$ python -m venv /path/to/renamed_venv # virtualenv will correct the directory associations while leaving your packages in place
3. An important caveat, if you have any static path dependencies in script files in your venv directory, you will have to change those too. It can be done with:
$ cd /path/to/venv/bin/
$ sed -i 's/old_dir_name/new_dir_name/g' *
4. Reactivate your venv & verify everything is OK
$ scripts/activate
$ pip freeze # to verify your packages are in place
From: https://stackoverflow.com/questions/6628476/renaming-a-virtualenv-folder-without-breaking-it/29482481#29482481
https://stackoverflow.com/questions/6628476/renaming-a-virtualenv-folder-without-breaking-it/49632744#49632744
- (3298)What is Python __all__?
What is __all__?
It's a list of public objects of that module, as interpreted by import *. It overrides the default of hiding everything that begins with an underscore.
When __all__ is used?
It is a list of strings defining what symbols in a module will be exported when from <module> import * is used on the module.
For example, the following code in a foo.py explicitly exports the symbols bar and baz:
__all__ = ['bar', 'baz']
​waz = 5
bar = 10
def baz(): return 'baz'
These symbols can then be imported like so:
from foo import *
​print bar
print baz
​# The following will trigger an exception, as "waz" is not exported by the module
print waz
From: https://sisyphus.gitbook.io/project/python-notes/python-__all__
- (3311)How to import a module from parent directory?
SOLUTION1:
from .. import testmsg
SOLUTION2:
import sys
sys.path.append(os.getcwd() + '/..')
import parent.file1
From: https://stackoverflow.com/questions/11393492/python-package-import-from-parent-directory
https://stackoverflow.com/questions/10078287/how-to-import-a-python-file-in-a-parent-directory/10078468#comment17421554_10078468
- (3316)How to list all versions of a package that are available?
SOLUTION1:
pip install <pkg>== # pip>9
pip install <pkg>==blork # pip<9
pip install --no-deps <pkg>==x.x.x
SOLUTION2:
pip install <pkg> -v
SOLUTION3:
pip install yolk
yolk -V <pkg>
SOLUTION4:
wget https://pypi.python.org/pypi/{PKG_NAME}/json
From: https://exceptionshub.com/python-and-pip-list-all-versions-of-a-package-thats-available.html
- (3317)How to correct py2 legacy code in python-language-server (pyls)?
In file /path/to/venv/lib/python3.8/site-packages/pyls/main.py
- replace `print(...)` by `print ...`
- replace `p2 __dict__.diritems():` by `p2 __dict__.items():`
From: https://github.com/palantir/python-language-server/issues/899
- (3319)How to create a progress bar in Python?
Use tdqm
from tqdm import tqdm
for i in tqdm(range(10000)):
...
76%|████████████████████████ | 7568/10000 [00:33<00:10, 229.00it/s]
trange(N) can be also used as a convenient shortcut for tqdm(range(N))
From: https://pypi.org/project/tqdm/
- (3354)How to drop Columns by name in Pandas DataFrame?
df.drop(['a'], axis = 1, inplace = True)
inplace = True => the columns are removed from the original DataFrame; otherwise, a copy of the original is returned.
From: https://www.delftstack.com/howto/python-pandas/pandas-drop-columns-by-index/
- (3358)How to do Litterate Programming in Python (a.k.a. How to format method docstrings)?
There are plenty possibilities, none satisfying.
Epytext Markup Language is simple and near complete: it looks like Markdown in most cases and allows to comment args/... in methods:
def example():
"""
@param x: This is a description of
the parameter x to a function.
Note that the description is
indented four spaces.
@type x: This is a description of
x's type.
@return: This is a description of
the function's return value.
It contains two paragraphs.
"""
From: http://epydoc.sourceforge.net/epytext.html
- (3364)How to create Abstract Classes in Python?
You have to include external packages!!
from abc import ABC
# Abstract Class
class Polygon(ABC):
# Abstract Method
def nbofsides(self):
pass
class Triangle(Polygon):
# Overriding abstract method
def noofsides(self):
print("I have 3 sides")
From: https://www.geeksforgeeks.org/abstract-classes-in-python/
- (3368)How to delete variables and functions from memory in Python?
SOLUTION1: for a single var/func
del <var/func name>
SOLUTION2: to remove everything
for element in dir():
if element[0:2] != "__":
del globals()[element]
del element
From: https://www.kite.com/python/answers/how-to-delete-variables-and-functions-from-memory-in-python
- (3385)How to pass an option the the C compiler when pip compiles a package from source?
SOLUTION1: pip (in fact its "build_ext" module) has a options for that
--include-dirs (-I) # for paths where to look for headers at compilation time
--global-option="-L/path/to/local" # for paths where to look for libraries at linking time
SOLUTION2: gcc can read Environment Variables like
- CPATH/C_INCLUDE_PATH for headers at compilation time
- LIBRARY_PATH for libraries at linking time
From: https://stackoverflow.com/questions/18783390/python-pip-specify-a-library-directory-and-an-include-directory/22942120#22942120
https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
- (3386)How to Is it possible to preserve tmp directories when running pip (a.k.a. How to access the compilation/installation logs of a Python package)?
pip --no-clean ...
From: https://github.com/pypa/pip/issues/420#issuecomment-62993072
- (3477)How to select rows based on column values in a Pandas DataFrame?
- To select rows whose column value equals a scalar, some_value, use ==:
df.loc[df['column_name'] == some_value]
- To select rows whose column value is in an iterable, some_values, use isin:
df.loc[df['column_name'].isin(some_values)]
- Combine multiple conditions with &:
df.loc[(df['column_name'] >= A) & (df['column_name'] <= B)]
Note the parentheses. Due to Python's operator precedence rules, & binds more tightly than <= and >=.
- isin returns a boolean Series, so to select rows whose value is not in some_values, negate the boolean Series using ~:
df.loc[~df['column_name'].isin(some_values)]
From: https://stackoverflow.com/questions/17071871/how-do-i-select-rows-from-a-dataframe-based-on-column-values/17071908#17071908
- (3478)How to "decompile" Python code (e.g. to see which instructions are faster)?
For instance we can compre how "not x is None" and "x is not None":
>>> import dis
>>> dis.dis("not x is None")
1 0 LOAD_NAME 0 (x)
2 LOAD_CONST 0 (None)
4 COMPARE_OP 9 (is not)
6 RETURN_VALUE
>>> dis.dis("x is not None")
1 0 LOAD_NAME 0 (x)
2 LOAD_CONST 0 (None)
4 COMPARE_OP 9 (is not)
6 RETURN_VALUE
There's no performance difference, as they compile to the same bytecode:
From: https://stackoverflow.com/questions/2710940/python-if-x-is-not-none-or-if-not-x-is-none/2711073#2711073
- (3479)How to configure flake8?
Globally for the user:
~/.config/flake8
In your project :
setup.cfg, tox.ini, or .flake8
Example for changing line length and ignoring some rules:
------ cat ~/.config/flake8
[flake8]
ignore = E221,E501,E203,E202,E272,E251,E211,E222,E701
max-line-length = 160
exclude = tests/*
max-complexity = 10
------
From: https://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations
https://www.reddit.com/r/emacs/comments/3c562f/using_emacs_elpy_flycheckpylint_how_to_disable/
- (3480)What is the Difference Between "is" and "==" in Python?
- == operator is used to check whether two variables reference objects with the same value.
- is operator is used to check whether two variables point to the same object in memory.
From: https://towardsdatascience.com/what-is-the-difference-between-is-and-in-python-999aed3a54f7
- (3499)How to detect if a Python variable is a function?
callable(obj)
hasattr(obj, '__call__')
BEWARE: types.FunctionTypes or inspect.isfunction approaches (both do the exact same thing) return False for non-Python functions. Most builtin functions are implemented in C and not Python, so they return False :{
From: https://stackoverflow.com/questions/624926/how-do-i-detect-whether-a-python-variable-is-a-function/624939#624939
- (3500)How to reverse an Array in Python?
arr = [11, 22, 33, 44, 55]
SOLUTION1:
res = arr[::-1] #reversing using list slicing
SOLUTION2:
arr.reverse() #reversing using reverse()
SOLUTION3:
result=list(reversed(arr))
SOLUTION4:
import array
new_arr=array.array('i',arr)
new_arr.reverse()
SOLUTION5:
import array
new_arr=array.array('i',arr)
res_arr=array.array('i',reversed(new_arr))
SOLUTION6:
import numpy as np
new_arr=np.array(arr)
res_arr=np.flip(new_arr)
SOLUTION7:
import numpy as np
new_arr=np.array(arr)
res_arr=np.flipud(new_arr)
SOLUTION8:
import numpy as np
new_arr=np.array(arr)
res_arr=new_arr[::-1]
From: https://www.askpython.com/python/array/reverse-an-array-in-python
- (3501)How to clear all variables in a Python script?
SOLUTION1: most brutal (also remove internal vars)
>>> import sys
>>> sys.modules[__name__].__dict__.clear()
SOLUTION2: more selective (does not remove internal vars)
>>> import sys
>>> this = sys.modules[__name__]
>>> for n in dir():
... if n[0]!='_': delattr(this, n)
From: https://stackoverflow.com/questions/3543833/how-do-i-clear-all-variables-in-the-middle-of-a-python-script/3543866#3543866
- (3505)How to change the default browser used by Jupyter?
Step 1: Generate a default config file
jupyter notebook --generate-config
This will generate the file ~/.jupyter/jupyter_notebook_config.py
Step 2: Edit this file and change the following line (chrome is also in a local installation)
c.NotebookApp.browser = u'/usr/bin/firefox %s'
or
c.NotebookApp.browser = u'/usr/bin/chromium %s'
From: https://stackoverflow.com/questions/47772157/how-to-change-the-default-browser-used-by-jupyter-notebook-in-windows
- (3522)How to manage Jupyter Notebooks in a Git Repository?
PROBLEM:
- Everytime a cell is executed, the result is stored in the .ipynb file => Git will see a lot of changes
- As the results will mostly be big binary blobs, the actual few/small code changes will be lost/difficult to find in the large Git diffs
SOLUTION1a: Convert to/from .py with jupytext [BEST]
jupytext [--from ipynb] --to py:percent notebook.ipynb
jupytext --to notebook notebook.py
Alternatively, you can synchronise the two representations by running
jupytext --sync notebook.ipynb
From: https://jupytext.readthedocs.io/en/latest/
SOLUTION1b: Convert to/from .py with nbconvert [WORKS ONLY 1-WAY: ipynb->py]
pip install nbconvert
ipython nbconvert --to script abc.ipynb
From: https://medium.com/@researchplex/the-easiest-way-to-convert-jupyter-ipynb-to-python-py-912e39f16917
SOLUTION2: Execute Notebooks in a Separate Branch
Then set Git hooks to:
- Execute All Notebooks
python3 -m nbconvert --execute --inplace *.ipynb **/*.ipynb
- Clean All Notebooks
python3 -m nbconvert --clear-output *.ipynb **/*.ipynb
From https://mg.readthedocs.io/git-jupyter.html
- (3525)How to convert a FloatTensor into a DoubleTensor in Pytorch?
Your numpy arrays are 64-bit floating point and will be converted to torch.DoubleTensor standardly. Now, if you use them with your model, you'll need to make sure that your model parameters are also Double. Or you need to make sure, that your numpy arrays are cast as Float, because model parameters are standardly cast as float.
Hence, do either of the following:
data_utils.TensorDataset(torch.from_numpy(X).float(), torch.from_numpy(Y).float())
or do:
model.double()
Depeding, if you want to cast your model parameters, inputs and targets as Float or as Double.
From: https://stackoverflow.com/questions/44717100/pytorch-convert-floattensor-into-doubletensor#44719369
- (3570)How to flatten a dictionary in Python?
I] Using flatdict
>>> import flatdict
>>> d = flatdict.FlatDict(data, delimiter='.')
>>> d # d is a FlatDict instance
<FlatDict id=140665244199904 {'a': 1, 'c.a': 2, 'c.b.x': 3, 'c.b.y': 4, 'c.b.z': 5, 'd': [6, 7, 8]}>"
>>> d['c.b.y'] # it allows accessing flat keys
4
>>> d['c']['b']['y'] # and nested ones
4
>>> dict(d) # can be converted back to a flatten dict
{'a': 1, 'c.a': 2, 'c.b.x': 3, 'c.b.y': 4, 'c.b.z': 5, 'd': [6, 7, 8]}
II] Using pandas::json_normalize()
>>> from collections.abc import MutableMapping
>>> import pandas as pd
>>> def flatten_dict(d: MutableMapping, sep: str= '.') -> MutableMapping:
[flat_dict] = pd.json_normalize(d, sep=sep).to_dict(orient='records')
return flat_dict
>>> flatten_dict({'a': 1, 'c': {'a': 2, 'b': {'x': 3, 'y': 4, 'z': 5}}, 'd': [6, 7, 8]})
{'a': 1, 'd': [6, 7, 8], 'c.a': 2, 'c.b.x': 3, 'c.b.y': 4, 'c.b.z': 5}
III] Using recursive function
>>> from collections.abc import MutableMapping
>>> def flatten_dict(d: MutableMapping, parent_key: str = '', sep: str ='.') -> MutableMapping:
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, MutableMapping):
items.extend(flatten_dict(v, new_key, sep=sep).items())
else:
items.append((new_key, v))
return dict(items)
>>> flatten_dict({'a': 1, 'c': {'a': 2, 'b': {'x': 3, 'y': 4, 'z': 5}}, 'd': [6, 7, 8]})
{'a': 1, 'c.a': 2, 'c.b.x': 3, 'c.b.y': 4, 'c.b.z': 5, 'd': [6, 7, 8]}
From: https://www.freecodecamp.org/news/how-to-flatten-a-dictionary-in-python-in-4-different-ways/
- (3593)How to set the C/C++ compiler options for when pip compiles the packages?
SOLUTION1: gcc compiler checks environment variables like (for includes):
- CPATH
- C_INCLUDE_PATH
- CPLUS_INCLUDE_PATH
SOLUTION2: pip has the "--global-option" parameter
pip install --global-option="-I/home/users/abc/include/" ...
From: https://stackoverflow.com/questions/4140504/linux-global-includes-path/4140549#4140549
https://stackoverflow.com/questions/19071708/pip-install-customized-include-path#28981343
- (3805)How to know where does pip installs its packages?
$ pip show <package name>
Name: ...
Version: ...
...
Location: /usr/local/lib/python2.7/site-packages
From: https://stackoverflow.com/questions/29980798/where-does-pip-install-its-packages/45309460#45309460
- (3806)What is the purpose of "pip install --user ..."?
From pip install --help:
--user Install to the Python user install directory for your platform.
Typically ~/.local/
From: https://stackoverflow.com/questions/42988977/what-is-the-purpose-of-pip-install-user/
- (3880)How to replace strings with numbers in Python (for Data Analysis) (a.k.a. How to encode/enumerize categorial values) (a.k.a. What is the equivalent of R's factors/levels in Python)?
PROBLEM: Sometimes we need to convert string values in a pandas dataframe to a unique integer so that the ML algorithm can perform better. So we assign unique numeric value to a string value in Pandas DataFrame. e.g. we want to assign 1 to "male" and 2 to "female".
SOLUTION1: Automatic, with SciKitLearn
encoder = sklearn.preprocessing.LabelEncoder() # From doc: "This transformer should be used to encode target values, i.e. y, and not the input X."
# encoder = sklearn.preprocessing.OrdinalEncoder()
# encoder = sklearn.preprocessing.OneHotEncoder()
X = enc.fit_transform(X) # fit & transform operation can be done separately
Also see dtype="category" for Series
https://pandas.pydata.org/docs/user_guide/categorical.html
SOLUTION2: Manual
# Create a dict file of target values
gender = { 'male': 1, 'female': 2 }
# Replace values
data.Gender = [gender[item] for item in data.Gender]
SOLUTION3: Manual
data.Gender[data.Gender == 'male'] = 1
data.Gender[data.Gender == 'female'] = 2
From: https://scikit-learn.org/stable/modules/preprocessing.html#encoding-categorical-features
https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html#sklearn.preprocessing.LabelEncoder
https://www.geeksforgeeks.org/replacing-strings-with-numbers-in-python-for-data-analysis/
- (3898)How to make amazing Visualizations with Python?
https://www.python-graph-gallery.com/
From: https://www.kdnuggets.com/2022/12/make-amazing-visualizations-python-graph-gallery.html
- (3976)How to make MatPlotLib/PySide6 work?
PROBLEM: When walling plot function directly after importing matplotlib, the following error is displayed:
"TypeError: int() argument must be a string, a bytes-like object or a real number, not 'KeyboardModifier'"
Most of the time, errors come from bad backend
SOLUTION1: OS-wide
export MPLBACKEND=tkagg # or GTK4Agg, Gtk3Agg, TkAgg, QtAgg, WxAgg, Agg
python simple_plot.py
SOLUTION2: In the code
import matplotlib
matplotlib.use('tkagg') # or GTK4Agg, Gtk3Agg, TkAgg, QtAgg, WxAgg, Agg
From: https://matplotlib.org/stable/users/explain/backends.html
https://stackoverflow.com/questions/74112099/importing-matplotlib-causes-int-argument-must-be-a-string-error/74113918#74113918
https://stackoverflow.com/questions/4930524/how-can-i-set-the-matplotlib-backend
- (3978)How to create a QRCode?
pip install qrcode
- qr "Some text/URL/..." > test.png
- in python
---
import qrcode
img = qrcode.make('Some data here')
type(img) # qrcode.image.pil.PilImage
img.save("some_file.png")
---
From: https://pypi.org/project/qrcode/
- (3979)How to create beautiful GUIs in Python?
Use CustomTkinter
From: https://github.com/TomSchimansky/CustomTkinter
- (4065)What is the difference between Python list::append() and list::extend()?
.append() appends a specified object at the end of the list:
>>> x = [1, 2, 3]
>>> x.append([4, 5])
>>> print(x)
[1, 2, 3, [4, 5]]
.extend() extends the list by appending elements from the specified iterable:
>>> x = [1, 2, 3]
>>> x.extend([4, 5])
>>> print(x)
[1, 2, 3, 4, 5]
From: https://stackoverflow.com/questions/252703/what-is-the-difference-between-pythons-list-methods-append-and-extend/252711#252711
- (4108)How to test if PyTorch is installed and working from Python?
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.device_count()
1
>>> torch.cuda.current_device()
0
>>> torch.cuda.device(0)
<torch.cuda.device at 0x7efce0b03be0>
>>> torch.cuda.get_device_name(0)
'GeForce GTX 950M'
From: https://stackoverflow.com/questions/48152674/how-do-i-check-if-pytorch-is-using-the-gpu
- (64)Manage binary file with CVS
# add file as binary file: cvs add -kb file
# indicate at a later time that file is binary: cvs admin -kb file
- (59)Creation and initialization of a repository
Creation du repository :
========================
=> setenv $CVSROOT ...
==> cvs init
Creation d'un module :
======================
aller dans le repertoire de travail du module
=> cvs import -m "Message" module vendor_tag branch_tag
si vous ne comprenez pas ce que sont les vendor et branch_tag, c'est
normal, personne ne le sait. mettez par exemple "main" et "start".
- (60)Creation of a local copy of a repository
Creation d'une copie locale d'un module :
=========================================
depuis la branche principale
=> cvs co module
depuis une branche
=> cvs co -d branch_name module_name
depuis un tag
=> cvs co -r tag module_name
http://bgoglin.free.fr/cvs.php
- (61)Manage Branches with CVS
Créer un tag :
==============
dans la branche courante
=> cvs tag tag_name
dans une autre branche
=> cvs rtag -r branch_name tag_name
uniquement les fichiers deja taggée
=> cvs rtag -r old_tag_name tag_name
en verifiant qu'aucun fichier n'est modifié localement
=> cvs tag -c tag_name
Créer une branche :
===================
dans la branche courante
=> cvs tag -b branch_name
dans une autre branche
=> cvs rtag -b -r branch_name new_branch_name
passer dans cette branche
=> cvs up -r branch_name
Associer un nouveau nom symbolique :
====================================
pour creer un alias sur un tag ou une branche existant
=> cvs admin -n newname:oldname [repertoire]
si le nom "oldname" est supprimé, le contenu de la branche reste accessible par "newname".
http://bgoglin.free.fr/cvs.php
- (191)Changing the port of the SSH connection with SVN
export SVN_SSH="ssh -p <port number>"
- (194)svn: Can't convert string from native encoding to 'UTF-8'
svn: Can't convert string from 'UTF-8' to native encoding
These errors typically appear when the svn repository's locale is different from the client locale.
The solution is to either rename the file/comment into the correct locale, or to set the correct local.
(from: http://svnbook.red-bean.com/en/1.2/svn-book.html#svn.advanced.l10n.svnuse)
- (210)How to recover the URL or username of repository of SVN's local copy?
cd <local copy>
grep '://' .svn/*
normally the URL is in the "Entries" file
- (245)How to recover a file deleted in the local SVN repository
To recover a file from svn that you deleted from your local repository, it’s first necessary to get the proper name of the file, and the revision of the repository it last existed in. To do that (assuming you don’t know, because if you do you have bigger issues), you go to the directory it was in (or as close as you can get to the directory it was in) and run:
> svn log --verbose
You should be able to find the file you’re looking for and the revision you need in the output of that command. Assuming your file’s name is ‘file.txt’ and it was in revision 250, you run the following to recover it:
> svn up -r 250 file.txt
From: http://m0j0.wordpress.com/2007/10/25/recovering-deleted-files-from-an-svn-repository/
- (280)How to get a warning in FF3.5 when closing multiple tabs (works only partially, since closing with C-q or C-w does not have the same effect)
With the "Warn me when closing multiple tabs" option selected, Firefox supposed to pop up a dialog box titled "Confirm Close" asking "You're about to close x open tabs. Are you sure want to continue?", as practiced in Firefox 2 shown in illustration below. In Firefox 3, this is not the case, and Firefox closes and quits without warning and confirmation even with more than one open tabs, even with "browser.warnOnQuit" preference set to true.
Confirm Close Multiple Open Tabs in Firefox
However, this new behavior looks like not going to be classified as a bug, according to replies from various developers in Bugzilla@Mozilla (see bug 422040, 434961, and 419009) . In fact, it's a new intentional change so that if Firefox is configured to enable session restore by selecting "Show my windows and tabs from last time" startup option (browser.startup.page pref is equal to 3), where Firefox will re-open and restore all opened tabs automatically on next restart, Firefox does not warn or prompt for confirmation when user closes a Firefox window of a Firefox session with only single window with multiple tabs or quit the Firefox application with multiple Firefox windows and/or tabs opened, as long as Firefox deems that these tabs and/or windows can be saved and reopened automatically by Firefox on next start up.
In short, current FF3 behavior on closing window with tabs is that user no longer be warned every time when quitting Firefox, but warning or confirm close dialog will only be prompted if the window or tabs cannot be restored.
The exit without confirmation feature may be nice for some people, but not all people will love it, especially users who tend to accidentally click on the Close (X) button in the web browser window, and when there are tens, if not hundreds of tabs open in the window. Just image the time Firefox requires to reopen all those tabs again.
The workaround to set Firefox to warn or ask for confirmation before closing window with multiple open tabs, or quit Firefox application, is to disable session restore by setting Firefox to start up with home page or blank page. To do so, click on Tools menu and then Options. In the Main tab Startup section, select Show my home page or Show a blank page for "When Firefox starts" option (Note that "Show my windows and tabs from last time" means session restore, which mean you won't get any close tabs confirm warning).
http://www.mydigitallife.info/2008/06/19/firefox-3-doesnt-prompt-or-warn-to-confirm-when-closing-multiple-tabs-as-warning-not-working/
- (281)Get Latitude and Longitude values from Google Maps
Looking up an address in Google Maps will center the map on that address if it was found. Because this trick provides the latitude and longitude of the center of the map, moving the map around manually after that will change the center position and this technique will not work accurately.
When the location you want is in the center of the map, copy and paste this code into the location bar of your browser and press enter:
javascript:void(prompt('',gApplication.getMap().getCenter()));
- (315)How to test a command in SVN (i.e. make a dry-run)?
How to make a dry-run with svn update
If you just want to figure out, what files will be updated and exactly what will be changed you might use this command.
1svn diff -r BASE:HEAD .
This will display the differences between current files in the directory (BASE) and the latest revision at the repository (indicated by HEAD).
Just for the record, here are some other useful hints.
If you just want to have all updated files:
1svn st -u
This however does not display all conflicted files, so you might use this workaround:
1svn merge --dry-run -r BASE:HEAD .
From : http://dracoblue.net/dev/generate-diff-svn-update-some-kind-of-dry-run/144/
- (371)Typical tree conflicts and solutions in SVN
"> local delete, incoming edit upon update"
a) svn resolve --accept working ???
b) backup local copy / svn update to restore old copy / move backup into local - manually merge changes / svn commit
- (417)Neat extensions for Firefox
- Privacy Badger/Possum (privacy: tracking removal)
https://addons.mozilla.org/en-US/firefox/addon/privacy-badger17/
https://addons.mozilla.org/en-US/firefox/addon/privacy-possum/
https://www.ghacks.net/2018/05/07/privacy-possum-is-privacy-badger-on-steroids/
- Ghostery (privacy: tracking removal)
https://addons.mozilla.org/en-US/firefox/addon/ghostery/
- AdBlockPlus -> AdBlockEdge -> uBlock Origin (removes advertisement)
https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/
- Fadblock (AdBlocker for Youtube 2023+)
https://addons.mozilla.org/en-US/firefox/addon/fadblock/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search
- LibRedirect -> redirects non-privacy sites (YT, ...) to privacy-aware counterparts
https://addons.mozilla.org/en-US/firefox/addon/libredirect/
https://www.ghacks.net/2022/03/16/libredirect-loads-privacy-friendly-sites-automatically-when-you-load-youtube-search-tiktok-and-other-sites/
- Kill Sticky (Kill off the annoying floating things blocking websites - like Pinterest account creation on gallery browsing pages)
https://addons.mozilla.org/en-US/firefox/addon/kill-sticky/
https://www.ghacks.net/2018/08/16/remove-anything-that-is-sticky-on-websites/
- Google Consent Dialogs Removers
https://addons.mozilla.org/en-GB/firefox/addon/google-consent-dialog-remover/
https://addons.mozilla.org/en-GB/firefox/addon/google-consent
- BETTER Consent-O-Matic to automate your acceptance/rejection of non-essential cookies (now that site have popup for RGPD compliance)
https://github.com/cavi-au/Consent-O-Matic
- Skip Redirect (goes straight away to final page instead of loading all intermediary pages)
https://addons.mozilla.org/en-US/firefox/addon/skip-redirect/
- NeatUrl (removes garbage from URLs)
https://addons.mozilla.org/en-US/firefox/addon/neat-url/
- Referrer Control (change/remove referrer: do not tell websites where you come from!)
https://addons.mozilla.org/en-US/firefox/addon/referrer-control/
- Don't touch my tabs (prevent child tab to modify parent tab's URL)
https://addons.mozilla.org/en-US/firefox/addon/dont-touch-my-tabs/
https://www.ghacks.net/2019/12/23/protect-your-tabs-in-firefox-with-dont-touch-my-tabs-relnoopener/
- Dark Reader (switch any site into night mode, with easy switch: alt-maj-d)
https://addons.mozilla.org/en-US/firefox/addon/darkreader
- Email Link Button (allows sending an email with current site as a link from a button next to the URL bar)
https://addons.mozilla.org/en-US/firefox/addon/email-link-button/
- CM send link (allows sending an email with current site as a link from Context Menu)
https://addons.mozilla.org/en-US/firefox/addon/cm-send-link/
- User Agent Switcher (fake M$ UserAgent)
https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/
- Hide.me free VPN
https://addons.mozilla.org/fr/firefox/addon/hide-me-vpn-free-proxy/
- DecentralEyes (protects you against tracking)
https://addons.mozilla.org/en-US/firefox/addon/decentraleyes/
- Local Sheriff (privacy: tells you what info the site shares with 3rd parties)
https://www.ghacks.net/2018/08/12/local-sheriff-reveals-if-sites-leak-personal-information-with-third-parties/
https://github.com/cliqz-oss/local-sheriff
- Grammalecte (orthographic/grammar correction/information)
https://addons.mozilla.org/fr/firefox/addon/grammalecte-fr/
- BETTER LanguageTool (better grammar correction - at least in French - + AI to rewrite/summarize)
https://languagetool.org/
- Video Download Helper (download videos from various sites)
https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/
- NetVideo Hunter (flash media downloader)
https://addons.mozilla.org/en-US/firefox/addon/netvideohunter-video-downloade/
- Unplug (flash media downloader)
https://addons.mozilla.org/en-US/firefox/addon/unplug/
- Flash Video Downloader (flash media downloader)
https://addons.mozilla.org/en-US/firefox/addon/flash-video-downloader/
- Mp3 Downloader for SoundCloud (download files from soundcloud)
https://addons.mozilla.org/en-US/firefox/addon/soundcloud-mp3-downloader/
- Cookie Editor (to dump cookies from Bing to make emacs-aichat work = BingAI from Emacs)
https://mybrowseraddon.com/cookie-editor.html
- Copy As org (to copy website content and insert it directly formatted as org into org-files)
https://github.com/kuanyui/copy-as-org-mode
- Edit With Emacs (Edit any FF/Chromium Field in Emacs with your own keybindings!)
https://github.com/stsquad/emacs_chrome
- Fox Replace (Powerful automatic replacement of text in viewed pages)
https://addons.mozilla.org/en-US/firefox/addon/foxreplace/
- Similar Pages / Similar Sites (proposes similar sites)
https://addons.mozilla.org/en-US/firefox/addon/similar-pages/
- Decodex (are information on the site reliable?)
https://addons.mozilla.org/en-US/firefox/addon/lemonde-decodex/
- Lazarus (recovers content entered in HTML-forms, securely)
https://addons.mozilla.org/en-US/firefox/addon/lazarus-form-recovery/ [DEAD]
https://addons.mozilla.org/en-US/firefox/addon/simple-form-history/
https://addons.mozilla.org/en-US/firefox/addon/formsave/
- Dummy Form Filler (Fills large forms with dummy data)
https://addons.mozilla.org/en-US/firefox/addon/dummy-form-filler/
- EPUBReader (integrated EPUB reader)
https://addons.mozilla.org/en-US/firefox/addon/epubreader/
- Block auto-refresh (not an extension!)
https://www.ghacks.net/2018/08/19/stop-websites-from-reloading-pages-automatically/
- Auto Unload Tab / Suspend Tab / Bar Tab Heavy (non-visible Tabs are removed from memory)
- Hunter (find email addresses anywhere on the web)
https://addons.mozilla.org/en-US/firefox/addon/hunterio/
- Rapportive (enrich gmail web interface with contact infos)
https://addons.mozilla.org/en-US/firefox/addon/rapportive/
- Mega (access to big files from mega.co.nz)
- Zapyo (proxy for region-limited streaming sites)
- Zotero (Bibliography tool)
https://www.zotero.org/download/
- Lightbeam (FF24+, privacy: see who is tracking)
[FF 50--]
- HTTPS everywhere (security: use SSL enabled website when possible)
https://addons.mozilla.org/en-US/firefox/addon/https-everywhere/
- NoScript (disables JS)
https://addons.mozilla.org/en-US/firefox/addon/noscript/
- Saved Passwords Editor (allows to manually add an entry to "Saved Logins")
https://addons.mozilla.org/en-US/firefox/addon/saved-password-editor/
https://support.mozilla.org/en-US/questions/1088612
- DuckDuckGo Plus (additional features/better integration of the anonymous search engine)
https://addons.mozilla.org/en-US/firefox/addon/duckduckgo-for-firefox/
- Syncplaces / Xmarks (bookmarks synchronization)
[FF 10--]
- WebDeveloper / Firebug (live editing of webpages: HTML/CSS/JS...)
[FF 9++]
- Memchaser (traces memory useage)
- Password Vizualizer (shows sites using similar passwords)
- (492)How to set permissions so that Git's central repository is shared by several users?
Create the repository with:
$ git init --shared --bare
--- or
1. Make users belong to the same group (say "git")
2. Set the 'core.sharedRepository' to 'group'
$ git config core.sharedRepository group
(Other possibilities are:
When group (or true), the repository is made shareable between several users in a group (making sure all the files and objects are group-writable).
When all (or world or everybody), the repository will be readable by all users, additionally to being group-shareable.
When umask (or false), git will use permissions reported by umask.)
- (493)Basic Git commands
# Très bonne référence: http://gitref.org/index.html
####################################################
# Attention
# Il faut que l'utilisateur soit dans le groupe git
root$ adduser xolive git
#################################
# GUIDE DU NEWBIE #
#################################
# En local
$ git clone xolive@192.168.33.40:~git/repository.git
# Les commit sont locaux, délocalisés du serveur
# Il faut ajouter un fichier avant de le committer, même si il est déjà dans le
# repository
$ git add file
$ git commit -m "Message explicite"
# Pour mettre la version courante sur le repository
$ git push
# Et pour récupérer les données du repository
$ git pull
#############################################
# POUR ALLER UN PEU PLUS LOIN #
#############################################
# Pour lister les repository distants
$ git remote -v
origin # origin est le repository d'où on fait le premier clone
# Pour ajouter un repository
$ git remote add cea path.to.cea:~git/repository.git
# Puis pour pousser
$ git push cea
# et pour récupérer les données
$ git pull cea
##########################
# BRANCHES #
##########################
# Création d'une branche
$ git branch toutcasser
# Changement pour la branche en question
$ git checkout toutcasser
# On peut alors committer plein de trucs sales
# Pour pousser la branche sur le repository
$ git push cea toutcasser
# et pour la récupérer
$ git pull cea toutcasser
# Pour un retour au mode normal
$ git checkout master
# On peut passer à la volée d'une branche à une autre! woooooot!
# Les fichiers sont mis à jour à la volée
$ git checkout toutcasser
$ git checkout master
# Pour lister les branches
$ git branch
#############################################
# CONFIGURATION DU REPOSITORY #
#############################################
# Création du repository CEA
# Sur la machine adéquate, créer un repository git:
$ mkdir repository.git
$ cd !$
$ git init .
# Autoriser le push (mode repository)
$ git config --bool core.bare true
From: XO
- (536)How to permanently remove files from a git repository?
git filter-branch --tree-filter 'rm -rf vendor/gems' HEAD
From: http://dalibornasevic.com/posts/2-permanently-remove-files-and-folders-from-a-git-repository
- (586)What to do in case of error "svn: File already exists: filesystem '/xxx/db', transaction 'yyy', path '/yyy/'"?
$ svn update conflicted/path/ --accept=mine-full
From: http://stackoverflow.com/questions/1407973/strange-problem-with-subversion-file-already-exists-when-trying-to-recreate
- (602)How to visualize log / branches?
git log --graph
git log --graph --full-history --all --color
gitk
gitg
gitx (MacOSX)
giggle
tig
"--pretty=<style>" option to the log family of commands can now be spelled as "--format=<style>".
In addition, --format=%formatstring is a short-hand for --pretty=tformat:%formatstring.
"--oneline" is a synonym for "--pretty=oneline --abbrev-commit".
- (603)How to undo an add?
git reset HEAD file
git rm -r --cached
git reset FILE
NOTE: Each time you do a command, git tells you how to undo it!!!!
...
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
...
- (604)How to resolve Git "out of memory" error?
"remote: fatal: Out of memory, malloc failed
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed"
Try:
$ git gc
$ git repack -adf --window=5
- (605)How do I copy file/dir from one git branch to another?
Run this *from the branch where you want the file to end up*:
$ git checkout otherbranch myfile.txt
From: http://stackoverflow.com/questions/307579/how-do-i-copy-a-version-of-a-single-file-from-one-git-branch-to-another
- (606)How to get pretty and colorful logs?
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit
I guess that's a bit too long, eh? Let's just make an alias. Copy and paste the line below on your terminal:
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit"
And every time you need to see your log, just type in
git lg
From: http://coderwall.com/p/euwpig?i=3&p=1&t=git
- (632)How to replace a directory by a link?
svn propset svn:externals 'path/to/changed/dir svn+ssh://user@machine.org/path/to/repository/' path/to/changed/dir
svn ci -m "Setting path/to/changed/dir from plain directory to a link" path/to/changed/dir
- (714)How to get a local copy of a repository?
svn co https://<USER>@<DNSName/IP>:<port/8443?>/path/to/repository
To list files/dirs that can be checkout'ed (if repo is on the local machine):
svn ls file:///path/to/repository/
- (718)What to do if tyou have a "fatal: object <SHA1> is corrupted in Git?
e.g. of the error from Jenkins: Command "git fetch -t file:///home/git/repository.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: fatal: object eb6a900bb3cceecdd057a1c3c7c1ddda223c0cac is corrupted
DO:
/home/git/repository.git$ git fsck --unreachable HEAD master
/home/git/repository.git$ git-fsck --full
-----
$ git gc
-----
$ git-fsck --full
broken link from tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8
to blob 4b9458b3786228369c63936db65827de3cc06200
missing blob 4b9458b3786228369c63936db65827de3cc06200
Ok, I removed the "dangling commit" messages, because they are just
messages about the fact that you probably have rebased etc, so they're not
at all interesting. But what remains is still very useful. In particular,
we now know which tree points to it!
Now you can do
$ git ls-tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8
and you should now have a line that looks like
10064 blob 4b9458b3786228369c63936db65827de3cc06200 my-magic-file
in the output. This already tells you a *lot* it tells you what file the
corrupt blob came from!
Now, it doesn't tell you quite enough, though: it doesn't tell what
*version* of the file didn't get correctly written! You might be really
lucky, and it may be the version that you already have checked out in your
working tree, in which case fixing this problem is really simple, just do
git hash-object -w my-magic-file
again, and if it outputs the missing SHA1 (4b945..) you're now all done!
But that's the really lucky case, so let's assume that it was some older
version that was broken. How do you tell which version it was?
The easiest way to do it is to do
git log --raw --all --full-history -- subdirectory/my-magic-file
and this actually tells you what the *previous* and *subsequent* versions
of that file were! So now you can look at those ("oldsha" and "newsha"
respectively), and hopefully you have done commits often, and can
re-create the missing my-magic-file version by looking at those older and
newer versions!
If you can do that, you can now recreate the missing object with
git hash-object -w <recreated-file>
and your repository is good again!
(Btw, you could have ignored the fsck, and started with doing a
git log --raw --all
and just looked for the sha of the missing object (4b9458b..) in that
whole thing. It's up to you - git does *have* a lot of information, it is
just missing one particular blob version.
Trying to recreate trees and especially commits is *much* harder. So you
were lucky that it's a blob. It's quite possible that you can recreate the
thing.
http://www.opensource.apple.com/source/Git/Git-17/src/git-htmldocs/howto/recover-corrupted-blob-object.txt
- (798)What is the synthax for the URL for 1rst "svn co"?
@reposiMachine $ svn mkdir file:///path/to/repository/Project
@remoteMachine $ svn co svn+ssh://user@domain.com/path/to/repository/Project Project/
- (802)Howto for Git (by GitHub)
- Save some usefull info for git
git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit
git config --global user.email "your_email@youremail.com"
# Sets the default email for git to use when you commit
From: https://help.github.com/articles/set-up-git
- Enable password caching
git config --global credential.helper cache
# Set git to use the credential memory cache
git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
From: https://help.github.com/articles/set-up-git
- Create a repo:
git init
git remote add origin https://github.com/<username>/<reponame>.git
git push -u origin master
From: https://help.github.com/articles/create-a-repo
- Get/Checkout a repo:
git clone https://github.com/<username>/<reponame>.git
From: https://help.github.com/articles/create-a-repo
- (804)How to resolve error 'No refs in common and none specified; doing nothing.' in Git?
git push origin master
- (829)How to create a new svn user with password?
if you dont have svn account, pls go to your subversion server to create.
do the dollowing step:
1. cat /etc/.svn-auth-file and it will list down all the user account.
2. htpasswd -m /etc/.svn-auth-file <username> -- to create user account(must be root)
---
You might not have password file as mentioned in the below thread, please use below command to create new password file
Please use -c option for creating the password file in the command provided by "si3w82". For example as below:
#sudo htpasswd -cm /etc/.svn-auth-file <username> -- to create user account
It will ask for password, provide the password and confirm again.
Note: For creating another user you don't need to give -c option in above command, otherwise it will replace the previous password file with new one. So, for creating new user in the existing file give the command as below:
#sudo htpasswd -m /etc/.svn-auth-file <username> -- to create another user account in existing password file.
---
From: http://www.svnforum.org/threads/33361-creating-a-new-svn-user-with-password
- (834)How to correctly set the svn:ignore property?
1. It is not recursive (even if svn propset -R svn:ignore can be used...), so you have to be /inside/ the directory on which you want to apply the svn:ignore property
2. You have to /quote/ the ingoring RegEx, otherwise the shell expands it!
--
At second, there was an optional way to set the property. Not by changing directory to sess/ directory before set it, but by applying the property from logs/ directory with directing the property on the sess/ directory :
$ svn propset svn:ignore '*' sess/
From: http://www.heavymind.net/2007/08/29/the-nightmare-has-returned-with-new-name-svnignore/
- (843)How to know the current revision number (or the revision number of the last change) of files in SVN?
$ svn info <project>/
Path: presans-crawling
Working Copy Root Path: /home/guillaume/Work/Code/presans-crawling
URL: http://localhost:8090/repos/presans-crawling/trunk
Repository Root: http://localhost:8090/repos
Repository UUID: 718e92e9-054e-4399-ac05-d45f6fdc7c69
Revision: 1033
Node Kind: directory
Schedule: normal
Last Changed Author: fcoulon
Last Changed Rev: 1032
Last Changed Date: 2013-01-29 13:53:31 +0100 (Tue, 29 Jan 2013)
From: http://stackoverflow.com/questions/1499811/how-to-programmatically-get-svn-revision-number
- (845)How to resolve "Skipped obstructing working copy" in SVN?
this means that there's a working copy folder in the way: your update wants to add a folder with name 'project', but you already have a versioned folder 'project' in your working copy. Maybe you moved that folder from another working copy? Or that folder is its own working copy (if it has the hidden .svn folders then it's an independent, separate working copy).
To resolve: move the folder out of your working copy (or just delete it). Then run update again. The update will fetch a folder with the same name again. But it might not be the same as you had - that's why I recommend that you move the folder and delete it only after checking that the updated folder is identical with the original folder.
From: http://stackoverflow.com/questions/10414814/tortoisesvn-reports-conflict-but-no-conflict-can-be-found
- (846)How to correct error "Cannot commit 'x' and 'y' as they refer to the same URL?" in Eclipse?
This generally occurs when using SVN outside of Eclipse instead of using the plugin SubClipse
Once I realised the problem was within Eclipse and not specific to Subversion it was easy to search for a solution. You need to add "**/.svn/" to the source exclusions in the Java Build Path of the Source tab:
Project --> Properties --> Java Build Path.
From: http://stackoverflow.com/questions/6157417/svn-cannot-commit-x-and-y-as-they-refer-to-the-same-url
- (847)How to recover deleted files in SVN?
1. Use to find the revision number when the element was deleted
$ svn log --verbose
2. Copy the
[THIS DOES NOT WORK] svn copy --revision <revision number> http://yourrepos/path/file ./file
[THIS WORKS] svn co --revision <revision number> http://yourrepos/path/file, then manually copy the file to the local repository
3. Commit it again
$ svn commit -m "Resurrected <file> from revision XXX"
From: http://svnbook.red-bean.com/en/1.1/ch04s04.html#svn-ch-4-sect-4.3
- (849)How to prevent SVN to commit changes made to files /into/ a directory while committing the directory itself?
use:
svn --non-recursive <dir>
svn -N <dir>
- (853)Good free documentation on CVS/SVN/Git/Maven
http://cvsbook.red-bean.com/cvsbook.html
http://svnbook.red-bean.com/index.en.html
http://git-scm.com/book
http://www.sonatype.com/books/mvnex-book/reference/public-book.html
http://www.sonatype.com/Support/Books/Maven-The-Complete-Reference
http://www.sonatype.com/Support/Books/The-Maven-Cookbook
http://www.sonatype.com/Support/Books/Developing-with-Eclipse-Maven
- (876)How to remove some files from tracking in SVN?
- First, remove the files from SVN's tracking (but not locally!!!)
svn rm --keep-local <the files>
- Second, for each file, make SVN ignore it
svn propedit svn:ignore <a file>
# NOTE: for sub-directories, you should be inside the dir! (and eventually use -R for recursive setting of the property svn:ignore)
# NOTE: see other note on this site about the proper use of svn:ignore
- (930)Does SVN support symbolic links/symlinks?
"On non-Windows platforms, Subversion is able to version files of the special type symbolic link (or “symlink”). "
From: http://svnbook.red-bean.com/nightly/en/svn.tour.cycle.html
- (962)How to ignore files in git?
If you create a file in your repository named .gitignore git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename
From: https://help.github.com/articles/ignoring-files
- (964)How do I resolve git saying “Commit your changes or stash them before you can merge”?
You can't merge with local modifications. Git protects you from losing important changes. You have three options. One is to commit the change using
git commit -m "My message"
The second is to stash it. stashing acts as a stack, where you can push changes, and you pop them in reverse order.
To stash type:
git stash
Do the merge, and than pull the stash:
git stash pop
The third options is to discard the local changes using:
git reset --hard.
http://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me
- (988)How to configure SVN authentication?
See files:
/etc/svn-auth-conf
/etc/svn-access-control
From: http://www.if-not-true-then-false.com/2010/svn-subversion-access-control-with-apache-and-mod-authz-svn/
- (989)How to get the remote repository URL?
svn info .
From: http://stackoverflow.com/questions/9128344/how-to-get-svn-remote-respository-url
- (1375)How to list files/projects on an SVN repository?
svn ls svn+ssh://user@machine/path/to/repository/
From: http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.list.html
- (1331)How to checkout my own repository on GitHub?
On the project page (http://github.com/you/project) there will be a link on the right at the bottom of project tools list with a path to a .git repo.
It's called "HTTPS clone URL"
From: http://stackoverflow.com/questions/5989893/github-how-to-checkout-my-own-repository#5989998
- (1006)How to resolve a simple file conflict with SVN?
RTFM!! using 's' will show the documentation!
Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved,
(mc) mine-conflict, (tc) theirs-conflict,
(s) show all options: s
(e) edit - change merged file in an editor
(df) diff-full - show all changes made to merged file
(r) resolved - accept merged version of file
(dc) display-conflict - show all conflicts (ignoring merged version)
(mc) mine-conflict - accept my version for all conflicts (same)
(tc) theirs-conflict - accept their version for all conflicts (same)
(mf) mine-full - accept my version of entire file (even non-conflicts)
(tf) theirs-full - accept their version of entire file (same)
(p) postpone - mark the conflict to be resolved later
(l) launch - launch external tool to resolve conflict
(s) show all - show this list
From: http://www.logicaltrinkets.com/wordpress/?p=178
- (1021)Why does "svn https://..." keeps asking for password?
- Could be because url1 (the currently used one) contains localhost and the "svn co" was done with an ssh tunnel that managed the auth => use the actual FQDN
- Could be because url1 (the currently used one) contains the username => relocate
To relocate:
svn switch --relocate url1 url2
To know the currently used url (url1): svn info <local repo>
From: http://permalink.gmane.org/gmane.comp.java.netbeans.php/5228
- (1022)How to solve a git conflict (e.g. file changed locally, but removed remotely)?
You have to resolve the conflict manually (copying the file over) and then commit the file (no matter if you copied it over or used the local version) like this
git commit -a -m "Fix merge conflict in test.foo"
Git normally autocommits after merging, but when it detects conflicts it cannot solve by itself, it applies all patches it figured out and leaves the rest for you to resolve and commit manually. The Git Merge Man Page, the Git-SVN Crash Course or this blog entry might shed some light on how it's supposed to work.
You don't actually have to copy the files yourself, but can use
git checkout --ours -- path/to/file.txt
git checkout --theirs -- path/to/file.txt
From: http://stackoverflow.com/questions/278081/resolving-a-git-conflict-with-binary-files#278207
- (1028)How to get a diff against changes in the remote repository in SVN?
1. Get the release number of the last modification on the file:
$ svn info <myfile>
...
Last Changed Rev: <thenumber>
...
2. Get the diff
$ svn diff -r <thenumber> <myfile>
From: http://blog.chmouel.com/2007/02/06/svn-diff-against-changes-in-the-remote-repository/
- (1242)How to prevent git from asking the password?
I] MOST SECURE SOLUTION: Do not use an HTTPS access to the repository, but an SSH access!
Change your .git/config file:
https://github.com/<username>/<project-name>.git -> git@github.com:<username>/<project-name>.git
Or use:
git remote set-url origin git@github.com:<username>/<project-name>.git
Then, you'll have to configure your access through the use of an SSH (public) key.
NOTE: also see TIPS #1243 on how to set your git user.name
II] INSECURE SOLUTIONS: if you cannot connect using ssh, you can still store the password, BUT IN A PLAIN-TEXT FILE!!!
- (a little more secure) Let git temporarily cache (in plain text?) the credentials (that you still need to manually enter from time to time)
git config credential.helper 'cache --timeout=3600'
- Definitively store the credentials in ~/.git-secret
git config credential.helper store # next time you type your creds, they will be stored in ~/.git-secret
- Definitively store the credentials in the remote URL [accessible in plaintext in <project dir>/.git/config or via git remote get-url origin]
git remote set-url origin https://<user>:<pass>@gitlab.domain.fr/user/repository.git
- UPDATE: there seems to be a more secure approach now with libsecret
sudo apt-get install libsecret-1-0 libsecret-1-dev
cd /usr/share/doc/git/contrib/credential/libsecret
sudo make
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
From: http://stackoverflow.com/questions/10909221/why-is-github-asking-for-username-password-when-following-the-instructions-on-sc
https://www.softwaredeveloper.blog/git-credential-storage-libsecret
- (1243)How to set your username in git?
- If you want to set the username that appears in commit messages:
git config [--global] user.name "Billy Everyteen" # Set a new name
git config [--global] user.name # Verify the setting
- If you want to set the username that is used for logins
git remote set-url origin https://<username>@<server>/<username>/<projectname>
From: https://help.github.com/articles/setting-your-username-in-git
- (1244)How to add an SSH key to GitHub?
- In the user bar in the top-right corner of any page, click "Account Settings" (the "tools" icon).
- Click "SSH Keys" in the left sidebar.
- Click "Add SSH key".
- In the Title field, add a descriptive label for the new key
- Paste your key into the "Key" field. Be careful not to add any extra \n or spaces
- Click Add key.
Confirm the action by entering your GitHub password.
From: https://help.github.com/articles/generating-ssh-keys
- (1221)How do I get/view an older version of an SVN file?
You can update to an older revision:
svn update -r 666 file
Or you can just view/get the file directly:
svn cat -r 666 file | less
svn cat -r 666 file > file.r666
From: http://stackoverflow.com/questions/4218859/how-do-i-view-an-older-version-of-an-svn-file
- (1144)How to solve "wyciwyg://[0-9]*/" bug in firefox's bookmarks?
sqlite3 ~/.mozilla/firefox/<your account>/places.sqlite
-- Get help
.help
-- List available tables
.tables
-- Show structure/schema of the table
.schema moz_places;
-- Load plugin to manage regexes / requires: sudo apt-get install sqlite3-pcre
.load /usr/lib/sqlite3/pcre.so
-- See which entries have been corrupted v1
-- SELECT * FROM moz_places WHERE url LIKE "%wyciwyg%";
-- DOES NOT WORK: replace() does not accept a regex :[
-- UPDATE moz_places SET url=replace(url,'wyciwyg://[0-9]*/','') WHERE url LIKE '%wyciwyg%';
-- See which entries have been corrupted v2
SELECT * FROM moz_places WHERE url REGEXP "wyciwyg://[0-9]/";
-- Remove the constraint of unicity on the url field
DROP INDEX moz_places_url_uniqueindex;
-- replace the corrupted entries with one digit
UPDATE moz_places SET url=substr(url,13) WHERE url REGEXP 'wyciwyg://[0-9]/';
-- replace the corrupted entries with two digits
UPDATE moz_places SET url=substr(url,14) WHERE url REGEXP 'wyciwyg://[0-9][0-9]/';
-- replace the corrupted entries with three digits
UPDATE moz_places SET url=substr(url,15) WHERE url REGEXP 'wyciwyg://[0-9][0-9][0-9]/';
-- See the remaining duplicates
-- SELECT id, url, COUNT(*) FROM moz_places GROUP BY moz_places.url HAVING COUNT(*)>1;
-- Remove the duplicates
DELETE FROM moz_places WHERE id IN (SELECT id FROM moz_places GROUP BY moz_places.url HAVING COUNT(*)>1);
-- Restore the unicity of the url field
CREATE UNIQUE INDEX moz_places_url_uniqueindex ON moz_places (url);
From: http://www.alekz.net/archives/740?ModPagespeed=noscript
http://www.quake3world.com/forum/viewtopic.php?f=13&t=41760
http://www.sqlite.org/lang_corefunc.html#replace
http://www.sqlite.org/lang_corefunc.html#substr
http://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query
- (1120)How to know what were the changes in a particular SVN revision?
svn log -v -r <directory where you want to know the changes>
From: http://www.quora.com/Subversion/In-SVN-how-do-you-get-detailed-information-about-a-specific-revision
- (1083)How to cicumvent git SSL errors?
GIT_SSL_NO_VERIFY=true git clone https://github.com/user/repo.git
GIT_CURL_VERBOSE=1 git clone https://github.com/user/repo.git
From: http://machine-cycle.blogspot.fr/2011/07/cloning-github-git-repository-on-ubuntu.html
- (1075)How to solve "Can't check path: ... File name too long" in svn?
PROBLEM: your local file system considers the name is too long. You cannot rename it from here.
SOLUTION: Rename thhe file by acting directly on the repository, where the file system considers the file name is OK:
svn mv file:///absolute/path/to/longfile file:///absolute/path/to/shortfile
- (1062)How to recover an old version of a file in git?
git checkout <commit number> -- some/file.c
To get the <commit number>:
git log -- some/file.c
or
git log --full-history -- some/file.c
BEWARE THAT THIS OVERWRITES THE CURRENT VERSION OF THE FILE!!!
To come back to HEAD version (BEWARE this might not be the latest
version if you had un-committed modifications before the "git checkout"):
git reset HEAD <myfile>
From: http://git.661346.n2.nabble.com/Get-a-copy-of-an-old-version-of-a-file-using-git-gui-gitk-td1100291.html
- (1063)How to make/apply a patch from a svn diff?
svn diff > ~/fix_ugly_bug.diff
patch -p0 -i ~/fix_ugly_bug.diff
From: http://ariejan.net/2007/07/03/how-to-create-and-apply-a-patch-with-subversion/
- (1435)How to move/relocate a SVN repository ("client" side)?
In SVN before 1.7:
svn switch --relocate FROM-PREFIX TO-PREFIX [PATH...]
In SVN 1.7:
svn relocate FROM-PREFIX TO-PREFIX [PATH...]
svn relocate TO-URL [PATH]
Description
Sometimes an administrator might change the location (or apparent location, from the client's perspective) of a repository. The content of the repository doesn't change, but the repository's root URL does. The hostname may change because the repository is now being served from a different computer. Or, perhaps the URL scheme changes because the repository is now being served via SSL (using https://) instead of over plain HTTP. There are many different reasons for these types of repository relocations. But ideally, a “change of address” for a repository shouldn't suddently cause all the working copies which point to that repository to become forever unusable. And fortunately, that's not the case. Rather than force users to check out a new working copy when a repository is relocated, Subversion provides the svn relocate command, which “rewrites” the working copy's administrative metadata to refer to the new repository location.
From: http://svnbook.red-bean.com/en/1.7/svn-book.html#svn.ref.svn.c.relocate
- (1457)How to relocate a git repository?
1. Verify current source
$ git remote show origin
* remote origin
URL: git@oldserver:project.git
...
2. Change source
$ git remote rm origin
$ git remote add origin git@newserver:project.git
3. Verify new source
$ git remote show origin
* remote origin
URL: git@newserver:project.git
...
4. NOTE: There might be errors in the last command. The first pull should resolve them:
$ git pull
From: http://www.radomirml.com/blog/2009/04/13/relocate-remote-git-repository-for-local-clone/
- (1480)How to move/relocate an SVN repository ("server" side)?
oldrep$ svnadmin dump myrepos > dump.file
newrep$ mkdir /path/to/myrepos
newrep$ svnadmin create /path/to/myrepos
newrep$ svnadmin load /path/to/myrepos < dump.file
Then use Tip#1435 (svn relocate) to adapt the "client" repositories reference.
From: http://svnbook.red-bean.com/en/1.1/ch05s03.html#svn-ch-5-sect-3.5
http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.dump.html
http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.load.html
http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.create.html
http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/
- (1489)How to create an SVN repository?
mkdir /path/to/repos
svnadmin create /path/to/repos
From: http://svnbook.red-bean.com/en/1.7/svn.ref.svnadmin.c.create.html
http://queens.db.toronto.edu/~nilesh/linux/subversion-howto/
- (1527)How to remove (forever) sensitive data from GitHub?
$ git clone <your URL>
$ cd <the local copy>
$ files=$(find <place> -type f -name 'files you want to remove')
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch $files" \
--prune-empty --tag-name-filter cat -- --all
$ git push origin --force --all
From: https://help.github.com/articles/remove-sensitive-data/
- (1528)How to remove (forever) the history of some files with git?
You can rewrite history thanks to the git-filter-branch tool which comes with git. However, it makes temporary backups of the filtered out files. To remove those, you need to do a little more work:
files=...
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch $files" HEAD
From: http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
- (1557)How to install Mac OSX Yosemite In VBox 4.3 (VBox config changes)?
> In VBox GUI: VM > Config
> System > Motherboard > 4096M RAM + ICH9 + Enable IO/Apic + Enable EFI
> System > Processor > 2cores + Enable PAE/NX
VBoxManage modifyvm 'OS X' --cpuidset 00000001 000306a9 00020800 80000201 178bfbff
VBoxManage modifyvm 'OS X' --cpuidset 00000001 000006fb 00000800 80000209 078bfbff
VBoxManage modifyvm 'OS X' --cpuidset 00000001 000206a7 02100800 1fbae3bf bfebfbff
VBoxManage modifyvm 'OS X' --cpuidset 1 000206a7 02100800 1fbae3bf bfebfbff
To control Graphics Output Protocol, use the following VBoxManage command: VBoxManage setextradata "VM name" VBoxInternal2/EfiGopMode N Where N can be one of 0,1,2,3,4,5 referring to the 640x480, 800x600, 1024x768, 1280x1024, 1440x900, 1920x1200 screen resolution respectively. For example, to set my OS X guest's resolution to 1920x1200 I ran
VBoxManage setextradata 'OS X' VBoxInternal2/EfiGopMode 5
VBoxManage modifyvm "OS X" --cpuidset 00000001 000306a9 04100800 7fbae3ff bfebfbff
VBoxManage setextradata "OS X" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro11,3"
VBoxManage setextradata "OS X" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "OS X" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "OS X" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "OS X" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1
Also see: https://github.com/myspaghetti/macos-guest-virtualbox/blob/master/macos-guest-virtualbox.sh
From: https://www.youtube.com/watch?v=tafqhSUfKnY
https://drive.google.com/folderview?id=0B9oZd81xqtTOckJOT25uTzVfT3c&usp=sharing
- (1585)How to examine the history of deleted file in SVN?
1) First, find the revision number where the file got deleted:
svn log -v | tee > log.txt | grep '^D\\s*<deleted file>'
2) Get the info about the file
svn log -r lastrevisionthefileexisted
svn cat http://server/svn/project/file@1234 # this syntax gets the file that was available as http://server/svn/project/file in revision 1234. So this syntax DOES work on deleted files.
From: http://stackoverflow.com/questions/401331/examining-history-of-deleted-file
- (1587)How to improve OSX/Yosemite performance when ran in a VMs?
PROBLEM:
[...] the graphics performance in a VM was sluggish and assigning more
RAM and processors to a VM did not address the issue.
[...] the root cause of the issue was beam synchronization,
SOLUTION:
BeamOff was written by JasF
(http://www.insanelymac.com/forum/user/1190299-jasf/), who developed
BeamOff to fix the performance issue he was having with Yosemite
VMs. JasF posted the source files to GitHub
(https://github.com/JasF/beamoff) and a compiled version of the
application as part of this thread on the InsanelyMac forums
(http://www.insanelymac.com/forum/topic/302424-yosemite-on-vmware-unusable/).
Because BeamOff must be started automatically, it must be installed in
the /Applications directory and the following LaunchAgent to launch
and run BeamOff on login written:
--- com.company.launch_beamoff.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.company.launch_beamoff</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/beamoff.app/Contents/MacOS/beamoff</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
view raw
There's also an installer for BeamOff and the LaunchAgent, which is
available as a .zip file from the installer directory. The installer
adds BeamOff to /Applications and installs the LaunchAgent to
/Library/LaunchAgents.
https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/fix_yosemite_vm_graphic_performance
For those interested in building their own installer, there's a copy
of the compiled BeamOff application, the LaunchAgent and the Packages
project files used to build the BeamOff installer. Those are available
in the resources directory up on my repo:
https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/fix_yosemite_vm_graphic_performance/resources
From: https://derflounder.wordpress.com/2014/12/13/improving-yosemite-vm-performance-in-vmware-fusion/
- (1610)How to block ads on GNT in Firefox?
1. Install FF's add-on "uBlock Origin"
2. Go to about:addons -> uBlock -> Preferences -> Show dashboard
3. In the panel "My Filters", add
--
! 9/22/2015, 2:36:55 PM http://www.generation-nt.com/
||www.generation-nt.com/*/*;;
||www.generation-nt.com/*/*/*;;
--
From: https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/?src=search
https://github.com/gorhill/uBlock
- (1645)How to pass a RAW disk (image) to QEmu, so that sect0 gets written correctly?
Instead of:
-hda XXX
Use:
-drive file=XXX,index=0,media=disk,format=raw
From: https://github.com/hartwork/grub2-theme-preview/issues/7
- (1775)How to tell SVN (diff) to ignore differences in space/tab indentation?
svn diff -x -w myfile
- "-x" is followed by arguments passed to the diff program
- For the default diff used by svn "-w" means ignore all whitespaces
From: https://stackoverflow.com/questions/8974307/how-to-tell-svns-diff-to-ignore-differences-in-space-tab-indentation
- (1862)How to create a Tag in SVN?
$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/tags/release-1.0 \
-m "Tagging the 1.0 release of the 'calc' project."
From: http://svnbook.red-bean.com/en/1.7/svn.branchmerge.tags.html
- (1887)How to configure Git for a Research Team?
CREATE CENTRAL git clone --bare --no-hardlinks <local> <central>
IN LOCAL git remote set-url origin <central-url>
IN CENTRAL git repo-config core.sharedRepository true
IN CENTRAL chmod g+rw -R *
IN CENTRAL chgrp -R <git group> <central>
IN NEW PC git clone <central-url>
NOTE : ne surtout pas faire de git --shared, ça réinitialise le repository à 0.
Pour rejoindre l'équipe de recherche :
1. sur "newgit" : ajouter un utilisateur
2. sur "newgit" : ajouter cet utilisateur au groupe <git group>
3. sur sa machine faire un git clone <username>@<newgit dnsname or ip>:~git/repository.git/ <localrepository>
4. travail normal : git add file / git commit file / git push / git pull
- (3861)How to find a deleted file in the commit history in Git?
- Find the exact path of the file
- Find commit with matching filenames
git log --all --full-history -- "*MyFile.*"
- Find the full path of the file
git show --pretty="" --name-only <sha1-commit-hash>
- Display the specified version of the file
git log --all --full-history -- <path-to-file>
- Display the file content
git show <sha1-commit-hash> -- <path-to-file>
From: https://www.w3docs.com/snippets/git/how-to-find-a-deleted-file-in-the-project-commit-history.html
- (3862)How to list files modified for particular commit in Git?
For filenames only:
git show --name-only abc
To see a summary of what happened to them:
git show --name-status abc
From: https://stackoverflow.com/questions/21515084/list-files-modified-for-particular-git-commit
- (2032)How to remove a too large file in a commit when the local branch is ahead of master by X commits in Git (within Github's file size limits)?
PROBLEM: Having a code project saved in Github. Committing a large
file to the local repository, which exceeds Github's limits. Commit
cannot occur until solution is found, but trying to delete the file
creates a new change that remains unstaged like the rest and makes git
still complaining about "being ahead of master by X commits".
SOLUTION1:
If you do a git status you should see the file listed as
removed/deleted. To undo this change you should:
git checkout -- <filename>
Then the file will be back and your branch should be clean.
SOLUTION2: [If you've not yet push'ed your changes?]
# Stage our giant file for removal, but leave it on disk
git rm --cached giant_file
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well
git commit --amend -CHEAD
# Push our rewritten, smaller commit
git push
SOLUTION3: [!!!BEWARE!!! drops your local changes!!!! DOES NOT WORK]
You can also git reset --hard this will bring your repo back to the
status where you made your commit.
SOLUTION4:
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA' --prune-empty --tag-name-filter cat -- --all
# Prevent future commits
echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore
git add .gitignore
git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
# Commit new files
git push origin --force --all
From: https://help.github.com/articles/removing-sensitive-data-from-a-repository/
https://help.github.com/articles/removing-files-from-a-repository-s-history/
https://stackoverflow.com/questions/20002557/how-to-remove-a-too-large-file-in-a-commit-when-my-branch-is-ahead-of-master-by
- (2035)How to make .gitignore ignore everything except a few files
Doc: An optional prefix ! which negates the pattern; any matching file
excluded by a previous pattern will become included again. If a
negated pattern matches, this will override lower precedence patterns
sources.
# Ignore everything
*
# But not these files...
!.gitignore
#...
# ...even if they are in subdirectories
!*/
From: https://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files#987162
- (2069)How can I determine the URL that a local Git repository was originally cloned from?
git config --get remote.origin.url
git remote show origin
From: http://stackoverflow.com/questions/4089430/how-can-i-determine-the-url-that-a-local-git-repository-was-originally-cloned-fr#4089452
- (2118)How to list branches/tags in Git?
git branch --list
git tag -n
From: http://manpages.ubuntu.com/manpages/precise/en/man1/git-branch.1.html
https://stackoverflow.com/questions/5358336/have-git-list-all-tags-along-with-the-full-message
- (2119)What does "Git-svn W: -empty_dir warning" mean?
SVN tracks directories, git doesn't, so empty directories cannot be
represented in git. Those warnings on files seem to tell you which
files that got deleted, causing an empty directory to be left in
place, in that particular svn commit being imported.
The difference between -empty_dir and +empty_dir is about how the
empty directory appears in the SVN repo:
-empty_dir A bunch of files are deleted, leaving a directory (branch
or tag) empty.
+empty_dir An empty branch or tag has just been created in the SVN revision being
imported, and git-svn won't import an empty directory.
From: https://stackoverflow.com/questions/4147356/git-svn-w-empty-dir-warnings-what-do-they-mean
- (2120)What is the HEAD in git?
HEAD is a ref (reference) to the currently checked out commit. In
normal states, it's actually a symbolic ref to the branch you have
checked out - if you look at the contents of .git/HEAD you'll see
something like "ref: refs/heads/master". The branch itself is a
reference to the commit at the tip of the branch.
From: http://www.stackoverflow.com/questions/2529971/what-is-the-head-in-git
- (2121)What is the origin in git?
"remote" is just some git repository not on your computer (e.g. on
github). "origin" is the repository you cloned your repository from
(e.g. the one on your github). "master" is just the name of the
default branch.
From: https://www.quora.com/What-does-git-remote-and-origin-mean
- (2122)What is remote in git?
A remote URL is Git's fancy way of saying "the place where your code
is stored." That URL could be your repository on GitHub, or another
user's fork, or even on a completely different server. You can only
push to two types of URL addresses: An HTTPS URL like
https://github.com/user/repo.git.
From: https://help.github.com/articles/about-remote-repositories/
- (2123)What is origin master?
Take a clone of a remote repository and run git branch -a (to show all
the branches git knows about). ... Here, master is a branch in the
local repository. remotes/origin/master is a branch named master on
the remote named origin . You can refer to this as either
origin/master , as in: git diff origin/master..master.
From: https://stackoverflow.com/questions/10588291/git-branching-master-vs-origin-master-vs-remotes-origin-master
- (2124)What is a ref in git?
A ref is anything pointing to a commit, for example, branches (heads),
tags, and remote branches. You should see heads, remotes, and tags in
your .git/refs directory, assuming you have all three types of refs in
your repository. refs/heads/0.58 specifies a branch named 0.58.
From: https://stackoverflow.com/questions/1526471/git-difference-between-branchname-and-refs-head-branchname
- (2125)What is a git rebase?
git rebase. Rebasing is the process of moving a branch to a new base
commit. The general process can be visualized as the following: From a
content perspective, rebasing really is just moving a branch from one
commit to another.
From: https://www.atlassian.com/git/tutorials/rewriting-history
- (2126)What is staged in git?
Staging is a step before the commit process in git. That is, a commit
in git is performed in two steps: staging and actual commit. As long
as a changeset is in the staging area, git allows you to edit it as
you like (replace staged files with other versions of staged files,
remove changes from staging, etc.).
From: https://softwareengineering.stackexchange.com/questions/119782/what-does-stage-mean-in-git
- (2147)How to convert a SVN repository into a Git repository?
* Create server side Git user :REMOTE:
=r# useradd -m -d /home/git git=
=r# su - git=
=r$ mkdir git-shell-commands=
=r$ chmod 755 git-shell-commands=
=r# usermod -s /usr/bin/git-shell git= [or # vim /etc/passwd : /bin/bash -> /usr/bin/git-shell]
* Authorize Git usersto login using SSH :REMOTE:
=r# vi /etc/ssh/sshd_config
# Authentication:
...
AllowUsers git
* Authorize remote users to login as Git :REMOTE:
=r# cat /path/to/authorized/user/id_rsa.pub >> ~git/.ssh/authorized_keys=
* Create/Convert repository [REPEAT for each repository/<reponame>] :LOCAL:
** Retrieve a list of all Subversion committers
=l$ svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > /tmp/authors-transform.txt=
TODO: if you only have ./trunk locally, git might complain that "authors-transform.txt" lacks users (e.g. those that committed in branches)
** Fill the list with lacking info. Format is 1 user by line: "pseudo = fullname <email>"
** Clone the Subversion repository using git-svn
=l$ git svn clone <SVN repo URL> --no-metadata -A /tmp/authors-transform.txt --stdlayout /tmp/<reponame> > /tmp/<reponame>.out 2>&1=
NOTE: if your repository does not have the standard trunk/branches/tags layout, replace --stdlayout above with --trunk=path/to/trunk --branches=path/to/branches --tags=path/to/tags .
* Recover svn:ignore properties to .gitignore :LOCAL:
=l$ cd /tmp/<reponame>=
=l$ git svn show-ignore --id=origin/trunk > .gitignore=
=l$ git add .gitignore=
=l$ git commit -m 'Convert svn:ignore properties to .gitignore.'=
* Push repository to a bare git repository :LOCAL:
** create a bare repository and make its default branch match svn's "trunk" branch name
=l$ git init --bare <reponame>.git=
=l$ cd <repo>.git=
=l$ git symbolic-ref HEAD refs/heads/trunk=
** push the temp repository to the new bare repository
=l$ cd <reponame>=
=l$ git remote add bare <reponame>.git=
=l$ git config remote.bare.push 'refs/remotes/*:refs/heads/*'=
=l$ git push bare=
* Re-set master/HEAD branch :LOCAL:
=l$ cd <reponame>.git=
=l$ git branch -m trunk master=
=l$ git symbolic-ref HEAD refs/heads/master=
* Clean up branches and tags :LOCAL:
=l$ cd <reponame>.git=
=l$ git for-each-ref --format='%(refname)' refs/heads/origin/tags | cut -d / -f 5 | while read ref ; do git tag "$ref" "refs/heads/origin/tags/$ref"; git branch -D "origin/tags/$ref"; done=
* Move the bare repository to the server :LOCAL::REMOTE:
=l$ scp -r <reponame>.git/ k2.presans.com:~/=
=l$ ssh k2.presans.com=
=r$ su=
=r# mv <reponame> ~git/=
=r# chown -R git: ~git/<reponame>.git=
* Clone the freshly created repository on the local machine :LOCAL:
=$ git clone ssh://git@k2.presans.com/~/<reponame>.git=
=$ cd <reponame>=
=$ git pull=
...change some files...
=$ git commit -a -m 'msg'=
=$ git push=
From: https://www.systutorials.com/366/set-up-git-server-through-ssh-connection/
http://john.albin.net/git/convert-subversion-to-git
https://stackoverflow.com/questions/25254694/git-svn-show-ignore-gives-error-command-returned-error-1
- (2159)How to have multiple identities with git?
GLOBAL CONFIG
The default user/email is configured in your ~/.gitconfig
You can edit it with:
git config --global --edit
or using:
git config --global user.name "Your Name Here"
git config --global user.email your@email.com
LOCAL CONFIG
You can configure an individual repo to use a specific user/email
address which overrides the global configuration. It is stored into
/path/to/repo/.git/config
*From the root of the repo*, you can edit it with:
git config --edit
or using:
git config user.name "Your Name Here"
git config user.email your@email.com
From: https://stackoverflow.com/questions/4220416/can-i-specify-multiple-users-for-myself-in-gitconfig#4220493
- (2171)What is a bare git repository?
Repositories created with the "git init" command are called working
directories. In the top level folder of the repository you will find
two things:
- A .git subfolder with all the git related revision history of your repo
- A working tree, or checked out copies of your project files.
A working repository created with git init is for... working. It is
where you will actually edit, add and delete files and git commit to
save your changes.
Repositories created with "git init --bare" are called bare
repos. They are structured a bit differently from working
directories. First off, they contain no working or checked out copy of
your source files. And second, bare repos store git revision history
of your repo in the root folder of your repository instead of in a
.git subfolder.
Bare repositories are customarily given a .git extension.
A bare repository created with git init --bare is for... sharing. If you
are collaborating with a team of developers, and need a place to share
changes to a repo, then you will want to create a bare repository in
centralized place where all users can push their changes
From: http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/
- (2176)How to create a Pull Request on GitHub?
NOTE: When thinking about branches, remember that the base branch
is where changes should be applied, the head branch contains what
you would like to be applied.
Creating the pull request:
1. On GitHub, navigate to the main page of the repository.
2. In the "Branch" menu, choose the branch that contains your commits.
3. To the right of the Branch menu, click "New pull request".
4. Use the base branch dropdown menu to select the branch you'd like
to merge your changes into, then use the /compare/ branch drop-down
menu to choose the topic branch you made your changes in.
5. Type a title and description for your pull request.
6. Click "Create pull request".
From: https://help.github.com/articles/about-pull-requests/
https://help.github.com/articles/creating-a-pull-request/
- (2180)How to make qupzilla open GMail?
Set the following UserAgent for the domain "mail.google.com" :
"Mozilla/5.0 (Windows 7; rv:24.0) Gecko/20131101 Firefox/24.1.0"
From: https://github.com/QupZilla/qupzilla/issues/2448
- (2181)How to compile/install QupZilla 2.x on Debian/Ubuntu-based distrib?
NOTE: installing with apt-get results in installation of the very
outdated v1.x. So you have to install dependencies manually and
compile/install by yourself :{
1a. Install Deps
sudo apt-get install git qt5-qmake libqt5positioning5 qtpositioning5-dev libqt5x11extras5 libqt5x11extras5-dev libx11-xcb-dev libx11-xcb1 libxcb-util-dev libxcb1 libxcb1-dev xcb-proto libssl-dev
1b. Install QT>5.8
wget https://download.qt.io/archive/online_installers/2.0/qt-unified-linux-x64-2.0.3-online.run
chmod +x qt-unified-linux-x64-2.0.3-online.run
sudo ./qt-unified-linux-x64-2.0.3-online.run ## <= select only BASE+QtWebEngine!!!
echo "export LD_LIBRARY_PATH=/opt/Qt/<version>/gcc_64/lib:${LD_LIBRARY_PATH}" >> ~/.bashrc
source ~/.bashrc
2. Get source code
git clone git://github.com/QupZilla/qupzilla.git
3. Create Makefile
export PATH=/opt/Qt/<version>/gcc_64/bin/:$PATH # (see step 1b)
qmake
NOTE: Qt version requirements are in file "QupZilla.pro". You can
sometimes comment-out these lines to be able to compile.
---
lessThan(QT_VERSION, 5.8) {
error("QupZilla requires at least Qt 5.8!")
}
lessThan(QT.webengine.VERSION, 5.8) {
error("QupZilla requires at least QtWebEngine 5.8!")
}
---
4. Compile
make
5. Test
./bin/qupzilla
6. Install
make install / cp -r ... /usr/local/bin ????
From: https://www.linuxhint.com/install-qupzilla-browser-linux/
- (2187)How to fork a GitHub repo?
1. Login to GitHub
2. Go to the page of the project youwant to fork
3. In the top-right corner of the page, click Fork.
To Keep your fork synced:
1. Set up your Git username & email => See Tip#1243
2. Set up your Git authentication mechanism (if using ssh => store your pub key@GitHub)
3. Get your local copy of the files
git clone https://github.com/<your username>/<project name>
4. Configure Git to sync your fork with the original repository
git remote add upstream https://github.com/<your username>/<fork name>.git
To contribute to the original project:
1. If you are hoping to contribute back to the original repository,
you can send a request to the original author to pull your fork into
their repository by submitting a pull request. => See Tip#2176
NOTE: When thinking about branches, remember that the base branch
is where changes should be applied, the head branch contains what
you would like to be applied.
From: https://help.github.com/articles/fork-a-repo/
- (2211)Selenium(IDE) CheatSheet
* Ensure page has been cleaned of any cached value
<tr>
<!-- command -->
<td>refresh</td>
<!-- target -->
<td></td>
<!-- value -->
<td></td>
</tr>
<tr>
<!-- command -->
<td>open</td>
<!-- target -->
<td>http://the.actual.url/you/want/to/test</td>
<!-- value -->
<td></td>
</tr>
<tr>
<!-- command -->
<td>refreshAndWait</td>
<!-- target -->
<td></td>
<!-- value -->
<td></td>
</tr>
https://stackoverflow.com/questions/18637123/selenium-ide-how-to-verify-assert-page-refresh
* Select elements using css/xpath (jsoup?) selector
<tr>
<!-- command -->
<td>click</td>
<!-- target -->
<td>css=input[id^='ema'] span.class a#id</td>
<!-- <td>xpath=//input[id^='ema']//span[@class=class]//a[@id=id]</td>
<!-- value -->
<td></td>
</tr>
http://www.seleniumeasy.com/selenium-tutorials/css-selectors-tutorial-for-selenium-with-examples
http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#locating-elements
* Matching content/value
** Selenium offers 3 possibilities:
*** exact:<expression>
matches the exact expression
*** [default] glob:<expression>
only '*' '?' '[a-z]' are recognized, works like file matcher in bash
*** regexp:<expression>
the full power of (Java?) regexes
https://www.codediesel.com/testing/selenium-ide-pattern-matching/
* Simulate typing of special keys (don't use deprecated type* or keyUp/Down/Press, rather sendKeys)
<tr>
<!-- command -->
<td>sendKeys</td>
<!-- target -->
<td>id=xxx</td>
<!-- value -->
<td>my text${KEY_ENTER}${KEY_ESC}\13</td>
</tr>
For TAB, you might need to use fireEvent:
<tr>
<!-- command -->
<td>fireEvent</td>
<!-- target -->
<td>id=xxx</td>
<!-- value -->
<td>blur</td>
</tr>
https://stackoverflow.com/questions/7904834/selenium-ide-how-to-simulate-non-printable-keys-enter-esc-backspace
http://blog.reallysimplethoughts.com/2013/09/25/using-special-keys-in-selenium-ide-part-1/
http://blog.reallysimplethoughts.com/2013/09/25/using-special-keys-in-selenium-ide-part-2/
* Wait for the page to be loaded
<tr>
<!-- command -->
<td>waitForPageToLoad</td>
<!-- target -->
<td></td>
<!-- value -->
<td></td>
</tr>
You must wait immediately after a Selenium command that caused a page-load.
You can use this command instead of the "*AndWait" methods
("clickAndWait", "selectAndWait", "typeAndWait"...), as they are
only available in the JS API.
https://stackoverflow.com/questions/25455362/selenium-ide-waitforelementpresent-visible-not-working-with-displaynone-to-dis
Sometimes it is better to wait for a particular element to appear in the loaded page
<tr>
<!-- command -->
<td>waitForElementPresent</td>
<!-- target -->
<td>id=...</td>
<!-- value -->
<td></td>
</tr>
* Fail/Pass test according to the page HTML title
<tr>
<!-- command -->
<td>assertTitle</td>
<!-- target -->
<td>This is the page title</td>
<!-- value -->
<td></td>
</tr>
http://www.software-testing-tutorials-automation.com/2013/07/asserttitle-and-assertnottitle.html
* Fail/Pass test according to the location/url you are visiting/were redirected to
<tr>
<!-- command -->
<td>assertLocation</td>
<!-- target -->
<td>http://www.google.com</td>
<!-- value -->
<td></td>
</tr>
http://www.software-testing-tutorials-automation.com/2013/03/use-of-verifylocation-and.html
* Fail/Pass test according to element presence/absence
<tr>
<!-- command -->
<td>assertElementPresent</td>
<!-- target -->
<td>id=...</td>
<!-- value -->
<td></td>
</tr>
http://www.software-testing-tutorials-automation.com/2013/03/selenum-ide-example-of.html
* Fail/Pass test according to element 'content' (=text() in xpath/css nomenclature)
<tr>
<!-- command -->
<td>assertText</td>
<!-- target -->
<td>id=buttonxxx</td>
<!-- value -->
<td>Search</td>
</tr>
http://www.software-testing-tutorials-automation.com/2012/11/different-between-verifytext-and.html
http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#matching-text-patterns
* What is the difference between assert*() and verify*()?
The difference is that as soon as an assert*() is not verified, the
execution of the test is stopped and FAILED is returned, leaving some
actions not executed. On the contrary, if a verify*() is not verified,
the test is marked as FAILED, but its execution continues. Thus with
verify*(), a test might have multiple reason for its failure.
assert*() is preferable if you need to FAIL as soon as possible or,
more importantly, if there are actions that might damage the system
under test, if executed in wrong conditions (). verify() is
prefereable if [it is possible and] you want to combine multiple
checks in a single test file.
https://stackoverflow.com/questions/5743848/assert-vs-verify-in-selenium
* For more documentation on these methods, type the name of a method in
the "command" field of the SeleniumIDE, type enter and read the
documentation at the bottom or see:
** http://docs.seleniumhq.org/docs/02_selenium_ide.jsp#commonly-used-selenium-commands
** http://www.software-testing-tutorials-automation.com/2013/07/list-of-selenium-commands-with-examples.html
** http://www.software-testing-tutorials-automation.com/2013/07/selenium-ide-complete-list-of-commands.html
** https://github.com/SeleniumHQ/selenium/blob/master/ide/main/src/content/selenium-core/reference.html
** https://www.frontendtest.org/blog/selenium-ide-commands/
* For the implementation in code, also see:
** http://www.seleniumhq.org/docs/03_webdriver.jsp
** http://seleniumhq.github.io/selenium/docs/api/java/
** http://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/interactions/Action.html
* For help on SeleniumIDE
** http://www.seleniumhq.org/docs/02_selenium_ide.jsp
- (2216)How to block content with uBlockOrigin?
1. Go to a webpage that shows the content to be blocked
2. Click on the uBlockOrigin logo in the toolbar
3. Select the "picker" mode. The mouse pointer takes a "cross" shape
4. Select the object to block in the page (beware of blocking the outest bounding box!)
5. Once the object is clicked, the mouse pointer take a "forbidden" shape
6. WHAT YOU PROBALY WON'T SEE IS THAT, IN THE LOWER RIGHT CORNER, A TRANSPARENT BOX HAS APPEARED
7. In this box, a rule for blocking the object has bben pre-filled.
8. Just verify/complete the rule, then click "Create"
9. The trick is in the fact that the rule is only created & activated when you click on the (non visible since transparent) "Create" button!!!
The format of the rules is explained in Tip#1611
Also see:
https://www.reddit.com/r/uBlockOrigin/comments/4dpje2/how_to_block_css_popups/
From: https://www.youtube.com/watch?v=SIYcI2tEqo8
https://github.com/gorhill/uBlock/wiki/Static-filter-syntax
https://adblockplus.org/en/filter-cheatsheet
- (2238)How to automatically export a FramaCalc/FramaPad (EtherCalcLite/EtherPad)?
- FramaCalc: HTML/CSV/ODS/PDF/XLSX export is as simple as adding .html/.csv/.pdf/.xlsx at the end the sheet URL
wget 'https://framacalc.org/<framacalc name>.csv'
- FramaPad: just add '/export/{html,txt,ods,pdf,docx}' at the end of the URL
wget 'https://quotidien.framapad.org/<framapad name>/export/docx'
From: https://github.com/audreyt/ethercalc/issues/51#issuecomment-21843223
https://github.com/ether/etherpad-lite/wiki/Backing-up-and-Restoring-Etherpad-Lite-Pads#accessing-a-prevision-revision-directly
- (2239)How to remote control a FramaCalc from commandline?
Remote actions on a cell:
curl -H "Content-Type: application/json" -X POST 'https://framacalc.org/<calc_name>' -d '{"command":"set 1:17 hide"}'
jQuery.ajax({
type: "POST",
url: window.location.href.replace(window.location.host,window.location.host+'/_'),
data: JSON.stringify({command: "set 1:17 hide"}),
contentType: 'application/json'
});
jQuery.ajax({
type: "POST",
url: window.location.href.replace(window.location.host,window.location.host+'/_'),
data: JSON.stringify({command: "set 3;4;6;7;8;11;12;14 hide"}),
contentType: 'application/json'
});
From: https://github.com/audreyt/ethercalc/issues/425
- (2260)How to solve GitHub's error "push declined due to email privacy restrictions" (a.k.a. How to change user.email in a commit)?
This error appears because the remote repository has been configured
to disallow you pushing a commit that would reveal your personal
e-mail address. For example in GitHub you have checked the "Block
command line pushes that expose my email"
(https://github.com/settings/emails) checkbox to enable this
(https://github.com/blog/2346-private-emails-now-more-private).
While you can of course uncheck that setting, it will expose your
private e-mail address to everyone in the world, as author information
is readable by anyone with access to your repository.
Instead, do this:
* You can see your personal e-mail address which is used by default
for your commits in Git:
git config --global user.email
* Find your "GitHub noreply address"
(https://help.github.com/articles/setting-your-email-in-git/) in
your GitHub's "Personal Settings > Emails"
(https://github.com/settings/emails). It's mentioned in the
description of the "Keep my email address private" checkbox. Usually
it's:
{username}@users.noreply.github.com
But more recent noreply addresses start with your unique identifier
number:
{ID}-{username}@users.noreply.github.com
* Change the global user e-mail address setting to your GitHub noreply
address:
git config --global user.email {ID?}-{username}@users.noreply.github.com
* Reset the author information on your last commit:
git commit --amend --reset-author
(* If you have multiple commits with your private e-mail address, see
this https://stackoverflow.com/a/25815116/146622 .)
* Now you can push the commit with the noreply e-mail address, and
future commits will have the noreply e-mail address as well.
git push
From: https://stackoverflow.com/questions/43378060/meaning-of-the-github-message-push-declined-due-to-email-privacy-restrictions#answer-44099011
- (2297)How to get a blob's specific version or sha-1 in git?
Vous pouvez extraire une copie de chacune de ces versions du fichier
en conflit avec la commande git show et une syntaxe spéciale.
$ git show :1:hello.rb > hello.common.rb
$ git show :2:hello.rb > hello.ours.rb
$ git show :3:hello.rb > hello.theirs.rb
Si vous voulez rentrer un peu plus dans le dur, vous pouvez aussi
utiliser la commande de plomberie ls-files -u pour récupérer les SHA-1
des blobs Git de chacun de ces fichiers.
$ git ls-files -u
100755 ac51efdc3df4f4fd328d1a02ad05331d8e2c9111 1 hello.rb
100755 36c06c8752c78d2aff89571132f3bf7841a7b5c3 2 hello.rb
100755 e85207e04dfdd5eb0a1e9febbc67fd837c44a1cd 3 hello.rb
La syntaxe :1:hello.rb est juste un raccourcis pour la recherche du
SHA-1 de ce blob.
From: https://git-scm.com/book/fr/v2/Utilitaires-Git-Fusion-avanc%C3%A9e
- (2355)How to seach for a String/Regex in git history (modified files/log messages/...)?
Git can search diffs with the -S option (it's called pickaxe in the docs)
git log -Spassword
This will find any commit that added or removed the string password. Here a few options:
-p: will show the diffs. If you provide a file (-p file), it will generate a patch for you.
-G: looks for differences whose added or removed line matches the given regexp, as opposed to -S, which "looks for differences that introduce or remove an instance of string".
--all: searches over all branches and tags; alternatively, use --branches[=<pattern>] or --tags[=<pattern>]
From: https://stackoverflow.com/questions/4468361/search-all-of-git-history-for-a-string#4472267
- (2357)How to list the uncommitted commits in Git?
Format is "git log <since>..<until>" (~ git log <originbranch>..<localbranch>)
e.g.:
git log origin/master..HEAD
You can also view the diff using the same syntax
git diff origin/master..HEAD
From: https://stackoverflow.com/questions/2016901/viewing-unpushed-git-commits#2016954
https://stackoverflow.com/questions/3080509/list-git-commits-not-pushed-to-the-origin-yet
- (2358)How to change the log message for a commit?
- If the commit is not pushed, it is easy:
git commit --amend
It will open your editor, allowing you to change the commit message of the most recent commit.
- If the commit is pushed, you'll have to "force push" the result, which can only be done if no one has committed after you. Otherwise, you'll loose the other persons' commit!!!
- If you want to change the message / amend earlier commits, you can use:
git rebase -i HEAD~<nb past commits>
and use e(edit)/r(reword)
Once you squash your commits - choose the e/r for editing the message
From: https://stackoverflow.com/questions/179123/how-to-modify-existing-unpushed-commits#179147
https://stackoverflow.com/questions/8981194/changing-git-commit-message-after-push-given-that-no-one-pulled-from-remote#8981216
- (2371)How to correct any mess done in Git?
TODO: rewrite in plain text :)
From: https://stackoverflow.com/questions/14096721/how-to-add-file-to-a-previous-commit#answer-14096773
http://justinhileman.info/article/git-pretty/
- (2392)What's the difference between git reset --mixed, --soft, and --hard?
When you modify a file in your repository, the change is initially unstaged. In order to commit it, you must stage it—that is, add it to the index—using git add. When you make a commit, the changes that are committed are those that have been added to the index.
git reset changes, at minimum, where the current branch (HEAD) is pointing. The difference between --mixed and --soft is whether or not your index is also modified. So, if we're on branch master with this series of commits:
- A - B - C (master)
HEADpoints to C and the index matches C.
When we run git reset --soft B, master (and thus HEAD) now points to B, but the index still has the changes from C; git status will show them as staged. So if we run git commit at this point, we'll get a new commit with the same changes as C.
Okay, so starting from here again:
- A - B - C (master)
Now let's do git reset --mixed B. (Note: --mixed is the default option). Once again, master and HEAD point to B, but this time the index is also modified to match B. If we run git commit at this point, nothing will happen since the index matches HEAD. We still have the changes in the working directory, but since they're not in the index, git status shows them as unstaged. To commit them, you would git add and then commit as usual.
And finally, --hard is the same as --mixed (it changes your HEAD and index), except that --hard also modifies your working directory. If we're at C and run git reset --hard B, then the changes added in C, as well as any uncommitted changes you have, will be removed, and the files in your working copy will match commit B. Since you can permanently lose changes this way, you should always run git status before doing a hard reset to make sure your working directory is clean or that you're okay with losing your uncommitted changes.
See the graphical representation here: https://i.stack.imgur.com/qRAte.jpg
From: https://stackoverflow.com/questions/3528245/whats-the-difference-between-git-reset-mixed-soft-and-hard
- (2395)How to revert uncommitted changes including files and folders in Git?
You can run these two commands:
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories. (`-f` is `force`, `-d` is `remove directories`)
git clean -fd
From: https://stackoverflow.com/questions/5807137/how-to-revert-uncommitted-changes-including-files-and-folders#5812972
- (2397)How to get out of (almost) any mess in Git?
See Picture: https://i.stack.imgur.com/TsDYW.png
From: https://stackoverflow.com/questions/14096721/how-to-add-file-to-a-previous-commit#answer-14096773
- (2398)What is the difference between git stash and git commit?
git stash -- The command saves your local modifications away and reverts the working directory to match the HEAD commit. It allows you to store your uncommited modifications into a buffer area called stash, and deletes it from the branch you are working on. You may later retreive them by applying the stash.
git commit -- This records your change for next push and this event is recorded in history too. You can commit to a fresh local branch to get a similar behaviour as git stash (pro: this adds the ability to recover your commit in case of problem)
From: https://www.quora.com/What-is-the-difference-between-git-stash-and-git-commit
- (2412)What does git blame do?
Annotates each line in the given file with information from the revision which last modified the line. Optionally, start annotating from the given revision.
When specified one or more times, -L restricts annotation to the requested lines.
From: https://stackoverflow.com/questions/31203001/what-does-git-blame-do#31204980
git-scm http://git-scm.com/docs/git-blame
- (2431)How to backup a SVN repository
You could use something like (Linux):
svnadmin dump repositorypath | gzip > backupname.svn.gz
From: https://stackoverflow.com/questions/33055/svn-repository-backup-strategies#33064
- (2506)How to undo a 'git push'?
!!!BEWARE!!!
You need to make sure that no other users of this repository are fetching the incorrect changes or trying to build on top of the commits that you want removed because you are about to rewind history.
SOLUTION1:
git push -f origin last_known_good_commit:branch_name
SOLUTION2:
git checkout <branch>
git reset --hard <last_known_good_commit>
git push origin +<branch>
SOLUTION3:
git revert <last_known_good_commit>
SOLUTION4: A way to do it without losing the changes you wanted:
git reset <last_known_good_commit>
git stash
git push -f origin <branch>
git stash pop
From: https://stackoverflow.com/questions/1270514/undoing-a-git-
http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#fixing-mistakes
https://git-scm.com/book/be/v2/Git-Basics-Undoing-Things
- (2507)How to count the number of lines contributed by each author in git?
SOLUTION1: for the final code:
# count the number of lines attributed to each author
git blame --line-porcelain file |
sed -n 's/^author //p' |
sort | uniq -c | sort -rn
From: https://www.git-scm.com/docs/git-blame#_the_porcelain_format
SOLUTION2: Use git-quick-stats (https://github.com/arzzen/git-quick-stats)
sh ./TSE/Cours/ProjetsJava/git-quick-stats.sh detailedGitStats
From: https://stackoverflow.com/questions/4592866/git-how-to-estimate-a-contribution-of-a-person-to-my-project-in-terms-of-added
- (2508)How to remove a file from the repository but not locally in Git?
For single file:
git rm --cached mylogfile.log
For single directory:
git rm --cached -r mydirectory
From: https://stackoverflow.com/questions/1143796/remove-a-file-from-a-git-repository-without-deleting-it-from-the-local-filesyste#1143800
- (2554)Wikibook: Computer Architecture /High Performance Computing (lecture @TSE)
=== Computer Architecture / High Performance Computing @TSÉ ===
* Logic
https://en.wikipedia.org/wiki/Boolean_algebra
* Logic Components / Circuits
https://en.wikipedia.org/wiki/Logic_gate
https://en.wikipedia.org/wiki/Transistor
https://en.wikipedia.org/wiki/Bipolar_junction_transistor
https://en.wikipedia.org/wiki/Field-effect_transistor#Gate
https://en.wikipedia.org/wiki/CMOS
https://en.wikipedia.org/wiki/NMOS_logic
https://en.wikipedia.org/wiki/PMOS_logic
https://en.wikipedia.org/wiki/Resistor%E2%80%93transistor_logic
https://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic
https://en.wikipedia.org/wiki/Very_Large_Scale_Integration
* Concepts
https://en.wikipedia.org/wiki/Virtual_memory
https://en.wikipedia.org/wiki/Instruction_pipelining
https://en.wikipedia.org/wiki/CPU_cache#CACHE-MISS
* Instruction Sets
** RISC
https://en.wikipedia.org/wiki/Reduced_instruction_set_computer
** RISC examples
https://en.wikipedia.org/wiki/MIPS_architecture
https://en.wikipedia.org/wiki/SPARC
https://en.wikipedia.org/wiki/DEC_Alpha
https://en.wikipedia.org/wiki/IBM_POWER_instruction_set_architecture https://en.wikipedia.org/wiki/PowerPC
https://en.wikipedia.org/wiki/ARM_architecture
** CISC
https://en.wikipedia.org/wiki/Complex_instruction_set_computer
** CISC examples
https://en.wikipedia.org/wiki/PDP-11
https://en.wikipedia.org/wiki/VAX
https://en.wikipedia.org/wiki/Zilog_Z80
https://en.wikipedia.org/wiki/Motorola_6800 https://en.wikipedia.org/wiki/Motorola_68000
https://en.wikipedia.org/wiki/X86 https://en.wikipedia.org/wiki/X86-64
* Instructions
https://en.wikipedia.org/wiki/Multiply%E2%80%93accumulate_operation
** x86 ASM
http://ref.x86asm.net/
** SSE
https://gist.github.com/detomon/fb9db687b154d67dbb50
** NEW: MMX/SSE/AVX
http://softpixel.com/~cwright/programming/simd/avx.php
https://software.intel.com/sites/landingpage/IntrinsicsGuide/
http://www.tommesani.com/index.php/simd/46-sse-arithmetic.html
https://docs.microsoft.com/en-us/cpp/intrinsics/compiler-intrinsics?view=vs-2017
https://en.wikipedia.org/wiki/X86_instruction_listings
https://en.wikibooks.org/wiki/X86_Assembly/AVX,_AVX2,_FMA3,_FMA4
https://db.in.tum.de/~finis/x86-intrin-cheatsheet-v2.1.pdf
https://en.wikipedia.org/wiki/SISD
https://en.wikipedia.org/wiki/SIMD
** https://en.wikipedia.org/wiki/MMX_(instruction_set)
** https://en.wikipedia.org/wiki/Streaming_SIMD_Extensions
** https://en.wikipedia.org/wiki/Advanced_Vector_Extensions
https://en.wikipedia.org/wiki/MIMD
* Processors
https://en.wikipedia.org/wiki/Central_processing_unit
https://en.wikipedia.org/wiki/Graphics_processing_unit
https://en.wikipedia.org/wiki/Scalar_processor
https://en.wikipedia.org/wiki/Superscalar_processor
https://en.wikipedia.org/wiki/Multi-core_processor
* Memory
https://en.wikipedia.org/wiki/Computer_memory
https://en.wikipedia.org/wiki/Memory_management_unit
https://en.wikipedia.org/wiki/Translation_lookaside_buffer
** Basics
https://en.wikipedia.org/wiki/Inverter_(logic_gate)
https://en.wikipedia.org/wiki/Flip-flop_(electronics) https://en.wikipedia.org/wiki/Flip-flop_(electronics)#Simple_set-reset_latches
https://en.wikipedia.org/wiki/Multiplexer
https://en.wikipedia.org/wiki/Memory_cell_(computing)
https://en.wikipedia.org/wiki/Bus_(computing)
** Volatility
https://en.wikipedia.org/wiki/Volatile_memory
https://en.wikipedia.org/wiki/Non-volatile_memory
** Types
https://en.wikipedia.org/wiki/Read-only_memory
https://en.wikipedia.org/wiki/Programmable_read-only_memory
https://en.wikipedia.org/wiki/EPROM
https://en.wikipedia.org/wiki/EEPROM
https://en.wikipedia.org/wiki/Random-access_memory
https://en.wikipedia.org/wiki/Dynamic_random-access_memory
https://en.wikipedia.org/wiki/Static_random-access_memory
https://en.wikipedia.org/wiki/Non-volatile_random-access_memory
https://en.wikipedia.org/wiki/Nano-RAM
https://en.wikipedia.org/wiki/Flash_memory
* Programming
https://docs.microsoft.com/en-us/cpp/cpp/alignof-and-alignas-cpp?view=vs-2017
https://stackoverflow.com/questions/11228855/header-files-for-x86-simd-intrinsics#11228864
** Intro
https://software.intel.com/en-us/articles/introduction-to-intel-advanced-vector-extensions/
** Examples
https://www.codeproject.com/articles/874396/crunching-numbers-with-avx-and-avx
https://thinkingandcomputing.com/posts/using-avx-instructions-in-matrix-multiplication.html
https://software.intel.com/en-us/articles/soa-cloth-simulation-with-256-bit-intel-advanced-vector-extensions-intel-avx
* MOOCs
https://www.youtube.com/user/cmu18447
https://www.youtube.com/results?search_query=Georgia+Tech+-+HPCA%3A+Part+1
https://www.youtube.com/watch?v=McLq1hEq3UY&list=PL3940DD956CDF0622
- (2657)How to create git aliases so that you can use shortcuts like in svn (git co, git ls, git cm)?
cat ~/.gitconfig
[alias]
st = status
cm = commit -m
cma = commit -a -m
br = branch
co = checkout
df = diff
ls = ls-files
sh = stash
sha = stash apply
shp = stash pop
shl = stash list
mg = merge
ph = push -u
- (2794)How to avoid repetitions in .gitlab-ci.yml file?
[ NOTE: Are you sure you cannot simply use parallelization? See Tip#2795]
You can use anchors.
YAML has a handy feature called ‘anchors’, which lets you easily duplicate content across your document. Anchors can be used to duplicate/inherit properties, and is a perfect example to be used with hidden keys to provide templates for your jobs.
The following example uses anchors and map merging. It will create two jobs, test1 and test2, that will inherit the parameters of .job_template, each having their own custom script defined:
----
.job_template: &job_definition # Hidden key that defines an anchor named 'job_definition'
image: ruby:2.6
services:
- postgres
- redis
test1:
<<: *job_definition # Merge the contents of the 'job_definition' alias
script:
- test1 project
test2:
<<: *job_definition # Merge the contents of the 'job_definition' alias
script:
- test2 project
----
& sets up the name of the anchor (job_definition), << means “merge the given hash into the current one”, and * includes the named anchor (job_definition again). The expanded version looks like this:
----
.job_template:
image: ruby:2.6
services:
- postgres
- redis
test1:
image: ruby:2.6
services:
- postgres
- redis
script:
- test1 project
test2:
image: ruby:2.6
services:
- postgres
- redis
script:
- test2 project
----
From: https://docs.gitlab.com/ee/ci/yaml/#anchors
https://stackoverflow.com/questions/54074433/gitlab-ci-specifying-stages-in-before-script/54077634#54077634
- (2795)How to parallelize tasks in GitLab's CI?
Simply set serveral jobs/scripts entries that depend on the same stage:
----
stages:
- first
- second
- third
script1:
stage: first
script:
- <commands>
script2.1:
stage: second
script:
- <commands>
script2.2:
stage: second
script:
- <commands>
script3:
stage: third
script:
- <commands>
---
Stages first, second, third will be run sequencially in this order, but:
Commands for script2.1 and script2.2 will be run in parallel (if the GitLab-runner supports it!) within stage second.
[ Strangely, this is not explained explicitely in any doc! ]
Found by myself
See Also
https://stackoverflow.com/questions/53293232/gitlab-dynamically-run-jobs-in-parallel/53298161#53298161
https://about.gitlab.com/blog/2016/07/29/the-basics-of-gitlab-ci/
- (2797)How to change visibility of a forked GitLab project (a.k.a. How to remove the fork link between two GitLab projects)?
Allowing users to change the visibility of a forked project (from private to public) would be a bad practice from a security point of view. Thus it is (silently :[) prohibited by GitLab.
You can do it only if you first "remove the link" between the two projects.
Think twice between doing so, has it will create 2 totally independent projects.
If this is really what you want, then:
- "General settings" page of your project
- "Advanced settings"
- "Remove fork relationship"
Then you'll be able to change the visibility.
From: https://gitlab.com/gitlab-org/gitlab-foss/issues/40088#note_47021192
- (2806)How do I undo 'git add' before I have "commit"ted the change?
You can undo git add before a commit with:
git reset <file>
which will remove it from the current index (the "about to be committed" list) without changing anything else.
From: https://stackoverflow.com/questions/348170/how-do-i-undo-git-add-before-commit/348234#348234
- (2816)How to fork a repository manually (set source as upstream origin) rather than with the "fork" button of GitLab/GitHub (e.g. when you want to fork a project twice)?
- Clone the original project/repo locally
$ git clone <original repo url>
- List curent remotes
$ git remote -v
origin <original repo url> (fetch)
origin <original repo url> (push)
- Create a new empty (remote) repo (e.g. @GitLab or @GitHub)
- Rename origin to upstream and add our new empty (remote) repo as the origin.
$ git remote rename origin upstream
$ git remote add origin <your new empty repo url>
$ git remote -v
origin <your new empty repo url> (fetch)
origin <your new empty repo url> (push)
upstream <original repo url> (fetch)
upstream <original repo url> (push)
- Push from your local repo to your new remote one.
$ git push -u origin master
NOTE: With this method GitLab's web interface does not show the two projects as forked :[
From: https://gist.github.com/benschw/7268134
https://web.archive.org/web/20160321104828/https://adrianshort.org/create-multiple-forks-of-a-github-repo/
- (2819)How to get a diff between file in local repo and remote repo (origin) in Git?
If [remote-path] and [local-path] are the same, you can do
$ git fetch origin master
$ git diff origin/master -- [local-path]
Note 1: The second command above will compare against the locally stored remote tracking branch. The fetch command is required to update the remote tracking branch to be in sync with the contents of the remote server. Alternatively, you can just do:
$ git diff master:<path-or-file-name>
Note 2: master can be replaced in the above examples with any branch name
Also See Tip#3542
From: https://stackoverflow.com/questions/21101572/git-diff-between-file-in-local-repo-and-origin/21101689#21101689
- (2820)How can I ignore files that have already been committed to the repo in git?
- Preparing the Cleanup
Before cleaning up your repository, you should conduct two important preparations:
- Make sure your .gitignore file is up-to-date and contains all the correct patterns you want to ignore.
- Commit or stash any outstanding local changes you might have. Your working copy should be clean before you continue.
- In three steps, you can clean up your repository and make sure your ignored items are indeed ignored:
$ git rm -r --cached .
$ git add .
$ git commit -m "Clean up ignored files"
From: https://www.git-tower.com/learn/git/faq/ignore-tracked-files-in-git
- (2872)How to make git work behind a proxy?
Apparently git does not use $http_proxy :[
You have to use:
git config --global http.proxy http://proxyuser:proxypwd@proxy.server.com:8080
To remove it:
git config --global --unset http.proxy
To check the current value:
git config --global --get http.proxy
From: https://stackoverflow.com/questions/783811/getting-git-to-work-with-a-proxy-server-fails-with-request-timed-out/19213999#19213999
- (2912)How to solve Git error on commit after merge "fatal: cannot do a partial commit during a merge"?
PROBLEM:
This occurred to me as I did a commit and got an error because repo was not up-to-date, thus had to do a pull, which resulted in conflicts & merges. I got the error when I tried to finish the commit (==to do it again).
SOLUTION:
Add "-i" to the commit command
-i basically tells it to stage additional files before committing. That is:
git commit -i myfile.php
From: https://stackoverflow.com/questions/5827944/git-error-on-commit-after-merge-fatal-cannot-do-a-partial-commit-during-a-mer/8062976#8062976
- (2919)How to switch to 2-page view in FF's internal PDF viewer (PDF.js)?
Edit the page and add these CSS lines to "viewer.html":
<style>
#viewer {
margin-left:20px;
}
div.page {
float:left;
}
</style>
Set zoom at around 75% (= two page view on my 1440x900 screen)
From: https://github.com/mozilla/pdf.js/issues/590#issuecomment-369433523
- (2983)How to transfer git repositories between GitLab & GitHub?
You can transfer those by simply by adding a remote to a (target) GitHub/GitLab repo and by pushing them
- create an empty repo on GitHub/GitLab (your target)
- git remote add git{hub,lab} https://yourLogin@git{hub,lab}.com/yourLogin/yourRepoName.git
- git push --mirror git{hub,lab}
The history will be the same. But you will loose the access control (teams defined in GitLab/GitHub with specific access rights on your repo)
From: https://stackoverflow.com/questions/22265837/transfer-git-repositories-from-gitlab-to-github-can-we-how-to-and-pitfalls-i/22266000#22266000
- (3040)How to manage several Github accounts (a.k.a. How to solve "Permission to personalUserName/repoName.git denied to globalUserName")?
You need to add your "personalUserName" key in the SSH agent:
ssh-add ~/.ssh/your-ssh-key
You can also do it permanently in the ~/.ssh/config file:
94 Host *
95 UseKeychain yes
96 AddKeysToAgent yes <------ Here
97 IdentityFile ~/.ssh/someFile.pem
98
99 Host github-newkeyname
100 Hostname github.com
101 User git
102 IdentityFile ~/.ssh/id_rsa_newkeyname
103 IdentitiesOnly yes
From: https://stackoverflow.com/questions/49335136/github-multiple-accounts-permission-to-personalusername-reponame-git-denied-to
- (3049)How to clone/checkout/get only a single dir from a Git repository?
mkdir <localcopy>
cd !:1
git init
git remote add -f origin "$rurl"
git sparse-checkout init
# same as: git config core.sparseCheckout true
git sparse-checkout set "path/to/get"
# same as: echo "A/B" >> .git/info/sparse-checkout
git sparse-checkout list
# same as: cat .git/info/sparse-checkout
git pull origin master
From: https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository/13738951#13738951
- (3104)How to make git follow symlink?
PROBLEM: All programs, including git will treat the file as a regular file and push it as-is into the repo.
SOLUTION1: Use hard links instead (ln without -s)
SOLUTION2: If it is a directory, bind mount / bwrap the directory
Also see Tip#3103
From: https://stackoverflow.com/questions/86402/how-can-i-get-git-to-follow-symlinks/63645471#63645471
- (3136)How to use Microsoft Word with git? [NOTE: storing blobs into git is a BAD idea!]
To enable Git to track changes in Word files, create hooks that translated Word to text
# .gitattributes file in root folder of your git project
*.docx diff=pandoc
# .gitconfig file in your home folder
[diff "pandoc"]
textconv=pandoc --to=markdown
prompt = false
[alias]
wdiff = diff --word-diff=color --unified=1
To see the changes, you can then use:
git wdiff important_file.docx
or
git log -p --word-diff=color important_file.docx # all changes
PS: I insist, storing blobs into git is a BAD idea!
From: https://blog.martinfenner.org/2014/08/25/using-microsoft-word-with-git/
- (3218)How to pull/push from multiple remote locations in Git?
git remote set-url origin [--push] --add <a remote>
git remote set-url origin [--push] --add <another remote>
git remote -v
- To fetch from all the configured remotes and update tracking branches, but not merge into HEAD, do:
git remote update
- To fetch the master branch from alt and pull it into your current head, do:
git pull alt master
- You can also define aliases
alias pushall='for i in `git remote`; do echo "Pushing to " $i; git push $i; done;'
alias pullall='for i in `git remote`; do echo "Pulling from " $i; git pull $i; done;'
From: https://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations#3195446
- (3243)What does rebase mean in git?
See very clear article:
https://www.miximum.fr/blog/git-rebase/
- (3276)How to move an existing GitLab project into a new subgroup?
Turns out the "slug" for a project... the part of the URL after the GitLab server domain name is made up of the "namespace" and the project name. The name space is the group/subgroup path, so I was looking to transfer project to new namespace.
So for example if the group is "important-group" and project is called "project". Then the slug will be something like /important-group/project. To then move that to /important-group/sub-group/project, we need to create the new subgroup (down arrow next to the "New project" button). Then change the project namespace.
To do this, go to the project page, click the settings button (cog bottom left). Go to the Advanced settings section. And it's just below the rename project option.
Just select the new subgroup and your done!
Here is the GitLab docs link (https://docs.gitlab.com/ee/user/project/settings/#transferring-an-existing-project-into-another-namespace) with more info on managing projects in GitLab, in case that is useful to anyone.
From: https://stackoverflow.com/questions/52778548/moving-an-existing-gitlab-project-into-a-new-subgroup/52778918#52778918
- (3277)How to configure GitLab a GitLab repository?
PROBLEM: Breaking Master branch breaks the whole project => NEVER commit to Master, Use Pull Requests
- To prevent commit to Master branch and force usage of Merge Requests:
Project settings > General
- Merge Checks
- All discussions must be resolved
Project settings > Members
- Differentiate roles Dev::commit / Maintainer::ManageMergeRequest
Project settings > Repository
- Protected Branches: Master::only Maintainers can merge on this branch
- Nobody can push to the Master branch
- To better track issues status (Kaban)
Issues > Labels
- Generate GitLab Defaults
- Add "Need Review"
Issues > Board
- Make "Need Review" appear in the board
From: https://www.youtube.com/watch?v=qcHdS7dXwL8
- (3344)How to extract a single file from a git repository?
SOLUTION1: If you just want to display the content to stdout
git show object
git show $REV:$FILE
git show somebranch:from/the/root/myfile
git show HEAD^^^:path/myfile
SOLUTION2: If you want to overwrite you current repos' version of the fiel with the
git checkout {branch,revision} -- <file>
git restore -s {<sha1>,<branch>} -- <file> #Git 2.23+
From: https://stackoverflow.com/questions/610208/how-to-retrieve-a-single-file-from-a-specific-revision-in-git#610315
- (3347)How to create a new Project (repo) on GitLab without connecting to the Web/GUI interface?
1. Create you local copy
mkdir myrepo && cd myrepo
git init .
2. Put some data
touch toto
git add toto
git commit -m "Initial commit" toto
3. Set remote
git remote add <url> # e.g. git@server:user-name/nonexistent-project-name
4. Push data to the remote with "--set-upstream" option
git push --set-upstream git@server:user-name/nonexistent-project-name.git master
From: https://stackoverflow.com/questions/33101962/how-to-create-a-new-gitlab-repo-from-my-existing-local-git-repo-using-cli
https://docs.gitlab.com/ee/user/project/working_with_projects.html#push-to-create-a-new-project
- (3351)What are the options & differences between the commands to add a remote origin to Git repository?
# 1. git remote add origin git@server/x/y.git
"git remote add" is for *adding a new remote* it *creates the entry*, not simply associates a URL to it.
# 2. git remote set-url origin git@server/x/y.git
"git remote set-url" is for (mainly) *changing* the URL associated with some *existing* remote (entry).
# 3. git config --local remote.origin.url git@server/x/y.git
The "git config" command is a much lower level thing. Most of the settings you can make or change in Git are ultimately done through configuration entries, and this includes adding or deleting remotes and changing the URLs associated with any one particular remote. What this means is that the higher level "git remote" command often *translates into one or more* low-level "git config" operations.
From: https://stackoverflow.com/questions/43435092/what-is-the-difference-between-git-remote-add-origin-set-url-origin-and-co
- (3352)How to solve Git error "There is no tracking information for the current branch"?
PROBLEM: the local branch is not set up to follow a remote (@git server) branch
You could specify what branch you want to pull:
git pull origin master
Or you could set it up so that your local master branch tracks github master branch as an upstream:
git branch --set-upstream-to=origin/master master
git pull
This branch tracking is set up for you automatically when you clone a repository (for the default branch only), but if you add a remote to an existing repository you have to set up the tracking yourself. Thankfully, the advice given by git makes that pretty easy to remember how to do.
From: https://stackoverflow.com/questions/32056324/there-is-no-tracking-information-for-the-current-branch#32056416
- (3355)How to generate a default .gitignore for typical environments (Prog Language, IDE, etc.)?
https://www.toptal.com/developers/gitignore
- (3419)What is a bare git repository?
- Repositories created with the git init command are called working directories.
In the top level folder of the repository you will find two things:
+ A .git subfolder with all the git related revision history of your repo
+ A working tree, or checked out copies of your project files.
- Repositories created with git init --bare are called bare repos.
They are structured a bit differently from working directories.
+ First off, they contain no working or checked out copy of your source files.
+ Second, bare repos store git revision history of your repo in the root folder of your repository instead of in a .git subfolder. Note&hellip; bare repositories are customarily given a .git extension.
From: https://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/
- (3540)How to Copy file or folder from one branch to another in Git?
Sometimes we may want to copy just one or two files from dev branch without merging the whole branch with master branch.
Below commands will do the same for us (assuming you are in another branch than dev):
- Copy One or two files from one branch to other.
git checkout dev -- path/to/your/file.
- Copy folder from one branch to other.
git checkout dev -- path/to/your/folder
- Copy files and folder from commit hash of another branch.
git checkout <commit_hash> <relative_path_to_file_or_dir>
From: https://www.tutsway.com/how-to-copy-file-or-folder-from-one-branch-to-another-in-git.php
- (3541)How to list all files in a branch in Git?
git ls-tree -r --name-only <commit> (where instead of <commit> there can be <branch>).
You might want to use also -t option which lists subdirectories before descending into them
From: https://stackoverflow.com/questions/1910783/git-1-list-all-files-in-a-branch-2-compare-files-from-different-branch
- (3542)How to compare files from different branch in Git?
git diff <branchA>:<fileA> <branchB>:<fileB>
Or if you want to compare the same file:
git diff <branchA> <branchB> -- <file>
Also See Tip#2819
From: https://stackoverflow.com/questions/1910783/git-1-list-all-files-in-a-branch-2-compare-files-from-different-branch
- (3549)What are the different Git commands doing?
See the graphical explanations here:
https://www.tutorialdocs.com/upload/2018/10/git-basic-command.png
https://miro.medium.com/max/1400/1*tjrF1ff5UjVNclwwe_GREg.png
https://miro.medium.com/max/1400/1*gZX2Cs-To3k1h63hHhPPcw.png
http://csharp-guide.blogspot.com/2014/11/git-architecture.html
https://miro.medium.com/max/700/1*ZG8OzO2oTPi6cwm_e1h7rw.png
- (3560)How to Undo git add?
git restore --staged index.html
If you also want to discard any local changes in this file, you can simply omit the --staged flag:
git restore index.html # WARNING: undoing uncommitted local changes *cannot be undone*!
- (3592)How to rename a local/remote branch in Git?
git branch -m old-name new-name
git push origin --delete old-name
git push origin -u new-name
BEWARE that you in fact create a new branch, thus you need to (re)set the current branch & upstream correctly on all your other machines!
From: https://www.hostinger.com/tutorials/how-to-rename-a-git-branch/
- (3615)How to store Git credentials?
git config credential.helper 'store [<options>]'
Credentials will be stored in PLAIN-TEXT (!!!) in the file:
~/.git-credentials
To improve security, you can put this file in your (encrypted) ~/Private/ dir and create a link to it in $HOME.
From: https://git-scm.com/docs/git-credential-store
- (3617)How to get Git (blame) statistics on commits (a.k.a. How to count how many line each contributor as made in the repo)?
1. INSTALL git-extras
apt install git-extras
2. USE git-summary
git summary --line
Gives output that looks like this:
project : TestProject
lines : 13397
authors :
8927 John Doe 66.6%
4447 Jane Smith 33.2%
23 Not Committed Yet 0.2%
From: https://stackoverflow.com/questions/4589731/git-blame-commit-statistics/39571384#39571384
- (3644)How to make Git use rebase instead of pull by default and automatically Stash local modifications to prevent loosing them?
git config --global pull.rebase true
git config --global rebase.autoStash true
BEWARE: As you do a rebase instead of a pull, you'll have to do the merge step manually (See Tip#3549) . If there are conflicts during this merge step, you might forgot to reapply the stashed modifications, then drop the stash and loose some work :{
From: https://leosiddle.com/posts/2020/07/git-config-pull-rebase-autostash/
- (3654)How to see the branches graph in GitHub?
Insights > Network
From: https://stackoverflow.com/questions/27469952/visualize-branches-on-github/27469979#27469979
- (3666)How to clean all unused branches in Git?
The following script will remove *all branches* apart from the master, the HEAD and those listed as command line args.
#!/bin/sh
function git_branch_delete_all_but() {
branch_names_to_keep=("$@")
branch_names_to_keep+=("master") # do no delete master
branch_names_to_keep+=("main") # do no delete main
branch_names_to_keep+=$(git symbolic-ref --short -q HEAD) # do not delete current branch
branch_names_to_delete=()
for branch_name in $(git for-each-ref --format='%(refname:short)' refs/heads/); do
if [[ ! " ${branch_names_to_keep[*]} " =~ " ${branch_name} " ]]; then
branch_names_to_delete+=$branch_name
fi
done
for branchName in "${branch_names_to_delete[@]}"
do
git branch -D $branchName
done
}
From: https://dev.to/radlinskii/shell-command-for-cleaning-up-git-repositories-from-unused-branches-pj6
- (3688)How to solve conflict "both deleted" in Git?
You can see a "both deleted" when branchA has a git mv oldfile newstandard commit, and branchB has a git mv oldfile newcustom commit.
In that case, when trying to merge customBranch into standardBranch, git will report a conflict on three files:
both deleted: oldfile
added by them: newcustom
added by us: newstandard
Like any conflict, the final choice resides in your hands:
git merely highlight the fact that maybe there could be a problem in the fact that newcustom and newstandard live together in your final code version, and maybe this could be linked to the fact that both were created by being a copy of oldfile.
You get to manually fix that:
- if removing oldfile is the expected outcome:
git reset -- oldfile,
- if keeping newstandard is the expected outcome, remove the other:
git reset newcustom && git rm newcustom,
- if some parts of newstandard and newcustom should be merged:
edit them by hand, or use a 3-way merge tool: meld newstandard newstandard newcustom
From: https://stackoverflow.com/a/44885129
- (3692)How to write better commit messages?
- Specify the Type of Commit. Example: Feature, Bugfix, Update, Refactor, Docs, Style, Test, Performance, CI...
- Answer the following questions:
+ Why have I made these changes?
+ What effect have my changes made?
+ Why was the change needed?
+ What are the changes in reference to?
For more detailed commit structure, search for "Conventional Commit".
From: https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/
- (3736)How to View the Contents of a Git Stash?
git stash show -p # for the latest stash
git stash list
git stash show -p <id> # for any other stash
From: https://www.designcise.com/web/tutorial/how-to-view-the-contents-of-a-git-stash
- (3883)How to get a single directory from a repository in Git?
Having only part of a working tree locally is not possible.
If you only want to grab the files, without having a working tree:
git archive --format=tgz --remote=<url-to-repo> master -- myfolder | tar zxvf -
From: https://stackoverflow.com/questions/18323534/git-fetch-only-one-directory/18392680#18392680
- (3955)How to resolve a Git conflict with binary files?
git checkout accepts an --ours or --theirs option for cases like this. So if you have a merge conflict, and you know you just want the file from the branch you are merging in, you can do:
$ git checkout --theirs -- path/to/conflicted-file.txt
to use that version of the file. Likewise, if you know you want your version (not the one being merged in) you can use
$ git checkout --ours -- path/to/conflicted-file.txt
From: https://stackoverflow.com/questions/278081/resolving-a-git-conflict-with-binary-files/2163926#2163926
- (3975)How to use Git behind a (socks) proxy?
git config --global http.proxy 'socks5://127.0.0.1:7070' # You need the 'global' setting if you are not already in a git project dir (e.g. when cloning)
git config --global --unset http.proxy
From: https://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport/16756248#16756248
- (4006)How to tell Git which private key to use?
From Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND like this:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example" git clone example
Note that -i can sometimes be overridden by your config file, in which case, you should give SSH an empty config file, like this:
GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_example -F /dev/null" git clone git@github.com:example/example.git
From: https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use/912281#912281
- (4010)How to solve "404" error when accessing a GitLab Pages site URL?
This problem most likely results from a missing index.html file in the public directory. If after deploying a Pages site a 404 is encountered, confirm that the public directory contains an index.html file. If the file contains a different name such as test.html, the Pages site can still be accessed, but the full path would be needed. For example: https//group-name.pages.example.com/project-name/test.html.
A 404 can also be related to incorrect permissions. If Pages Access Control is enabled, and a user navigates to the Pages URL and receives a 404 response, it is possible that the user does not have permission to view the site. To fix this, verify that the user is a member of the project.
From: https://repository.prace-ri.eu/git/help/user/project/pages/introduction.md#user-content-404-error-when-accessing-a-gitlab-pages-site-url
- (4016)How to move a personal project to a group in GitLab?
Before you move your project to a group:
- You must have the Owner role for the project.
- Remove any container images
- Remove any npm packages. If you transfer a project to a different root namespace, the project must not contain any npm packages. When you update the path of a user or group, or transfer a subgroup or project, you must remove any npm packages first. You cannot update the root namespace of a project with npm packages. Make sure you update your .npmrc files to follow the naming convention and run npm publish if necessary.
Now you’re ready to move your project:
- On the left sidebar, at the top, select Search GitLab () to find your project.
- Select Settings > General.
- Expand Advanced.
- Under Transfer project, choose the group to transfer the project to.
- Select Transfer project.
- Enter the project’s name and select Confirm.
You are redirected to the project’s new page. If you have more than one personal project, you can repeat these steps for each project.
From: https://docs.gitlab.com/ee/tutorials/move_personal_project_to_group/index.html
- (4063)How to enable Copilot in GitHub?
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the "Code, planning, and automation" section of the sidebar, click
- On the GitHub Copilot settings page, click Enable GitHub Copilot.
- Choose whether you want to pay monthly or yearly, and click Continue to get access to Copilot.
- If your personal account meets the criteria for a free GitHub Copilot subscription instead of a trial or paid subscription, you will automatically be taken to step 6.
- Follow the steps to confirm your payment details, then click Submit.
- Select your preferences, then click Save and get started.
- You can change these preferences at a later time by returning to your GitHub Copilot settings. For more information, see "Configuring GitHub Copilot in your environment."
Note: As a member of an organization owned by a GitHub Enterprise Cloud account with a GitHub Copilot subscription, you must be assigned a GitHub Copilot seat by your organization before you can use GitHub Copilot.
From: https://docs.github.com/en/copilot/quickstart#signing-up-for-github-copilot-for-your-personal-account
- (4068)How to increase the depth of a "git clone" after cloning?
PROBLEM: Sometimes, to limit the amount of information downloaded, one use "git clone --depth=1".
SOLUTION: To increase the depth of the local copy of the repo afterward, use:
git fetch --unshallow # To convert to a full clone
or
git fetch --deepen 20 # To increase to a specific number
See Tip#4069 for the converse operation.
From: https://stackoverflow.com/questions/58756229/git-clone-increase-depth-after-cloning/58756277#58756277
- (4069)How to reduce the depth of an existing Git repo?
$ git clone https://github.com/elixir-lang/elixir.git
$ cd elixir
$ git log --oneline | wc -l
15670 # 15670 entries!
$ git pull --depth=1
# ...pulling the shallow repo
$ git log --oneline | wc -l
1 # 15670 to 1... woah!
$ git log
# ...output from just one commit
See Tip#4068 for the converse operation.
From: https://til.hashrocket.com/posts/kmhi4k1ct2-reduce-depth-of-an-existing-git-repo-
- (4072)How/Why use "git worktree" instead of "git stash"?
You are in the middle of a refactoring session and your boss comes in and demands that you fix something immediately. You might typically use git-stash to store your changes away temporarily, however, your working tree is in such a state of disarray (with new, moved, and removed files, and other bits and pieces strewn around) that you don’t want to risk disturbing any of it. Instead, you create a temporary linked worktree to make the emergency fix, remove it when done, and then resume your earlier refactoring session.
$ git worktree add -b emergency-fix ../temp master
$ pushd ../temp
# ... hack hack hack ...
$ git commit -a -m 'emergency fix for boss'
$ popd
$ git worktree remove ../temp
From: https://dev.to/programmingdecoded/why-use-git-worktree-5gj0
https://git-scm.com/docs/git-worktree
- (12)How to control the mouse with the numpad (thanks to gwen)
On peut très facilement contrôler le curseur avec les chiffres du pavé numérique.
Pour cela il suffit de presser shift+verr-num.
Le curseur se dirige avec les chiffres.
----
How to enable mouse moves with numpad in Xorg >2011?
setxkbmap -option keypad:pointerkeys
Then you can toogle this special mode with Shift+Num_Lock.
When the mode is on, you can control the mouse with the numpad :)
From: https://bbs.archlinux.org/viewtopic.php?pid=904880
On choisit le bouton avec / (gauche),* (m), -(droite).
5 pour un simple clic,
5 5 pour un double
0, mouvement, 5 pour un drag&drop.
http://linuxfr.org/tips/78.html
- (137)Change the level of the backlight
Get the possibilities and IDs of the screen
$ xrandr --prop
$ xrandr --output LVDS --set BACKLIGHT_CONTROL {combination, native, legacy,kernel}
$ xrandr --output LVDS --set BACKLIGHT 1001
$ xbacklight -get
$ xgamma
- (138)Configure compose key to manage all types of accents
Simply add "keycode <unused key: ex win-popup=115> = Multi_key" in ~/.Xmodmap
- (136)Set up the colors
use xgamma -rgamma [.1 1.0] -ggamma [.1 1.0] -bgamma [.1 1.0]
- (161)Sometimes the window manager does not start
The full path of the window manager must appear in the .xinitrc
- (178)How to allow Xnest to open the display in order to receive windows
Xnest -ac :1
-ac to remove access control
- (182)Reload the Xresources file
xrdb -merge ~/. Xresources
- (277)Dynamically change resolution / frate / ...
1. Compute MODE
cvt 1280 1280 60
=># 1280x1280 59.96 Hz (CVT) hsync: 79.57 kHz; pclk: 137.50 MHz
=>Modeline "1280x1280_60.00" 137.50 1280 1368 1504 1728 1280 1283 1293 1327 -hsync +vsync
2. Create MODE and add MODE to output (copy end of 2nd line: see [])
xrandr --output LVDS --newmode ["1280x1280_60.00" 137.50 1280 1368 1504 1728 1280 1283 1293 1327 -hsync +vsync]
xrandr --addmode LVDS "1280x1280_60.00"
3. Use MODE
xrandr --output LVDS --mode "1280x1280_60.00"
- (288)In AwesomeWM, if a program, for instance ThB or Evolution, does not tile (and shows a butterfly)
Then it may be a problem of floating or maximization => bind a key to float/maximize in awesome config file
- (291)When audacious appears on all desks of the WM
It might be a problem of the WM (sticky windows, floating, maximized) or a problem in audacious
=> try to rename/remove .config/audacious
- (353)Change the keys for moving windows insde the same screen in AwesomeWM
awful.button({ modkey, "Control" }, 1, awful.mouse.client.move)
- (357)How to start .xsession in AwesomeWM (a.k.a. how to define startup applications without any Desktop Manager while using a Session Manager)
Add the two following lines:
-- Load script that launches startup applications
os.execute("source ~/.xsession");
to your ~/.config/awesome/rc.lua file
- (361)How to circumvent a bug in GDM (2.32) where it cannot stop from beeping at boot even if sound if shutdown in gdmsetup & gnome-volume-control?
From: https://bugzilla.redhat.com/show_bug.cgi?id=503360
1. Use gconf-editor to disable
apps/gdm/simple-greeter/setting-manager-plugins/sound
2. # rm -rf /var/lib/gdm/.gconf/
3. # cp -r /root/.gconf /var/lib/gdm/.
4. # chown -R gdm:gdm /var/lib/gdm/.gconf
5. # gnome-volume-control
6. Set 'Sound Theme' to 'No sounds'
7. Close gnome-volume-control
8. Re-logon
9. Enjoy reclaimed silence :)
--------------------------------------------------
try to blacklist pcspkr module, just add to your /etc/modprobe.d/blacklist the
following line:
blacklist pcspkr
--------------------------------------------------
/usr/bin/gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
-t bool -s /desktop/gnome/sound/event_sounds false
--------------------------------------------------
gconftool-2 --type=bool --set /desktop/gnome/sound/event_sounds false
gconftool-2 --type=bool --set /apps/gnome_settings_daemon/plugins/sound/active false
gconftool-2 --type=bool --set /apps/gdm/simple-greeter/settings-manager-plugins/sound/active false
----
Add to .gtkrc-2.0
gtk-enable-event-sounds=0
gtk-enable-input-feedback-sounds=0
gtk-error-bell=0
- (365)My AwesomeWM (v3.4.9) config file (for 2 screens display)
(
CTL-ALT-arrows switches current screen's vdesktop
CTL-ALT-Q quits
CTL-ALT-a maximizes
CTL-ALT-i minimizes
CTL-ALT-f toogles floating
CTL-ALT-mousemove moves window
CTL-ALT-k kills
CTL-ALT-Tab activate next window
CTL-ALT-KP_8/2 resises active window
CTL-ALT-r restarts awesome (reload config file)
CTL-ALT(-SHIFT)space selects next/previous tiling algo/style
CTL-ALT-h/l toogles secondary tiling algo/style
CTL-ALT-mouse1 moves active window to selected workspace
CTL-ALT-mouse3 resises active window
)
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- Load Debian menu entries
require("debian.menu")
-- GM: Load script that launches startup applications
os.execute("source ~/.xsession");
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
beautiful.init("~/.config/awesome/theme.lua")
-- This is used later as the default terminal and editor to run.
terminal = "uxterm"
editor = os.getenv("EDITOR") or "editor"
editor_cmd = terminal .. " -e " .. editor
xlockcmd = " xscreensaver-command -lock"
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod1"
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier,
awful.layout.suit.floating
}
-- }}}
-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag({ "Chat-" .. s, "W1-" .. s, "W2-" .. s, "W3-" .. s, "Mail-" .. s, "Web-" .. s, "Mumule-" .. s }, s, layouts[1])
end
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "Debian", debian.menu.Debian_menu.Debian },
{ "Terminal", terminal },
{ "XChat", "xchat" },
{ "Midori", "midori" },
{ "Firefox", "firefox" },
{ "Thunderbird", "thunderbird" },
{ "Evolution", "evolution" },
{ "Audacious", "audacious2" },
{ "Nautilus", "nautilus" },
{ "Xlock", xlockcmd }
}
})
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
menu = mymainmenu })
-- }}}
-- {{{ Wibox
-- Create a textclock widget
mytextclock = awful.widget.textclock({ align = "right" })
xchatbox = widget({ type="imagebox", name="icon", align=align })
xchatbox.image = image("/usr/local/lib/xemacs/xemacs-packages/etc/xwem/mini-xchat.xpm")
xchatbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("xchat") end)))
midoribox = widget({ type="imagebox", name="icon", align=align })
midoribox.image = image("/usr/share/icons/gnome-colors-common/24x24/apps/midori.png")
midoribox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("midori") end)))
firefoxbox = widget({ type="imagebox", name="icon", align=align })
firefoxbox.image = image("/usr/lib/xulrunner-1.9.2.17/chrome/icons/default/default32.png")
firefoxbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("firefox") end)))
thunderbirdbox = widget({ type="imagebox", name="icon", align=align })
thunderbirdbox.image = image("/usr/share/icons/Mint-X/apps/24/mozilla-thunderbird.png")
thunderbirdbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("thunderbird") end)))
evolutionbox = widget({ type="imagebox", name="icon", align=align })
evolutionbox.image = image("/usr/share/icons/hicolor/24x24/apps/evolution.png")
evolutionbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("evolution") end)))
audaciousbox = widget({ type="imagebox", name="icon", align=align })
audaciousbox.image = image("/usr/share/icons/Mint-X/apps/24/audacious.png")
audaciousbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("audacious2") end)))
nautilusbox = widget({ type="imagebox", name="icon", align=align })
nautilusbox.image = image("/usr/share/icons/Mint-X/apps/24/nautilus.png")
nautilusbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("nautilus") end)))
xlockbox = widget({ type="imagebox", name="icon", align=align })
xlockbox.image = image("/usr/local/lib/xemacs/xemacs-packages/etc/gnus/lock.xpm")
xlockbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(xlockcmd) end)))
-- Create a systray
mysystray = widget({ type = "systray" })
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey, "Control" }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
)
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
client.focus = c
c:raise()
end),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ width=250 })
end
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end))
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(function(c)
return awful.widget.tasklist.label.currenttags(c, s)
end, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Add widgets to the wibox - order matters
mywibox[s].widgets = {
{
mylauncher,
mytaglist[s],
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s],
mytextclock,
xlockbox,
nautilusbox,
audaciousbox,
evolutionbox,
thunderbirdbox,
firefoxbox,
midoribox,
xchatbox,
s == 1 and mysystray or nil,
mytasklist[s],
layout = awful.widget.layout.horizontal.rightleft
}
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "Left", awful.tag.viewprev ),
awful.key({ modkey, "Control" }, "Right", awful.tag.viewnext ),
awful.key({ modkey, "Control" }, "Escape", awful.tag.history.restore),
awful.key({ modkey, "Control" }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end),
-- awful.key({ modkey, }, "k",
-- function ()
-- awful.client.focus.byidx(-1)
-- if client.focus then client.focus:raise() end
-- end),
-- awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
-- Layout manipulation
-- awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
-- awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
-- awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
-- awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
-- awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
awful.key({ modkey, "Control" }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
-- Standard program
awful.key({ modkey, "Control" }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Control" }, "q", awesome.quit),
awful.key({ modkey, "Control" }, "KP_8", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, "Control" }, "KP_2", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
awful.key({ modkey, "Control" }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Control", "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Prompt
awful.key({ modkey, "Control" }, "x", function () mypromptbox[mouse.screen]:run() end)
--,
-- awful.key({ modkey }, "x",
-- function ()
-- awful.prompt.run({ prompt = "Run Lua code: " },
-- mypromptbox[mouse.screen].widget,
-- awful.util.eval, nil,
-- awful.util.getdir("cache") .. "/history_eval")
-- end)
)
clientkeys = awful.util.table.join(
-- awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
awful.key({ modkey, "Control" }, "k", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "f", awful.client.floating.toggle ),
awful.key({ modkey, "Shift" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, "Control" }, "i", function (c) c.minimized = not c.minimized end),
awful.key({ modkey, "Control" }, "a",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey, "Control" }, 1, awful.mouse.client.move),
awful.button({ modkey, "Control" }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
-- {{{ Rules
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = true,
keys = clientkeys,
buttons = clientbuttons } },
-- GM
{ rule = { class = "Audacious" },
properties = { tag = tags[1][4] } }, -- W3-1 --, switchtotag = true
{ rule = { class = "Navigateur" }, -- "Navigator"
properties = { tag = tags[2][6], maximized_horizontal = true, maximized_vertical = true } }, -- Web-2 --switchtotag = true,
{ rule = { class = "Firefox" }, -- "Navigator"
properties = { tag = tags[2][6], maximized_horizontal = true, maximized_vertical = true } }, -- Web-2 --switchtotag = true,
{ rule = { class = "gimp" },
properties = { floating = true } },
{ rule = { class = "LibreOffice" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
{ rule = { class = "Midori" },
properties = { tag = tags[2][6], maximized_horizontal = true, maximized_vertical = true } }, -- Web-2 --- switchtotag = true,
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "Mail" }, -- "Mail"
properties = { tag = tags[2][5] } }, -- Mail-2 --, switchtotag = true
{ rule = { class = "Thunderbird" }, -- "Mail"
properties = { tag = tags[2][5] } }, -- Mail-2 --, switchtotag = true
{ rule = { class = "Wine" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
{ rule = { class = "Xchat" },
properties = { tag = tags[1][1] } }, -- Chat-1 --, switchtotag = true
{ rule = { class = "Xpdf" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
-- Set Firefox to always map on tags number 2 of screen 1.
-- { rule = { class = "Firefox" },
-- properties = { tag = tags[1][2] } },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.add_signal("manage", function (c, startup)
-- Add a titlebar
-- awful.titlebar.add(c, { modkey = modkey })
-- Enable sloppy focus
c:add_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
end)
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
- (370)How to run a .xsession at AwesomeWM's startup?
The one that works (combinaison of the 2 that follow)
os.execute("source ~/.xsession");
----------------------------------------------------------------------
>> If you start awesome from the command line, you can run programs
>> by putting them in your ~/.xinitrc file:
>>
>> xscreensaver -nosplash &
>>
>> (the "&" makes execution of the xinitrc file continue)
>>
>> If you run awesome from a graphical login (xdm/gdm/kdm),
>> you can use ~/.xsession in a similar manner.
----------------------------------------------------------------------
From: https://wiki.archlinux.org/index.php/Awesome3
Autorun programs
See also the Autostart page on the Awesome wiki105.
awesome doesn't run programs set to autostart by the Freedesktop specification like GNOME or KDE. However, awesome does provide a few functions for starting programs (in addition to the Lua standard library function os.execute). To run the same programs on startup as GNOME or KDE, you can install dex106 from the AUR107 and then run that in your rc.lua:
os.execute"dex -a"
If you just want to set up a list of apps for awesome to launch at startup, you can create a table of all the commands you want to spawn and loop through it:
do
local cmds =
{
"swiftfox",
"mutt",
"consonance",
"linux-fetion",
"weechat-curses",
--and so on...
}
for _,i in pairs(cmds) do
awful.util.spawn(i)
end
end
(You could also run calls to os.execute with commands ending in '&', but it's probably a better idea to stick to the proper spawn function.)
To run a program only if it is not currently running, you can spawn it with a shell command that runs the program only if pgrep doesn't find a running process with the same name:
function run_once(prg)
awful.util.spawn_with_shell("pgrep -u $USER -x " .. prg .. " || (" .. prg .. ")")
end
So, for example, to run parcellite only if there is not a parcellite process already running:
run_once("parcellite")
- (377)Cannot move old logfile ("/var/log/Xorg.0.log" to "/var/log/Xorg.0.log.old"
This happens when xorg 7.2 gets installed from a package, and there is already
an earlier xorg 6.x installed.
- (385)How to get the name of the running application from its window? (useful to define the "rules" section of rc.lua in AwesomeWM)
xwininfo or
xprop (WM_CLASS)
How to define the "rules" section of of rc.lua in awesome?
Use a small-cased version of the name of the application (got it using xprop)
e.g., it had to be "g", even though: WM_CLASS(STRING) = "gimp", "Gimp"
From: http://www.docunext.com/blog/2009/11/awesomewm-titlebar-34-1-update.html
- (394)How to set the lightning of the screen?
man xrandr
--brightness brightness
Multiply the gamma values on the crtc currently attached to the
output to specified floating value. Useful for overly bright or
overly dim outputs. However, this is a software only
modification, if your hardware has support to actually change
the brightness, you will probably prefer to use xbacklight.
=> use xbacklight !!!
- (414)How to change Gtk's theme?
ln -s /usr/share/themes/Clearlooks/gtk-2.0/gtkrc .gtkrc-2.0
---
For GTK2 applications (Firefox, Gimp), add a line including the gtkrc of the Gnome theme you want to use in ~/.gtkrc-2.0
--
$ cat ~/.gtkrc-2.0
include "/usr/local/share/themes/niglo-openSUSE/gtk-2.0/gtkrc"
style "user-font"
{
font_name="Sans Serif"
}
widget_class "*" style "user-font"
gtk-theme-name="niglo-openSUSE"
gtk-font-name="Sans Serif 9"
--
For GTK3 applications (applications which come with Gnome3), create a symlink ~/.config/gtk-3.0 to point to the GTK3 theme you want to use.
$ ln -s /usr/local/share/themes/niglo-openSUSE/gtk-3.0 ~/.config/gtk-3.0
From: http://forums.opensuse.org/showthread.php/475115-How-to-set-Gtk-and-Gnome-themes-from-a-KDE-desktop
For GTK2
--- format of ~/.gtkrc-2.0:
gtk-icon-theme-name = "[name-of-icon-theme]"
gtk-theme-name = "[name-of-theme]"
gtk-font-name = "[font-name] [size]"
--- cat ~/.gtkrc-2.0
gtk-icon-theme-name = "Tango"
gtk-theme-name = "Murrine-Gray"
gtk-font-name = "DejaVu Sans 8"
For GTK3:
--- $XDG_CONFIG_HOME/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme = false
gtk-theme-name = Zukitwo
gtk-fallback-icon-theme = gnome
gtk-icon-theme-name = [icon theme name]
gtk-font-name = [font name] [font size]
If it still does not change, delete old gtk-3.0 folder in $XDG_CONFIG_HOME and copy gtk-3.0 folder from /path/to/theme to $XDG_CONFIG_HOME. Example:
$ rm -r ~/.config/gtk-3.0/
$ cp -r /usr/share/themes/Zukitwo/gtk-3.0/ ~/.config/
From: https://wiki.archlinux.org/index.php/GTK+#GTK.2B_1.x
- (497)How to set the keyboard options correctly?
Add this line in your .xinitrc (if using startx) or .xsession (if using a display manager):
setxkbmap -layout us -variant dvorak -option ctrl:nocaps -option compose:menu
Also Also see Tip#1086
- (476)How to solve "No protocol specified" error in Xorg
I had the exact same problem, not able to start from user, able to start in
root, same "No protocol specified .. No protocol specified ..", etc.
Solved by deleting the .Xauthority in the users home directory.
- (477)How to build a simple keyloader (in userland!)?
xinput list
xinput test <id kdb>
- (480)Set keyboard to dvorak-fr-mouette
// concaténer ce fichier dans /usr/share/X11/xkb/symbols/fr
// activer avec : setxkbmap -variant dvorak-fr-mouette
// désactiver avec : setxkbmap -variant basic
// Keymap Dvorak pour le Français
// par Josselin Mouette <josselin.mouette@ens-lyon.org>.
partial alphanumeric_keys
xkb_symbols "dvorak-fr-mouette" {
name[Group1]= "France - (Legacy) Dvorak";
key <TLDE> { [ oe, OE, ae, AE ] };
key <AE01> { [ slash, 1, ampersand, onesuperior ] };
key <AE02> { [ plus, 2, asciitilde, twosuperior ] };
key <AE03> { [ minus, 3, numbersign, threesuperior ] };
key <AE04> { [ asterisk, 4, less, guillemotleft ] };
key <AE05> { [ equal, 5, greater, guillemotright ] };
key <AE06> { [ backslash, 6, at, notsign ] };
key <AE07> { [ parenleft, 7, dead_circumflex, multiply ] };
key <AE08> { [ grave, 8, dead_grave, division ] };
key <AE09> { [ parenright, 9, asciicircum, plusminus ] };
key <AE10> { [ quotedbl, 0, dead_diaeresis, dead_diaeresis ] };
key <AE11> { [bracketleft, braceleft, bar, degree ] };
key <AE12> { [bracketright, braceright, percent, percent ] };
key <AD01> { [ colon, question, question, questiondown ] };
key <AD02> { [ agrave, Agrave, aring, Aring ] };
key <AD03> { [ eacute, Eacute, EuroSign, cent ] };
key <AD04> { [ g, G, oslash, Ooblique ] };
key <AD05> { [ period, exclam, periodcentered, exclamdown ] };
key <AD06> { [ h, H, eth, ETH ] };
key <AD07> { [ v, V ] };
key <AD08> { [ c, C, copyright, registered ] };
key <AD09> { [ m, M, mu, mu ] };
key <AD10> { [ k, K, dollar, dollar ] };
key <AD11> { [ egrave, Egrave, sterling, sterling ] };
key <AD12> { [ z, Z, yen, yen ] };
key <AC01> { [ o, O, ocircumflex, Ocircumflex ] };
key <AC02> { [ a, A, acircumflex, Acircumflex ] };
key <AC03> { [ u, U, ucircumflex, Ucircumflex ] };
key <AC04> { [ e, E, ecircumflex, Ecircumflex ] };
key <AC05> { [ b, B, ssharp, ssharp ] };
key <AC06> { [ f, F ] };
key <AC07> { [ s, S ] };
key <AC08> { [ t, T, thorn, THORN ] };
key <AC09> { [ n, N, ntilde, Ntilde ] };
key <AC10> { [ d, D, section, section ] };
key <AC11> { [ w, W, paragraph, paragraph ] };
key <BKSL> { [ ugrave, Ugrave, masculine, ordfeminine ] };
key <AB01> { [ apostrophe, underscore, dead_acute, macron ] };
key <AB02> { [ q, Q, guillemotleft, guillemotleft ] };
key <AB03> { [ comma, semicolon, guillemotright, guillemotright ] };
key <AB04> { [ i, I, icircumflex, Icircumflex ] };
key <AB05> { [ y, Y, ydiaeresis, Ydiaeresis ] };
key <AB06> { [ x, X, ediaeresis, Ediaeresis ] };
key <AB07> { [ r, R, udiaeresis, Udiaeresis ] };
key <AB08> { [ l, L, adiaeresis, Adiaeresis ] };
key <AB09> { [ p, P, odiaeresis, Odiaeresis ] };
key <AB10> { [ j, J, idiaeresis, Idiaeresis ] };
key <SPCE> { [ space, space, nobreakspace, nobreakspace ] };
key <LSGT> { [ ccedilla, Ccedilla ] };
include "level3(ralt_switch)"
};
// setxkbmap -layout fr -variant dvorak-fr-mouette
// Use KTouch to train :)
- (481)My awesomeWM's 3.4.15 configuration file (rc.lua) from work (Presans)
-- Standard awesome library
require("awful")
require("awful.autofocus")
require("awful.rules")
-- Theme handling library
require("beautiful")
-- Notification library
require("naughty")
-- Widgets library
require("vicious")
-- {{{ Variable definitions
-- Themes define colours, icons, and wallpapers
-- beautiful.init("~/.config/awesome/theme.lua")
-- beautiful.init("/usr/local/share/awesome/themes/zenburn/theme.lua")
-- beautiful.init("/usr/local/share/awesome/themes/sky/theme.lua")
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
-- GM: Load script that launches startup applications
os.execute("source ~/.xsession");
--os.execute("source ~/Softs/run_ssh_add");
-- This is used later as the default terminal and editor to run.
terminal = "uxterm"
editor = os.getenv("EDITOR") or "vim"
editor_cmd = terminal .. " -e " .. editor
xlockcmd = "/home/guillaume/Softs/run_screensaver"
minBattery = .2
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod1"
-- Table of layouts to cover with awful.layout.inc, order matters.
layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.max,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
-- }}}
-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag({ "Chat-" .. s, "W1-" .. s, "W2-" .. s, "W3-" .. s, "Mail-" .. s, "Web-" .. s, "Mumule-" .. s }, s, layouts[2])
end
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "Terminal", terminal },
{ "XChat", "xchat" },
{ "Nautilus", "nautilus" },
{ "XXXTerm", "xxxterm" },
{ "Firefox", "firefox" },
{ "Chromium", "~/.mychromium" },
{ "Midori", "~/.mymidori" },
{ "Thunderbird", "thunderbird" },
{ "Audacious", "audacious2" },
{ "aMule", "amule" },
{ "KTorrent", "ktorrent" },
{ "Transmission", "transmission-gtk" },
{ "Xlock", "xlock" }
}
})
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
menu = mymainmenu })
-- }}}
-- {{{ Wibox
-- Create a textclock widget
mytextclock = awful.widget.textclock({ align = "right" })
xchatbox = widget({ type="imagebox", name="icon", align=align })
xchatbox.image = image("/usr/share/icons/HighContrast/24x24/apps/xchat.png")
xchatbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("xchat") end)))
nautilusbox = widget({ type="imagebox", name="icon", align=align })
nautilusbox.image = image("/usr/share/icons/GartoonRedux/24x24/apps/nautilus.png")
nautilusbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("nautilus") end)))
skypebox = widget({ type="imagebox", name="icon", align=align })
skypebox.image = image("/usr/share/icons/hicolor/24x24/apps/skype.png")
skypebox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("skype") end)))
midoribox = widget({ type="imagebox", name="icon", align=align })
midoribox.image = image("/usr/share/icons/hicolor/24x24/apps/midori.png")
midoribox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("/home/guillaume/.mymidori") end)))
--xxxtermbox = widget({ type="imagebox", name="icon", align=align })
--xxxtermbox.image = image("/usr/local/share/icons/hicolor/24x24/apps/gnome-panel-fish.png")
--xxxtermbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("xxxterm") end)))
firefoxbox = widget({ type="imagebox", name="icon", align=align })
firefoxbox.image = image("/usr/lib/firefox/browser/chrome/icons/default/default32.png")
firefoxbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("firefox") end)))
--eclipsebox = widget({ type="imagebox", name="icon", align=align })
--eclipsebox.image = image("/usr/share/app-install/icons/eclipse.png")
--eclipsebox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("/home/guillaume/Softs/eclipse/eclipse") end)))
chromiumbox = widget({ type="imagebox", name="icon", align=align })
chromiumbox.image = image("/usr/share/icons/hicolor/24x24/apps/chromium-browser.png")
chromiumbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("/home/guillaume/.mychromium") end)))
thunderbirdbox = widget({ type="imagebox", name="icon", align=align })
thunderbirdbox.image = image("/usr/lib/thunderbird/chrome/icons/default/default32.png")
thunderbirdbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("thunderbird") end)))
audaciousbox = widget({ type="imagebox", name="icon", align=align })
audaciousbox.image = image("/usr/share/icons/hicolor/48x48/apps/audacious.png")
audaciousbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("audacious") end)))
--amulebox = widget({ type="imagebox", name="icon", align=align })
--amulebox.image = image("/usr/local/share/pixmaps/amule.xpm")
--amulebox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("amule") end)))
--ktorrentbox = widget({ type="imagebox", name="icon", align=align })
--ktorrentbox.image = image("/usr/local/share/apps/ktorrent/www/coldmilk/icon.png")
--ktorrentbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("ktorrent") end)))
transmisbox = widget({ type="imagebox", name="icon", align=align })
transmisbox.image = image("/usr/share/pixmaps/transmission.png")
transmisbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("transmission-gtk") end)))
xlockbox = widget({ type="imagebox", name="icon", align=align })
xlockbox.image = image("/usr/share/icons/gnome/24x24/actions/lock.png")
xlockbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(xlockcmd) end)))
------------------------------------ WIDGETS START
mycpugraph0 = awful.widget.graph()
mycpugraph0:set_width(25)
mycpugraph0:set_background_color('#000000')
mycpugraph0:set_color('#F01010')
--
mycpugraph1 = awful.widget.graph()
mycpugraph1:set_width(25)
mycpugraph1:set_background_color('#000000')
mycpugraph1:set_color('#D03030')
--
mycpugraph2 = awful.widget.graph()
mycpugraph2:set_width(25)
mycpugraph2:set_background_color('#000000')
mycpugraph2:set_color('#E02020')
--
mycpugraph3 = awful.widget.graph()
mycpugraph3:set_width(25)
mycpugraph3:set_background_color('#000000')
mycpugraph3:set_color('#C04040')
mybatprogressbar = awful.widget.progressbar()
mybatprogressbar:set_width(10)
--mybatprogressbar:set_height(10)
mybatprogressbar:set_vertical(true)
mybatprogressbar:set_background_color('#000000')
mybatprogressbar:set_color('#F0F0F0')
mybatprogressbar:set_gradient_colors({ '#444444', '#DDDDDD', '#EEEEEE' })
-- TODO : mybatprogressbar:set_value(<call func>)
mynetgraphin = awful.widget.graph()
mynetgraphin:set_width(35)
mynetgraphin:set_background_color('#000000')
mynetgraphin:set_color('#00D000')
--
mynetgraphout = awful.widget.graph()
mynetgraphout:set_width(35)
mynetgraphout:set_background_color('#000000')
mynetgraphout:set_color('#00B000')
myramgraph = awful.widget.graph()
myramgraph:set_width(30)
myramgraph:set_background_color('#000000')
myramgraph:set_color('#0000F0')
myswapgraph = awful.widget.graph()
myswapgraph:set_width(30)
myswapgraph:set_background_color('#000000')
myswapgraph:set_color('#00E0E0')
--myhomefsprogressbar = awful.widget.progressbar()
--myhomefsprogressbar:set_width(50)
----myhomefsprogressbar:set_height(10)
--myhomefsprogressbar:set_vertical(false)
--myhomefsprogressbar:set_background_color('#000000')
--myhomefsprogressbar:set_color('#DDDDDD')
--myhomefsprogressbar:set_gradient_colors({ '#AECF96', '#88A175', '#FF5656' })
---- TODO : myhomefsprogressbar:set_value(<call func>)
myrootfsprogressbar = awful.widget.progressbar()
myrootfsprogressbar:set_width(10)
--myrootfsprogressbar:set_height(10)
myrootfsprogressbar:set_vertical(true)
myrootfsprogressbar:set_background_color('#000000')
myrootfsprogressbar:set_color('#AEAEA0')
myrootfsprogressbar:set_gradient_colors({ '#FFFFFE', '#FFA175', '#000000' })
-- TODO : myrootfsprogressbar:set_value(<call func>)
-- GM: To get the output of a shell command
function os.capture(cmd2Run, asNumber)
local f = assert(io.popen(cmd2Run, 'r'))
local s = assert(f:read('*a'))
f:close()
if asNumber
then
return tonumber(s)
end
return s
end
-- Initializations
cpu0Last = os.capture("~/Softs/getCPUpercent 0", true);
cpu1Last = os.capture("~/Softs/getCPUpercent 1", true);
cpu2Last = os.capture("~/Softs/getCPUpercent 2", true);
cpu3Last = os.capture("~/Softs/getCPUpercent 3", true);
netinLast = os.capture("~/Softs/getNETpercent in", true);
netoutLast = os.capture("~/Softs/getNETpercent out", true);
rootfs = os.capture("~/Softs/getFSpercent root");
myrootfsprogressbar:set_value(rootfs);
bat = os.capture("~/Softs/getBATpercent");
mybatprogressbar:set_value(bat);
-- Updates of the values
myhighspeedtimer = timer({ timeout = 1 })
myhighspeedtimer:add_signal("timeout", function()
cpu0 = os.capture("~/Softs/getCPUpercent 0", true);
mycpugraph0:add_value(cpu0-cpu0Last);
cpu0Last=cpu0
cpu1 = os.capture("~/Softs/getCPUpercent 1", true);
mycpugraph1:add_value(cpu1-cpu1Last);
cpu1Last=cpu1
cpu2 = os.capture("~/Softs/getCPUpercent 2", true);
mycpugraph2:add_value(cpu2-cpu2Last);
cpu2Last=cpu2
cpu3 = os.capture("~/Softs/getCPUpercent 3", true);
mycpugraph3:add_value(cpu3-cpu3Last);
cpu3Last=cpu3
ram = os.capture("~/Softs/getRAMpercent", true);
myramgraph:add_value(ram);
swap = os.capture("~/Softs/getSWAPpercent", true);
myswapgraph:add_value(swap);
netin = os.capture("~/Softs/getNETpercent in", true);
mynetgraphin:add_value(netin-netinLast);
netinLast = netin;
netout = os.capture("~/Softs/getNETpercent out", true);
mynetgraphout:add_value(netout-netoutLast);
netoutLast = netout;
-- print("******", cpu0, " ", cpu1, " ", cpu2, " ", cpu3, " ", ram, " ")
-- print("******~", (netin-netinLast), " ", (netout-netoutLast))
end)
myhighspeedtimer:start()
mylowspeedtimer = timer({ timeout = 30 })
mylowspeedtimer:add_signal("timeout", function()
bat = os.capture("~/Softs/getBATpercent", true);
if bat < minBattery
then
mybatprogressbar:set_background_color('#FFFFFF')
mybatprogressbar:set_color('#FF0000')
mybatprogressbar:set_gradient_colors({ '#FF0000', '#FF0000', '#FF0000' })
else
mybatprogressbar:set_background_color('#000000')
mybatprogressbar:set_color('#F0F0F0')
mybatprogressbar:set_gradient_colors({ '#444444', '#DDDDDD', '#EEEEEE' })
end
mybatprogressbar:set_value(bat);
-- homefs = os.capture("~/Softs/getFSpercent home");
-- myhomefsprogressbar:set_value(homefs);
rootfs = os.capture("~/Softs/getFSpercent root");
myrootfsprogressbar:set_value(rootfs);
-- print("******", homefs, ", ", rootfs, ", ", bat)
end)
mylowspeedtimer:start()
------------------------------------ WIDGETS END
-- Create a systray
mysystray = widget({ type = "systray" })
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey, "Control" }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
)
mytasklist = {}
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, function (c)
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
client.focus = c
c:raise()
end),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ width=250 })
end
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end))
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(function(c)
return awful.widget.tasklist.label.currenttags(c, s)
end, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Add widgets to the wibox - order matters
mywibox[s].widgets = {
{
mylauncher,
mytaglist[s],
mypromptbox[s],
layout = awful.widget.layout.horizontal.leftright
},
mylayoutbox[s],
mytextclock,
-- GM clickable icons for applications
xlockbox,
ktorrentbox,
transmisbox,
amulebox,
audaciousbox,
thunderbirdbox,
chromiumbox,
firefoxbox,
midoribox,
xxxtermbox,
nautilusbox,
skypebox,
xchatbox,
--eclipsebox,
-- GM widgets for mem/CPU/net/fs/batt
myrootfsprogressbar.widget,
-- myhomefsprogressbar.widget,
myramgraph.widget,
myswapgraph.widget,
mynetgraphout.widget,
mynetgraphin.widget,
mybatprogressbar.widget,
mycpugraph3.widget,
mycpugraph2.widget,
mycpugraph1.widget,
mycpugraph0.widget,
s == 1 and mysystray or nil,
mytasklist[s],
layout = awful.widget.layout.horizontal.rightleft
}
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "Left", awful.tag.viewprev ),
awful.key({ modkey, "Control" }, "Right", awful.tag.viewnext ),
awful.key({ modkey, "Control" }, "Escape", awful.tag.history.restore),
awful.key({ modkey, "Control" }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end),
-- awful.key({ modkey, }, "k",
-- function ()
-- awful.client.focus.byidx(-1)
-- if client.focus then client.focus:raise() end
-- end),
-- awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
-- Layout manipulation
-- awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
-- awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
-- awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
-- awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
-- awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
awful.key({ modkey, "Control" }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(-1)
if client.focus then
client.focus:raise()
end
end),
awful.key({ modkey, "Control", "Shift" }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(1)
if client.focus then
client.focus:raise()
end
end),
-- Standard program
awful.key({ modkey, "Control" }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Control" }, "q", awesome.quit),
-- GM: Cannot use KP_8/KP_2. Indeed, in my config @PreSans, the keyboard is redefined after awesome is loaded => I must use here the definition of keys as it is when awesome starts up, i.e. in standard Xorg config
awful.key({ modkey, "Control" }, "KP_Right", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, "Control" }, "KP_Left", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Control" }, "l", function () awful.util.spawn(xlockcmd) end),
awful.key({ modkey, "Control" }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Control", "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Prompt
awful.key({ modkey, "Control" }, "x", function () mypromptbox[mouse.screen]:run() end)
--,
)
clientkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "k", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "f", awful.client.floating.toggle ),
awful.key({ modkey, "Shift" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, "Control" }, "i", function (c) c.minimized = not c.minimized end),
awful.key({ modkey, "Control" }, "a",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
end
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.toggletag(tags[client.focus.screen][i])
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey, "Control" }, 1, awful.mouse.client.move),
awful.button({ modkey, "Control" }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
secondScreen = screen.count();
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = true,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "QEMU" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
{ rule = { class = "Qemu" },
properties = { floating = true } },
{ rule = { name = "Xpdf: Find" },
properties = { floating = true } },
{ rule = { class = "Xpdf" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
{ rule = { class = "GQview" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
-- GM
{ rule = { class = "Emacs" },
properties = { floating = false, size_hints_honor = false } },
{ rule = { class = "Eclipse" },
properties = { tag = tags[1][2] } }, -- "Work1"
{ rule = { name = "Java" },
properties = { tag = tags[1][2] } }, -- "Work1"
{ rule = { class = "Xchat" },
properties = { tag = tags[1][1] } }, -- "Chat"
{ rule = { class = "Skype" },
properties = { tag = tags[1][1] } }, -- "Chat"
{ rule = { class = "Audacious" },
properties = { tag = tags[1][4] } }, -- Work3
{ rule = { class = "Thunderbird" },
properties = { tag = tags[1][5] } }, -- Mail
{ rule = { class = "Firefox" },
properties = { tag = tags[1][6] } }, -- Web
{ rule = { class = "Chromium" },
properties = { tag = tags[1][7] } }, -- Web
{ rule = { class = "Midori" },
properties = { tag = tags[1][7] } }, -- Web
{ rule = { class = "Xxxterm" },
properties = { tag = tags[1][6] } }, -- Web
{ rule = { class = "Amule" },
properties = { tag = tags[1][7] } }, -- Mumule
{ rule = { class = "Ktorrent" },
properties = { tag = tags[1][7] } }, -- Mumule
-- Set Firefox to always map on tags number 2 of screen 1.
-- { rule = { class = "Firefox" },
-- properties = { tag = tags[1][2] } },
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.add_signal("manage", function (c, startup)
-- Add a titlebar
-- awful.titlebar.add(c, { modkey = modkey })
-- Enable sloppy focus
c:add_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
end
end)
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
- (550)Where are AwesomeWM's error logged?
In .xsession-errors
- (568)How to persistanly export your X-applications/DISPLAY (a.k.a. a "screen/tmux" for X); a.k.a. a virtual Xorg server that runs on remote server and can be attached/detached anytime locally)?
Use Xpra:
https://xpra.org/
https://code.google.com/p/partiwm/wiki/xpra
# On server/distant machine
xpra start :7 # Start an xpra server using display number :7.
DISPLAY=:7 firefox # Start firefox running inside the xpra server. No window will appear.
# or:
# export DISPLAY=:7 ; firefox
# On local machine
xpra attach ssh:<server ip>:7 # Use ssh to attach to the xpra server that is running on the "server" machine and using display :7. Any apps running on that server will appear on your local screen.
# You can also use
# xpra list Show a list of xpra servers you have running on the current host.
- (578)How to change the font size quickly in XTerm?
Alt-Maj +/-
- (611)How to manage gnome keyring?
$ seahorse
- (612)Where are Nautilus bookmarks stored?
in ~/.gtk-bookmarks
- (613)How to make Nautilus remember passwords?
In fact, the keyring actually stores the credentials, but the domain is missing in the bokkmarks, so nautilus does not recognize the share being obtained.
The solution is to add the domain in the bookmarks file:
vi ~/.gtk-bookmarks
The patern is:
smb://DOMAIN;USER@MACHINE/SHAREDDIR
From:
https://bugzilla.gnome.org/show_bug.cgi?id=618091
http://www.clearfoundation.com/docs/howtos/add_linux_workstation_to_the_samba_domain
http://darklaunch.com/2010/10/31/where-are-nautilus-bookmarks-stored-nautilus-bookmark-location
- (615)How to disable sound in GDM?
1. Use gconf-editor to disable
apps/gdm/simple-greeter/setting-manager-plugins/sound
2. # rm -rf /var/lib/gdm/.gconf/
3. # cp -r /root/.gconf /var/lib/gdm/.
4. # chown -R gdm:gdm /var/lib/gdm/.gconf
5. # gnome-volume-control
6. Set 'Sound Theme' to 'No sounds'
7. Close gnome-volume-control
8. Re-logon
9. Enjoy reclaimed silence :)
From: https://bugzilla.redhat.com/show_bug.cgi?id=503360
- (700)Script to switch off screens
sleep 1; xset dpms force off
- (701)Script to automatically set screen/overhead projector best resolution
xrandr --output LVDS1 --auto
xrandr --output VGA1 --auto
- (703)How to reduce the Xorg screen?
xrandr --output VGA1 --scale 0.9x0.9
- (707)How to swap CTL and CAPSLOCK with Xmodmap?[wrong way to do it!]
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
And to recover:
echo -e "remove Lock = Caps_Lock \n remove Control = Control_L \n keycode 37 = Caps_Lock \n keycode 66 = Control_L \n add Lock = Caps_Lock \nadd Control = Control_L" | xmodmap -
The right way to do it:
setxkbmap -option ctrl:swapcaps
Tip#814 & Tip#1163
- (708)How to restart XFCE?
xfwm4 --replace &
- (710)Script to disable annoying sounds in GDM
# Mute (use 'M' key) 'Beep' output in alsamixer
amixer sset 'Beep' 0%
amixer sset 'Beep' disable
# Set gdm not to use beeps with gconftool
gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
-t bool -s /desktop/gnome/sound/event_sounds false
gconftool-2 --direct \
--config-source xml:readwrite:/etc/gconf/gconf.xml.defaults -t bool \
-s /apps/gdm/simple-greeter/settings-manager-plugins/sound/active false
# Set gdm not to use beeps with gsettings
gsettings set org.gnome.desktop.sound event-sounds false
gsettings set org.gnome.desktop.sound input-feedback-sounds false
# Another option is to run gconf-editor (as root), check the toggle box next to
# event_sounds off, right click on it and choose "Set as Default"
#
# Some other relevent gconf keys are discussed in the gdm manual:
# http://projects.gnome.org/gdm/docs/2.24/
- (711)Script to capture a demo of a running program
#recordmydesktop
# the target to capture
#--windowid <get it with xwininfo>
# if working with awesome
#--no-wm-check
# for user interaction
#--pause-shortcut Control+Mod1+p --stop-shortcut Control+Mod1+s
# for sound
#--device /dev/audio0 --no-sound / --s_quality <-1-10>
# for video
#--v_bitrate <45000-2000000> --v_quality <0-63> --fps <~25.0?>
# optimization/speed up capture?
#--on-the-fly-encoding
# needed in some cases
#--no-cursor # remove cursor from video
#--delay n[H|h|M|m] # before start of capture
WID=`xwininfo | grep "Window id" | cut -d':' -f 3 | cut -d' ' -f2`
#recordmydesktop --no-wm-check --no-sound --windowid $WID --on-the-fly-encoding -fps 2.0 --v_quality 25
recordmydesktop --no-wm-check --s_quality 2 -device /dev/sound0 --windowid $WID --on-the-fly-encoding -fps 2.0 --v_quality 25
--
Another option is to use "Istanbul"
http://directory.fsf.org/wiki/Istanbul
- (712)Script to run compiz
## conftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true
#metacity --replace
compiz ccp --sm-disable --replace
emerald --replace
- (716)Name of the Gnome network applet
/usr/bin/nm-applet
- (734)What to do in case of "X11 connection rejected because of wrong authentication."?
It generally occurs when you connect via SSH to a machine then switch user there. The tunneling of the Xorg connexion is not assured. You have to transmit the authorization granted to the primary user to the secondary user:
user1@machine$ xauth list
fileserver/unix:10 MIT-MAGIC-COOKIE-96951c0622f80fd52186129dd06f2f6
Next, sudo/su to the other account and add the authorization key.
user1@machine$ su - user2
user2$ xauth add fileserver/unix:10 MIT-MAGIC-COOKIE-96951c0622f80fd52186129dd06f2f6
Now, you should be able to start any X Windows application,
user2$ xclock
- (761)How to prevent Gnome to auto-open CD/DVD?
Panel Menu -> Preferences -> File Management
From: http://superuser.com/questions/417081/how-to-get-gnome-to-open-cd-automatically
- (766)Where are stored the associations files<->opening application for MATE (Gnome2)?
.mateconf/desktop/mate/applications/*/%mateconf.xml
- (799)How to enable/configure MultiMedia keys?
1. Install xbinkeys
2. Edit ~/.xbindkeysrc
3. The format of a single entry is:
# Comment
"<command to run on press>"
<keycode>
To get an entry generated automatically for you, run the following command:
"xbindkeys -k" or "xbindkeys -mk" for testing multiple keys at once
From: https://wiki.archlinux.org/index.php/Xbindkeys
- (800)How to enable/disable Emulate3Buttons with XInput [Ubuntu 12.04]?
--- enable
#!/bin/sh
xinput list | sed -ne 's/^[^ ][^V].*id=\([0-9]*\).*/\1/p' | while read id
do
case `xinput list-props $id` in
*"Middle Button Emulation"*)
xinput set-int-prop $id "Middle Button Emulation" 8 1
xinput set-int-prop $id "Evdev Middle Button Emulation" 8 1
;;
esac
done
--- disable
#!/bin/sh
xinput list | sed -ne 's/^[^ ][^V].*id=\([0-9]*\).*/\1/p' | while read id
do
case `xinput list-props $id` in
*"Middle Button Emulation"*)
xinput set-int-prop $id "Middle Button Emulation" 8 0
;;
esac
done
From: https://wiki.ubuntu.com/X/Config/Input#Example:_Disabling_middle-mouse_button_paste_on_a_scrollwheel_mouse
From: http://www.seebs.net/log/articles/459/disabling-emulate3buttons-on-ubuntu
- (813)How to set correctly the touchpad (Emulates3Buttons, VerticalScrolling, etc.) in Ubuntu 12.04?
1. Create a file /etc/X11/xorg.conf.d/touchpad.conf with the following content:
Section "InputClass"
Identifier "Touchpad" # required
MatchIsTouchpad "on" # required
Driver "synaptics" # required
Option "MinSpeed" "0.5"
Option "MaxSpeed" "1.0"
Option "AccelFactor" "0.075"
Option "TapButton1" "1"
Option "TapButton2" "2" # multitouch
Option "TapButton3" "3" # multitouch
Option "VertTwoFingerScroll" "1" # multitouch
Option "HorizTwoFingerScroll" "1" # multitouch
Option "VertEdgeScroll" "1"
Option "CoastingSpeed" "8"
Option "CornerCoasting" "1"
Option "CircularScrolling" "1"
Option "CircScrollTrigger" "7"
Option "EdgeMotionUseAlways" "1"
Option "LBCornerButton" "8" # browser "back" btn
Option "RBCornerButton" "9" # browser "forward" btn
EndSection
2. Run dconf-editor from your user (don't sudo). Go to org.gnome.settings-daemon.plugins.mouse, uncheck active. (It is a known issue that Gnome's Settings Daemon may override your xorg.conf settings).
3. Log out and log in. Things should be working fine now.
From: http://askubuntu.com/questions/12435/how-do-i-restore-two-finger-middle-click-again
- (913)How to change the X cursor?
sudo update-alternatives --config x-cursor-theme
From: http://askubuntu.com/questions/78888/how-to-change-the-mouse-pointer-theme
- (997)How to configure Alps touchpad?
xinput list # get ID of touchpad
xinput list-props $id # list configuration parameters
xinput set-prop $id "Synaptics Off" 2 # disable scroll+tap
synclient # get current configuration values
synclient TouchpadOff=0 # enable scroll+tap
synclient LeftEdge=0 # remove left scrollbar
synclient RightEdge=1700 # set right scrollbar size
synclient TopEdge=0 # remove top scrollbar
synclient BottomEdge=1500 # remove bottom scrollbar
From: http://ubuntuforums.org/showthread.php?t=827891
- (1327)How to launch Configure Kde control module by command line?
1. Get the names of configuration tabs:
kcmshell4 --list
2. Launch the Configurator with the selected modules:
kcmshell4 kwincompositing kwindecoration kwinoptions kwinrules kwinscreenedges kwintabbox
From: http://askubuntu.com/questions/153495/how-to-launch-configure-kde-control-module-by-command-line
- (1000)How to disable ALPS Trackpad while Typing?
First of all you should test if it works properly for your trackpad and if the settings are accurate:
$ synclient PalmDetect=1
Then test the typing. You can tweak the detection with:
$ synclient PalmMinWidth=
which is the width of the area your hand touches, and
$ synclient PalmMinZ=
which is the minimum Z distance at which the detection is performed.
Once you have found the correct settings, save them into /etc/X11/xorg.conf.d/50-synaptics.conf like this:
#synclient PalmDetect=1
Option "PalmDetect" "1"
#synclient PalmMinWidth=10
Option "PalmMinWidth" "10"
#synclient PalmMinZ=200
Option "PalmMinZ" "200"
From: https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Disable_Trackpad_while_Typing
# To actually disable TouchPad while tying even on buggy devices
syndaemon -d -i .6
From: http://codeidol.com/unix/fedora/Using-Fedora-on-Your-Notebook/Configuring-a-Touchpad/
- (1010)How to make AwesomeWM cycle through all the windows with alt+tab?
In the default rc.lua, the section that controls window cycling looks like this:
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
To cycle through all the windows, and not just the previous, change the above code to the following:
awful.key({ modkey, }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(-1)
if client.focus then
client.focus:raise()
end
end),
awful.key({ modkey, "Shift" }, "Tab",
function ()
-- awful.client.focus.history.previous()
awful.client.focus.byidx(1)
if client.focus then
client.focus:raise()
end
end),
From: http://stackoverflow.com/questions/11697102/awesome-alttab-just-switches-between-two-apps
- (1016)Why does xbindkeys suddently stops working in AwesomeWM?
It appears that enabling numlock (with keystate_numlock = enable) with some Xorg configs make Mod2 be appended to any special key.
SOLUTION1: disable keystate_numlock and rather use xmodmap to redefine KP_* keys
(SOLUTION2: double all your bindings in .xbindkeysrc with a version containing "Mod2 +")
From: http://forums.fedoraforum.org/showthread.php?t=167419
TIPS1 : check if your config is vulnerable to this "bug"
$ xmodmap
...
mod2 Num_Lock
...
TIPS2 : run $ xbindkeys -v -s -k -n to see which key is detected by xbindkeys
- (1272)How to disable Keys intercepted by XFCE4/XFWM4 in order to re-assigning them with Xmodmap?
You can g oto Xfce4 Settings Manager through the menus or launch xfce4-settings-manager from terminal.
The trick is to go to the "Window Manager" configuration tab, not the "Keyboard" tab. Then, find the keyboard part.
look for Window operations menu, and then hit on Clear button, which will remove that shortcut key, effects immedately
From: http://unix.stackexchange.com/questions/44643/xfce-4-change-global-keyboard-shortcuts
- (1173)How to print the available console colors?
emacs -nw
M-x list-colors-display
From: http://www.enigmacurry.com/2009/01/20/256-colors-on-the-linux-terminal/
--- display_color.sh
#!/bin/bash
for((i=16; i<256; i++)); do
printf "\e[48;5;${i}m%03d" $i;
printf '\e[0m';
[ ! $((($i - 15) % 6)) -eq 0 ] && printf ' ' || printf '\n'
done
---
From: https://askubuntu.com/questions/558280/changing-colour-of-text-and-background-of-terminal
- (1168)How to prevent gnome dialogs (e.g. update-indicator) to take the mouse focus when then popup?
gsettings set org.gnome.desktop.wm.preferences focus-mode 'mouse'
From: http://askubuntu.com/questions/64605/how-do-i-set-focus-follows-mouse
- (1170)How to get the console color names and RBG values?
showrgb
From: man showrbg / man setvtrbg
- (1171)How to print the number of colors your terminal supports?
tput colors
From: http://www.enigmacurry.com/2009/01/20/256-colors-on-the-linux-terminal/
- (1163)How to swapcaps at startup in XFCE4?
To make sure this happens every time XFCE4 comes up, add an entry to Settings > Session and Startup > Application Autostart
The command to run is:
/usr/bin/setxkbmap -option 'ctrl:swapcaps'
Tip#707 & Tip#814
From: http://software.clapper.org/cheat-sheets/xfce.html
- (1126)How to prevent Nautilus from changing the background image (and creating a desktop), when using another window manager?
alias nautilus='nautilus --no-desktop'
From: http://forums.linuxmint.com/viewtopic.php?f=220&t=107701
- (1138)How to get the current Xorg settings (keyboard, etc)?
xset q
From: man xset
- (1084)How to activate numpad at Xorg startup?
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
#
numlockx &
exec window_manager
From: https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#startx
- (1404)How to resize windows vertically/horizontally in AwesomeWM?
Depending on when my redefinition of keyboard's bindings occurs, I use:
- If it occurs after Awesome is loaded (i.e. Awesome uses Xorg's default keybindings):
awful.key({ modkey, "Mod1" }, "KP_Right", function () awful.tag.incmwfact( 0.01) end),
awful.key({ modkey, "Mod1" }, "KP_Left", function () awful.tag.incmwfact(-0.01) end),
awful.key({ modkey, "Mod1" }, "KP_Down", function () awful.client.incwfact( 0.01) end),
awful.key({ modkey, "Mod1" }, "KP_Up", function () awful.client.incwfact(-0.01) end),
- If it occurs before Awesome is loaded (i.e. Awesome sees my redefinition of keypad keys as alwsays outputing numbers):
awful.key({ modkey, "Mod1" }, "KP_4", function () awful.tag.incmwfact( 0.01) end),
awful.key({ modkey, "Mod1" }, "KP_6", function () awful.tag.incmwfact(-0.01) end),
awful.key({ modkey, "Mod1" }, "KP_2", function () awful.client.incwfact( 0.01) end),
awful.key({ modkey, "Mod1" }, "KP_8", function () awful.client.incwfact(-0.01) end),
From: http://stackoverflow.com/questions/17705888/resizing-window-vertically
- (1423)How to allow Emacs (or any other window) to truely maximize in AwesomeWM?
Add a rule to rc.lua:
{ rule = { class = "Emacs" },
properties = { size_hints_honor = false } },
From: http://earthwithsun.com/questions/751075/emacs-maximized-but-leaves-few-pixels-in-awesome-wm
- (1458)How to prevent the display/screen to go blank (eg. when watching movies)?
1. Stop the screensaver
pkill gnome-screensaver
xscreensaver-command --exit
2. Stop Xorg from blanking
xset s off ; xset s noblank ; xset s 0 0 ; # xset s 3600 3600
3. Stop DMPS from blanking
xset dpms standby 0 ; xset dpms suspend 0 ; xset dpms off 0
xset dpms force on ; xset -dpms
3b. Verify Xorg's settings
xset -q
4. Stop console from blanking
setterm -blank 0 ; setterm -powersave off ; setterm -powerdown 0
#echo -ne "\033[9;0]" >> /etc/issue # does that work?
From: https://wiki.archlinux.org/index.php/Display_Power_Management_Signaling
- (1486)How to set/remove (WindowManager's) key bindings in XFCE4?
When using Settings > Window Manager > Keyboard, some changes happen, but:
- it's not recorded in the GUI (for instance, even if redefined/cleared "Hide window" remains set to Alt-F9)
- the wrong key bindings are created (eg: my keyboard has swapped Shift&CTL-L, and when I try to redifine a command to CTL-L+Alt-L+i, the keybinding is set to Shift)
- multiple (conflicting) entries are created in the file.
So, the best is to edit the following file manually:
~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
- (1529)How to adjust backlight in a dual monitor's configuration?
xrandr --output VGA1 --brightness .5 ## only plays with gamma values... not actual backlight
or:
redshift -l 45:5 -t 6500:6500 -b 0.5
From: http://superuser.com/questions/256084/how-to-change-brightness-on-crt-display-through-the-linux-command-lin
https://bbs.archlinux.org/viewtopic.php?id=124391
- (1530)How to set dual screen (resolution, position & color balance)?
## Set resolution v1.0
#xrandr --output LVDS1 --mode "1366x768"
#xrandr --output VGA1 --mode "1600x900"
## Set resolution v2.0
xrandr --output LVDS1 --auto
xrandr --output VGA1 --auto
## Position screens with respect to one another
xrandr --output VGA1 --right-of LVDS1
## Set color balance (less blue, as it seems this troubles our sleeping)
#xgamma -screen LVDS1 -bgamma .6
#xgamma -screen VGA1 -bgamma .6
xrandr --output LVDS1 --brightness 1.0 --gamma 1.0:1.0:.6
xrandr --output VGA1 --brightness 1.0 --gamma 1.0:1.0:.6
# Decrease LVDS's brigthness to a little less than VGA so that they look the same
xbacklight -set 40
# Does not exists anymore in 2015?
# xrandr --output LVDS1 --set BACKLIGHT_CONTROL {combination, native, legacy,kernel}
# xrandr --output LVDS1 --set BACKLIGHT 1001
# xrandr --output VGA1 --set BACKLIGHT_CONTROL {combination, native, legacy,kernel}
# xrandr --output VGA1 --set BACKLIGHT 1001
- (1599)How to know the names of the Xorg/X11 colors?
locate rgb.txt
less /etc/X11/rgb.txt
From: https://en.wikipedia.org/wiki/X11_color_names
- (1606)How to restart AwesomeWM from commandline (~ dynamically send any command to awesome)?
echo 'awesome.restart()' | awesome-client
From: https://awesome.naquadah.org/wiki/FAQ
- (1617)My AwesomeWM (v3.5.6) config file (for 2 screens display)
---- TODO1: Minimizing with C-A-i does not work correctly in 3.5.6 (works only if mouse is on systray) => use if mouse clic on systray
---- TODO2: Do so that the systray (icons to control running softs: dropbox, nm-applet, etc.) appears on the screen where the mouse is
-- Standard awesome library
local gears = require("gears")
local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus")
-- Widget and layout library
local wibox = require("wibox")
-- Theme handling library
local beautiful = require("beautiful")
-- Notification library
local naughty = require("naughty")
local menubar = require("menubar")
-- Load Debian menu entries
require("debian.menu")
-- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to
-- another config (This code will only ever execute for the fallback config)
if awesome.startup_errors then
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors })
end
-- Handle runtime errors after startup
do
local in_error = false
awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop
if in_error then return end
in_error = true
naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = err })
in_error = false
end)
end
-- }}}
-- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers.
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
-- GM: Load script that launches startup applications
HOME = "/home/guillaume/"
awful.util.spawn_with_shell("source " .. HOME .. ".xsession")
-- awful.util.spawn_with_shell("source " .. HOME .. "Softs/run_ssh_add");
-- This is used later as the default terminal and editor to run.
terminal = "uxterm -bg WhiteSmoke -fg black"
editor = os.getenv("EDITOR") or "emacs"
editor_cmd = terminal .. " -e " .. editor
xlockcmd = HOME .. "Softs/run_screensaver"
minBattery = .2
-- Default modkey.
-- Usually, Mod4 is the key with a logo between Control and Alt.
-- If you do not like this or do not have such a key,
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
-- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod1"
-- Table of layouts to cover with awful.layout.inc, order matters.
local layouts =
{
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
awful.layout.suit.max,
awful.layout.suit.max.fullscreen,
awful.layout.suit.magnifier
}
-- }}}
-- {{{ Wallpaper
if beautiful.wallpaper then
for s = 1, screen.count() do
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
end
end
-- }}}
-- {{{ Tags
-- Define a tag table which hold all screen tags.
tags = {}
for s = 1, screen.count() do
-- Each screen has its own tag table.
tags[s] = awful.tag({ "Chat-" .. s, "W1-" .. s, "W2-" .. s, "W3-" .. s, "Mail-" .. s, "Web-" .. s, "Mumule-" .. s }, s, layouts[2])
end
-- }}}
-- {{{ Menu
-- Create a laucher widget and a main menu
myawesomemenu = {
{ "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart },
{ "quit", awesome.quit }
}
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
{ "Debian", debian.menu.Debian_menu.Debian },
{ "Terminal", terminal },
--{ "PidGin", "pidgin" },
{ "Nautilus", "nautilus" },
{ "Firefox", "firefox" },
{ "Chromium", HOME .. ".mychromium" },
{ "Midori", HOME .. ".mymidori" },
{ "QupZilla", "qupzilla" },
{ "Thunderbird", "thunderbird" },
{ "Xlock", xlockcmd }
}
})
mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menu = mymainmenu })
-- Menubar configuration
menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}}
-- {{{ Wibox
-- Create a textclock widget
mytextclock = awful.widget.textclock("%a %b %d, %R (w%V)", 1)
myxchatbox = wibox.widget.imagebox()
myxchatbox:set_image("/usr/share/icons/HighContrast/24x24/apps/xchat.png")
myxchatbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("xchat") end)))
-- mypidginbox = wibox.widget.imagebox()
-- mypidginbox:set_image("/usr/share/icons/HighContrast/24x24/apps/pidgin.png")
-- mypidginbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("pidgin") end)))
mynautilusbox = wibox.widget.imagebox()
mynautilusbox:set_image("/usr/share/icons/GartoonRedux/24x24/apps/nautilus.png")
mynautilusbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("nautilus --no-desktop") end)))
myskypebox = wibox.widget.imagebox()
myskypebox:set_image("/usr/share/icons/hicolor/24x24/apps/skype.png")
myskypebox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("skype") end)))
mymidoribox = wibox.widget.imagebox()
mymidoribox:set_image("/usr/share/icons/hicolor/24x24/apps/midori.png")
mymidoribox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(HOME .. ".mymidori") end)))
myqupzillabox = wibox.widget.imagebox()
myqupzillabox:set_image("/usr/share/app-install/icons/qupzilla.png")
myqupzillabox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("qupzilla") end)))
myfirefoxbox = wibox.widget.imagebox()
myfirefoxbox:set_image("/usr/lib/firefox/browser/chrome/icons/default/default32.png")
myfirefoxbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("firefox") end)))
mychromiumbox = wibox.widget.imagebox()
mychromiumbox:set_image("/usr/share/icons/hicolor/24x24/apps/chromium-browser.png")
mychromiumbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(HOME .. ".mychromium") end)))
mythunderbirdbox = wibox.widget.imagebox()
mythunderbirdbox:set_image("/usr/lib/thunderbird/chrome/icons/default/default32.png")
mythunderbirdbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("thunderbird") end)))
myaudaciousbox = wibox.widget.imagebox()
myaudaciousbox:set_image("/usr/share/icons/hicolor/48x48/apps/audacious.png")
myaudaciousbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn("audacious") end)))
myxlockbox = wibox.widget.imagebox()
myxlockbox:set_image("/usr/share/icons/gnome/24x24/actions/lock.png")
myxlockbox:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn(xlockcmd) end)))
-- mytextbox = wibox.widget.textbox()
------------------------------------ WIDGETS START
-- GM: To get the output of a shell command
function capture(cmd2Run, asNumber)
local f = assert(io.popen(cmd2Run, 'r'))
local s = assert(f:read('*a'))
f:close()
if asNumber
then
return tonumber(s)
end
return s
end
--- CPU
mycpugraph0 = awful.widget.graph()
mycpugraph0:set_width(25)
mycpugraph0:set_background_color('#000000')
mycpugraph0:set_color('#F01010')
--
mycpugraph1 = awful.widget.graph()
mycpugraph1:set_width(25)
mycpugraph1:set_background_color('#000000')
mycpugraph1:set_color('#D03030')
--
mycpugraph2 = awful.widget.graph()
mycpugraph2:set_width(25)
mycpugraph2:set_background_color('#000000')
mycpugraph2:set_color('#E02020')
--
mycpugraph3 = awful.widget.graph()
mycpugraph3:set_width(25)
mycpugraph3:set_background_color('#000000')
mycpugraph3:set_color('#C04040')
--- BAT
mybatprogressbar = awful.widget.progressbar()
mybatprogressbar:set_width(10)
--mybatprogressbar:set_height(10)
mybatprogressbar:set_vertical(true)
mybatprogressbar:set_background_color('#000000')
-- mybatprogressbar:set_color('#F0F0F0')
mybatprogressbar:set_color({ type = "linear", from = { 0,0 }, to = { 0,10 }, stops = { {0, "#444444"}, {0.5, "#DDDDDD"}, {1, "#EEEEEE"}}})
--- NET
mynetgraphin = awful.widget.graph()
mynetgraphin:set_width(35)
mynetgraphin:set_background_color('#000000')
mynetgraphin:set_color('#00D000')
--
mynetgraphout = awful.widget.graph()
mynetgraphout:set_width(35)
mynetgraphout:set_background_color('#000000')
mynetgraphout:set_color('#00B000')
-- RAM / SWAP
myramgraph = awful.widget.graph()
myramgraph:set_width(30)
myramgraph:set_background_color('#000000')
myramgraph:set_color('#0000F0')
--
myswapgraph = awful.widget.graph()
myswapgraph:set_width(30)
myswapgraph:set_background_color('#000000')
myswapgraph:set_color('#00E0E0')
--
myrootfsprogressbar = awful.widget.progressbar()
myrootfsprogressbar:set_width(10)
myrootfsprogressbar:set_vertical(true)
myrootfsprogressbar:set_background_color('#000000')
-- myrootfsprogressbar:set_color('#AEAEA0')
myrootfsprogressbar:set_color({ type = "linear", from = { 0,0 }, to = { 0,10 }, stops = { {0, "#FFFFFE"}, {0.5, "#FFA175"}, {1, "#000000"}}})
-- Initializations
cpu0Last = capture(HOME .. "Softs/getCPUpercent 0", true);
cpu1Last = capture(HOME .. "Softs/getCPUpercent 1", true);
cpu2Last = capture(HOME .. "Softs/getCPUpercent 2", true);
cpu3Last = capture(HOME .. "Softs/getCPUpercent 3", true);
--
netinLast = capture(HOME .. "Softs/getNETpercent in", true);
netoutLast = capture(HOME .. "Softs/getNETpercent out", true);
--
bat = capture(HOME .. "Softs/getBATpercent");
mybatprogressbar:set_value(bat);
--
rootfs = capture(HOME .. "Softs/getFSpercent root");
myrootfsprogressbar:set_value(rootfs);
-- Updates of the values
myhighspeedtimer = timer({ timeout = 1 })
myhighspeedtimer:connect_signal("timeout", function()
cpu0 = capture(HOME .. "Softs/getCPUpercent 0", true);
mycpugraph0:add_value(cpu0-cpu0Last);
-- mytextbox:set_text('<span color="white">CPU VALUE=' .. cpu0)
cpu0Last=cpu0
cpu1 = capture(HOME .. "Softs/getCPUpercent 1", true);
mycpugraph1:add_value(cpu1-cpu1Last);
-- mytextbox:set_text('<span color="white">CPU VALUE=' .. cpu1)
cpu1Last=cpu1
cpu2 = capture(HOME .. "Softs/getCPUpercent 2", true);
mycpugraph2:add_value(cpu2-cpu2Last);
-- mytextbox:set_text('<span color="white">CPU VALUE=' .. cpu2)
cpu2Last=cpu2
cpu3 = capture(HOME .. "Softs/getCPUpercent 3", true);
mycpugraph3:add_value(cpu3-cpu3Last);
-- mytextbox:set_text('<span color="white">CPU VALUE=' .. cpu3)
cpu3Last=cpu3
--
ram = capture(HOME .. "Softs/getRAMpercent", true);
myramgraph:add_value(ram);
swap = capture(HOME .. "Softs/getSWAPpercent", true);
myswapgraph:add_value(swap);
--
netin = capture(HOME .. "Softs/getNETpercent in", true);
mynetgraphin:add_value(netin-netinLast);
-- mytextbox:set_text('<span color="white">NETIN VALUE=' .. netin)
netinLast = netin;
netout = capture(HOME .. "Softs/getNETpercent out", true);
mynetgraphout:add_value(netout-netoutLast);
-- mytextbox:set_text('<span color="white">NETOUT VALUE=' .. netout)
netoutLast = netout;
--
end)
myhighspeedtimer:start()
mylowspeedtimer = timer({ timeout = 30 })
mylowspeedtimer:connect_signal("timeout", function()
bat = capture(HOME .. "Softs/getBATpercent", true);
if bat < minBattery
then
mybatprogressbar:set_background_color('#FFFFFF')
--mybatprogressbar:set_color('#FF0000')
mybatprogressbar:set_color({ type = "linear", from = { 0,0 }, to = { 0,10 }, stops = { {0, "#FF0000"}, {0.5, "#FF0000"}, {1, "#FF0000"}}})
else
mybatprogressbar:set_background_color('#000000')
--mybatprogressbar:set_color('#F0F0F0')
mybatprogressbar:set_color({ type = "linear", from = { 0,0 }, to = { 0,10 }, stops = { {0, "#444444"}, {0.5, "#DDDDDD"}, {1, "#EEEEEE"}}})
end
mybatprogressbar:set_value(bat);
--
rootfs = capture(HOME .. "Softs/getFSpercent root");
myrootfsprogressbar:set_value(rootfs);
end)
mylowspeedtimer:start()
------------------------------------ WIDGETS END
-- Create a wibox for each screen and add it
mywibox = {}
mypromptbox = {}
mylayoutbox = {}
mytaglist = {}
mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly),
awful.button({ modkey, "Control" }, 1, awful.client.movetotag),
awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag),
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
)
mytasklist = {}
toggleminimize = function (c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() then
awful.tag.viewonly(c:tags()[1])
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end
end
mytasklist.buttons = awful.util.table.join(
awful.button({ }, 1, toggleminimize),
awful.button({ }, 3, function ()
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({
theme = { width = 250 }
})
end
end),
awful.button({ }, 4, function ()
awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end),
awful.button({ }, 5, function ()
awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end))
for s = 1, screen.count() do
-- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
-- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(mylauncher)
left_layout:add(mytaglist[s])
left_layout:add(mypromptbox[s])
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
if s == 1 then right_layout:add(wibox.widget.systray()) end
-- if s == 2 then right_layout:add(wibox.widget.systray()) end
-- right_layout:add(wibox.widget.systray())
right_layout:add(mycpugraph0)
right_layout:add(mycpugraph1)
right_layout:add(mycpugraph2)
right_layout:add(mycpugraph3)
--
right_layout:add(mybatprogressbar)
--
right_layout:add(mynetgraphin)
right_layout:add(mynetgraphout)
--
right_layout:add(myswapgraph)
right_layout:add(myramgraph)
--
right_layout:add(myrootfsprogressbar)
--
right_layout:add(myxchatbox)
-- right_layout:add(mypidginbox)
right_layout:add(mynautilusbox)
right_layout:add(myskypebox)
right_layout:add(mymidoribox)
right_layout:add(myqupzillabox)
right_layout:add(myfirefoxbox)
right_layout:add(mychromiumbox)
right_layout:add(mythunderbirdbox)
right_layout:add(myaudaciousbox)
right_layout:add(myxlockbox)
-- right_layout:add(mytextbox)
right_layout:add(mytextclock)
right_layout:add(mylayoutbox[s])
-- Now bring it all together (with the tasklist in the middle)
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_middle(mytasklist[s])
layout:set_right(right_layout)
mywibox[s]:set_widget(layout)
end
-- }}}
-- {{{ Mouse bindings
root.buttons(awful.util.table.join(
awful.button({ }, 3, function () mymainmenu:toggle() end),
awful.button({ }, 4, awful.tag.viewnext),
awful.button({ }, 5, awful.tag.viewprev)
))
-- }}}
-- {{{ Key bindings
globalkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "Left", awful.tag.viewprev ),
awful.key({ modkey, "Control" }, "Right", awful.tag.viewnext ),
awful.key({ modkey, "Control" }, "Escape", awful.tag.history.restore),
awful.key({ modkey, "Control" }, "j",
function ()
awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end
end),
awful.key({ modkey, }, "Tab",
function ()
awful.client.focus.history.previous()
if client.focus then
client.focus:raise()
end
end),
-- Standard program
awful.key({ modkey, "Control" }, "Return", function () awful.util.spawn(terminal) end),
awful.key({ modkey, "Control" }, "r", awesome.restart),
awful.key({ modkey, "Control" }, "q", awesome.quit),
-- GM: Cannot use KP_8/KP_2. Indeed, in my config @PreSans, the keyboard is redefined after awesome is loaded => I must use here the definition of keys as it is when awesome starts up, i.e. in standard Xorg config
awful.key({ modkey, "Control" }, "KP_Right", function () awful.tag.incmwfact( 0.05) end),
awful.key({ modkey, "Control" }, "KP_Left", function () awful.tag.incmwfact(-0.05) end),
awful.key({ modkey, "Control" }, "l", function () awful.util.spawn(xlockcmd) end),
awful.key({ modkey, "Control" }, "space", function () awful.layout.inc(layouts, 1) end),
awful.key({ modkey, "Control", "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Prompt
awful.key({ modkey, "Control" }, "x", function () mypromptbox[mouse.screen]:run() end),
-- awful.key({ modkey }, "x",
-- function ()
-- awful.prompt.run({ prompt = "Run Lua code: " },
-- mypromptbox[mouse.screen].widget,
-- awful.util.eval, nil,
-- awful.util.getdir("cache") .. "/history_eval")
-- end),
-- Menubar
awful.key({ modkey }, "p", function() menubar.show() end)
)
clientkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "k", function (c) c:kill() end),
awful.key({ modkey, "Control" }, "f", awful.client.floating.toggle ),
awful.key({ modkey, "Shift" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
awful.key({ modkey, "Control" }, "i", toggleminimize), -- function (c) c.minimized = not c.minimized end
awful.key({ modkey, "Control" }, "a",
function (c)
c.maximized_horizontal = not c.maximized_horizontal
c.maximized_vertical = not c.maximized_vertical
end)
)
-- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, 9 do
globalkeys = awful.util.table.join(globalkeys,
-- View tag only.
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewonly(tag)
end
end),
-- Toggle tag.
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
local tag = awful.tag.gettags(screen)[i]
if tag then
awful.tag.viewtoggle(tag)
end
end),
-- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i]
if tag then
awful.client.movetotag(tag)
end
end
end),
-- Toggle tag.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i]
if tag then
awful.client.toggletag(tag)
end
end
end))
end
clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
awful.button({ modkey, "Control" }, 1, awful.mouse.client.move),
awful.button({ modkey, "Control" }, 3, awful.mouse.client.resize))
-- Set keys
root.keys(globalkeys)
-- }}}
-- {{{ Rules
-- Rules to apply to new clients (through the "manage" signal).
awful.rules.rules = {
-- All clients will match this rule.
{ rule = { },
properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons } },
{ rule = { class = "MPlayer" },
properties = { floating = true } },
{ rule = { class = "QEMU" },
properties = { floating = true } },
{ rule = { class = "pinentry" },
properties = { floating = true } },
{ rule = { class = "gimp" },
properties = { floating = true } },
{ rule = { class = "Qemu" },
properties = { floating = true } },
{ rule = { name = "Xpdf: Find" },
properties = { floating = true } },
{ rule = { class = "Xpdf" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
{ rule = { class = "GQview" },
properties = { maximized_horizontal = true, maximized_vertical = true } },
-- GM
{ rule = { class = "Emacs" },
properties = { floating = false, size_hints_honor = false } },
{ rule = { class = "Eclipse" },
properties = { tag = tags[1][2] } }, -- "Work1"
{ rule = { name = "Java" },
properties = { tag = tags[1][2] } }, -- "Work1"
{ rule = { class = "Xchat" },
properties = {
tag = tags[1][1],
maximized_horizontal = true,
maximized_vertical = true
},
}, -- "Chat"
{ rule = { class = "Pidgin" },
properties = {
tag = tags[1][1],
maximized_horizontal = true,
maximized_vertical = true
},
}, -- "Chat"
{ rule = { class = "NickServ" },
properties = {
tag = tags[1][1],
maximized_horizontal = true,
maximized_vertical = true
},
}, -- "Chat"
{ rule = { class = "Buddy List" },
properties = {
tag = tags[1][1],
maximized_horizontal = true,
maximized_vertical = true
},
}, -- "Chat"
{ rule = { class = "Skype" },
properties = { tag = tags[1][1] } }, -- "Chat"
{ rule = { class = "Audacious" },
properties = { tag = tags[1][4] } }, -- Work3
{ rule = { class = "Thunderbird" },
properties = {
tag = tags[screen.count()][5],
-- maximized_horizontal = true,
-- maximized_vertical = true,
},
}, -- Mail
{ rule = { class = "Mail" },
properties = {
tag = tags[screen.count()][5],
-- maximized_horizontal = true,
-- maximized_vertical = true,
},
}, -- Mail
{ rule = { name = "Firefox" },
properties = {
tag = tags[screen.count()][6],
-- maximized_horizontal = true,
-- maximized_vertical = true
},
}, -- Web
{ rule = { class = "Navigator" },
properties = {
tag = tags[screen.count()][6],
-- maximized_horizontal = true,
-- maximized_vertical = true
},
}, -- Web
{ rule = { class = "Chromium" },
properties = {
tag = tags[screen.count()][6],
maximized_horizontal = true,
maximized_vertical = true,
},
}, -- Web
{ rule = { class = "QupZilla" },
properties = {
tag = tags[screen.count()][7],
-- maximized_horizontal = true,
-- maximized_vertical = true,
},
}, -- Web
{ rule = { class = "Midori" },
properties = {
tag = tags[screen.count()][7],
-- maximized_horizontal = true,
-- maximized_vertical = true,
},
}, -- Web
{ rule = { class = "Xxxterm" },
properties = { tag = tags[1][6] } }, -- Web
{ rule = { class = "Amule" },
properties = { tag = tags[1][7] } }, -- Mumule
{ rule = { class = "Ktorrent" },
properties = { tag = tags[1][7] } }, -- Mumule
}
-- }}}
-- {{{ Signals
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup)
-- Enable sloppy focus
c:connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then
-- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c)
-- Put windows in a smart way, only if they does not set an initial position.
if not c.size_hints.user_position and not c.size_hints.program_position then
awful.placement.no_overlap(c)
awful.placement.no_offscreen(c)
end
elseif not c.size_hints.user_position and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count change
awful.placement.no_offscreen(c)
end
local titlebars_enabled = false
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
-- buttons for the titlebar
local buttons = awful.util.table.join(
awful.button({ }, 1, function()
client.focus = c
c:raise()
awful.mouse.client.move(c)
end),
awful.button({ }, 3, function()
client.focus = c
c:raise()
awful.mouse.client.resize(c)
end)
)
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(awful.titlebar.widget.iconwidget(c))
left_layout:buttons(buttons)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
right_layout:add(awful.titlebar.widget.stickybutton(c))
right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local middle_layout = wibox.layout.flex.horizontal()
local title = awful.titlebar.widget.titlewidget(c)
title:set_align("center")
middle_layout:add(title)
middle_layout:buttons(buttons)
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c):set_widget(layout)
end
end)
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
c.opacity = 1
end)
client.connect_signal("unfocus", function(c)
c.border_color = beautiful.border_normal
c.opacity = 0.7
end)
-- }}}
- (1636)How to configure the double-click behavior in an X terminal (a.k.a. how to make double-click select a whole path/url instead of a single word)?
You do it with X resources. I have a file, .Xresources, that contains these xterm-related resources:
XTerm*VT100.cutNewLine: false
XTerm*VT100.cutToBeginningOfLine: false
XTerm*VT100.charClass: 33:48,35:48,37:48,42:48,45-47:48,64:48,95:48,126:48
In my .xinitrc file, I have some line that merge in those resources:
if [ -f $userresources ]; then
/usr/X11/bin/xrdb -merge $userresources
fi
Those lines make xterm double-clicks and triple-clicks do what I like:
Double-click considers a "word" to include slash (/), dot (.), asterisk (*) and some other non-alphanumeric characters. That's the "charClass" resource. I had to do some tedious fiddling with that charClass to get it to do what I want. That mostly lets you double-click on URLs and fully- or partially-qualified paths to highlight them.
The other two lines make triple-click start from the word under the mouse, and go to the end of the line, but not include any new-line. That way, you can triple click on a command you just executed, paste it in another window, and because it has no new-line, you can edit it before running it in the other window.
The Arch Wiki (https://wiki.archlinux.org/index.php/X_resources) has an article on X resources, including a section on xterm resources, but those xterm resources aren't complete.
From: https://unix.stackexchange.com/questions/45925/how-to-configure-the-double-click-behavior-in-an-x-terminal
- (1657)How to stop the infinite MATE caja (1.10.3) respawn loop in PC-BSD?
Log-Off and log-in ON THE CONSOLE (tty1) then delete the following files manually:
~/.local/share/*
~/.config/caja/*
/tmp/* (as user)
From: https://www.linuxquestions.org/questions/slackware-14/caja-will-respawn-again-after-it%B4s-been-closed-4175561039/
- (1659)How to add a DELETE entry in the popup menu of Caja/Nautilus?
Go to Nautilus -> Preferences -> Behaviour and check "Include a Delete command that bypasses Trash"
From: https://askubuntu.com/questions/18863/how-to-delete-files-bypassing-trash
- (1692)How to run a program each time xscreensaver is started/stopped/blanks/unblanks?
For example, suppose you want to run a program that turns down the
volume on your machine when the screen blanks, and turns it back up
when the screen un-blanks. You could do that by running a Perl program
like the following in the background. The following program tracks the
output of the -watch command and reacts accordingly:
#!/usr/bin/perl
my $blanked = 0;
open (IN, "xscreensaver-command -watch |");
while (<IN>) {
if (m/^(BLANK|LOCK)/) {
if (!$blanked) {
system "sound-off";
$blanked = 1;
}
} elsif (m/^UNBLANK/) {
system "sound-on";
$blanked = 0;
}
}
Note that LOCK might come either with or without a preceding BLANK
(depending on whether the lock-timeout is non-zero), so the above
program keeps track of both of them.
From: https://www.jwz.org/xscreensaver/man3.html
- (1708)How to move XFCE panel to the bottom?
- Right Click on the Panel
- Go to Panel > Panel Preferences…
- Un-Check "Lock panel"
- Grab the panel by one of the ends. The handles (two vertical dots rows)on the ends.
- Drag the panel to the bottom.
From: http://www.namhuy.net/449/xfce-move-top-panel-to-bottom.html
- (1717)How to get the 2-fingers tap act like middle button (copy/paste)?
synclient "EmulateMidButtonTime=40" ## <- supposed to make Butt1+Butt2 close click emulate wheel-click
synclient "TapButton1=1"
synclient "TapButton2=2" ## <- simulates wheel-click with 2-fingers tap anywhere
synclient "TapButton3=3"
synclient "ClickFinger1=1"
synclient "ClickFinger2=2" ## <- simulate wheel-click with 2-fingers tap on left button
synclient "ClickFinger3=3"
From: https://wiki.archlinux.org/index.php/Touchpad_Synaptics#Synclient
http://www.x.org/archive/X11R7.5/doc/man/man4/synaptics.4.html
- (1722)How to recover the mouse pointer when it disappears?
- [WHAT WORKED FOR ME] Go to tty1 (ctrl+alt+f1) and then back to GUI (ctrl+alt+f7)
- Remove & add again mouse driver
sudo modprobe -r psmouse # disable the driver
sudo modprobe psmouse # enable the mouse driver
- sudo service lightdm restart
- gsettings set org.gnome.settings-daemon.plugins.cursor active false
From: https://askubuntu.com/questions/626078/mouse-cursor-invisible-after-15-04-update
- (1726)How to set the Gtk theme through commandline (i.e. without installing the whole gnome tools)?
I] Gtk-2
- Create a file "~/.gtkrc-2.0" with contents:
include '/home/<username>/.gtkrc.mine'
- Create ".gtkrc-1.2-gnome2" with the same content
- Create ".gtkrc.mine" with contents:
gtk-theme-name = "Clearlooks"
II] Gtk-3
- Create a file "~/.config/gtk-3.0/settings.ini" with contents:
[Settings]
gtk-icon-theme-name = <icon-theme-name>
gtk-theme-name = <gtk-3-theme-name>
- Create a file '.gtkrc.mine' with contents:
gtk-icon-theme-name = "Tango"
From: https://awesomewm.org/wiki/Customizing_GTK_Apps
- (1731)How to change background image/wallpaper in awesome 3.5?
PROBLEM: awsetbg does not exist anymore.
SOLUTION:
- set gears as global in ~/.config/awesome/rc.lua
gears = require("gears") instead of local gears = require("gears")
- to change the image, run!
echo 'gears.wallpaper.maximized("<image>", <screen number>, true)' | awesome-client
- (1732)How to ensure xbindkeys actually executes the scripts configured for each key combination?
- Ensure script is executable (for user)
- Ensure it is a script (by adding #!/path/to/shell as header/1rst line)
- Check with xbindkeys -f <your.rc> -n -v
- (1763)My ~/.xbindkeysrc
[note: "command"-lines are duplicated since only 2 lines of key descriptions are expected after a "command"-line]
keystate_numlock = enable
"~/Softs/decrease_volume"
m:0x8 + c:116
Alt + Down
"~/Softs/decrease_volume"
m:0x18 + c:116
Alt+Mod2 + Down
"~/Softs/decrease_volume"
m:0x50 + c:116
Mod2+Mod4 + Down
"~/Softs/increase_volume"
m:0x8 + c:111
Alt + Up
"~/Softs/increase_volume"
m:0x18 + c:111
Alt+Mod2 + Up
"~/Softs/increase_volume"
m:0x50 + c:111
Mod2+Mod4 + Up
"~/Softs/toggle_volume"
m:0x8 + c:47
Alt + m
"~/Softs/toggle_volume"
m:0x18 + c:47
Alt+Mod2 + m
"~/Softs/toggle_volume"
m:0x50 + c:47
Mod2+Mod4 + m
"~/Softs/decrease_brightness"
m:0x8 + c:113
Alt + Left
"~/Softs/decrease_brightness"
m:0x18 + c:113
Alt+Mod2 + Left
"~/Softs/decrease_brightness"
m:0x50 + c:113
Mod2+Mod4 + Left
"~/Softs/increase_brightness"
m:0x8 + c:114
Alt + Right
"~/Softs/increase_brightness"
m:0x18 + c:114
Alt+Mod2 + Right
"~/Softs/increase_brightness"
m:0x50 + c:114
Mod2+Mod4 + Right
"~/Softs/set_screens.sh"
m:0x8 + c:74
Alt + F8
"~/Softs/set_screens.sh"
m:0x18 + c:74
Alt+Mod2 + F8
"~/Softs/set_screens.sh"
m:0x50 + c:74
Mod2+Mod4 + F8
"~/Softs/toggle_mousepad.sh"
m:0x8 + c:75
Alt + F9
"~/Softs/toggle_mousepad.sh"
m:0x18 + c:75
Alt+Mod2 + F9
"~/Softs/toggle_mousepad.sh"
m:0x50 + c:75
Mod2+Mod4 + F9
"~/Softs/decrease_brightness"
m:0x10 + c:71
Mod2 + XF86MonBrightnessUp
"~/Softs/increase_brightness"
m:0x10 + c:72
Mod2 + XF86MonBrightnessDown
"~/Softs/decrease_volume"
m:0x10 + c:122
Mod2 + XF86AudioLowerVolume
"~/Softs/increase_volume"
m:0x10 + c:123
Mod2 + XF86AudioRaiseVolume
"~/Softs/toggle_volume"
m:0x10 + c:121
Mod2 + XF86AudioMute
"~/Softs/toggle_mousepad.sh"
m:0x10 + c:199
Mod2 + XF86TouchpadToggle
# XF86AudioPlay, XF86AudioStop, XF86AudioPrev, XF86AudioNext, XF86Eject, XF86AudioMicMute
# XF86Sleep, XF86WakeUp
# XF86Copy, XF86Cut, XF86Paste
# XF86Open, XF86Close
# XF86Calculator, XF86Explorer, XF86WWW, XF86Mail, XF86ScreenSaver
# XF86Battery, XF86Bluetooth, XF86WLAN
- (1764)How to prevent Firefox (or any app) to popup on a wrong desktop of XFCE?
PROBLEM: When a new tab is opened from an external link in Firefox, it
asks the WM to show the window containing the new tab. If the window
that has requested to be raised is not on the current desktop, the
Xfce Window manager will bring it to the current desktop by
default.
If you do not want this behavior, there is a hidden option to control
this behavior. For Xfce 4.4 in ~/.config/xfce4/xfwm4/xfwm4rc you can
put the following:
activate_action=bring|switch|none
For Xfce 4.6 and 4.8 you can go to Xfce Menu > Settings > Window
Manager Tweaks and go to the tab Focus, or you need to use the
xfconf-query tool to change the setting:
xfconf-query -c xfwm4 -p /general/activate_action -s bring|switch|none
As the name suggests, the “bring” option moves the window requesting
to be raised to the current workspace, the “switch” option switches
workspaces, and the “none” option takes no action.
The above command edits the file
“~/.config/xfce4/xfconf/xfce-perchannel-xml/xfwm4.xml” by adding or
modifying this line: “ <property name=“activate_action” type=“string”
value=“switch”/> ”
From: https://wiki.xfce.org/faq#window_manager
- (1888)How to get the output of a shell command in Lua (AwesomeWM)?
If you have io.popen, then this is what I use:
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
From: http://stackoverflow.com/questions/132397/get-back-the-output-of-os-execute-in-lua
- (1932)How to make application windows always on top in Linux mint?
On Linux, with a window manager that follows the Extended Window
Manager Hints (EWMH) you can do this by setting the "above" property.
wmctrl -r :SELECT: -b add,above
and then click in the window that you want to have at the top. You can
also replace :SELECT: by a substring of a window title (this better be
unique as the first match found is used).
From: http://unix.stackexchange.com/questions/180790/how-to-make-application-windows-always-on-top-in-linux-mint
- (3835)What fonts to used to have access to pretty icons?
https://www.nerdfonts.com/cheat-sheet
- (3840)How to Enable/Disable the XFCE compositor (a.k.a. How to solve slow XFCE or black screen in XFCE 3D/accelerated windows)?
PROBLEM When the composite is enabled, 3D acceleration won't work. Sometimes you'll get only black screens or a sluggish WM.
killall xfwm4 && xfwm4 --compositor={on,off} &
You can also add this option to the script that is started by your DM.
You can also change that by GUI:
window manager > tweaks.
From: https://ubuntuforums.org/showthread.php?t=272890
https://blog.programster.org/xfce-slow-desktop-compositing
- (1984)How to save/restore monitor configuration profiles on a per-user and per-display basis?
Regarding a tool which can store monitor configuration profiles on a
per-user and per-display basis, autorandr will do exactly
that. https://github.com/wertarbyte/autorandr.
My laptop has an NVIDIA card, so I use the disper backend instead of
xrandr: http://willem.engen.nl/projects/disper/. Autorandr will use
disper as the backend to manage your monitors if you call it as
autodisper. For the rest of this post though, I'll refer to it as
autorandr for consistency.
You can save profiles with autorandr --save profile_name. Running
autorandr by itself will then give you a list of profiles, and
identify which one is detected as the current configuration.
For instance:
$ autorandr
laptop
syncmaster19 (detected)
You can tell it to automatically load the appropriate profile for the
current configuration with autorandr --change. This command, paired
with a udev rule to run it when it is hotplugged, would do what you
requested.
As an added precaution I've appended --default laptop to that command,
which will make it default to the laptop's display if there is no
saved profile that matches the current configuration. So the full
command I use to switch displays is:
autorandr --change --default laptop
Unfortunately my machine doesn't give any udev output when I hotplug
my monitor. I'm using the NVIDIA proprietary drivers, so that isn't
surprising. So I have bound it to the XF68Display key (Fn-F8) for now,
which is almost as good. shareimprove this answer
NOTE: (Jack Senechal) autorandr was a waste of time, bad documented,
random monitor blinks, no install/uninstall instructions. Could solve
it using udev – Leo Gallucci Jan 26 '14 at 15:38
From: http://unix.stackexchange.com/questions/4489/a-tool-for-automatically-applying-randr-configuration-when-external-display-is-p
- (2010)How to add directories/"Places" to the left/side pane of Thunar?
~/.gtk-bookmarks
~/.config/gtk-3.0/bookmarks
From: https://bugs.launchpad.net/ubuntu/+source/thunar/+bug/1280641
- (2006)How to get an on-screen virtual keyboard (a.k.a what do I do when I have only the mouse wokring in my graphical environment and still need to type some things)?
apt-get install onboard # ~3MB
apt-get install florence # ~1.6MB crashes on Ubuntu 16.10
There's also "GOK (GNOME Onscreen Keyboard)" and "kvkbd", but they are
not distributed as packages for Ubuntu.
From: http://xmodulo.com/onscreen-virtual-keyboard-linux.html
- (2027)How to know which version of Qt you are running/is installed?
Starting with Qt 5.3 you can use:
$ qtdiag
From: http://stackoverflow.com/a/40112592
- (2034)How to enter path/file location manually in GTK 3 open/save dialog (e.g.: FF 52+)?
PROBLEM: Many apps use the GTK 3 toolkit. Unlike the GTK 2 dialogs,
where there is a special button to enter the "location" text box
(place where you can copy-paste a path), the GTK 3 dialogs have no
option to do this.
SOLUTION: To fix this annoyance, you can use the good old CTRL-L hotkey.
http://winaero.com/blog/how-to-enter-file-location-manually-in-gtk-3-opensave-dialog/
- (2044)How to open newly spawned windows (== opened programs) in the screen where the mouse/focus is? [DOESNOT WORK: var mouse.screen is nil at startup]
What you want to do is modify the manage signal for clients; this signal is emitted whenever a new client is spawned. In the most recent version of awesome, this signal is used in the default rc.lua, and the relevant code begins like this:
client.connect_signal("manage", function (c, startup)
You are going to want to add the following code to the function passed to that signal:
awful.client.movetoscreen(c, mouse.screen)
This tells awesome to move the client to the screen the mouse is on. You could also do it for the screen the active client is on, if you prefer:
awful.client.movetoscreen(c, client.focus.screen)
From: http://stackoverflow.com/questions/12648254/open-programs-to-active-selected-screen-in-awesome-wm
- (2064)How to open windows on focused screen by default?
awful.rules.rules = {
{
rule = { },
properties = {
...
screen = awful.screen.focused,
...
}
}
From: https://github.com/awesomeWM/awesome/issues/1091
- (2090)Where are gnome's File Associations stored?
~/.local/share/applications/mimeapps.list
From: https://unix.stackexchange.com/questions/41372/changing-file-associations-in-gnome#41374
- (2101)How can I switch users from the command line?
$ dm-tool switch-to-greeter
From: https://askubuntu.com/questions/111116/how-can-i-invoke-a-user-switch-from-the-command-line
- (2113)How to take a screenshot with the mouse pointer?
xfce4-screenshooter -m -d 5 # include pointer, delay 5 seconds
gnome-screenshot -p -d 5 # include pointer, delay 5 seconds
Gimp: File > Create > Screenshot > Entire Screen > Include Mouse Pointer
[NOTE: scrot/ImageMagick::import => does not seem possible]
From: https://askubuntu.com/questions/545430/how-to-take-a-screenshot-with-the-actual-pointer-icon
- (2212)How to setup a udev rule to reset display settings when a new monitor is plugged in/out?
--/etc/udev/rules.d/50-auto-displays-byGM.rules
ACTION=="change", KERNEL=="card0", SUBSYSTEM=="drm", ENV{HOTPLUG}=="1", RUN+="/usr/bin/X11/auto_set_screens.sh > /tmp/output.drm"
--
udevadm control --reload-rules
--/usr/bin/X11/auto_set_screens.sh
#!/usr/bin/env bash
# verifies if a display is connected
function isConnected () {
test -z "$(xrandr -q | grep $1' disconnected')" && echo "true" || echo "false"
}
export DISPLAY=:0
export XAUTHORITY=/home/guillaume/.Xauthority ### TODO: not generic enough!!!!
# !!!gamma values from "xrandr --verbose" are the invert of the value set!!!
# Configures VGA if connected
vga=$(isConnected "VGA-1")
echo "VGA=$vga"
if [[ "$vga" = "true" ]] ; then
echo "Setting VGA"
xrandr --output VGA-1 --auto
xrandr --output VGA-1 --brightness 1.0 --gamma 1.0:1.0:.6
fi
# Configures HDMI if connected
hdmi=$(isConnected "HDMI-1")
echo "HDMI=$hdmi"
if [[ "$hdmi" = "true" ]] ; then
echo "Setting HDMI"
xrandr -q --output LVDS-1 --auto --output HDMI-1 --auto --left-of LVDS-1
xrandr -q --output HDMI-1 --brightness 1.0 --gamma 1.0:1.0:.6
xgamma -q -screen HDMI-1 -rgamma 1.0 -ggamma 1.0 -bgamma 0.6
fi
# Configures LVDS if connected
lvds=$(isConnected "LVDS-1")
echo "LVDS=$lvds"
if [[ "$lvds" = "true" ]] ; then
echo "Setting LVDS"
xrandr -q --output LVDS-1 --auto --output VGA-1 --auto --right-of LVDS-1
xrandr -q --output LVDS-1 --brightness 1.0 --gamma 1.0:1.0:.6
xgamma -q -screen LVDS-1 -rgamma 1.0 -ggamma 1.0 -bgamma 0.6
# Decrease LVDS's brigthness to a little less than VGA so that
# they look the same
xbacklight -set 40
fi
# If a change occurred => reload awesomeWM ### TODO: not generic enough!!!
if [[ "$vga" = "true" || "$hdmi" = "true" || "$lvds" = "true" ]]; then
sleep 1
echo 'awesome.restart()' | awesome-client
fi
#exit 0
From: https://bbs.archlinux.org/viewtopic.php?id=170294
https://askubuntu.com/questions/790743/udev-rules-d-hot-plug-hdmi-monitor-script-not-running
https://github.com/codingtony/udev-monitor-hotplug/blob/master/usr/local/bin/monitor-hotplug.sh
- (2213)How to know how much monitors are currently connected to the computer?
xrandr -q | grep ' connected' | wc -l
From: https://unix.stackexchange.com/questions/13746/how-can-i-detect-when-a-monitor-is-plugged-in-or-unplugged
- (2214)How to detect that a monitor as been plugged in/out?
udevadm monitor
xrandr -q | grep ' connected'
cat /sys/class/drm/card0-<connector>/status
From: https://unix.stackexchange.com/questions/13746/how-can-i-detect-when-a-monitor-is-plugged-in-or-unplugged
- (2248)What screen/desktop image/video capture/record software to use?
Install OBS Studio:
sudo add-apt-repository ppa:obsproject/obs-studio
sudo apt-get update && sudo apt-get install obs-studio
There is also:
- [gtk-]recordmydesktop
- deskscribe
- kazam
- vokoscreen
Thanks PhM
- (2267)How to get the screen size (monitor diagonal in inches)?
----- compute_monitor_size.sh
#!/usr/bin/env bash
if [[ $# != 1 ]]; then
echo "USAGE: $0 <monitor name>"
else
monitor=$1
size=$(xrandr | grep "${monitor}" | sed -rn "s/.* ([0-9]*)mm x ([0-9]*)mm.*/scale=0; sqrt(\1*\1+\2*\2)\/25.4/p" | bc -l)
echo "Monitor ${monitor} is ${size}\""
fi
----- all_monitor_sizes.sh
#!/usr/bin/env bash
xrandr | grep ' connected' | cut -d ' ' -f 1 |
while read monitor ; do
. compute_monitor_size.sh "${monitor}"
done
Inspired by: https://gist.github.com/jmunsch/0579a4a633c84558b5b5
- (2290)How to display/configure a text/digital clock in AwesomeWM (e.g. to add week number)?
mytextclock = awful.widget.textclock("%a %b %d, %R (w%V)", 1)
From: https://unix.stackexchange.com/questions/149099/how-to-make-awesomewm-textclock-reflect-timezone-change#150329
- (2630)How to customize the XFCE's menu?
- You can use GUI tools like LXMenuEditor or MenuLibre
- If you want to change the hardcoded values
cp /usr/etc/xfce/xdg/menus/xfce-applications.menu ${XDG_CONFIG_HOME:-~/.config}/menus/ && vi ${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu
- If you want to Add an entry
cp /usr/share/applications/<application_to_add>.desktop ~/.local/share/applications/
- If you want to hide an entry
cp /usr/share/applications/<application_to_hide>.desktop ~/.local/share/applications/
+ add "NoDisplay=true" (hide the application from the menu but maintain the mime type associations) / "Hidden=true" (equivalent to deleting the file)
- Hide only root entries
cp /usr/share/applications/<application_to_hide>.desktop ~/.local/share/applications/
+ remove Category "X-Xfce-Toplevel"
- Create a new .desktop file
exo-desktop-item-edit --create-new ~/.local/share/applications
+ You'll need to manually edit the file to add "Categories"
NOTE: The categories determine where the new entry will be displayed. For display in the root menu, include category X-Xfce-Toplevel. For display in a sub-menu, include at least one of the categories defined for that sub-menu. These can be found by examining your ${XDG_CONFIG_HOME:-~/.config}/menus/xfce-applications.menu.
From: https://wiki.xfce.org/howto/customize-menu
- (2663)How to get the process ID/name that created a given X11 window?
I] Xorg native tools
- id:
xprop _NET_WM_PID
- name
xprop _NET_WM_NAME
II] xdotool pkg:
xdotool selectwindow getwindowpid
From: https://unix.stackexchange.com/questions/5478/what-process-created-this-x11-window
- (2671)How to changing window's border size in Xfce4?
- Find the currently used theme (Settings > Window Manager)
- Copy the corresponding directory to your home
cp -fr /usr/share/themes/<theme name>/ $HOME/.themes/
- Manually edit the title1-{active,inactive}.xpm files in:
$HOME/.themes/<theme name>/xfwm4/
From: https://mxlinux.org/wiki/xfce/changing-border-size-with-xfce4-window-manager/
https://superuser.com/questions/436541/how-do-you-increase-the-resize-border-thickness-in-xubuntu-12-04
- (2674)How can I keep my browser from workspace hopping (i.e. switching automatically of workspace (e.g. clicking a link in Thunderbird@VDesktop1 switches Firefox@VDesktop2 to VDesktop1) in XFCE4?
- Go to Settings > 'Windows Tweaks'
- Switch from option to "Switch to window's workplace" to "Do nothing"?
From: https://forum.xfce.org/viewtopic.php?id=6269#p22881
- (2712)How to enable "rolling up" windows (a.k.a. reducing the window to its title bar) with the rolling of the mouse wheel?
Go to "Settings Editor -> xfwm4 -> Uncheck option "mousewhell_rollup""
From: https://bbs.archlinux.org/viewtopic.php?pid=1756022#p1756022
- (2733)How to create a Symlink from Thunar in XFCE?
1. Go to Edit > Configure custom actions
2. Create a new "Symlink action"
3. Set the command to
ln -s %f %n.link
4. Configure when you when this action to appear in Thunar's popup menu in the "appearance conditions" Tab
From: https://stackoverflow.com/questions/21024258/custom-action-in-xfce4-thunar-how-to-create-a-link-under-current-directory#21694769
- (2762)How to make screen locking work in XFCE?
SOLUTION1: PREFERRED, as the config below is used in the script of SOLUTION2
First install a locker application, then set it as tour preferred one:
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "light-locker-command -l"
or if you don't have the variable yet:
$ xfconf-query -c xfce4-session -p /general/LockCommand -s "light-locker-command -l" --create -t string
SOLUTION2:
The file /usr/bin/xflock4 manages the screen lockers known/used by XFCE. If you've installed a locker app and it is not working, this might be because it is not already in the list of known locker apps.
Then add it in the for loop:
for lock_cmd in \
"xscreensaver-command -lock" \
"gnome-screensaver-command --lock" \
"light-locker-command -l"\
"dm-tool lock"
....
From: https://unix.stackexchange.com/questions/101806/why-doesnt-my-screen-lock-in-xfce/565725#565725
- (2845)How to create an initial AwesomeWM config file?
First, run the following to create the directory needed in the next step:
$ mkdir -p ~/.config/awesome/
Whenever compiled, awesome will attempt to use whatever custom settings are contained in ~/.config/awesome/rc.lua. This file is not created by default, so we must copy the template file first:
$ cp /etc/xdg/awesome/rc.lua ~/.config/awesome/
From: https://wiki.archlinux.org/index.php/Awesome#Configuration
- (2950)How to "simulate" a tiling WM with XFCE?
Install quicktile, then CTRL-ALT-KP{1..9} will allow you to place windows like in i3/awesome
From: https://ssokolow.com/quicktile/index.html
- (2977)How to change the wifi signal strength icon in XFCE?
PROBLEM: when selecting a dark theme for XFCE, the various levels of the wifi signal icon become unreadable (dark grey on darker grey)
SOLUTION:
You have to change the icon-set, not only the theme :)
Settings > Apparence > Icons
From: https://askubuntu.com/questions/960902/wifi-signal-strength-icon-how-to-change-it
- (2978)How to invert the colors of the whole screen at once, when an app does not propose a "dark theme"?
xcalib -i -a # -i=invert / -a=alter current color profile instead of creating one
From: https://manpages.ubuntu.com/manpages/bionic/en/man1/xcalib.1.html
- (2993)How to access the clipboard content from CLI?
Use "xsel"
From: https://askubuntu.com/questions/11925/a-command-line-clipboard-copy-and-paste-utility/11927#11927
- (2995)Where does XFCE store the setting for the selected desktop wallpaper file?
~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml
From: https://superuser.com/questions/1506179/where-does-xfce-store-the-setting-for-the-selected-desktop-wallpaper-file#1506230
- (2999)My i3 WM config file (4.17) [with: named workspaces + bg pics by workspace + lock + suspend + readaloud + inline-scripts]
# i3 config file (v4)
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
# Syntax: "bindsym [--release] [Modifiers+]keysym command"
# Where [Modifiers+] is a list of modifiers separated and ended with +. Recognized modifiers are
# Mod1 (usually aka "Alt" or "Meta")
# Mod2 ("NumLock")
# Mod3 (unused on default QWERTY layout)
# Mod4 (aka "Super" or "Windows-Key")
# Mod5 (e.g. "Alt_Gr" on german QWERTZ layout)
# Shift
# Control
# Mode_Switch
# From: https://faq.i3wm.org/question/6212/modshifta-works-strgalta-doesnt/%3C/p%3E.html
#set $lockercmd "/usr/bin/lxlock"
set $lockercmd "/usr/bin/light-locker-command -l" # Makes the Ubuntu sound evertime :[ # ALSO requires to run light-loacker deamon (cf + bas)
# set $lockercmd /usr/bin/i3lock
# set $lockercmd /usr/bin/dm-tool lock # Makes the Ubuntu sound evertime :[
set $mod control+Mod1
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
#font pango:monospace 8
font pango:DejaVu Sans Mono 8
# Start background pics script manager
exec --no-startup-id /home/$USER/Softs/.backgroundpic.sh
## ------ /home/$USER/Softs/.backgroundpic.sh
## #!/usr/bin/env bash
## xprop -spy -root _NET_CURRENT_DESKTOP | \
## while read -r event
## do
## name=$(i3-msg -t get_workspaces | jq ".[] | select(.foc#used==true) | .name" | tr -d '"')
## feh --bg-fill "/home/$USER/.pics/${name}.jpg"
## done
## -----
# Start LightLocker
exec --no-startup-id /usr/bin/light-locker
# lock session
bindsym --release $mod+l exec $lockercmd
# Suspend machine
### Requires (/etc/sudoers -- visudo):
### %sudo ALL=(ALL:ALL) NOPASSWD: /home/$USER/Softs/pm-suspend
bindsym $mod+Shift+s exec sh -c '$lockercmd && sleep 2 && sudo /home/$USER/Softs/pm-suspend'
# Start a terminal
bindsym $mod+Return exec xfce4-terminal
# kill focused window
bindsym $mod+Shift+k kill
# start dmenu (a program launcher)
bindsym $mod+m exec dmenu_run
bindsym $mod+Shift+m exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+Shift+Left focus left
bindsym $mod+Shift+Down focus down
bindsym $mod+Shift+Up focus up
bindsym $mod+Shift+Right focus right
# move focused window [Not the best key bindings :{ Mod4 would be better, but it is redefined as Multi_key here]
bindsym $mod+Mod5+Left move left
bindsym $mod+Mod5+Down move down
bindsym $mod+Mod5+Up move up
bindsym $mod+Mod5+Right move right
# change container layout (stacked, tabbed)
bindsym $mod+t layout tabbed
bindsym $mod+s layout stacking
# split in horizontal/vertical orientation
bindsym $mod+h split h
bindsym $mod+v split v
bindsym $mod+p layout toggle split
# # change focus between tiling / floating windows
# bindsym $mod+space focus mode_toggle
# enter fullscreen mode for the focused container
bindsym $mod+a fullscreen toggle
# toggle tiling / floating
bindsym $mod+f floating toggle
# # focus the parent container
# bindsym $mod+q focus parent
# focus the child container
# bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 1:Chat
set $ws2 2:Firefox
set $ws3 3:Thunderbird
set $ws4 4:Work1
set $ws5 5:Work2
set $ws6 6:Work3
set $ws7 7:Work4
set $ws8 8:8
set $ws9 9:9
set $ws10 10:10
# switch to workspace
## WAS: bindsym $mod+ampersand workspace number $ws1
bindsym $mod+ampersand workspace $ws1
bindsym $mod+eacute workspace $ws2
bindsym $mod+quotedbl workspace $ws3
bindsym $mod+apostrophe workspace $ws4
bindsym $mod+parenleft workspace $ws5
bindsym $mod+minus workspace $ws6
bindsym $mod+egrave workspace $ws7
bindsym $mod+underscore workspace $ws8
bindsym $mod+ccedilla workspace $ws9
bindsym $mod+agrave workspace $ws10
# Cycle through active workspaces
bindsym $mod+Right workspace next
bindsym $mod+Left workspace prev
# move focused container to workspace
bindsym $mod+Shift+ampersand move container to workspace $ws1
bindsym $mod+Shift+eacute move container to workspace $ws2
bindsym $mod+Shift+quotedbl move container to workspace $ws3
bindsym $mod+Shift+apostrophe move container to workspace $ws4
bindsym $mod+Shift+5 move container to workspace $ws5
bindsym $mod+Shift+minus move container to workspace $ws6
bindsym $mod+Shift+egrave move container to workspace $ws7
bindsym $mod+Shift+underscore move container to workspace $ws8
bindsym $mod+Shift+ccedilla move container to workspace $ws9
bindsym $mod+Shift+agrave move container to workspace $ws10
# # reload the configuration file
# bindsym $mod+Shift+r reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'xfce4-session-logout'"
# # resize window (you can also use the mouse for that)
# mode "resize" {
# # These bindings trigger as soon as you enter the resize mode
# # Pressing left will shrink the window’s width.
# # Pressing right will grow the window’s width.
# # Pressing up will shrink the window’s height.
# # Pressing down will grow the window’s height.
# bindsym j resize shrink width 10 px or 10 ppt
# bindsym k resize grow height 10 px or 10 ppt
# bindsym l resize shrink height 10 px or 10 ppt
# bindsym m resize grow width 10 px or 10 ppt
# # same bindings, but for the arrow keys
# bindsym Left resize shrink width 10 px or 10 ppt
# bindsym Down resize grow height 10 px or 10 ppt
# bindsym Up resize shrink height 10 px or 10 ppt
# bindsym Right resize grow width 10 px or 10 ppt
# # back to normal: Enter or Escape or $mod+r
# bindsym Return mode "default"
# bindsym Escape mode "default"
# bindsym $mod+r mode "default"
# }
# bindsym $mod+r mode "resize"
# # Start i3bar to display a workspace bar (plus the system information i3status
# # finds out, if available)
# bar {
# status_command i3status
# }
# Start TTS of current xselection with pico
bindsym $mod+Shift+F9 exec sh -c '/home/$USER/Softs/read_xselection.sh'
# Special keys to switch to/from to low-blue-light mode // NOT NEEDED if i3 is started from XFCE
##bindsym $mod+KP_4 exec sh -c '/home/$USER/Softs/decrease_brightness.sh'
##bindsym $mod+KP_6 exec sh -c '/home/$USER/Softs/increase_brightness.sh'
# Start a few programs at boot
exec --no-startup-id i3-msg 'workspace $ws1;exec psi ; workspace $ws2;layout tabbed;exec firefox ; workspace $ws3;exec thunderbird ; workspace $ws4;exec xfce4-terminal'
# Forces some App to be on specific workspaces
assign [class="Psi"] $ws1
assign [class="Firefox"] $ws2
assign [class="Thunderbird"] $ws3
# Make dialog floating => FF dialog boxes remain on current workspace
for_window [title="Save As"] move to workspace current
for_window [window_role="Dialog"] move to workspace current
for_window [window_role="GtkFileChooserDialog"] move to workspace current
for_window [window_role="MsgCompose"] move to workspace current
# Manage FF popups?
#for_window [window_role="pop-up"] floating enable
# switch to workspace with urgent window automatically
#for_window [urgent=latest] focus
# # The middle button over a titlebar kills the window
# bindsym --release button2 kill
# # The middle button and a modifer over any part of the window kills the window
# bindsym --whole-window $mod+button2 kill
- (3000)How to send a command to i3 WM?
i3-msg <command>
e.g.:
i3-msg reload # re-reads config file
i3-msg restart # re-starts in place (e.g. after upgrade)
i3-msg workspace next # Switches to next workspace
i3-msg workspace "XXX" # Switches to workspace XXX
i3-msg border normal # changes the border style of the windows
i3-msg -t get_tree # Dump the layout tree
From: man i3-msg
- (3001)How to configure i3 with XFCE (panels)?
I] Install the i3 Window Manager
sudo apt-get update
sudo apt-get install i3
II] Install i3ipc-GLib and i3 Workspaces Plugin
i3ipc is a prerequisite for being able to switch between i3 workspaces in XFCE.
sudo add-apt-repository ppa:aacebedo/libi3ipc-glib
sudo apt-get update
sudo apt-get install libi3ipc-glib
i3-workspaces-plugin is a wonderful plugin allows you to place an i3-compatible workspace switcher on your XFCE panel.
sudo add-apt-repository ppa:aacebedo/xfce4-i3-workspaces-plugin
sudo apt-get update
sudo apt-get install xfce4-i3-workspaces-plugin
III] Deactivate Xubuntu's window manager
- Open 'Session and Startup', and go to the 'Session' tab.
- Note xfwm4 and xfdesktop. These processes will be replaced by the i3 Window Manager.
- For xfwm4, click 'Immediately' and change it to the 'Never' option.
- For xfdesktop, click 'Immediately' and change it to the 'Never' option.
- Click the button: 'Save Session'.
- Go to the 'Application Autostart' tab to activate the i3 window manager in the next stage.
Note: leave xfce4-panel and Xfsettingsd as they are
IV] Activate the i3 window manager
- In the 'Session and Startup' window, make sure you are in the 'Application Autostart' tab.
- Click the button 'Add' to add i3 to the list of startup applications.
- Fill out the form:
Name: i3 (or whatever you want to call i3)
Description: Tiling Window Manager (or whatever you want)
Command: i3 (must be "i3", as below)
- Click the button: OK
- You should scroll down to the bottom of the list and verify that i3 is listed and checked.
- Click the button: Close
V] Remove non-i3 Keyboard Shortcuts
For the sake of peace-of-mind, as well as avoiding strange conflicts, let's use i3 for managing ALL keyboard shortcuts:
- Open the 'Keyboard' dialogue.
- Go to the 'Application Shortcuts' tab as above.
- Remove all keyboard shortcuts
NOTE: You can shift-select all of them and click the button: 'Remove'
- Click the button: Close
VI] Install a background image manager
apt install feh
Also see Tip#3008
VII] Configure i3
You can generate a "default" ~/.config/i3/config with:
i3-config-wizard
Or copy mine (see Tip#2999) or copy the original one from Feeble Nerd at the link below
From: https://feeblenerd.blogspot.com/2015/11/pretty-i3-with-xfce.html
- (3002)How to configure a Multi-Key modifier in i3?
You can simply use:
set $mod Mod4+Mod1 # Windows+Alt
But beware that you can only use Modifiers (in the sense of xmodmap -pm) here.
From: https://github.com/i3/i3/issues/3017#issuecomment-345719391
- (3003)How to create modes in i3 (a.k.a. How to manage "sub" control keys) (a.k.a. How to create more than 10 workspaces)?
set $mode_workspace "goto_ws"
mode $mode_workspace {
bindsym 1 workspace 1; mode "default"
bindsym 2 workspace 2; mode "default"
# […]
bindsym a workspace a; mode "default"
bindsym b workspace b; mode "default"
# […]
bindsym Escape mode "default"
}
bindsym $mod+w mode $mode_workspace
set $mode_move_to_workspace "moveto_ws"
mode $mode_move_to_workspace {
bindsym 1 move container to workspace 1; mode "default"
bindsym 2 move container to workspace 2; mode "default"
# […]
bindsym a move container to workspace a; mode "default"
bindsym b move container to workspace b; mode "default"
# […]
bindsym Escape mode "default"
}
bindsym $mod+shift+w mode $mode_move_to_workspace
From: https://unix.stackexchange.com/a/339985
- (3004)How to prevent firefox to switch to fullscreen mode when maximized in i3?
- Go to about:config
- Search for browser.fullscreen.autohide
- Toggle it to false
From: https://www.reddit.com/r/i3wm/comments/edd5fx/fullscreen_mode_in_i3_automatically_set_firefox/
- (3005)How to define key bindings to cycle through active workspaces in i3?
# Cycle through active workspaces
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev
From: https://faq.i3wm.org/question/4979/cycling-through-active-workspaces/index.html
- (3006)How to work with named workspaces instead of numbered workspaces in i3?
Use:
bindsym $mod+1 workspace "MyWSP1"
bindsym $mod+Shift+1 move container to workspace "MyWSP1"
Instead of
bindsym $mod+1 workspace number 1
bindsym $mod+Shift+1 move container to workspace number 1
From: https://faq.i3wm.org/question/1018/named-workspaces.1.html
- (3008)How to define different background images for different workspaces in i3?
1. Install feh:
apt install feh
2. In i3's config file, where you define how to switch workspaces:
bindsym $mod+1 workspace 1
Change those lines to:
bindsym $mod+1 workspace 1; exec feh --bg-fill /path/to/picture.jpg
From: https://www.reddit.com/r/i3wm/comments/8ak3ix/different_background_image_per_workspace/
- (3011)How to start automatically an application on a specific workspace in i3?
SOLUTION1: i3 startup
According to the Arch Wiki i3 page, to autostart an application on a specific workspace, you use i3-msg:
exec --no-startup-id i3-msg 'workspace 1:Web; exec /usr/bin/firefox'
SOLUTION2: You can also assign a specific workspace to an app according to its "class", as in AwesomeWM
##=================================================##
## *** Workspace specific settings *** ##
##=================================================##
# Assign Workspaces:
assign [class="Firefox"] $ws3
assign [class="Chromium"] $ws3
assign [class="Google-chrome-beta"] $ws3
assign [class="^Geany"] $ws1
From: https://unix.stackexchange.com/questions/96798/i3wm-start-applications-on-specific-workspaces-when-i3-starts#97081
- (3013)How to force the layout (stacking, tabbed, split v, split h) on a given workspace with i3?
SOLUTION1: move to workspace & set layout there
bindsym $mod+2 workspace 2:web; layout tabbed; exec firefox -new-tab
From: https://unix.stackexchange.com/questions/96798/i3wm-start-applications-on-specific-workspaces-when-i3-starts#97081
SOLUTION2: layout save/restore
1. Save
i3-save-tree --workspace 1 > ~/.i3/workspace-1.json
2. Tweak (e.g. uncomment class info for the apps/windows)
3. Restore
i3-msg -q "workspace 1; append_layout ~/.config/i3/workspace-1.json"
Please note that the output of i3-save-tree(1) is NOT useful until you manually modify it — you need to tell i3 how to match/distinguish windows (for example based on their WM_CLASS, title, etc.). By default, all the different window properties are included in the output, but commented out. This is partly to avoid relying on heuristics and partly to make you aware how i3 works so that you can easily solve layout restoring problems.
From: https://i3wm.org/docs/layout-saving.html
- (3021)How to make Qt5 Apps use the current Gtk+ Style?
sudo apt install qt5-style-plugins
echo "export QT_QPA_PLATFORMTHEME=gtk2" >> ~/.profile
From: https://www.linuxuprising.com/2018/05/get-qt5-apps-to-use-native-gtk-style-in.html
https://www.linuxuprising.com/2018/05/use-custom-themes-for-qt-applications.html
- (3034)How to change/toogle the orientation of an existing container in i3?
You can use the layout command with a splitv or splith argument (here, without a space before H or V!). You can bind a keystroke to these commands if you wish, in your i3's configuration file.
As an example, here is what stands in my configuration (I got ride of $mod+e):
bindsym $mod+v layout splitv
bindsym $mod+h layout splith
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+Shift+h split h
bindsym $mod+Shift+v split v
With this, $mod+h and $mod+v acts for the tilling orientation like $mod+w and $mod+s act for the overlapping orientation (not toggling, directly specifying an orientation instead), and creation of a split container (toogling) needs a shift modifier.
From: https://faq.i3wm.org/question/75/how-do-i-change-the-orientation-of-an-existing-container.1.html#post-id-4137
- (3038)How to solve black screen problem when running VirtualBox in fullscreen with i3?
Make sure that in the VM options (VM > Settings > User Interface) you don't have the "mini-toolbar: show in fullscreen/seamless" checked.
From: https://github.com/i3/i3/issues/2324#issuecomment-216045371
- (3039)How to run slock/lxlock from i3 (a.k.a. How to solve "slock: unable to grab XXX for screen YYY)?
Please use the --release flag for bindsym:
bindsym --release $mod+l exec /usr/bin/lxlock
From: https://github.com/i3/i3/issues/3298
https://i3wm.org/docs/userguide.html#keybindings
- (3060)How to set workspaces layout at i3 launch?
You cannot use:
workspace $w; layout tabbed
if you do not open a window there, since as soon as the workspace is exited, it is destroyed.
A work-around could be to change the layout everytime you switch to the layout:
workspace_layout tabbed
bindsym $mod+2 workspace 2; layout default
bindsym $mod+3 workspace 3; layout default
...
You can also modify the default settings:
workspace_layout $ws <default|stacking|tabbed>
workspace_default_orientation $ws <vertical|horizonal>
From: https://faq.i3wm.org/question/260/setting-layouts-upon-i3-launch.1.html#post-id-1118
- (3138)How to change the relative/abolute cursor positioning mode of a Wacom tablet?
1. Find you wacom device
xsetwacom --list devices
2. switch to relative/absolute mode
xsetwacom set "<PEN device long name>" Mode "Relative"/"Absolute"
NOTE: You have to set the attribute on the PEN/STYLUS device, not the PAD. Otherwise you'll get the error:
X Error of failed request: XI_BadMode (invalid Mode parameter)
From: https://askubuntu.com/questions/1048048/wacom-bamboofun-cant-change-mode-to-relative
- (3179)How to reset a workspace layout (a.k.a. How to move all nodes to root)?
You can run:
i3-msg '[tiling workspace="__focused__"] move workspace "reorder"; [workspace="reorder"] move workspace current'
You can also associate these commands to a key.
From: https://www.reddit.com/r/i3wm/comments/8c6yfy/how_to_reset_a_workspace_move_all_nodes_to_root/
- (3210)How to move a full i3 workspace to another monitor?
bindsym $mod+$numl+KP_4 move workspace to output left
bindsym $mod+$numl+KP_6 move workspace to output right
bindsym $mod+$numl+KP_8 move workspace to output up
bindsym $mod+$numl+KP_2 move workspace to output down
- (3212)How to move a container (window) to another workspace?
e.g. to move a window of class "CLASS" to current workspace:
i3-msg "[class=CLASS] move container to workspace current"
To get CLASS, use xprop (see Tips#385 & Tip#2663) Or us the script at:
https://major.io/2019/02/08/automatic-floating-windows-in-i3/#identifying-windows
From: https://www.reddit.com/r/i3wm/comments/a5sz72/how_can_i_move_a_window_from_a_different/#t1_ebpvve6
- (3338)How to display remaining HD space in i3status?
NOTE: the trick is to use "Available" space (is what's useful to normal users), not the "Free" space (which includes space that is reserved for the root user - as a kind-of panic rescue spare if something non-root eats all your disk).
Example:
disk "/" {
format = "<span background='#4c566a' color='#d8dee9'> 🖴 / %avail (%percentage_avail) </span>" # %availaible = for user / %free = for system
format_below_threshold = "<span background='#4c566a' color='#ff0000'> 🖴 / %avail (%percentage_avail) </span>"
low_threshold = 10
threshold_type = percentage_free
prefix_type = binary # binary / decimal / custom
}
From: https://www.reddit.com/r/i3wm/comments/c3kn23/i3status_disk_options/
- (3339)How to take a screenshot with 'scrot' using a binkey when running i3 WM?
The trick is to use "--release", otherwise 'scrot' cannot grab the mouse and returns an error.
bindsym --release $mod+z exec scrot -s
From: https://faq.i3wm.org/question/6066/scrot-selection-using-bindkeys.1.html#post-id-6072
- (3417)How to manually add items to i3\'s dmenu?
dmenu will look for executables in the directories defined in your $PATH. Just add the apps you want to acess from dmenu in your PATH.
From: https://wiki.archlinux.org/index.php/Dmenu#Manually_Adding_Items
- (3483)What is that thing called --no-startup-id in i3 WM?
--no-startup-id is used to properly launch windows on the right workspace when starting and to display an hourglass mouse pointer while startup is in progress.
The release notes say:
i3 now supports startup notifications, meaning that during an application
starts up, the mouse cursor will change to 'watch' on the root window. Also,
the application window will appear on the workspace on which it was launched
(not on the currently focused workspace). Some applications don’t support
startup notifications. If the cursor change bothers you, turn it off by using
the --no-startup-id flag (see the userguide).
Also, the userguide says:
The --no-startup-id parameter disables startup-notification support for this
particular exec command. With startup-notification, i3 can make sure that a window
appears on the workspace on which you used the exec command. Also, it will change
the X11 cursor to watch (a clock) while the application is launching. So, if an
application is not startup-notification aware (most GTK and Qt using applications
seem to be, though), you will end up with a watch cursor for 60 seconds.
So, in short: use it if your app does not support startup notifications or if you are not starting a graphical application at all (e.g. all shell script) if the watch cursor bothers you.
From: https://faq.i3wm.org/question/561/what-is-that-thing-called-no-startup-id/index.html
- (3538)How to make Gnome file dialog buttons appear at the bottom, where they used to be?
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DialogsUseHeader':<0>}"
or (from XFCE)
xfconf-query -c xsettings -p /Gtk/DialogsUseHeader -s false
From: https://askubuntu.com/questions/1031665/move-gnome-file-dialog-buttons/1053819#1053819
- (3550)How to refresh/restart/replace the linux Desktop/WM from commandline without rebooting?
- XFCE
xfce4-panel -r && xfwm4 --replace
- LXDE
lxpanelctl restart && openbox --restart
- Gnome Shell
gnome-shell --replace & disown
- Unity
unity
- KDE Plasma
kquitapp5 plasmashell && kstart5 plasmashell
From: https://www.makeuseof.com/tag/refresh-linux-desktop-without-rebooting/#xfce
- (3563)How can I move a floating window with keys?
HEre is a "move" mode for ~/.i3/config:
# move floating windows with keys
bindsym $mod+m mode "move" focus floating
mode "move" {
bindsym $mod+Tab focus right
bindsym Left move left
bindsym Down move down
bindsym Up move up
bindsym Right move right
# back to normal: Enter or Escape
bindsym Escape mode "default"
}
To start the "move" mode press Alt+m, then the first floating window gets focus.
To move focus press Alt+Tab. You can use the arrow keys to move the floating window which has focus.
From: https://faq.i3wm.org/question/4615/how-can-i-move-a-floating-window-with-keys/index.html
- (3583)How to make gaps in i3 be dragable in resize mode?
- Press and hold mod and right click
- Hold anywhere near the gap and resize it
- You'll see the margin where it works is actually pretty large & mouse changes
From: https://www.reddit.com/r/i3wm/comments/9naa2c/how_to_make_gaps_in_i3_be_dragable_in_resize_mode/
- (3613)What applet to use to manage sound volume (a.k.a. access a mixer) in i3?
- BEST: pnmixer => volumeicon-alsa (work with pavucontrol too...)
- pa-applet
From: https://wiki.archlinux.org/title/List_of_applications#Volume_control
https://github.com/fernandotcl/pa-applet
- (3773)How to make rofi (i3WM menu) aware of aliases?
----- .config/i3/config
...
bindsym $mod+m exec --no-startup-id rofi -show run -show-icons -run-list-command "$HOME/Softs/get_aliases.sh" -run-command "bash -i -c '{cmd}'"
...
-----
----- ~/Softs/get_aliases.sh
grep '^alias' .bashrc | awk -F'[ =]' '{ print $2 }'
-----
From: https://github.com/davatorium/rofi/issues/97#issuecomment-68850141
https://github.com/davatorium/rofi/issues/97#issuecomment-66774825
https://github.com/davatorium/rofi/issues/97#issuecomment-68783044
- (3789)How to configure the theme for Rofi (i3 menu to start apps)?
$ rofi-theme-selector ## I use "fancy"
From: https://wiki.archlinux.org/title/Rofi#Custom_themes
- (3807)How to set the default programs/apps in XFCE?
SOLUTION1: In preferences
xfce4-settings-manager > "Preferred Applications"
SOLUTION2: In file manager (thunar)
1. Open up the Thunar file manager on the XFCE desktop.
2. Find the file in the Thunar file manager which you’d like to change the defaults for and right-click on it with the mouse.
3. In the right-click menu in the Thunar file manager, find "Properties" and select it to access the settings for the individual file.
4. Look through the "Properties" window for "Open With" Once you’ve found it, click on the drop-down menu to change the default program for the file.
SOLUTION3: In the MIME type editor
xfce4-mime-settings
From: https://www.addictivetips.com/ubuntu-linux-tips/set-program-defaults-in-xfce/
- (3812)How to enable/set dark theme on a per-application basis in GTK/Gnome?
Set the GTK_THEME environment variable:
GTK_THEME=Adwaita:dark gedit
GTK_THEME=Adwaita:light gedit
From: https://unix.stackexchange.com/questions/14129/gtk-enable-set-dark-theme-on-a-per-application-basis/185115#185115
- (3823)How to make Qt Apps look like Gtk Apps (i.e. use same theme)?
SOLUTION: set the QT_QPA_PLATFORMTHEME environment variable:
export QT_QPA_PLATFORMTHEME=qt5ct # or gtk2
From: https://unix.stackexchange.com/questions/680483/how-to-add-qt-qpa-platformtheme-qt5ct-environment-variable-in-arch-linux
https://bbs.archlinux.org/viewtopic.php?id=238344
- (3825)How to disable User List at the Login Screen of GDM3?
gsettings set org.gnome.login-screen disable-user-list true;
From: https://bytefreaks.net/gnulinux/ubuntu-20-04lts-with-gdm3-disable-user-list-at-the-login-screen
- (3952)How to source environment vars on startup?
Use .pam_environment. It's pretty simple, you specify the variable you want to set, and then DEFAULT=value.
E.g. to set my Qt theme and enable Firefox's wayland:
QT_QPA_PLATFORMTHEME DEFAULT=qt5ct
MOZ_ENABLE_WAYLAND DEFAULT=1
It's worth noting that Sway doesn't source this file, PAM does.
From: https://www.reddit.com/r/swaywm/comments/f98jlp/comment/fivqgsn/?context=3
https://wiki.archlinux.org/title/Environment_variables#Using_pam_env
- (3960)How to make Numpad work in Gnome/Gtk environments (Chrome, Xivo, etc.)?
NOTE: to make my Numpad always active, I set a Xmodmap with first column (values without modifyiers) replaced by the KP_<digit> values (values with NumLock modifier).
- Look at what key code a key in the NumPad actually returns.
xbindeys -mk # then press KP_5, for instance
"(Scheme function)"
m:0x10 + c:84
Mod2 + KP_5
- In my case, there's a Mod2 in addition to KP_5, when NumLock is activated
- In my current Xmodmap NumLock is associated to Mod2
xmodmap -pm
- in Xmodmap Mod2 values are in *column 3*, thus I have to also orverride values in col3 with KP_<digit>!!!
From: https://gitlab.gnome.org/GNOME/gtk/-/issues/3868#note_1081135
- (3989)How to get the Master/Stack layout (i.e. dwm/awesome default layout) in i3?
Install i3-master-stack
From: https://github.com/windwp/i3-master-stack
- (4058)What to do if VLC does not work/goes Berzerck (e.g. does not play playlist as configured with the buttons)?
rm -rfv ~/.config/vlc ~/.local/share/vlc
From: https://forums.linuxmint.com/viewtopic.php?t=324987#p1847065
- (4079)How to focus the nagbar (top menu line for exiting i3) with keyboard?
NOT TESTED
# Set shut down, restart and locking features
bindsym $mod+0 mode "$mode_system"
set $mode_system (l)ock, (e)xit, switch_(u)ser, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown
mode "$mode_system" {
bindsym l exec --no-startup-id i3exit lock, mode "default"
bindsym s exec --no-startup-id i3exit suspend, mode "default"
bindsym u exec --no-startup-id i3exit switch_user, mode "default"
bindsym e exec --no-startup-id i3exit logout, mode "default"
bindsym h exec --no-startup-id i3exit hibernate, mode "default"
bindsym r exec --no-startup-id i3exit reboot, mode "default"
bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"
# exit system mode: "Enter" or "Escape"
bindsym Return mode "default"
bindsym Escape mode "default"
}
From: https://faq.i3wm.org/question/6412/focus-nagbar-with-keyboard.1.html
- (4087)How to force Unity reload ~/.local/share/applications/?
As per this guide https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles, don't just edit or create your .desktop files in /usr/local/share/applications or ~/.local/share/applications. Instead, create the file somewhere else and use:
desktop-file-install <your_file.desktop>
to add the file.
E.g. you create ~/myapp.desktop and do
desktop-file-install --dir=$HOME/.local/share/applications ~/myapp.desktop
Existing files of the same name will be overwritten and unity updated, you can use --delete-original if the source is not needed anymore, or
sudo desktop-file-install ~/myapp.desktop
to install it for all users.
From: https://askubuntu.com/questions/375975/how-to-force-unity-reload-local-share-applications/447703#447703
- (4090)How to restart X Window Server from command line?
SOLUTION1: On systems with systemd (Ubuntu 15.04 and newer)
sudo systemctl restart display-manager
SOLUTION2: On other systems
sudo systemctl restart lightdm/gdm/kdm/mdm
See Tip#4091 for finding the currently used session manager (DM)
From: https://askubuntu.com/questions/1220/how-to-restart-x-window-server-from-command-line#1222
- (4091)How to find the session manager currently in use?
SOLUTION1: works on recent distributions
cat /etc/X11/default-display-manager
SOLUTION2: partial (there might be DM not using "dm" in their names and non-DM programs using "dm" in their name)
ps aux | grep "gm"
From: https://askubuntu.com/questions/1220/how-to-restart-x-window-server-from-command-line#1222
- (145)How to re-open the last closed tab in Firefox?
use: ctrl+shift+t
- (153)How to send same mass emailing but making each recipient unique
Personalize messages
Sends each recipient an individual message, using data from your address book or a CSV file.
To use this feature, write a message by choosing: Message &gt; Personalize... You can address it to a list, or to individuals in your address book. Alternatively, select cards in your address book, then get a context menu (for example, by right-clicking a card) and choose: Personalize To use addresses from a CSV file, do not specify any addresses in the message.
To send the message, press the Personalize button or choose: File &gt; Personalize If the message has no recipients, then MailTweak prompts you to choose a CSV file that specifies the recipients.
MailTweak creates an individual copy of the message for each recipient. The messages are placed in your Unsent folder, so if you wish you can review them before sending them.
To include data from your address book or CSV file, specify fields in your message. For example, if you specify %%firstName%% then the actual message sent will have the recipient\'s first name in that position in the message.
The available address book field names are the properties listed here: nsIAbCard Field names in a CSV file are as specified in the first line of the file, but with spaces changed to underscores. For example, if the CSV file specifies the field name First Name, then type %%First_Name%% (with an underscore) in the message.
You can specify a different field marker (default: %%).
By default each personalized message has a unique internal message ID. You can turn this off to send messages with the same internal message ID (but some mail systems might not be able to handle distinct messages that have the same ID).
In each record of a CSV file, the first field that contains an @ sign is taken to be the e-mail address. Alternatively, set the preference extension.mailtweak.personal.csv.to to the name of the field that contains the e-mail address, changing spaces in the name to underscores.
CSV files are taken to be in the platform charset by default. Alternatively, set the preference extension.mailtweak.personal.csv.charset to specify the charset of the CSV file.
Note: In Templates and Drafts folders, the default action is Edit Message As New. To personalize a template or draft, choose: Message &gt; Personalize As New...
Restrictions: The following restrictions apply in the current version. Future versions might have fewer restrictions:
* If you specify recipients in the message, then each recipient must be in your address book (even if you do not use any address book fields in your message).
* There is no special handling for fields that require a different charset (\"character encoding\") from the message charset. To work around this, if your data requires various charsets, send your message using Unicode (UTF-8).
* Fields are supported in the message subject, but only if the field data is US-ASCII. No other charset is supported, not even the charset of the message body.
* There is no special handling for missing field data.
* Performance may be poor if you use this feature for large messages or many recipients, and you might see warning messages from Thunderbird. For more information about these warnings, see: Script_busy For bulk mailing, it is better to use a specialized bulk mailing program.
From http://mailtweak.mozdev.org/tweaks.html#personal
- (226)How to open a URL in a new tab from CLI?
firefox -remote \'openurl(\"http://www.mozilla.org\",NEW-TAB)\'
firefox -new-tab \"http://www.mozilla.org\"
- (279)How to get a warning in Firefox 3.5 when closing when a download is not finished (works only partially)
Hi,
I also noticed that I didn\'t get any warnings when a download hadn\'t finished. I did some investigation and this behavior is controled by the browser.download.manager.quitBahvior setting in about:config. There a multiple values which can be given to this settings as described here:
http://kb.mozillazine.org/Browser.download.manager.quitBehavior
To get a warning set the value to 2.
Hope this helps you.
From: http://support.mozilla.com/tiki-view_forum_thread.php?locale=fi&amp;comments_parentId=217909&amp;forumId=1
see also: http://kb.mozillazine.org/Browser.download.manager.quitBehavior
- (289)What to do if Firefox complains about sqlite?
1. Go to the directory where the special libsqlite for FF is stored (in OpenBSD: /usr/local/mozilla-thunderbird/)
2. There are probably 2 versions of the lib.
3. Remove the oldest one.
- (501)How to remove annoying error Beeps in Thunderbird / Firefox?
1. Goto about:config (ThB:tools-&gt;preferences-&gt;advanced-&gt;advanced config button)
2. Search for \"sound\"
3. Toogle the entry \"...typehead...\" to false
4. *Restart the program*
5. Silence reclaimed!
- (309)How to remove the delay at the installation of an add-on in Firefox?
NOTE: this is a useless security measure, you ALWAYS have to check if the source is reliable BEFORE clicking on an install link
- type \'about:config\' in the address bar
- then defines security.dialog_enable_delay = 0
- (313)How to set attachments keywords for the \"missing attachment autodetection\" algorithm in Thunderbird?
Hi,
I have installed Thunderbird 3.1 and there is nice feature of notifying that mail has found word \"attachment\" and there is no attachment file. I have tried and this works fine for English words, but what about non-English words? Is there any way, that I can insert words to some kind of notify list, that Thunderbird would notify me that there is probably a missing attachment?
Thanks
DanRaisch
Moderator
Find that option under Tools-&gt;Options-&gt;Composition-&gt;General tab-&gt;click on the button labeled \"Keywords\".
From : http://forums.mozillazine.org/viewtopic.php?f=28&amp;t=1933469
- (338)How to get Gmaps show in full screen in Firefox?
Just wondering if anyone knows how to make embedded google maps full screen with the full google maps toolbar.
Click on the little link that says \"powered by google maps\" in the bottom left corner
- (340)How to unlock GMail?
https://www.google.com/accounts/DisplayUnlockCaptcha
Don't go back to Thunderbird 2.x. Just turn off syncing. I was getting gmail within about 20 min of turning of the sync and it's been fine since. Just go to Tools>Account Settings> Your Mail Account >Synchronization> and uncheck the box that says to keep messages on the computer. And/or change your settings for the number of days to keep email and the size of the email.
- (343)How to link FF and ThB to open one another links (mailto/http)?
Rudi,
Clear your Location Bar, then type: about:config
In the blank "filter" field type: network.protocol-handler
Check these three settings to ensure the "value" is Firefox
network.protocol-handler.app.ftp......user set......string........firefox
network.protocol-handler.app.http.....user set......string.......firefox
network.protocol-handler.app.https....user set......string.......firefox
If these settings aren't listed in about:config, then add all three. You can do this by a right click in any blank space,
Select: New
Select: String
Type the preference name, e.g. network.protocol-handler.app.ftp
Click: OK
Type the value: Firefox
Click: OK
Close Window
Close Firefox and reopen
------------------------------------------------------------
=> ATTENTION now it is included in the "preferences -> attachments" config !
- (354)Bookmark All Tabs in Firefox 4++
- Right-click on a tab, choose \"Bookmark All Tabs\"
- Ctrl+Shift+D
- press &amp; release the ALT or F10 key, the Menu Bar will temporarily display at the top left, click Bookmarks &gt; Bookmark All Tabs
From: https://support.mozilla.com/en-US/questions/841781#answer-206437
- (369)Extensions to install into Thunderbird
calendar : lightning
Exchange (external App) : davmail (proxy that transforms it into a pop/imap+smtp+caldav+ldap server
- (381)Change Firefox Address Bar Search
Set "keyword.URL" in about:config
Google Default: http://www.google.com/search?ie=UTF-8&q=
From: http://www.ghacks.net/2011/04/20/how-to-change-the-default-firefox-4-address-bar-search-engine/
- (395)How to get the URL of a flash file (e.g., megaupload movie) in Firefox?
about:cache
- (418)How to close the \"about\" dialog box in Firefox?
PROBLEM: it does not respond to CTL-w, does not show any close button and my tiling WM does not show any decoration, that would contain a close button
SOLUTION: Hit ESC!
- (419)How to search in tabs?
Trouver rapidement cet onglet %Gâ??%@ c'est plus facile que de trouver une aiguille dans une botte de foin.
Cliquez sur le bouton « Groupes d'onglets » à l'extrême droite de la barre des onglets.
Pour ceux d'entre vous qui aiment les raccourcis clavier, vous pouvez utiliser Cmd + Maj + ECtrl + Maj + E.
Cliquez sur le bouton de recherche sur le côté droit de la fenêtre pour afficher la boîte de recherche, puis commencez simplement par saisir le nom de l'onglet que vous essayez de trouver.
En fait, vous n'avez pas à cliquer sur le bouton de recherche. Commencez simplement par taper et une recherche se fera automatiquement.
Au fur et à mesure que vous tapez, les onglets qui correspondent à votre recherche sont mis en surbrillance. Cliquez simplement sur un onglet pour le sélectionner et être de retour dans Firefox. Panorama search
Si vous avez plus d'une fenêtre de Firefox ouverte, vous pouvez voir les onglets d'autres fenêtres, qui correspondent à votre recherche, listés en bas de la fenêtre. Cliquez sur l'un d'entre eux vous fera commuter vers cette fenêtre, cet onglet et ce groupe de Firefox.
From: https://support.mozilla.com/fr/kb/que-sont-groupes-onglets#w_comment-puis-je-rechercher-dans-mes-ongletsa
- (422)What to do if the button \"Permanently store this exception\" is greyed out when accessing a website that uses a certificate in Firefox?
When visiting a site or internal Intranet site with a untrusted certificate you keep getting asked if you want to trust the certificate and the \"Permanently store this exception\" is greyed out. Just turn history back on, trust the certificate and store, then turn history off again.
From: http://www.stevenwhiting.com/blog/?p=658
- (619)How to make chromium search on google even when typing in the URL bar?
Set this 'URL' in the "Manage search engines" setting:
{google:baseURL}search?{google:RLZ}{google:acceptedSuggestion}{google:originalQueryForSuggestion}{google:searchFieldtrialParameter}{google:instantFieldTrialGroupParameter}sourceid=chrome&client=ubuntu&channel=cs&ie={inputEncoding}&q=%s
- (636)How to resume a download in FF?
1 Move both files to a new location (only cut / paste and no copy - if you copied, just delete source files).
2- Start download again from the beginning.
3- Let it download a few bytes, just to have those two files created again, with the exact same name. Now PAUSE this download.
4- Go to the folder where files were backed up. Copy both of these files to download folder and replace the new created files when asked.
5- Now go to Firefox's Downloads window and resume the download.
From: http://www.devarticles.in/miscelleneous/resume-download-of-part-extension-file-in-firefox/
- (762)How to force Firefox to update [Win7 only?]?
Go into Help -> About Firefox
From: https://support.mozilla.org/en-US/questions/880417
- (764)How to save save complete/whole conversation to disk in GMail?
You can do it from Thunderbird, or:
1. You need to install the "Create a document" feature from the Labs:
- go to the Gmail Labs tab under Settings,
- select "Enable" next to "Create a document"
- hit "Save Changes" at the bottom.
2. Go to the conversation you want to save
- clic on "More" -> "Create a document"
From: http://gmailblog.blogspot.fr/2008/12/new-in-labs-turn-email-into-google-doc.html
- (788)How to disable word wrapping in outgoing messages?
Edit -> Preferences -> Advanced -> General -> Config Editor
Set the preference called "mail.wrap_long_lines" to false
From: http://superuser.com/questions/378184/tell-thunderbird-not-to-truncate-or-wrap-lines-when-sending-email
From http://kb.mozillazine.org/Plain_text_e-mail_%28Thunderbird%29#Advanced
- (790)How to prevent chromium to store history?
Find the file named History and make it read only!
Linux: .config/chromium/Default/
Windows: C:\Users\User Name\AppData\Local\Google\Chrome\User Data\Default\
From: http://productforums.google.com/forum/#!topic/chrome/ygQP3OWsVLs
- (830)What are the ports used by GMail (for Thunderbird)?
IMAP / SSL / 993
SMTP / TLS / 587
- (835)Why is Google Chrome ignoring my proxy settings?
It reads its config from dconf-tools or environment vars (but these can't be changed from within the WM. Therefore a chrome instance started from shortcut does not work!)
From: http://askubuntu.com/questions/66554/why-is-google-chrome-ignoring-my-proxy-settings
- (840)How to prevent ThB editor to wrap lines when composing an email?
Try setting mail.compose.wrap_to_window_width to true and mail.wrap_long_lines to false. Worked for me in v3.1.8
From: http://forums.mozillazine.org/viewtopic.php?f=39&t=2090561
- (862)How to add a certificate to chromimum's trusted list?
certutil -d sql:$HOME/.pki/nssdb -L
Note: to trust a self-signed server certificate, we should use
certutil -d sql:$HOME/.pki/nssdb -A -t "P,," -n <certificate nickname> -i <certificate filename>
Unfortunately that doesn't work because of NSS bug 531160. To work around the NSS bug, you have to trust it as a CA using the "C,," trust flags.
From: http://code.google.com/p/chromium/wiki/LinuxCertManagement
- (868)How to make chromium not warn you about self-signed certificates?
1. Get the certificate
-> With Java
keytool -printcert -sslserver <host:port> -rfc >> <filename>.<pem/p7>
-> With FF
Open the page in FF and permanently accept the certificate
Go to FF -> Edit -> Preferences -> Advanced -> Encryption -> View Certificates
Export the certificate to <filename>.<pem/p7>
2. Go to Chromimum -> Menu -> [Search for "certificate" keyword] -> Manage Certificates
3. Import the PKCS#7/PEM certificate
- (894)How to prevent FF 20+ to annoyingly asks for installation of Twitter/GMail/G+/...?
- Easy way for 12.10, 13.04 :
-> Goto the software center and search for the specific web app and uninstall it. Like
unity-webapps-gmail or unity-webapps-googledocs
- Hard way, For 12.04 ,12.10 & 13.04
-> Press Alt + F2 , run dconf-editor.
-> Now goto com ? canonical ? unity ? webapps.
-> Edit Allowed domain value and remove the undesired entry.
-> To prevent any more pop up for a site, add the site url to:
firefox :Edit > preferences > General > Desktop integration > exception
chrome : Settings > Extension > Desktop integration > Exception
From: http://askubuntu.com/questions/166655/how-do-i-remove-a-website-from-ubuntus-web-applications
http://askubuntu.com/questions/206710/how-do-i-disable-unity-webapps-notifications-from-popping-up-everytime-i-visit-a
- (915)How to disable built-in pdf viewer in FF 19+?
To switch from the built-in PDF viewer to another PDF viewer:
At the top of the Firefox window, click on the Edit menu and select Preferences
Select the Applications panel.
Find Portable Document Format (PDF) in the list and click on it to select it.
Click on the drop-down arrow in the Action column for the above entry and select the PDF viewer you wish to use.
From: https://support.mozilla.org/en-US/kb/disable-built-pdf-viewer-and-use-another-viewer
- (941)How to get an entry "show only this frame" in chromium?
Install the addon called "This Frame"
- (960)How to Make Thunderbird look like Apple's Mail?
"Unified Folders (originally named Smart Folders when it was added in 3.0) is a folder pane view which looks like a global inbox account by merging the contents of all inbox folders (both POP, IMAP and local folders) from all accounts. It also shows the inbox of each account as a child folder of the unified Inbox account. Any messages in an inbox shows up in both the root of the unified Inbox, plus the child folder of the unified Inbox for that account."
To use this functionality:
View >> Folders >> Unified
From: http://kb.mozillazine.org/Global_Inbox#Unified_Folders
http://askubuntu.com/questions/132833/can-i-get-a-combined-inbox-in-thunderbird
- (977)How to solve "Cant donwload files because Firefox keeps asking for consent and there isnt an ALLOW button anywhere" error in FF21++? DOES NOT WORK
PROBLEM: Everytime I try to download a "large" file Firefox keeps asking me:
SOLUTION:
1) Left Click on the lock image in the address bar (next to the https://), then click the "More Information" button that pops up.
2) Select the Permissions tab.
3) On the "Maintain Offline Storage" section, leave 'Use Default' clicked and 'Allow' radio button selected, but click the "Clear Storage" button.
4) On your next Mega download, you'll get asked about storing locally - say Yes and that fixed it here. In fact, as you go over the 50 MB limit, it will ask again as in the second image.
--- GM: also see dom.indexedDB.warningQuota
If you do not have the blue-circle-question-mark icon, you might have chosen the "Never for This Site" option at one point. This prevents Firefox from prompting you to allow in the future.
I couldn't find a way just to clear that one decision without clearing all settings and history for the site using the "Forget about this site" feature. Someone might know a shortcut that allows you to preserve history and perhaps more importantly for this site, past files downloaded to local storage.
If you don't find another way, open the Library dialog to your History using either
History > Show All History
Ctrl+Shift+h
Then right-click an entry for that site and choose Forget About This Site. Do not be alarmed if this takes a minute or two, since Firefox is going through history and cache to clear all references to the site. Your next visit will be as though it were your first.
----
You can inspect and manage the permissions for all domains on the about:permissions page or for the current domain via the ""Site Identity Button" (globe/padlock) on location bar" and click "More Information" to open "Page Info" and go to the Permissions tab.
https://support.mozilla.org/kb/how-do-i-manage-website-permissions
You can delete the permissions.sqlite file to reset all permissions.
From: http://support.mozilla.org/en-US/questions/960444
- (985)How to recover bookmarks when XMarks cannot synch/overwrite them in FF?
1. de-activate the Xmarks plugin
2. mv ~/.mozilla/firefox/<your profile>/xmarks-baseline<number>.json{,.old}
mv ~/.mozilla/firefox/<your profile>/xmarks.sqlite{,.old}
rm ~/.mozilla/firefox/<your profile>/
3. re-start FF
4. re-activate Xmarks
5. re-start FF
6. Go to Xmarks plugins prefs -> Advanced -> Force overwrite of localdata
- (1030)How to convert .mozilla/firefox/xxx/cookies.sqlite to old format cookies.txt (e.g. to use with wget or curl)?
#!/bin/bash
function cleanup {
rm -f $TMPFILE
exit 1
}
trap cleanup SIGHUP SIGINT SIGTERM
# This is the format of the sqlite database:
# CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);
# We have to copy cookies.sqlite, because FireFox has a lock on it
TMPFILE=`mktemp /tmp/cookies.sqlite.XXXXXXXXXX`
cat $1 >> $TMPFILE
sqlite3 -separator ' ' $TMPFILE << EOF
.mode tabs
.header off
select host,
case substr(host,1,1)='.' when 0 then 'FALSE' else 'TRUE' end,
path,
case isSecure when 0 then 'FALSE' else 'TRUE' end,
expiry,
name,
value
from moz_cookies;
EOF
cleanup
Usage should be like this:
$ extract_cookies.sh $HOME/.mozilla/firefox/*/cookies.sqlite > /tmp/cookies.txt
$ wget --load-cookies=/tmp/cookies.txt http://mysite.com
$ # OR
$ curl --cookie /tmp/cookies.txt http://mysite.com
From: http://slacy.com/blog/2010/02/using-cookies-sqlite-in-wget-or-curl/
- (1262)How to enable case sensitive searches when using find (CTRL-f) in Firefox?
If you use Firefox's Find (Ctrl+f) to find a term or name on a web page, you might try using case sensitive searches to make things easier. This is disabled by default but can easily be changed by taking the following steps.
1. Open Firefox.
2. Go to the address bar and input about:config.
3. Click through the warning window.
4. Locate accessibility.typeaheadfind.casesensitive and double-click it and change the value to 1.
5. Restart Firefox.
NOTE: in FF 29+ there apparently is a button "Match case" on the right of the search bar (at bottom)
From: http://www.tech-recipes.com/rx/4933/firefox-enable-case-sensitive-searches-when-using-find-ctrlf/
- (1200)What to do when Midori does not enable the numpad correctly?
Play with Shift+Num_Lock and Num_Lock and \"setxkbmap -option keypad:pointerkeys\" and it should come back.
From: https://bbs.archlinux.org/viewtopic.php?id=115072
- (1178)How to prevent FF to redirecting to www.localhost.com?
- Type about:config in the browser bar
- Type browser.fixup.alternate.enabled in the search box that appears
- Right click on the browser.fixup.alternate.enabled that appears in the filtered list below and choose Toggle to set the value to false
- Problem fixed, breath out.
From: http://cdivilly.wordpress.com/2013/08/15/disable-firefox-redirecting-to-localhost-com/
- (1166)How to extract .eml content in CLI (a.k.a. how to extract MIME/Base64 content) in Thunderbird?
sudo apt-get install mpack
munpack -f thefile.eml
From: http://superuser.com/questions/406125/utility-for-extracting-mime-attachments
--
uudeview +e .zip -i mail.eml
From: http://www.commandlinefu.com/commands/view/14241/decode-a-mime-message
- (1407)How to create custom snooze times for Lightning alarms? [TO SUM UP]
The .jar files were found in:
C:\Users\<Username>\AppData\Roaming\Thunderbird\Profiles\<Profilename>.default\extensions\{e2fda1a4-762b-4020-b5ad-a41df1933103}\chrome\
To be safe I made copies of calendar.jar and calendar-en-US.jar under slightly modified names so I could restore them if something went wrong.
I then opened a regular command prompt (administrator status is not required).
In my working folder (C:\Temp\calendarjar\) I used this command to extract the contents of calendar.jar:
CODE: SELECT ALL
jar xf calendar.jar
I used this page for reference for the jar.exe commands:
http://java.sun.com/developer/Books/javaprogramming/JAR/basics/index.html
I then used Notepad++ to open calendar-alarm-snooze-popup.xul from my working folder:
C:\Temp\calendarjar\content\calendar
Copying the syntax of the existing snooze options, I added this to the end of the list:
CODE: SELECT ALL
<radio label="&calendar.alarm.snooze.5day.label;"
value="7200"
onclick="radioSnooze(event)"
onkeypress="radioSnooze(event)"/>
These options are located between:
CODE: SELECT ALL
<radiogroup id="custom-menupopup-radiogroup"
onblur="radiogroupBlur(event, this)"
onmouseover="radiogroupMouseOver(event, this)">
and
CODE: SELECT ALL
</radiogroup>
In my case I just copy and pasted the 1 Day option and changed "1day.label" to "5day.label"
and value="1440" to value="7200". The value is just the snooze time in minutes.
I saved the revised calendar-alarm-snooze-popup.xul and then put the files back in the .jar with this command:
CODE: SELECT ALL
jar cvf0 calendar.jar content skin
The arguments "content" and "skin" are the folders that contain everything in the .jar file. The 0 (zero) part of "cvf0" creates the .jar without compressing it. If you make the .jar with Java's jar.exe without the zero it will still work but the file sizes look funny. (I left out the zero on my first attempt and worried that the jar being 1/3 the original size meant something was missing but all the files were there and it worked ok.)
Then in my other working folder (C:\Temp\calendar-en-USjar\) I extracted the contents of calendar-en-US.jar:
CODE: SELECT ALL
jar xf calendar-en-US.jar
Next I used Notepad++ to open calendar.dtd from this folder:
C:\Temp\calendar-en-USjar\locale\en-US\calendar
In the section under
CODE: SELECT ALL
<!-- Calendar Alarm Dialog -->
I appended this to the list of Entities:
CODE: SELECT ALL
<!ENTITY calendar.alarm.snooze.5day.label "5 Days" >
Again I just cut and pasted the "1 Day" entry substituting 5 for 1 in the label and description sections. The Entity label has to match the label you created in the calendar-alarm-snooze-popup.xul file.
I saved the revised calendar.dtd and then put the files back in the .jar with this command:
CODE: SELECT ALL
jar cvf0 calendar-en-US.jar locale
In this case, "locale" is the only folder in the root of the calendar-en-US.jar file.
With Thunderbird NOT running, I copied calendar.jar and calendar-en-US.jar back to their original "chrome" folder, overwriting the original copies.
From: http://forums.mozillazine.org/viewtopic.php?f=46&t=2060111
- (1437)How to Recover Accidentally Deleted Bookmarks in Chrome/Firefox?
- Chrome
* Close Chrome
* Go to ~/.config/chromium/ProfileXXX/ (or C:\Users\NAME\AppData\Local\Google\Chrome\User Data\Default under windows)
* Overwrite the "Bookmarks" file with the "Bookmarks.bak" file
- Mozilla Firefox
* Open the Library: "Bookmarks->Show All Bookmarks" (Ctl-Shft-O)
* Click the "Organize" menu
* Select "Undo" to undo the deletion
From: http://www.howtogeek.com/111784/how-to-recover-accidentally-deleted-bookmarks-in-chrome-firefox/?PageSpeed=noscript
- (1456)How to allow/disallow a site to go full-screen once the permission as already benen set&saved in Firefox 35++?
PROBLEM: I accidentally set youtube's HTML5 player to disable full screen - how do I re-enable it or manage my permissions for HTML 5 full screen video?
SOLUTION: You can open the about:permissions page via the location bar and select www.youtube.com in the left pane.
From: https://support.mozilla.org/en-US/questions/938781
- (1555)How to live-edit/debug/hack a website in Firefox / Chromium?
- View page source / View selection source
- Right-Click + Inspect Element
- Inspector: look at/change HTML
- Style Editor: look at/change HTML
- Network (often requires page reload): see included scripts/pages (in the timeline) + POST/GET arguments (clic link+\"Edit and resend\")
- Storage: observe cookies/local/session storage
- (1597)How to clear HTTP Authentication data from FF?
Shorter version:
- Open the ≡ menu > Library > History > Clear Recent History
Longer version:
- Preferences -> Privacy
- In History section, toggle to "Never Remember History"
- Run the "You may also want to clear all current history"
- Go back to "Custom settings" if necessary
From: http://blog.jonschneider.com/2008/09/how-to-get-firefox-to-discard-cached.html
- (1598)How to put FF cache in RAM?
about:config
browser.cache.disk.enable false
browser.cache.memory.enable true
browser.cache.memory.capacity -1 pour une taille dynamique, sinon définir la taille voulue (en kilo-octet, donc par exemple 1000000 pour 1 Go).
From: http://korben.info/accelerez-votre-navigateur-en-mettant-son-cache-en-ram.html
http://korben.info/comment-mettre-le-cache-de-firefox-dans-la-memoire-ram.html
- (1611)How to write a filtering rule for ads in AdBlockPlus/AdBlockEdge/uBlock?
Example 1: Blocking by address parts
/banner/*/img^
Blocked http://example.com/banner/foo/img
Not blocked http://example.com/banner/img
Example 2: Blocking by domain name
||ads.example.com^
Blocked http://ads.example.com/foo.gif
Not blocked http://ads.example.com.ua/foo.gif
Example 3: Blocking exact address
|http://example.com/|
Blocked: http://example.com/
Not blocked: http://example.com/foo.gif
Options:
||ads.example.com^$script,image,domain=example.com|~foo.example.info
This rule blocks http://ads.example.com/foo.gif only if the following conditions are met:
- This address is being loaded as a script or an image.
- The page loading it comes from example.com domain (for example
example.com itself or subdomain.example.com) but not from
foo.example.com or its subdomains.
Exceptions 1: Exception for particular requests
@@||ads.example.com/notbanner^$~script
Exceptions 2: Exception for an entire site
@@||example.com^$document
Comments
!This is a comment
Type
script ~script Include or exclude JavaScript files
image ~image Include or exclude image files
stylesheet ~stylesheet Include or exclude stylesheets (CSS files)
object ~object Include or exclude content handled by browser plugins like Flash or Java
object-subrequest
~object-subrequest Include or exclude files loaded by browser plugins
subdocument ~subdocument Include or exclude pages loaded within pages (frames)
Exceptions
document Used to whitelist the page itself (e.g. @@||example.com^$document)
elemhide Used to prevent element rules from applying on a page (e.g. @@||example.com^$elemhide)
Domains
domain= Specify a list of domains, separated by bar lines (|), on which a filter should be active.
A filter may be prevented from being activated on a domain by preceding the domain
name with a tilde (~).
third-party
~third-party Specify whether a filter should be active on third-party or first domains
From: https://adblockplus.org/en/filter-cheatsheet
- (1627)How to display/reduce FF memory usage?
- Go to about:performance and see which tab/addons consumes the most memory.
- Close/Stop/Kill/Uninstall the faulty tab/addon
- Go to about:memory
- Run GC + CC + "Minimize memory usage"
From: http://www.ghacks.net/2015/07/10/garbage-collection-improvements-in-firefox-improve-memory-usage/
- (1786)How to disable Firefox (in fact Gnome/XFCE) error/alert/event sounds?
gconf-editor
/desktop/gnome/sound/event_sounds => false
---
1. Go to Settings Manager -> Appearance -> Settings
2. Disable "Event Sounds"
From: https://forum.xfce.org/viewtopic.php?id=8618
https://bbs.archlinux.org/viewtopic.php?id=117696
https://bbs.archlinux.org/viewtopic.php?id=116649
- (1865)How to get back/recover the text you typed when you've completed a HTML-form then closed it (a.k.a. How to recover form content lost when a timeout occurs after you filled a phpmyadmin.free.fr form)?
---- WORKS!! ----
As soon as the page showing the tbl_change.php / db error / timeout error appears:
- Open the developer tools (C-S-i)
- Go to Networktab
- Click the "Reload" button to reload the page
- Accept resending information
- Go to the tbl_replace.php ligne in the network exchange list
- Click on it
- In the right pane, click to see the "Request" pane
You'll find the text you typed somewhere there!!!!
-- --- --- --- --
- If just closed the Tab => CTL-SHIFT-T => re-opens the with content
- Another option is to set "browser.sessionstore.resume_session_once"
to "true" in "about:config" and restart Firefox. It will restore the
session, just once.
- It's not guaranteed (particularly if you've asked FF to save as
least info as possible), but it is possible that in "about:cache",
you can find under "disk" a list of cache entries that contains the
URL you were working on. If you click it, Firefox should show the
content there and list the compression type, which most often will
be: "Content-Encoding: gzip". In that case, if you save the encoded
content to a new file with a .gz extension you should be able to
decompress it using your favorites ZIP utility. Of course, finding
the beginning and end of the content may not be intuitive.
- Finally, probably the best option (but that will work only for
future cases), is to install the "Lazarus" extension. It copies &
encrypts everything you type in HTML-forms. Thus allows you to
restore it, while keeping it secured.
From: http://kb.mozillazine.org/Session_Restore#Restoring_a_session_once
https://support.mozilla.org/en-US/questions/1116770
https://addons.mozilla.org/en-US/firefox/addon/lazarus-form-recovery/
- (1936)How to take a screenshot of a webpage directly in FF?
Press keys : MAJ + F2 (or: MAJ + Fn + F2 for OSX/laptops)
A console will appear. In this concole, you can type:
:screenshot --fullpage capture.png
--delay : adds a delay of x seconds before taking the screenshot.
--selector : selects an element of the page with a CSS selector.
--chrome : get the window frame in the screenshot.
--clipboard : stores the image into the clipboard
<Tab> can be used to auto-complete the commands!
Combined with https://snag.gy/ it's so cool!
From: https://korben.info/faire-une-capture-ecran-complete-de-site-web-directement-depuis-firefox.html
http://korben.info/snaggy-moyen-simple-de-partager-captures-ecrans.html
https://developer.mozilla.org/en-US/docs/Tools/Web_Console/The_command_line_interpreter#screenshot
- (3833)How to share a calendar in Partage (RENATER's WebMail app)
The calendar URL is composed of 3 parts:
- "https://<server>/dav/"
- email of the owner
- name of the agenda
Example: https://partage.etab.fr/dav/jean.dubois@etab.fr/vacances
From: https://services.renater.fr/partage/faq#partage_d_agenda_en_caldav
- (3866)How to repair a Thunderbird email folder (a.k.a. What to do when old emails get corrupted - e.g. headers end up in the middle of body)?
- Right click the folder
- Select "Properties"
- Click "repair" button
From: https://support.mozilla.org/en-US/questions/1285757#answer-1309923
- (1994)How to strike-out text in a email with ThunderBird?
- Type out some text
- Select the text you want formatted with the strike through
- Go to Format > Text Style > Strikethrough
From: https://tbirdhowto.wordpress.com/2007/03/05/how-to-format-strike-through-text/
- (2047)How to debug Firefox/Thunderbird?
$ thunderbird -ProfileManager ## create empty profile
$ thunderbird -safe-mode ## start FF/ThB without addons, etc.
- (2074)How to keep a col/row appearing even if we move in the sheet in GoogleSheets?
- \"View\" menu &gt; \"Freeze\"
From: http://blogmines.com/blog/always-keep-headings-visible-in-google-spreadsheet/
- (2084)How to backup all GMail folders in ThB?
I can acheive what I need to do using free software "System Scheduler" (SS).
Basically, use SS to start Thunderbird, send key presses, then close Thunderbird.
The key presses are simple:
{wait=5000}%F{wait=1000}L{wait=1000}S{wait=1000}{enter}
The waits just put in a short delay (1000=1 sec) and %F simulates pressing Alt+F
So having started Thunderbird I am simulating menu commands to do:
File - Offline - Download/Sync Now
Maybe that will help someone else, it is a very simple solution to backing up Gmail.
From: http://forums.mozillazine.org/viewtopic.php?f=39&t=2114129
- (2086)How to allow access to local resources with NoScript (a.k.a. How to allow SonarQube-server\'s page with NoScript)?
Q: ABE is preventing my bank web site from accessing the \"Warsaw\"
authentication agent. What should I do?
A: Open NoScript Options|Advanced|ABE, select the SYSTEM ruleset, and
insert the following rule in the *beginning* of the text box:
# Warsaw Agent exception.
Site https://127.0.0.1:30900
Accept from https://*
From: https://forums.informaction.com/viewtopic.php?f=7&amp;t=22389
https://noscript.net/faq#qa8_13
- (2175)How to create/save HTTP BasicAuthentication in FF's plugin "Saved Password Editor"?
1. Find out the HTTP realm. This is displayed in the login window,
after the words "The site says:".
2. Go to Saved Logins.
3. Click the "New" button.
4. Set the type to "Annotated".
5. Enter the information, as follows:
* Host: The first part of the URL for the set of pages you are
accessing, starting with the method ("http" or "https") and
ending with the hostname (and port number, if present). Do not
include the slash after that. For instance, if the URL is
"http://www.foo.com/bar", then you would enter
"http://www.foo.com". If the URL is
"https://www.example.org:8000/foo", then enter
"https://www.example.org:8000".
* Annotation: Enter the HTTP realm, without the quotes.
* Username, Password: Your credentials.
6. Click "OK".
Thanks to Daniel Dawson (add-ons' dev for his quick answer)
From: https://groups.google.com/forum/#!topic/ddawson-addonssupport/4bQ7COtMiKU
- (2192)How to make Pocket work in FF?
Add an Exception for Pocket in Firefox Privacy Settings
Pocket relies on "cookies" to keep you logged in and to save pages to your Pocket account. If your Firefox Privacy settings are set to "Never remember history", Pocket will ask you to log in each time you try to save to Pocket.
The easiest way fix this issue is to relax your Privacy settings:
Go into Firefox Preferences, and select Privacy
In the History section, select Use Custom Settings For History
Uncheck Always use private browsing mode
[Optional] Uncheck any other privacy options that you prefer not to use
Click the Exceptions button
Enter https://getpocket.com in Address of Website field, and click the Allow button. Then, click Save Changes
After making these changes, please try again to save to Pocket.
From: https://help.getpocket.com/article/1046-trouble-saving-to-pocket-stuck-in-a-loop
- (2206)Neat extensions for Chromium
- Contact Out (find anyone's email address)
https://chrome.google.com/webstore/detail/find-anyones-email-contac/jjdemeiffadmmjhkbbpglgnlgeafomjo?hl=en
- (2217)What is the difference between assert*() and verify*() in Selenium/Selenese?
The difference is that as soon as an assert*() is not verified, the
execution of the test is stopped and FAILED is returned, leaving some
actions not executed. On the contrary, if a verify*() is not verified,
the test is marked as FAILED, but its execution continues. Thus with
verify*(), a test might have multiple reason for its failure.
assert*() is preferable if you need to FAIL as soon as possible or,
more importantly, if there are actions that might damage the system
under test, if executed in wrong conditions (*). verify*() is
prefereable if [it is possible and] you want to combine multiple
checks in a single test file.
(*) \"If you are running Selenium tests on a production system and want
to make sure you are logged-in as a test user e.g., instead of your
personal account, it is a good idea to first *assert* that the right
user is logged in *before triggering any actions that would have
unintended effects, if used by accident*.\"
From: https://stackoverflow.com/questions/5743848/assert-vs-verify-in-selenium
- (2225)How to send the link to the current page by email in FF without any plugin?
"File" menu, and choose the "Send" Link command
From: http://www.freeemailtutorials.com/webBrowsingAndEmail/emailLinksFromFirefox.cwd
- (2233)How to copy an extension from one Chrome installation to another (without internet and installer - crx file)?
- Open the extensions page (chrome://extensions/)
- Click the Developer mode check-box
- Examine the ID of the extension (long string of letters next to ID:)
- Open the User Data Directory, then the Extensions directory
- Copy the folder with the same name as the extensions’s ID to the Extensions folder of the target system
- Open the file Preferences in the User Data Directory in a text editor
- Find the section containing the extension (do a search for the ID)
- Copy the whole section, making sure to match braces correctly, for example:
"jchfimlohbodnpamghfgfgabbnfajpbe": {
"from_bookmark": false,
"from_webstore": false,
…
"path": "jchfimlohbodnpamghfgfgabbnfajpbe\\2012.6.9_0",
"state": 1
},
- Paste the extension in the Preferences file of the target computer. Check the trailing comma ( the }, at the end of the block). If the block you pasted is the last one (i.e., the next line is a single brace one indent back), then you must remove the comma, but if it is another block, then you must make sure it’s there (it’s obvious whether you need it or not when you actually paste it)
- Save the file (you may want to make a backup of Preferences and maybe even your whole Extensions directory) and run Chrome
From: https://superuser.com/questions/462804/how-to-copy-an-extension-from-one-chrome-installation-to-another
- (2284)How to fake the referer when accessing a website in Firefox?
- Goto FF &gt; Web Developer &gt; Toogle Tools &gt; Network [&gt; Reload]
- Select the page in the \'Gantt\' diagram on the left
- Select \'Edit and Resend\', in the \'Header\' part on the right
- Add \'Referer: http://this.is.my.referer\'
From: https://w3guy.com/hidding-http-referer/
- (2306)Neat extensions for Thunderbird
- To send email with a delay or at a specific date => "Send Later"
https://addons.mozilla.org/en-US/thunderbird/addon/send-later-3/
https://korben.info/programmer-lenvoi-demail-avec-thunderbird.html
- To improve ThB's AdressBook and allow access to remote (e.g. Outlook) servers => "CardBook"
https://addons.thunderbird.net/en-US/thunderbird/addon/cardbook/
- To sort Search Results By Date (Not Relevance) by default
https://addons.thunderbird.net/en-US/thunderbird/addon/srsbdnr/
- To signal a spam to the French govt in 1-click
https://addons.thunderbird.net/en-US/thunderbird/addon/signal-spam/?src=cb-dl-mostpopular
- (2313)Workaround for installing VideoDownloadHelper companion .deb on ubuntu
My current (dirty) workaround:
# dpkg -x net.downloadhelper.coapp-1.1.3-1_amd64.deb /tmp/out/
# mkdir -p /etc/chromium && cp -fr /tmp/out/etc/chromium/* /etc/chromium/
# mkdir -p /opt/net.downloadhelper.coapp/ && cp -fr /tmp/out/opt/net.downloadhelper.coapp/* /opt/net.downloadhelper.coapp/
# mkdir -p /usr/lib/native-messaging-hosts/ && cp -fr /tmp/out/usr/lib/mozilla/native-messaging-hosts/* /usr/lib/native-messaging-hosts/
- (2348)How to Paste Text Without Formatting in Thunderbird?
Paste Without Formatting Shortcut Key : Ctrl + Shift + V
From: https://www.shorttutorials.com/thunderbird-keyboard-shortcuts/paste-without-formatting.html
- (2382)How to disable the double-spacing when editing html messages in Thunderbird?
- Go to Tools > Options > Composition > General tab.
- Uncheck where it says "When using paragraph format, the enter key creates a new paragraph.
From: https://support.mozilla.org/en-US/questions/1118727
- (2427)How to install Video DownloaderHelper companion app in Mint/Ubuntu?
My current (dirty) workaround:
# dpkg -x net.downloadhelper.coapp-1.1.3-1_amd64.deb /tmp/out/
# mkdir -p /etc/chromium && cp -fr /tmp/out/etc/chromium /etc/chromium
# mkdir -p /opt/net.downloadhelper.coapp/ && cp -fr /tmp/out/opt/net.downloadhelper.coapp/ /opt/net.downloadhelper.coapp/
# mkdir -p /usr/lib/native-messaging-hosts/ && cp -fr /tmp/out/usr/lib/mozilla/native-messaging-hosts/ /usr/lib/native-messaging-hosts/
- (2511)How to disable Firefox delay for activating OK button on Download Dialog Box
- Go to about:config
- Set security.dialog_enable_delay setting to 0.
From: https://superuser.com/questions/1023643/firefox-disable-delay-on-download-dialog-buttons#1023644
- (2527)Make Firefox understand new protocols (e.g.apt://) (a.k.a. how to solve "The address wasn’t understood" error)
- Go to about:config in your Firefox browser
- Right-click > New > Boolean > Name: network.protocol-handler.expose.apt > Value > false
- Try opening an apt:// link (if you type in yourself, it searches for it on Google). It will show a pop-up, select AptUrl, and tick the option to remember it.
From: https://askubuntu.com/questions/968711/firefox-the-address-wasn-t-understood#969085
- (2532)How to change playback speed in Vimeo or Netflix video in Firefox?
- Inspect Element
- Search video Tag
- Open the URL in another tab
- Inspect Element in the new tab
- Search for &lt;video&gt; tag
- In the \"JS console\" type $(\'video\').playbackRate=1.5
From: https://www.youtube.com/watch?v=FFdz2LrkNuQ
- (2536)How to "Bookmark all tabs" in Firefox 64+?
1. Right click on a tab and select "Select all Tabs", all tabs will be selected.
1b. You can Ctrl+Click to unselect a few tabs
2. Now right click on any tab again and select "Bookmark Tabs".
3. New Bookmarks dialog pops up, type the folder name and click ‘Add bookmarks’, done. Click on any tab to remove tabs from the selection.
You can use Ctrl+Shift+D shortcut also
From: https://techdows.com/2018/12/firefox-64-how-to-bookmark-all-open-tabs-at-once-now.html
- (2555)How to to force "Reader View" in FireFox on pages where the icon doesn't appear?
- AUTOMATIC: install "Activate Reader View" (https://addons.mozilla.org/en-US/firefox/addon/activate-reader-view/), an add-on for Firefox that will force reader view even if the icon is not displayed.
- MANUAL: add the following prefix to the URL in the address bar:
about:reader?url=<url>
From: https://superuser.com/questions/1113362/is-there-a-way-to-force-enable-reader-view-in-firefox-on-pages-where-the-icon-do
- (2656)How to automatically remove duplicate mails in Thunderbird?
1. Click on Tools > Options to open the preferences in Thunderbird
2. Click on the Advanced tab there
3. Select Config Editor under Advanced Configuration.
4. Enter mail.server.default.dup_action in the filter
5. Now right-click that entry and select modify from the menu.
You can change the parameter to the following values:
0 - this is the default value. It retrieves duplicate mails like normal mails.
1 - if you set the value to 1 duplicate mails will be deleted automatically once retrieved
2 - if you set the value to 2 duplicated mails will be moved right into the trash
3 - the value 3 finally marks duplicate mails as read
If you want to delete duplicate mails automatically in Thunderbird you set the value 1.
From: https://www.ghacks.net/2007/05/18/automatically-remove-duplicate-mails-in-thunderbird/
- (2670)How to exclude content from Thunderbird's global search (e.g. to remove RSS feeds from appearing in global search results)?
right click a folder > properties > general information, then unselect "Include messages in this folder in Global Search results"
Unfortunately such exceptions can only be configured on per-folder, not per-account basis :( This makes the process tedious if you have multiple folders to exclude!
From: https://superuser.com/questions/1125724/can-i-exclude-content-from-thunderbirds-global-search/1234728#1234728
- (2714)How to remove "What's New" Gift Icon from Toolbar and Main Menu in FF70+?
1. Open about:config (type in the addressbar)
2. Type whatsnew in Search filter box
3. Look for following preference in the window:
browser.messaging-system.whatsNewPanel.enabled
4. Double-click on browser.messaging-system.whatsNewPanel.enabled preference to Toggle the option value.
From: https://www.askvg.com/firefox-tip-remove-whats-new-gift-icon-from-toolbar-and-main-menu/
- (2911)How to enable/disable the microphone in Firefox once the dialog offering to do so has disappeared?
SOLUTION1:
- Right-click a blank area of the page
- Select "View Page Info" > "Permissions"
SOLUTION2:
- "Tools" menu > "Page Info" > "Permissions"
SOLUTIONS3:
- Click the padlock or "i" icon to the left of the site address
- Select the ">" icon
- Then "More Information" > "Permissions"
Then, in "Use the microphone" choose the option you need.
From: https://support.mozilla.org/en-US/questions/1168156
- (2913)How to solve Thunderbird's error: "Your message was sent but a copy was not placed in your sent folder (Sent) due to network or file access errors. You can retry or save the message locally to Local Folder" occurring repeatedly whereas your connection is OK?
This happened to me because I brutally deleted the whole content of /tmp/.
SOLUTION:
restart Thunderbird
Thanks PYF!
- (2955)How to change the colours of Thunderbird (a.k.a DarkTheme not fully applied)
PROBLEM: I've installed a dark theme for ThB, but the background of the email content remains white.
Edit > Preferences > Display > Formatting > Colors > "Use System Colors"
From: https://support.mozilla.org/en-US/questions/1090347#answer-797573
- (2996)How to Switch Between HTML and Plain Text Emails in Thunderbird?
= Output
Account Settings > Composition & Addressing > Compose Messages in HTML format
= Input
View > Message Body As > Original HTML / Simple HTML / Plain Text
From: https://www.ghacks.net/2010/08/16/switch-between-html-and-plain-text-emails-in-thunderbird/
- (3018)How to reduce Firefox's fonts without extension?
- Go to about:config
- Search layout.css.devPixelsPerPx
- Change value (BEWARE not too much under 1.0)
BEWARE: It is a global zoom factor. It affects both firefox's own fonts and the visited sites fonts. You might need to set Preferences > General > Zoom > Default Zoom to adjust site fonts
From: https://support.mozilla.org/en-US/questions/1199377#answer-1063520
- (3037)How to get French-like / 24hrs date format under lightning's Thunderbird extension?
If you want the ISO 8601 date format (YYYY-MM-DD) and 24hrs format, set the "LC_TIME" environment variable, use the "en_DK" locale.
From: https://support.mozilla.org/en-US/questions/1237962#answer-1170016
- (3041)How to remove the delay before activation of the "save" button in a Firefox download-dialog?
PROBLEM
It is supposed to be a security feature to prevent a malevolent website to trick you into saving a file one you disk.
I don't see how it is a problem as long as you're not dumb enough to execute a file you don't know. The only problem I can see arises if the file is so big that it fills your remaining free HDD space. But in such a case you would notice (and stop) it because the download would take a long time.
The problem is detailed here:
https://www.squarefree.com/2004/07/01/race-conditions-in-security-dialogs/
SOLUTION
1. Go to about:config
2. Set security.dialog_enable_delay = 0
From: https://security.stackexchange.com/questions/118077/is-the-save-button-delay-in-a-firefox-download-dialog-a-security-feature-what-d
- (3151)How to get your RSS feeds into folders in ThB (a.k.a. How to import Android\'s Aggregator exported OPML file into ThB\'s RSS reader)?
PROBLEM: in the subscribe window the RSS feeds appear in directories, whereas in the account left pane, only the directories appear (and all the feeds articles are mixed up inside).
1. Export your feeds in opml
2. Run the following script with \"xsltproc\" (it simply wraps each feed in a second layer of directory)
&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;
&lt;xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"&gt;
&lt;xsl:template match=\"outline[not(child::*)]\"&gt;
&lt;xsl:element name=\"outline\"&gt;
&lt;xsl:attribute name=\"text\"&gt;&lt;xsl:value-of select=\"@title\"/&gt;&lt;/xsl:attribute&gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select=\"@* | node()\"/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:element&gt;
&lt;/xsl:template&gt;
&lt;xsl:template match=\"/ | @* | node()\"&gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select=\"@* | node()\"/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
3. Remove all the feeds and import the new opml file
From: https://stackoverflow.com/questions/15483824/where-is-the-folder-view-for-rss-feeds-in-thunderbird#40496926
- (3153)How to read all the feeds from a top-level directory in the same place?
PROBLEM: when your feeds are in separate directories (2 levels hierarchy: 1 bottom-level dir for each feed + a few top-level dirs to organize them), some feed readers (like Android's Aggregator) allow you to read a mixup of all the feeds inside a directory directly when clicking the top-level dir. In ThB the top-level dir is empty.
A work-around it to create a "Saved Search" for each directory:
- Right click on your rss folder
- Search Messages...
- Change the drop down box from "contains" to "doesn't contain"
- Type a crazy word in the text field (I put "zigloo", pretty safe to assume that will never pop up in a rss feed, but you could go crazier)
- Click on "Save as Search Folder"
NOTE: every time you add a new feed in a directory you have to manually update the "Saved Search" and (unfortunately) the GUI is badly designed: you cannot select the whole directory checkbox to recursively select all the contained feeds, you have to select each feed one by one :[
From: https://stackoverflow.com/questions/15483824/where-is-the-folder-view-for-rss-feeds-in-thunderbird#15571275
- (3182)How to link to an internal position in a webpage even if there's no "id" attribute on it?
You can use "Text Fragments" to link-to / highlight any text in a webpage.
<webpage url>#:~:text=<Text To Link to>
NOTE: Only work in Chrome Version 81+
From: https://stackoverflow.com/questions/7983290/is-there-any-way-to-bookmark-or-link-to-a-section-of-a-page-without-an-anchor
- (3281)How to remove Google Cookies Collection warning with uBlockOrigin in Firefox?
PROBLEM: On most of its pages (Google, YouTube, etc.) Google has added an annoying popup that forces you to accept the collection of cookies, etc.
SOLUTION: use &micro;BlockOrigin + the following rules:
- by CSS:
www.google.*##body.QVCmK:style(position: static !important; overflow-y: visible !important;)
www.google.*##html.QVCmK:style(overflow-y: visible !important;)
www.google.*###main #lb &gt; div[id^=\"_\"] &gt; div[class*=\" \"]:not([id]):empty:matches-css(opacity: 0.7)
www.google.*###main #lb &gt; div[id^=\"_\"] &gt; div[class*=\" \"]:not([id]):has( &gt; span &gt; div[role=\"dialog\"] &gt; #cnsw &gt; iframe[src*=\"://consent.google.com\"])
- by :remove():
www.google.*###main #lb &gt; div[id^=\"_\"] &gt; div[class*=\" \"]:not([id]):empty:matches-css(opacity: 0.7):remove()
www.google.*###main #lb &gt; div[id^=\"_\"] &gt; div[class*=\" \"]:not([id]):has( &gt; span &gt; div[role=\"dialog\"] &gt; #cnsw &gt; iframe[src*=\"://consent.google.com\"]):remove()
From: https://www.reddit.com/r/uBlockOrigin/comments/iqtou7/remove_google_warning/
- (3310)How to prevent bookmarks toolbar from disappearing in fullscreen mode?
(1) Set up your chrome folder and userChrome.css file following the five steps in this article:
https://www.userchrome.org/how-create-userchrome-css.html
I have a boring video there if you like demonstrations.
(2) This is the code to paste into the file. You can edit the file using Notepad or a better editor. Make sure to keep it in a plain text format with a .css file extension (not .css.txt).
/*
Override hiding of Bookmarks Toolbar in F11 full screen
when you roll down the tabs/main toolbar
*/
#navigator-toolbox[inFullscreen="true"] #PersonalToolbar {
visibility: unset !important;
}
(3) Firefox should read the file at its next startup. If the Bookmarks Toolbar is displayed before going into full screen, it should roll down with the main toolbar after you're in full screen.
From: https://support.mozilla.org/en-US/questions/1212156
- (3359)How do I get rid ow the \"What\'s New\" button in Firefox?
- Go to about:config
- Set \"browser.messaging-system.whatsNewPanel.enabled\" to false
From: https://support.mozilla.org/en-US/questions/1271264
- (3387)How to access Google Calendars in Thunderbird without plugin?
You can access Google's calendar as CalDAV:
In Google Web interface for the calendar:
- Get the calendar ID: in the pull-down menu next to the calendar name, select Calendar Settings. On the resulting page the calendar ID is shown in a section labelled Calendar Address. The calendar ID for a user's primary calendar is the same as that user's email address.
In Thunderbird
- Choose CalDAV
- Enter the URL in the Location field
https://apidata.googleusercontent.com/caldav/v2/<calendar_id>/events
- Click Next
- Choose the name and color for the calendar you just added
- If you also check the Offline Support option, you can use your calendar when you are offline
- Click Next
- You'll get a confirmation that your calendar has been created
- Click Finish.
From: https://support.mozilla.org/en-US/questions/1261974
- (3388)Where to find the configuration (e.g. URL) of the calendars in Thunderbird?
- All settings are stored in file prefs.js, including Thunderbird and Lightning settings.
- Data is stored in storage.sdb and the mentioned calendar-data folder.
From: http://forums.mozillazine.org/viewtopic.php?p=9759569&sid=a8da61603b8bff7adf8ed68795deb847#p9759569
- (3457)How to show Firefox Bookmark Toolbar in Fullscreen Mode?
1. Find your profile directory (~/.mozilla/firefox/<hash>.<profile_name>)
Also See Tip#3458
2. Create a folder named "chrome" if it doesn’t exist yet.
3. Create a file called "userChrome.css" in the "chrome" folder
4. Add the following content
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
/* full screen toolbars */
#navigator-toolbox[inFullscreen] toolbar:not([collapsed="true"]) {
visibility:visible!important;
}
5. Restart your Firefox and Voila!
From: https://shinglyu.com/web/2016/06/20/firefox_bookmark_toolbar_in_fullscreen.html
- (3458)Where does Firefox stores the profile directory?
SOLUTION1: GUI
- Open about:support in Firefox.
- Click the "Open Directory" button in the "Profile Directory" field.
SOLUTION2: CLI
$ grep "^Default" .mozilla/firefox/profiles.ini
From: https://shinglyu.com/web/2016/06/20/firefox_bookmark_toolbar_in_fullscreen.html
- (3497)How to remove the annoying Google Consent Dialogs?
https://addons.mozilla.org/en-GB/firefox/addon/google-consent-dialog-remover/
https://addons.mozilla.org/en-GB/firefox/addon/google-consent
- (3498)How to remove the delay on the OK button to download?
NOTE: it's a stupid pseudo-security measure for Windows users...
- about:config
- set security.dialog_enable_delay to 0
From: https://support.mozilla.org/en-US/questions/1176544
- (3531)How to search on Google page for another country?
Since 2017, Google automatically detects your country and redirects to the specific page for your country, even if you type https://www.google.<another country> as the URL. So if you are a foreigner in another country or if you use a VPN or if you use DDG shebangs, you're out of luck...
- Cliquez sur Paramètres en bas à droite de l’écran
- Cliquez sur Paramètres de recherche.
- Cliquez sur Langues.
- À l’étape « Affichage des résultats de recherche en » sélectionnez la langue du pays dans lequel vous voulez chercher.
- Pour l’expérience complète, vous pouvez aussi modifier la langue d’affichage de Google juste au-dessus.
- Enregistrez : voilà , c’est fini.
From: https://www.numerama.com/tech/301753-comment-faire-une-recherche-sur-le-google-dun-autre-pays.html
- (3534)How to solve problem that ùeetings are assigned to the wrong calendar and are not changeable in Thunderbird?
- Each calendar has an email address assigned.
- Right-click the calendar - Properties.
Is the email address assigned to your pool hours calendar the same as the email address the meeting invitation has been sent to?
If so, you know why the meeting invitation ends up in your pool hours calendar.
You'd need to assign the email address the meeting invitation has been sent to to your business calendar.
You don't need to assign any email address to your pool hours calendar.
From: https://support.mozilla.org/en-US/questions/1154187#answer-954917
- (3628)How to solve the "empty message" problem when searching in ThB?
PROBLEM:
- Search for email.
- Get search results.
- Click on message.
- It's empty.
SOLUTION:
Try to rebuild the index.
- Quit Thunderbird.
- Locate the global-messages-db.sqlite file in your Thunderbird Profile.
- Delete the global-messages-db.sqlite file.
- Start Thunderbird.
The re-indexing process will start automatically. Depending on the number of messages, it might take some time for the indexing to complete. You can continue to use Thunderbird, but performance might be affected and search will return only partial results or even no results until the indexing is complete.
The indexing progress can be monitored through the Tools > Activity Manager menu.
From: https://support.mozilla.org/en-US/questions/1066139
https://support.mozilla.org/en-US/kb/rebuilding-global-database
- (3686)How to disable annoying "Downloads" pop-up windows in FF 98+?
- about:config
- Search for pref browser.download.manager.showAlertOnComplete
- double-click to change to false
- Search for browser.download.alwaysOpenPanel
- double-click to change to false
From: https://support.mozilla.org/en-US/questions/822640
https://support.mozilla.org/en-US/questions/1370696
- (3689)How to set the default volume level for FF tabs?
about:config
media.default_volume
media.volume_scale
- (3696)How to disable the annoying new behavior of Firefox 99 that saves files (into Downloads/) that you only wanted to open (a.k.a. How to force Firefox 99+ to Start Downloads in Temp Folder Again)?
- about:config
- set browser.download.improvements_to_download_panel to false
- set browser.download.start_downloads_in_tmp_dir
From: https://support.mozilla.org/en-US/questions/1370409
https://www.askvg.com/tip-force-firefox-to-start-downloads-in-temp-folder-again/
- (3722)How to move emails from different folder/emails from a single user?
PROBLEM: When doing a search, email are presented as a thread and not selectable.
SOLUTION: force display of search result as a list, then moved emails
- Do a Global Search (Ctrl+K)
- Enter joe@123.com
- Select filters if desired in the left pane
- **Click 'Open email as list'**
- Select all the messages (Ctrl+A)
- Right-click > 'Move to...'
From: https://support.mozilla.org/en-US/questions/1167083#answer-984890
- (3744)How to disable automatic update checking in Firefox for Windows (e.g. if they are managed externally e.g. with PortableApps)?
PROBLEM: Starting in version 63, Firefox no longer includes the option to completely disable updates. The option "Never check for updates" has been removed from the Preferences > General section.
SOLUTION:
- Close Firefox.
- Open the Registry Editor app.
- Go to the following Registry key : HKEY_LOCAL_MACHINE\Software\Policies
- Create a new subkey here named Mozilla. You will get the path HKEY_LOCAL_MACHINE\Software\Policies\Mozilla
- Under the Mozilla key, create a new subkey Firefox. You will get the path HKEY_LOCAL_MACHINE\Software\Policies\Mozilla\Firefox
- On the right, create a new 32-Bit DWORD value DisableAppUpdate
Set its value to 1
- You can open Firefox. The updates are now disabled.
From: https://winaero.com/disable-updates-firefox-63-above/
- (3745)What are the parameters that you can set in the registry for Firefox in Windows?
Also see Tip#3744
From: https://github.com/mozilla/policy-templates/blob/master/README.md
- (3748)How to (de)(re)authorize access to mic/cam when firefox does not show the related popup anymore?
- Tools > Page Info (Ctrl-I) > Permissions
From: https://support.mozilla.org/en-US/kb/how-manage-your-camera-and-microphone-permissions#w_use-firefoxs-address-bar-to-clear-camera-or-microphone-permissions-for-a-site
- (3766)How to restore firefox windows or tabs after accidentally closing them?
- Open a new Firefox window
- Type Alt-f to display/open the menu line
- Go to History
- Visit either "Recently closed Tabs" or "Recently closed Windows"
BEWARE: might not work if you completely closed ALL firefox windows and have set your privacy settings to delete History on close.
From: https://www.theinternetpatrol.com/how-to-restore-firefox-windows-or-tabs-after-closing-and-accidentally-reopening-firefox/
- (3811)How to temporarily switch between Plain-Text & HTML email composition?
Hold the [SHIFT] key while clicking the "Write" (Compose) button.
From: https://blog.pengoworks.com/index.cfm/2005/6/20/Thunderbird--Temporarily-Switch-Composing-Between-Plain-TextHTML
- (3822)How to enable browsing with DNS Over TLS (DoT) on the whole system?
1. Edit your /etc/systemd/resolved.conf by adding the following single line of text
DNSOverTLS=yes
2. Go to any Network Manager's configuration tools (e.g. nm-applet)
3. Point the DNS to one that supports DoT:
e.g. Quad9 DNS servers: 9.9.9.9, 149.112.112.112
( If you use IPv6: 2620:fe::fe, 2620:fe::9 )
4. Restart services
# systemctl restart systemd-resolved
# systemctl restart NetworkManager
5. Test the config: https://on.quad9.net
# tcpdump -i 'port 853'
+ surf any website on FF, you should see requests to Quad9 (or any other DoT server condifgured at step 3.)
From: https://www.ubuntubuzz.com/2022/04/enable-browsing-with-dns-over-tls-dot-on-ubuntu-made-easy.html
https://www.internetsociety.org/fr/blog/2018/12/dns-over-tls-sous-linux-systemd/
- (3827)How to permanently zoom any page (change font size) in Thunderbird?
- Menu app icon > Options/Preferences > General
- Scroll down to the very bottom
- Click on 'Config Editor' button to open 'about:config'
- Accept the risk.
- In search type: pixels
- Look for this line: layout.css.devPixelsPerPx
- Double left click on that line to open the 'Enter string Value' box so you can edit the Value.
- The default value will be a negative number: -1.0
- Enter a new positive number eg: 1.25 or 1.5 or 2.0 or 2.2
- Click on OK
From: https://support.mozilla.org/bm/questions/1345517#question-reply
- (3885)How to disable 'threading' (sorting email by conversation) on a folder in Thunderbird?
- Disable threading on a folder
+ At the top of the Thunderbird window, click on the 'View' menu
+ In the 'Sort by' submenu, choose Unthreaded
- Apply current threading mode to other folders
+ Click the "column chooser" icon to the far right of the message list column headers ("Select columns to display")
+ Click Apply Current View to... near the bottom of the menu
+ Choose a target folder from the "Folder..." menu to apply the current view only to a single folder, or from the "Folder and its children..." menu to apply it to multiple folders, which can also be an entire email account.
- Change default threading mode
+ At the top of the Thunderbird window on the Menu Bar toolbar, click the Edit menu and select Settings, or on the Mail Toolbar click the "burger menu" ≡ button and choose "Settings".
+ At the bottom right corner of the "General" section, click the "Config Editor" button to open the "Advanced Preferences" tab.
+ Type "mailnews.default_view_flags" into the Search preference name search box.
+ Click the "Edit" ✎ button
+ Change the value of the preference:
0: New folders will default to Unthreaded.
1: New folders will default to Threaded (this is the default).
+ Press Enter or click the ✓ Save button to confirm the new value.
From: https://support.mozilla.org/en-US/kb/message-threading-thunderbird#w_applying-threading-to-other-folders
- (3896)How to download YouTube videos Subtitles/Transcriptions?
SOLUTION1: Copying Transcripts from YouTube
- Navigate to a YouTube video with subtitles
- Click "…" below the video.
- Click "Open Transcript"
- Click "⋮" followed by Toggle Timestamps (Optional)
- Select (ctrl+a) + Copy (ctrl+c) the text into a text editor
SOLUTION2: Using A Subtitle Downloader
- Navigate to a YouTube video with subtitles
- Copy the video URL
- Go to https://savesubs.com/ in a web browser
- Paste the URL of the video
- Click "Extract & Download"
From: https://www.wikihow.com/Download-YouTube-Video-Subtitles
- (3924)Howto test if mic/cam work in WebRTC on any browser (Firefox/Chrome/...)?
https://webrtc.github.io/samples/src/content/getusermedia/audio/
https://webrtc.github.io/samples/src/content/devices/input-output/
https://webrtc.github.io/samples/src/content/peerconnection/audio/
https://webcammictest.com/de/check-mic.html
https://mictests.com/
https://www.onlinemictest.com/
https://test.bigbluebutton.org/
From: https://github.com/bigbluebutton/bigbluebutton/issues/9568
- (3929)How to recover a Deleted Draft in Thunderbird?
- In your ThB profile (~/.thunderbird/<id>/<Imap>Mail/<server>/) there is a "Drafts" file.
- Copy it
- Open it with a text editor and extract the mail you are interested in into file xxx.email
- In ThB go to File>Open>Saved message and select the file xxx.email
From: http://forums.mozillazine.org/viewtopic.php?f=39&t=1971971 [text above is adapted from this source but works also with ciphered emails]
- (4057)How to definitively remove "YT Shorts"?
SOLUTION1: Go to the "Shorts" section of the YT welcome page, hit the cross "X" at top right of this section
SOLUTION2: Define a rule in µBlockOrigin to bloc kthis section
SOLUTION3: Install "YouTube Shorts blocker" extension
From: https://www.youtube.com/watch?v=I2eUWbdwMeY
- (4074)How to disable translation popup in Firefox?
- Load about:config in the Firefox address bar
- Confirm that you will be careful
- Search for extensions.translations.disabled
browser.translation.ui.show
browser.translations.automaticallyPopup
browser.translations.panelShown
- Set the preference to FALSE to enable translations in Firefox
From: https://www.ghacks.net/2021/05/29/mozilla-integrates-firefox-translations-into-firefox/
https://techvenkat.com/disable-firefox-translation-popup/
- (4084)How to make pdf.js full screen?
Ctrl + Alt + P
From: https://github.com/mozilla/pdf.js/issues/3286#issuecomment-467721644
- (255)difference Proba / Fuzzy
- en proba, on est soit vrai soit faux. En fuzzy on peut être vrai ET faux en même temps
- proba disent "Je crois à X% que le fait Z est vrai. Mais, dans le monde réel, Z ne peut être que vrai XOR faux (la vérité absolue dans le monde est vrai/faux, mais l'agent peut avoir des croyances subjective sur le monde)". Fuzzy dit "Dans le monde réel, Z peut être plus ou moins vrai ou faux (la vérité absolue est fuzzy, l'agent "possède" la vérité absolue)"
- (97)How to be a candidate to a teaching and research position in France
1. Use ANTARES/ANTEE to get the published jobs.
(being member of young researchers associations and subscribing to lots of mailinglist also helps)
2. Call the names / send emails to the names given
a. prepare a mail for teachings, with a synthetic view of what you did: audience, durations, domains, type: Lectures/Pratical works, investment in material and organization, etc.), link to synthetic tables on you web site, and complete description on your website
b. prepare a mail for research activities with a synthetic view of what you did, the places you where, the names of famous people that supervised you. Talk about research and projects you are involved in. Link to the complete work on your website, link to the list of your publications on your web site. Add a word about your openness towards participating into projects and your mobility.
Tip:
- the teaching contact is the one called "Directeur du département XXX"
- the research contact is the one called "Directeur du laboratoire XXX"
3. Send an application file
- must contains: short CV, list of publications, section on past teachings, section on past research, section on administrative tasks and responsibilities. Add a section about your integration with the teaching team, idem with the research team.
-
- remember to facilitate the work of the reader : give tables of teachings by year, by type (Lecture, etc.) and by domain (groups: basics, classical, with link to research domain)
4. If you are selected for an audition, get your laptop, a copy of the slides on paper for overhead projector, on USB key and on URL. Prepare paper copies for the jury.
- (110)How to review a paper
Most of the automatic reviewing processes have their own evaluation criteria. Remember to use the given criteria if it is your case.
Otherwise, a complete form should contain the following fields (it is
inspired from seral forms found on the web):
- About the reviewer
-> Reviewer's name
-> Reviewer's confidence: High / Medium / Low
- About this review
-> Authors: list the authors.
-> Title: give the title of the paper.
-> Abstract: in a few sentences, explain (in your terms what the paper) is about.
-> Final evaluation: accept paper with no modification / with minor modifications / with major modifications / accept as short paper / reject paper
-> Arguments: give arguments for the final decision (advantages and drawbacks of the paper)
- General Remarks
->Significance:
* Does the paper correspond to the conference's CFP?
* How important is the work reported?
* How difficult is the problem it adresses?
* What lesson(s) does the paper offer the scientific community?
-> Originality:
* To what extent is the reported work new?</LI>
* To what extent are the techniques, methods, or findings new?
* To what extent does the paper discuss relevant research?
-> Correctness (more adapted for theoretical papers): is the paper technically sound?
-> Positioning: is the paper well positioned with respect to the current state of the art?
-> Evaluation of the results (more adapted for papers with applications):
* Do the authors carefully evaluate their approach through systematic experiments, theoretical analysis, or some challenging, application-specific demonstration?
* Does the evaluation result in compelling evidence for performance gains over alternative approaches, psychological validity, and/or practical utility?
-> Clarity:
* Does the paper describe the method(s) in sufficient detail for a reader to replicate the work?
* Does it describe the inputs, outputs, and the procedure(s) employed?
* Is the paper well written and organized?
- Detailed domments:
-> Give page and line references
-> Give precise bibliographical references
Also see tips from http://distill.pub: https://docs.google.com/document/d/16BNLdSmoUc1zqydECJ8trYkVNDnKVlxT57EEXhCxWSc
- (248)How to recruit an internship (apprenti @ CEA)
Preparation:
1. You can ask the candidate to do a programming/algorithm test (beware: it's often not free...):
- https://www.testdome.com/
- https://projecteuler.net/
- https://codility.com/
- https://www.codewars.com/
- http://adventofcode.com/2017
- https://www.hackerrank.com/
- http://www.kaggle.com (DataScience mini-projects)
- http://ideone.com/ (Online Java/C/C++/... environment for testing code during interview)
2. You can test the candidate language skills (English/French/..., not programming)
- https://tests.hermes.nflx.io/
The job interview can be split into 3 parts, which help prevent blank in communication and make the candidate comfortable:
Phase 1. Present briefly the enterprise/lab
Phase 2. Ask question about the Curriculum
Phase 3. Present how the job is supposed to take place (se dérouler)
Phase 1
=======
- Present (10 slides max) the enterprise/lab and projects
e.g. - HUMAN RESOURCES: We are composed of X divisions, ours is the Yth, with Z billions euros budget and K persons working together, etc.
- SCIENTIFIC CONTENT: We are doing AI: research/modelling and development/software
- APPLICATIONS: The models we develop are applied on different domains: health, energy, etc.
- Present the people in presence (Name, Title, Role)
- Note the behavior of the candidate: is s/he pro-active, asking questions? Does s/he show interest (or, at least, that he follows the discussion)? Is s/he too relax and almost sleeps?
- END WITH : Do you have any question on the enterprise or projects you have seen?
Phase 2
=======
- Ask the candidate to present herself
- Ask the candidate to rephrase the internship proposal (then correct/complete her understanding)
- Ask the candidate to explain some of the main concepts/requirements/keywords of the internship
- If there are any ambiguities/holes in the Curriculum, then ask for explanations. And observe reactions/answers of the candidate when s/he answers.
- For the subject of interest (e.g. "Programming"), ask questions about
- The origins of the motivation (e.g. "When did you start being interested in computer science?", ask more about the hobbies: do they include geek stuff? cite several areas of interest - e.g., those of computer science: systems, networks, databases, security, programming, software design, etc.- and ask which ones are the ones that the candidate prefers)
- The practical competences (e.g. "What are the languages you know? Which one do you prefer? Would you be interested/reluctant to use another one?")
- The theoretical competences (e.g. "Did you use any design/software engineering methodologies (like UML) in your projects? Did you write yourself the specifications/cahier des charges? Were your interactions with your bosses formal (specifications) or rather informal (mainly oral/friendly interactions)?")
- Understand if the candidate is able to work in Team and/or Autonomously
- Ask within the previous school-projects and internships if s/he has been taken to work with others or if s/he worked alone.
- Ask for the sizes of the teams s/he worked in
- Ask for his/her role in the team
- Ask if the interactions within the team were rather formal (write specifications) or informal (mainly oral interactions in a P2P fashion)
- Ask if s/he used revision control systems
- Ask how the candidate organized him/her-self during these works (see if s/he pronounce the keyword "gantt diagram")
- Ask what is the future/final job that the candidate would like to have (e.g. see if there is a problem, like s/he wants to be researcher while applying for an industrial internship)
- Imagine you have finished your internship & diploma, you have the job of your dreams ; we are 10 years from know, in what position are you ? In what kind of company/institution? ...
- Quick&Dirty test for programming skills: 'please describe the last bug that took you very long to find/correct". [Thanks José@ESM]
- Test if the candidate has abilities in English (TOEIC, TOEFL, speak directly in English, etc.)
- Ask questions about her knowledge in research
- What do you know of the research domain?
- Have you ever read/reproduced/written a (scientific) paper?
- Administrative questions:
- When can you start the internship?
- How long the internship should be for your student program?
- Do you have the accommodation in <City>?
- Do you need a visa? How much it takes to have one?
- For an internship: is your administration prompt to fill papers?
[Thanks DJ]
- More questions to assess the candidate's motivation
- Do you have any other pending application(s)? If you are accepted on all of them, which one will you select and why?
- How would you position this job with respect to your whole career?
- What do you want to learn when joining us? What skills/competences to you want to bring to us/use/exploit when joining us?
- Pro/Cons of working in a startup (+flexibility/+responsibilities/+take risks/+flat organization/-do with little resources)/big company (+CE/+network??/-string hierarchy/-??)
- Do you already have a job? Why do you want to leave?
[Thanks DJ]
- Note the behavior of the candidate: is s/he pro-active, asking questions? Does s/he show interest (or, at least, that he follows the discussion)? Is s/he too relax and almost sleeps/yaws/makes annoyed noises? Does the candidate show timidity: does s/he look the interviewers in the eyes? Does s/he shake?
- END WITH : "Did/Do you have any other job interviews?". That might provide an idea about: if other companies were interested in his/her profile (not so much other job interviews), to see if the candidate will available rapidly (not so much other job interviews), if the candidate is motivated by this particular offer (or s/he is broadcasting)
Phase 3
=======
- Explain how would the job take place if the person is recruited
(e.g., "You will have 3 missions, one each year". "First we will introduce you to the programming language we use, using Labs-TP-likes exercises, then we will give you a mission that we will supervise, then a mission not supervised, to provide you with more and more autonomy", etc.)
- Explain the local work conditions (below examples are more specific to CEA):
-> There are XXX holidays per month
-> You have YYY compensations for lunch
-> You'll have full and unique access to an office and computer, etc.
-> You'll be considered as a full member of the team, don't hesitate to ask questions to anyone
-> The work day starts at XXX and spans YYY
-> You get a compensation of XXX for taking the bus to go to work/ You can access the "campus" thanks to private bus lines
-> The earnings are YYY, depending on (age, diplomas, etc.)
-> You have access to a (good) "mutuelle" / social&sports associations
-> The team is young and the atmosphere sympathetic
-> Explain how the previous internships took place and forward feedback for the previous candidates (e.g., lunch is cheaper than anywhere else, etc.)
- END WITH : Do you have any questions?
- Tell the candidate that you'll see other candidates and when you think you'll be able to give the partial (e.g. ranking)/final answer.
- For CEA: don't forget to sign the badge for the candidate to be able to get out of the "campus".
======================================================================
The final grid to evaluate:
- Motivation: .../5
- Technical competences: .../5
- Team-work: .../5
- Behavior during interview: .../5
- School notes/ranking: .../5
- Others: external +/- recommendations, etc.
- (319)How to write/review an introduction?
- Context
1. "In the domain of A, researchers have often worked on X, Y and Z [refs]..."
2. "<Description of an application domain>[ref]..."
- Problem (+ relavance & importance to the community)
1a. "...However, nobody has ever worked on K. K is important because it is complementary to X, Y and/or Z..."
1b. "...However, nobody has ever worked on K. K is important because X, Y, and/or Z rely on K to be applicable/feasible..."
2. "...When applying methodology X to this application domain, problems X, Y and Z arise. These problems are new to the community of X, because R, and are interesting since no trivial solution exists [refs]. Here we will focus particularly on Y".
- Methodology
1. "Based on AI's original principle "divide-and-conquer", we sub-divide our main problem into the following simpler sub problems..."
2. "In order to address this problem, we first do X, then Y, and finally Z..."
- Contribution
1. "The main contribution of this paper relies in the definition/formalization of..." [more theoretical contribution]
2. "In this paper we presents results that tend to show that..." [more practical contribution]
- (346)Home Automation Protocols
USHARE, XBMC ou MiniDLNA
- (471)How to do Machine Learning on Big Data?
Je crois qu'on va bientôt commencer à parler de "Big Data"... (j'ai
entendu parler de 300 Go de données pour un seul avion...)
Google, Facebook, Amazon & co utilisent Hadoop pour gérer leurs rivières
de données (Google a sa propre version codé en C++).
http://hadoop.apache.org/
En deux mots c'est un framework où l'on utilise des ordinateurs
conventionnels (un data center) et où la donnée est répartie sous forme
de "cluster" (des paquets de 64 ou 128 Mo en général). Le grand intérêt
de hadoop est de s'appuyer sur un algorithme s'appelant MapReduce. C'est
un principe où quand une tâche de calcul est à effectuer, elle est
"mappée", c'est à dire transformée en autant de sous-taches sur tous les
clusters concernés. Ensuite chaque résultats de chaque taches est
"réduite", c'est à dire aggloméré dans un résultat final.
Exemple : Tâches "Moyenne des temps de vol".
--> se mappe en "Calcul de la moyenne des temps de vol dans chaque
cluster de donnée"
--> résultat : un couple (Somme, NbVol)
--> Opération de reduce : Resultat = (Somme1 + Somme2 + ...) / (NbVol1 +
NbVol2 + ...)
En fait, dans le framework Hadoop, le code compilé et la donnée
"attaquée" sont dans la même machine, c'est ceci qui évite le goulot
d'étranglement de l'accès aux données.
Autres avantages, les clusters de données se dupliquent tout seul (en
général en 2 ou 3 exemplaires, c'est configurable) ce qui rend le data
center robuste aux crashs des machines. Personne n'a jamais perdu ses
données personnelles chez Google jusque là...
Sur le framework, des projets très intéressants (open source) se sont
mis en place. Par exemple, Cassandra est un projet qui permet d'obtenir
globalement les mêmes services qu'une base de données. Autre projet,
Mahout, propose une bibliothèque d'algorithmes de Data Mining et de
Machine Learning sous une forme MapReduce. La liste d'algo est ici :
https://cwiki.apache.org/confluence/display/MAHOUT/Algorithms
From: Stéphane
- (531)"Correlation does not imply causation" "Cum hoc ergo propter hoc"
Deux cyclistes arrivent de front. Ils doivent s'éviter. Ils peuvent chacun prendre la décision d'aller soit à droite, soit à gauche, soit tout droit. Ils ont un accident, se rentrent dedans.
- L'accident et les décisions des cyclistes sont liés par un lien de *corrélation*,
mais
- L'accident n'est pas la cause des décisions des cyclistes. Ces deux événements ne sont *pas* lié par un lien de *causalité*.
http://www3.ac-clermont.fr/etabliss/stael/ses/spip.php?article21
Il y a statistiquement plus de cyclistes dopés dans le Tour de France que dans les autres courses nous révèlent apparemment les observations, faut-il en conclure que ce sont les organisateurs du Tour qui obligent les coureurs à ce doper ?!!!
http://cyberzoide.developpez.com/opinions/index.php3?page=stat
C => A et C => B alors A&B corrélés mais A&B sans lien de causalité. Penser au cas de faits de la vie courrante complètement indépendants que des enquêtes médicales stupides relient par des liens de causalité au lieu de corrélations.
- (562)Cool news & mailing-lists sites
- PhD Guides:
http://cjc.jeunes-chercheurs.org/expertise/
http://guilde.jeunes-chercheurs.org/Alire/guide/
http://www.uq.edu.au/student-services/phdwriting/index.html -> https://web.archive.org/web/20140531032545/http://www.uq.edu.au/student-services/phdwriting/fr_phsta.html
- CS/IA/SMA Mailing lists
- Associations
https://fil.cnrs.fr/
http://www.afia.asso.fr/
http://scidolyse.ens-lyon.fr/ [DEAD: 2020?]
https://www.specif.org/ [DEAD: 2012?]
http://ssfam.org/
https://www.egc.asso.fr/liste-de-diffusion
- GdR
https://www.madics.fr/
https://www.gdria.fr/inscription/
https://gdr-tal.ls2n.fr/
http://www.irit.fr/GRACQ/rubrique.php3?id_rubrique=19
http://www.irit.fr/GDR-I3/Abonnement.html / https://listes.irit.fr/sympa/info/bull-i3
http://www.gdr-isis.fr/
https://www.gdr-robotique.org/
https://www.gdr-im.fr/
https://www.gdr-soc.cnrs.fr/
https://gdr-securite.irisa.fr/en/gdr-securite-informatique-en/
https://gdr-gpl.cnrs.fr/
https://gdr-rsd.cnrs.fr/
- MAS
http://www.loria.fr/~chevrier/ListeSMA.html
http://lists.cs.umbc.edu/mailman/listinfo/agents/
http://www.csee.umbc.edu/csee/research/kqml/misc/dailist.html
https://www.turing.ac.uk/research/interest-groups/multi-agent-systems
- SMA sites
http://turing.cs.pub.ro/auf2/html/chapters/chapter1/sommaire.html
http://www.agentlink.org/index.php
http://www.damas.ift.ulaval.ca/~jlaumoni/recherche-sma-n-nonchercheurs1.php4
http://multiagent.com/
- Robots
http://www.automatesintelligents.com/
http://www.ledroideenchaine.com/
http://www.robot-intelligence-artificielle.com/
http://robots.net/
http://shyrobotics.com/
http://www.zonerobotique.com/
http://www.generationrobots.com/boutique/index.cfm
- Science News
http://interstices.info/jcms/jalios_5127/accueil
http://ercim-news.ercim.eu/
http://www.bulletins-electroniques.com/
https://ellis.eu/news
http://theaidaily.com/
https://aiweekly.co/
https://blog.acolyer.org/
http://blog.acolyer.org/feed/
https://www.linkedin.com/today/author/andriyburkov?trk=pulse-article_more-articles
https://twitter.com/ai__pub/
- (563)Cool sites & books
- In General:
http://www.faqs.org
https://devdojo.com/rahulism/21-super-devtools-you-may-have-not-heard-of
https://learnxinyminutes.com/
https://dzone.com/refcardz
https://www.cheat-sheets.org/
https://cheatography.com/
https://www.codecademy.com/resources/cheatsheets/all
https://www.kdnuggets.com/cheatsheets/index.html
https://www.rstudio.com/tags/cheatsheet/
https://www.datacamp.com/cheat-sheet
- HUGE list of educational material in many languages
https://limnology.co/
https://fireship.io/
https://fr.vittascience.com/code
- Online Coding Games/Challenges
https://dev.to/annequinkenstein/games-to-learn-coding-3o9k
- CSS
https://dzone.com/asset/download/143
- JavaScript
https://wtfjs.com/
http://perfectionkills.com/
- Java
http://mindprod.com/jgloss/jgloss.html
http://www.faqs.org/faqs/computer-lang/java/programmers/faq/
http://www.jmdoudoux.fr/accueil_java.htm
https://dzone.com/asset/download/51834
- Caml
http://www.faqs.org/faqs/meta-lang-faq/
- C
http://www.faqs.org/faqs/C-faq/faq/
- C++
https://isocpp.org/faq
http://yosefk.com/c++fqa/index.html
http://www.faqs.org/faqs/C++-faq
- Python
http://www.briggs.net.nz/snake-wrangling-for-kids.html
https://dzone.com/asset/download/141
https://github.com/gto76/python-cheatsheet
https://www.python-graph-gallery.com/
- R
http://www.r-exercises.com/
http://journal.r-project.org/
http://www.statmethods.net/
http://addictedtor.free.fr/graphiques/
http://www.aphysicistinwallstreet.com/2011/11/free-books-for-r.html
http://rwiki.sciviews.org/doku.php?id=tips:tips
http://rwiki.sciviews.org/doku.php?id=guides:guides
http://rgm2.lab.nig.ac.jp/RGM2/images.php?show=all&amp;pageID=2194
https://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R
https://cran.r-project.org/doc/contrib/Short-refcard.pdf
https://cran.r-project.org/doc/contrib/YanchangZhao-refcard-data-mining.pdf
https://cran.r-project.org/doc/contrib/usingR.pdf
https://cran.r-project.org/doc/contrib/Zhao_R_and_data_mining.pdf
https://cran.r-project.org/doc/contrib/Robinson-icebreaker.pdf?
http://www.r-bloggers.com/
http://www.rdatamining.com/
https://journal.r-project.org/
https://cran.r-project.org/manuals.html
https://cran.r-project.org/doc/contrib/
https://cran.r-project.org/web/views/
https://dzone.com/asset/download/88835
- SCRUM
https://dzone.com/asset/download/75531
https://dzone.com/asset/download/111
https://www.lego4scrum.com/
- RegExes
https://dzone.com/asset/download/127
https://regex101.com/
- PostGreSQL
https://dzone.com/asset/download/5332
- Design Patterns
https://dzone.com/asset/download/273
http://www.mcdonaldland.info/files/designpatterns/designpatternscard.pdf
https://refactoring.guru/design-patterns/
- Docker
https://ostechnix.com/getting-started-with-docker/
- SSH
https://www.marcobehler.com/guides/ssh-cheat-sheet
- CVS
http://cvsbook.red-bean.com/cvsbook.html
- SVN
http://svnbook.red-bean.com/
https://dzone.com/asset/download/158
- GIT
https://dzone.com/asset/download/261
https://git-scm.com/book/en/v2
https://www.miximum.fr/blog/decouvrir-git/ [intro]
https://www.miximum.fr/blog/git-rebase/ [branching/rebasing]
https://dev.to/mursalfk/git-cheatsheet-for-2022-11m6
https://developer.ibm.com/tutorials/d-learn-workings-git/
- LaTeX
http://www.faqs.org/faqs/tex-faq/
http://www.faqs.org/faqs/fr/faq-latex-francaise/part1/
https://www.ntg.nl/literatuur/bayart/lxmanuel.pdf
https://www.learnlatex.org/en/
https://www.overleaf.com/learn
https://tug.org/FontCatalogue/
https://latex-cookbook.net/
https://texample.net/
- Tikz
http://www.texample.net/
http://math.et.info.free.fr/TikZ/bdd/TikZ-Impatient.pdf
- PlantUML
https://plantuml.com/starting
https://plantuml-documentation.readthedocs.io/en/latest/formatting/all-skin-params.html
- Dot
https://graphviz.org/doc/info/lang.html
- OpenBSD
http://www.faqs.org/faqs/386bsd-faq/part1/
http://openbsd.org/faq/index.html
https://openbsdjumpstart.org/
- Linux
http://www.faqs.org/faqs/linux/info-sheet/
- Networking
https://packetlife.net/library/cheat-sheets/
- Bash
http://tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashPitfalls
http://www.etalabs.net/sh_tricks.html
http://blackskyresearch.net/shelltables.txt
- GNU Make
http://www.gnu.org/software/make/manual/make.htm
- Emacs
https://www.reddit.com/r/emacs/comments/uioib2/wrote_some_basic_emacs_notes_for_myself_as_i_kept/
- Org-mode
http://orgmode.org/org.html
https://dzone.com/articles/ascii-art-diagrams-in-emacs-org-mode
https://github.com/fniessen/refcard-org-beamer
- Research
+ Reading papers
https://www.freecodecamp.org/news/building-a-habit-of-reading-research-papers/
+ Finding papers &amp; code
http://www.arxiv-sanity.com/
https://paperswithcode.com/sota
https://openreview.net/group?id=ML_Reproducibility_Challenge/2020
https://www.thecvf.com/?page_id=413#Helmholtz
+ Writing PhD/Articles
https://www.uq.edu.au/student-services/phdwriting/ -&gt; https://web.archive.org/web/20140531032545/http://www.uq.edu.au/student-services/phdwriting/fr_phsta.html
https://kmh-lanl.hansonhub.com/techwriting.html
https://perso.ens-lyon.fr/francis.albarede/conseils.php
https://web.archive.org/web/20120711192744/beethoven.site.uottawa.ca/dsrg/writing-style.htm
https://kmh-lanl.hansonhub.com/talks/writing18vgr.pdf
https://online.stanford.edu/courses/som-y0010-writing-sciences
+ Typography
https://web.archive.org/web/20160303175347/gargas.biomedicale.univ-paris5.fr/lt/typo.html
- SMA
http://turing.cs.pub.ro/auf2/index.html
- DataScience / Machine Learning
https://machinelearningmastery.com/
https://www.kdnuggets.com/
https://www.r-bloggers.com
- SciKit-Learn
https://www.kdnuggets.com/publications/sheets/Scikit-Learn_Cheatsheet_for_Machine_Learning.pdf
http://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html
http://scikit-learn.org/stable/auto_examples/cluster/plot_cluster_comparison.html
http://scikit-learn.org/stable/auto_examples/manifold/plot_compare_methods.html
- IA - Websites
http://www.faqs.org/faqs/ai-faq/general/part1/preamble.html
- IA - Books
Agent Intelligence Through DataMining 0387243526.pdf
ArtificialIntelligence3rdEdModernApproachRussell.pdf
G.Weiss - Multiagent systems - a modern approach to distributed artificial intelligence.pdf
LesSMA_Ferber.pdf
OReilly.Programming.Collective.Intelligence.Aug.2007.pdf
Prentice Hall - Artificial Intelligence - A Modern Approach 2ed.djvu
Prentice Hall - Artificial Intelligence - A Modern Approach 2ed.pdf
Russel - Artificial Intelligence - A Modern Approach 2ed.pdf
Russel - Artificial Intelligence - A Modern Approach 3ed.pdf
The Agent-Oriented SW Eng Handbook.pdf
Wiley - An Introduction To Multiagent Systems [Wooldridge].pdf
ebooksclub.org__Collective_Intelligence_in_Action.pdf
jade_book.pdf
\"A collection of Data Science Interview Questions Solved in Python and Spark vol I &amp; II\"
- http://libgen.io/ads.php?md5=8F063BB8E101C5D3655034513A4-remove-37341
- http://libgen.io/ads.php?md5=C320F52FF7B7FCE2D133896F72A-remove-23B62
- Sites/Books recommended for a Google Interview
-&gt; Sites
https://projecteuler.net/
https://codility.com/
https://www.testdome.com/
-&gt; Books
\"Effective C++ 55 Specific Ways to Improve Your Programs and Designs\"
Myers
\"Introduction to Algorithms\"
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein
\"Programming Pearls\"
Jon Bentley
\"Cracking the Coding Interview 150 Programming Questions and Solutions\"
Gayle Laakmann McDowell
\"Programming Interviews Exposed Secrets to Landing Your Next Job\"
John Mongan, Noah Kindler, Eric Giguere
\"How Google Tests Software\"
James Whittaker, Jason Arbon, Jeff Carollo
\"The Art of Computer Programming\"
Donald E. Knuth
\"Design Patterns, Elements Of Reusable Object Oriented Software\"
Erich Gamma, Richard Helm, Ralph Johnson, John M. Vlissides
- \"How would you move Mount Fuji?\"
William Poundstone
- Hardware
https://www.storagesearch.com/ssdmyths-endurance.html
- LockPicking
https://www.youtube.com/watch?v=rnmcRTnTNC8
- Security
https://systemweakness.com/how-to-hack-any-website-c08daec978f6#6eb2
- Sustainable Dev
https://www.half-earthproject.org/
http://vhemt.org/
- (588)A few cool lectures on MAS
Cours en-ligne "Agents Intelligents"
http://turing.cs.pub.ro/auf2/index.html
----
Chapitre 6 - Logique de connaissance et de croyance
http://www.bj.refer.org/cours/coursenligne/autres_cours/agentintel/cours/apprenant/chapitres/chapitre6.htm#6.3
- (590)What are Asimov's three rules for robots?
1. Un robot ne peut porter atteinte à un être humain, ni, restant passif, permettre qu'un être humain soit exposé au danger.
2. Un robot doit obéir aux ordres que lui donne un être humain, sauf si de tels ordres entrent en conflit avec la Première loi.
3. Un robot doit protéger son existence tant que cette protection n'entre pas en conflit avec la Première ou la Deuxième loi.
- (620)How to get the impact factor of confs/journals?
http://www.adaptivebox.net/CILib/CICON_stat.html
Journal Citation Reports / Impact Factor
http://www2.lib.udel.edu/colldev/impact.htm
- (622)Basic questions to ask at the end of a presentation?
1. S'il fallait refaire, tu referais pareil ou changerais ? Tu changerais quoi ?
2. S'il ne fallait retenir qu'une seule chose ce serait quoi ? / Quelles sont tes contributions majeures ?
- (630)How to prepare/pass a job interview?
- Bcp de très bons conseils:
https://www.youtube.com/watch?v=IB9jFRLE56I&list=PLfSFLujgfxj5v86xhyx8ztkkP3rTpoyo2
- On peut s'entraîner sur:
https://dev.to/areedev/google-launched-the-best-interview-preparation-tool-24n9
- Choses à penser avant l'entretien
-> Se renseigner sur l'entreprise (buts, thèmes, etc.)
-> Se renseigner sur la/les personne/s de contact
-> [Recherche] Contacter les futurs collègues
-> Noter le nom et la position de la personne
-> Noter le téléphone de la personne de contact
-> Noter l'adresse du lieu + Imprimer un plan
-> Confirmer les rendez-vous
- Avant : Préparation entretien [See Tip#2254 & Tip#2261]
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/les-5-questions-a-se-poser-avant-un-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/quelles-questions-se-preparer-pour-un-entretien-telephonique.html
- Avant : Apparence
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-comment-ne-pas-etre-desavantage-par-son-physique.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/s-habiller-pour-un-entretien-d-embauche-les-erreurs-selon-les-secteurs-d-activite.html
- Avant : Le droit
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/4-exemples-de-mail-a-envoyer-apres-un-entretien-d-embauche.html
- Avant: Get info on the company (& bosses) before responding to an offer
* Previous employees opinions:
https://www.glassdoor.fr/Avis
* Typical Job Interview questions asked in this company
https://www.glassdoor.fr/Entretien
* Typical salaries in this company
https://www.glassdoor.fr/Salaires/
https://www.indeed.fr/salaries/D%C3%A9veloppeur-Salaries
https://www.indeed.fr/salaries/D%C3%A9veloppeur-Java-Salaries
https://www.indeed.fr/salaries/D%C3%A9veloppeur-Java-J2EE-Salaries
https://www.indeed.fr/salaries/Data-Scientist-Salaries [to find other jobs, use erroneous page: https://www.indeed.fr/salaries/D%C3%A9veloppeur-Javaeur-Salaries]
- Prepare for skills tests (coding, DataScience...)
I] Coding Tests
- Book "Coding Interview Ninja" Ekim Ouye
http://libgen.io/ads.php?md5=841BAF4161F654013F983D14B70-remove-7D8B8)
- Book "Programmation efficace : Les 128 algorithmes qu’il faut avoir compris et codés dans sa vie" Christoph Dürr, Jill-Jênn Vie
http://tryalgo.org/book/
- Online lessons & tests
https://codility.com/programmers/lessons/1-iterations/
https://codility.com/programmers/challenges/
https://www.testdome.com/
https://www.codewars.com/
http://adventofcode.com/2017
https://www.hackerrank.com/
+ See Tip#1995
II] DataScience Tests
- Book "A collection of Data Science Interview Questions Solved in Python and Spark vol I & II"
http://libgen.io/ads.php?md5=8F063BB8E101C5D3655034513A4-remove-37341
http://libgen.io/ads.php?md5=C320F52FF7B7FCE2D133896F72A-remove-23B62
- Book "120 real data science interview questions"
http://libgen.io/ads.php?md5=E780DDEDFE46FDD0CC5B5C9A404-remove-69CFE
- Online tips&tricks
https://www.springboard.com/blog/data-science-interview-questions/
- Online tests
https://www.kaggle.com/ (DataScience)
+ See Tip#1977
- Pour répondre
-> Attention au vocabulaire
-> Donner des exemples
-> Rester toujours positif
-> si question touche point difficile => dire que "il arrive que" (diminuer effet temporel) ou "on dit de moi que" (diminuer portée)
-> Parler en termes de réalisations
-> Sourire
- Se présenter / "Parlez-moi de vous" [See Tip#2254 & Tip#2263]
https://www.youtube.com/watch?v=8i4BaK9tUws
- Questions au candidat [See Tip#2255 & Tip#2268]
https://www.youtube.com/watch?v=-y3aB0kl5XE
https://www.youtube.com/watch?v=LkFDb1-UY6k
https://www.youtube.com/watch?v=Vv9RiBRE88A
https://www.youtube.com/watch?v=3G3yw-1NS_M
https://www.youtube.com/watch?v=u1xhzQg66xs
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-questions-evidentes-que-vous-negligez-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/doit-on-dire-la-verite-a-la-question-pourquoi-souhaitez-vous-quitter-votre-job.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-repondre-a-la-question-pourquoi-voulez-vous-travailler-ici.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/trou-de-memoire-en-entretien-dembauche-comment-ne-pas-perdre-la-face.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/defauts-qualites-cette-question-est-elle-encore-posee-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-phrases-que-les-recruteurs-entendent-a-chaque-entretien-d-embauche-et-qu-il-faut-oublier.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/les-questions-les-plus-ratees-par-les-candidats-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/justifier-un-trou-dans-son-cv-les-erreurs-a-ne-pas-faire.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/repondre-a-la-question-qui-tue-pourquoi-devrais-je-vous-embaucher.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-questions-auxquelles-on-ne-s-attend-pas-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-les-6-questions-auxquelles-il-faut-se-preparer.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/ce-quil-faut-cacher-aux-recruteurs-en-entretien-dembauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-dembauche-les-7-phrases-interdites.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/question-dentretien-repondre-a-pourquoi-vous-et-pas-un-autre.html
- Questions du candidat [See Tip#2262]
https://www.youtube.com/watch?v=ec0k0s3XWUk
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-reussir-a-faire-parler-un-recruteur-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/ne-quittez-jamais-un-entretien-d-embauche-sans-avoir-demande.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/ces-questions-que-les-recruteurs-aimeraient-que-vous-posiez-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/les-questions-a-oser-poser-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-questions-que-l-on-peut-poser-a-n-importe-quel-entretien-d-embauche.html
- Langage / Langage corporel
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-les-gestes-qui-tuent.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/les-phrases-a-bannir-quand-on-se-presente-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/ces-attitudes-qui-sement-le-doute-chez-les-recruteurs-en-entretien.html
- Gestion du stress
https://www.youtube.com/watch?v=clujak5AmoM
- Salaire
https://www.youtube.com/watch?v=Rf7NwRal3To [Leviers]
https://www.youtube.com/watch?v=TT161JONPBs
https://www.entretienembauche.tv/coaching-negocier-salaire-negociation-coach/ https://www.youtube.com/watch?v=npWkV5yVoaI [ "un salaire mal négocié au départ ne se rattrape jamais" / ne jamais croire aux promesses orales de renégociations futures ]
https://www.entretienembauche.tv/comment-negocier-son-salaire-d-embauche/ [ règle 3: toujours demander plus ]
https://www.youtube.com/watch?v=dsobAUgsrfA
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/pretentions-salariales-comment-evaluer-son-juste-prix.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/negociation-salariale-quels-avantages-peut-on-demander.html
- Techniques
https://www.youtube.com/watch?v=4nQ4fcgdtIA
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-5-astuces-pour-retrouver-l-interet-d-un-recruteur.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/6-trucs-pour-garder-la-main-pendant-un-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-4-phrases-pour-briser-la-glace-avec-un-recruteur.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-comment-obtenir-des-infos-que-les-autres-n-auront-pas.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-reagir-face-a-un-recruteur-grossier.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-demontrer-ses-qualites-a-un-recruteur.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-repondre-aux-attaques-des-recruteurs.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-dembauche-le-piege-des-3-dernieres-minutes.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-faiblesses-qui-servent-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-comment-parler-de-son-ancien-chef-quand-on-le-deteste.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-comment-reperer-un-mauvais-boss.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/5-techniques-pour-apprendre-a-se-vendre-en-entretien-d-embauche.html
- Ce que je peux apporter à une entreprise/labo:
-> Compétences en SMA et plus généralement IA
-> Compétences générales en info (Admin Système/Réseau, gestion site web...)
-> Compétences en gestion de projet
-> Relations internationales (Brésil, Espagne, Luxembourg, etc.)
- Se présenter ?
-> faire court (1 ou 2 minutes) / description rapide puis détails
-> cibler par rapport à l'entreprise/labo => parler des réalisations !
-> montrer qu'il y a une cohérence dans le projet de carrière
-> Exemple :
- Passionné d'info depuis bien avant le Bac
- => cursus informatique jusqu'à maîtrise à Paris XI
- découverte IA/SD, volonter de mélanger les 2 + intérêt bio (apport dans les 2 sens)
- => DEA (IARFA) à Paris VI avec but Vie Artificielle
- découverte des SMA, qui mélange tous les intérêts ci-dessus AI+SD+Bio
- => Thèse EMSE dans ce domaine
- dévpt 2 axes : communication agents / organisation (normes) / confiance-Rp
en + : ART-testbed
- poursuivi ses axes dans différents postes (ATER, "post-doc")
-> ESIL Marseille : modèles confiance, moteur recherche Web2
-> LORIA, 2 parties :
1. modélisation organisationnelle, système aérien
2. startup IntuitieMachine : assistant domestique intelligent et communicant
- ["élargissement à l'IA"] maintenant plus apprentissage
-> Brésil : création de joueur virtuels par apprentissage sur traces jeux réels
-> AiRPX : fouille de masses de données pour maintenance prédictive/détection pannes avions
-> mais en restant SMA, CEA : optimisation gestion énergie dans maisons solaires / décentralisation logique floue / modularité, remplacement appareil
- Mes domaines de compétence
-> Technique / AdminSys / Logiciels libres
- SMA : MadKit, Jade, Jason, MAST
- Web : HTML, XML, PHP, MySQL
- Développement : R, Java, C, C++, C#, Prolog, Caml, Pascal, assembleur, bash, Basic, Perl
- Génie Logiciel : UML, fusion
- Éditeurs : Eclipse, XEmacs, MonoDevelop, Visual C# & C++, vi
- Bureautique : LaTeX, OpenOffice, Microsoft Office
- Administration : Hadoop, IPCop, OpenVPN
- Logiciels et bibliothèques : CVS/SVN/Git, Weka, Gnuplot, GNU make, OpenGL, MPI/PVM
- OS : Slackware/ArchLinux/Ubuntu, OpenBSD, Windows 98/XP/7
-> Intelligence Artificielle : SMA, Clustering (KMeans, XMeans, EM, SOM, DBScan, LVQ, Mahalanobis), Classification (SMO, MLP, J48, RandomForest, HMM), Régression (régression linéaire, SMO, MLP, REPTree, ZeroR), Prise de Décision (Fuzzy Logic, Algorithmes Génétiques{}, Programmation Génétique)
-> Informatique : Simulation, Systèmes Distribués, Sécurité Réseau, Big Data, Tests Statistiques, Développement Logiciel
- Mes domaines applicatifs
-> Épidémiologie
-> Peer-to-peer
-> Web 2.0
-> Air Trafic Management
-> Domotique
-> Sérious Games
-> Natural Resource Management
-> Maison Solaire Termique
-> Air Fleet Management
- Comment gérez-vous les personnes avec qui vous ne vous entendez pas ?
-> Je m'entends avec tout le monde
-> Il est arrivé que je ne m'entende pas avec mon directeur de thèse => au final très bien passé
-> Il est arrivé au CEA avec supérieure => Stratégie : comprendre pb / rechercher la source => langage
- Qu'est-ce qui vous déplaît dans votre travail ?
-> Pas le temps de tout faire : plein de projets quand croise autres chercheurs en conférence.
-> Pas de résultats concrets
- Avez-vous déjà eu une déconvenue au travail ?
-> À l'ESIL, difficile de trouver collègues pour travailler en local => projet international ART
-> Pas de résultats concrets en fin de thèse.
- 3 Qualités [Mnémotechnique: A-P-E=Autonomie+Précision+Équipe]
-> Travail en équipe [ART-testbed: ]
-> Travail en autonomie [ESIL: pas de collègues]
-> Précision
-> Pédagogie
-> Organisation
-> Communication Orale et Écrite
-> Curiosité scientifique
- 3 Défauts [Mnémotechnique: =]
-> Hyperactif: mes collègues/amis me trouvent généralement Hyperactif (bcp sports, peu vacances). Je ne supporte pas de ne rien faire. Si pas d'activités/projet => je m'en crée.
-> Bavard : il arrive que l'on dise de moi que je suis Bavard, mais c'est surtout une bone façon d'amener les autres à parler d'eux et à créer des liens sociaux / projets
-> Perfectionniste: Il m'arrive d'être trop perfectionniste. C'est mon côté scientifique : Rigueur/Précision. Mais je sais être pragmatique quand il le faut. Exemple : correction orthographe des élèves.
- Pourquoi vous êtes intéressé par cette offre ?
-> Bien sûr, premièrement car il correspond à mes compétences actuelles (au que je souhaite acquérir)
-> Grand groupe :
- Qualité de vie (associations sportives et culturelles)
- Pérénité/Cadre d'évolution (moyens: poste travail, conférences, etc.)
Petite structure :
- Taille humaine
- Flexibilité
-> Challenge intellectuel
-> Mélange Recherche / Industriel : applications concrètes des travaux
- 3 Critères de choix final
-> Lien R&D + conception
-> Résultats concrets
-> Correspondance tâches affectées au poste / mes désirs/compétences
-> Localisation home/travail
-> Ambiance (futurs collègues)
- Le mail de remerciements [voir exemple plus bas]
-> ATTENTION: c'est la dernière image que vous laissez
-> surtout, rester formel, même si l'entretien ne l'était pas
-> message est précis, sobre, efficace, structuré et fluide (salutation de départ + deux phrases + formule de politesse: bien cordialement"/"restant à votre disposition")
-> conforme à l'image renvoyée lors de l'entretien (poli, clair, compétent, sérieux, professionnel, etc.)
-> personnaliser les propos (utiliser le nom de la personne rencontrée, rappel date entretien, intitulé du poste)
-> anticiper les points bloquants
-> reprendre les points clés du poste et les relier systématiquement aux compétences personnelles
-> réaffirmer sa motivation
-> répondre aux éléments donnés en entretien
-> (éventuellement demander un feedback à la fin, de manière humble et ouverte à l'échange)
-> NE PAS essayer de sauver les meubles en appuyant sur un point qu'on a trouvé négatif (si ça se trouve le recruteur ne l'a pas perçu comme ça => ne pas attirer l'attention sur un point qu'on se sait faible)
-> NE PAS répéter les propos déjà tenus en entretien mais les reprendre éventuellement pour illustrer
- Après : Évaluation
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-savoir-si-vous-etes-mauvais-en-entretien-d-embauche.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/entretien-d-embauche-comment-savoir-ce-qu-un-recruteur-pense-de-votre-candidature.html
- Après : Mal passé
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/comment-sauver-un-entretien-d-embauche-qui-s-est-mal-passe.html
- Après : Mail de remerciement
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/ces-mails-de-remerciement-a-ne-surtout-pas-envoyer-apres-un-entretien.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/4-exemples-de-mail-a-envoyer-apres-un-entretien-d-embauche.html
- Cas spécifiques
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/reussir-un-entretien-d-embauche-sur-skype.html
https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche/detail/article/quand-les-recruteurs-vous-piquent-vos-idees-en-entretien-d-embauche.html
- Outils pour faire de jolis CVs
http://creddle.io/
From: https://www.keljob.com/editorial/chercher-un-emploi/entretien-dembauche.html + Own experience
--- Exemple de mail de remerciement :
Monsieur/Madame XXX,
Suite à notre rendez-vous du YYY à propos du poste ZZZ, je tiens à vous remercier de m'avoir reçu, ainsi que pour la réelle qualité de notre échange.
J'ai bien noté votre inquiétude à propos de NNN (ex: lacune algo). Comme je vous le disais, lors de mon EXPERIENCE j'ai fait MMM (ex: consolidation données en java), ce qui m'a permis d'acquérir LIEN-COMPÉTENCES-PERSO (ex: en algorithmique). Je me sens donc parfaitement prêt à RÉPONSE-INQUIÉTUDE (e.g. faire un test de programmation).
Restant à votre disposition pour toute information complémentaire, je vous prie d'agréer, Monsieur/Madame XXX l'expression de mes salutations distinguées,
Guillaume MULLER
- (831)Websites to read for persons starting/ending a PhD
- J'avais bcp aimé ce site (surtout la FAQ) à la fin de ma thèse quand je me suis posé pas mal de questions pour savoir si je devais finir ma thèse ou pas... Depuis, je le conseille à tous les doctorants que je croise
http://www.uq.edu.au/student-services/phdwriting/index.html --> https://web.archive.org/web/20140531032545/http://www.uq.edu.au/student-services/phdwriting/fr_phsta.html
- Et puis les mêmes personnes ont fait un guide de rédaction que j'imagine aussi très bon :
http://www.phys.unsw.edu.au/~jw/thesis.html
- Un site plus général sur la rédaction en Français
http://www.assoabcd.fr/images/info/Ressources/typo.html
http://gargas.biomedicale.univ-paris5.fr/lt/typo.html --> https://web.archive.org/web/20160303175347/gargas.biomedicale.univ-paris5.fr/lt/typo.html
http://j.poitou.free.fr/pro/html/typ/resume.html
- Et plus généralement, sur le avant/pendant/après une thèse en France.
http://guilde.jeunes-chercheurs.org/Alire/guide/
- Valou also gave me:
https://kmh-lanl.hansonhub.com/techwriting.html
https://perso.ens-lyon.fr/francis.albarede/conseils.php
https://web.archive.org/web/20120711192744/beethoven.site.uottawa.ca/dsrg/writing-style.htm
https://kmh-lanl.hansonhub.com/talks/writing18vgr.pdf
https://online.stanford.edu/courses/som-y0010-writing-sciences
- (869)How to make a better presentation?
En plus d'apprendre les 2/3 premiers slides par cœur afin de ne pas hésitailler et d'en profiter pour regarder le jury dans les yeux, vla 2/3 trucs que j'avais appris :
- Faut bien penser à prendre le public par la main au début (c'est à l'orateur d'amener le public de là où il est à là où il veut)
- Surtout faut pas speeder (compresser les 1h++ en 45min, c'est toujours faisable en parlant vite...). Au contraire, pour pas perdre les gens, faut parler lentement et pas hésiter à reformuler plusieurs fois (en utilisant des expressions style : "autrement dit", "en d'autres termes", etc. pour que ce soit explicite pour le spectateur).
- Y'a un truc pas mal aussi pour se forcer à faire des pauses et à prendre du recul, c'est d'écrire le méta-discours dans les commentaires des slides (pour chaque slide, tu mets une phrase qui dit d'où on vient, la nouvelle idée que le slide apporte et où l'on va) et de reprendre régulièrement ce méta-discours à l'oral (sans forcément afficher un plan ou un slide particulier). Régulièrement (genre tous les 2/3 slides, là où une sous-partie se termine), tu dis un truc du genre "dans les 2 derniers slides on a vu XXX, maintenant on va voir YYY".
- 1 idées par slide/paragraphe
- regarder le public
- Apprends les 2/3 premiers slides par cœur (pour ne pas paraître hésitailler et pour te lancer. Une fois parti en général le discours se déroule tout seul)
- Prends le public par la main (c'est à toi d'amener le public de là où il est à là où tu veux)
- Regarde bien différentes personnes du public (pour voir si elle suivent et pour que ta voix porte bien vers eux)
- Parle lentement (compresser les 1h++ en 45min, c'est toujours faisable en parlant vite...) et n'hésites pas à reformuler plusieurs fois
- Reprends régulièrement le méta-discours à l'oral (pour chaque slide, tu peux noter dans les commentaires une phrase qui dit d'où on vient, la nouvelle idée que le slide apporte et où l'on va). Tous les 2/3 slides, tu peux dire un truc du genre "on était dans le cadre XXX, on vient de voir YYY, maintenant on va voir ZZZ".
- (976)What are Precision & Recall in ML?
- Precision (also called positive predictive value) is the fraction of retrieved instances that are relevant. Precision can be seen as a measure of exactness or quality.
P = nb correct recognitions / nb recognitions
In a classification task, the precision for a class is the number of true positives (i.e. the number of items correctly labeled as belonging to the positive class) divided by the total number of elements labeled as belonging to the positive class
- Recall (also known as sensitivity) is the fraction of relevant instances that are retrieved. Recall is a measure of completeness or quantity.
R = nb correct recognitions / nb objects in the category to be recognized
Recall in this [classification task] is defined as the number of true positives divided by the total number of elements that actually belong to the positive class (i.e. the sum of true positives and false negatives, which are items which were not labeled as belonging to the positive class but should have been).
From: https://en.wikipedia.org/wiki/Precision_and_recall
* Recall = "How many relevant are selected?" = TP/(TP+FN)
* Precision = "How many selected are relevant?" = TP/(TP+FP) <- *P*recision has only *P*s in its formula!
Selected elements = those returned as "positive" by the algorithm
Relevant elements = those that we know are "positive"
From: https://en.wikipedia.org/wiki/Precision_recall
https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Precisionrecall.svg/350px-Precisionrecall.svg.png
https://en.wikipedia.org/wiki/Confusion_matrix
- (994)How to make a copy of WEKA Instances?
PROBLEM: there is no clone method in the class "Instances"
SOLUTION:
Instances source = ...;
Instances destination = new Instances(source);
From: http://chaoticity.com/making-a-copy-of-weka-instances/
- (1029)How to download google's websearch result page in a script?
FAKE_AGENT="Firefox/3.0.15"
QRY=key+word+to+search
SEARCH_URL="http://www.google.com/search?ie=ISO-8859-1&hl=en&q=${QRY}#q=${QRY}"
CONTENT=`wget -U ${FAKE_AGENT} -O - ''''${SEARCH_URL}''''`
If you want to set the number of results per page:
SEARCH_URL="http://www.google.com/search?ie=ISO-8859-1&hl=en&num=200&q=${QRY}#q=${QRY}"
If you want to get results from a particular site (e.g. googlepatents):
QRY="site:www.google.com/?tbm=pts+${KEYWORDS}"
SEARCH_URL="http://www.google.com/search?ie=ISO-8859-1&hl=en&source=hp&q=${QRY}#q=${QRY}"
NOTE: apparently, instead of repeating the query, you can use wget's option -P${QRY}
From: http://www.mail-archive.com/wget@sunsite.dk/msg06564.html
- (1235)Difference entre complexe et compliqué? Difference between complex and complicated?
- Complexe: la complexité existe quand notre niveau de connaissance ne nous permet pas d’apprivoiser l'ensemble des informations. Un ensemble de choses liées, que nous ne trouvons pas simples et pour lesquelles il nous est difficile voire impossible d'anticiper le résultat, d'en comprendre complètement le fonctionnement, la structure ou d'en trouver la finalité.
Le caractère complexe est intrisèque à l'élément observé.
- Compliqué: C'est un ensemble de choses simples, qu'un observateur a rendu "volontairement" difficile à comprendre. Quand c'est compliqué, nous avons les capacités pour trouver la solution.
Le caractère compliqué intrinsèque à la personne qui observe/raconte
Exemples mélangeant les deux notions:
- L'amour est déjà un sentiment *complexe*. Alors pourquoi Isabelle s'entête-t-elle à vivre des amours compliquées qui tournent toujours au drame?
- Alexandre considère que cette règle de grammaire est compliquée et que la langue française en général est complexe.
From: http://bdl.oqlf.gouv.qc.ca/bdl/gabarit_bdl.asp?id=2310
http://www.simplixi.fr/difference-complexe-et-complique/
- "Complicated" means something that is knowable, and although it may take time, it's wholly possible to understand. You might just need some good old-fashioned brute force to do it—you'll get tired in the process, but it's doable. A complicated machine (think of the printing press or digital delivery service that brought you this book) is understandable.
- "Complex" means something that is not knowable, and even brute force can't easily tackle it. I say easily because in the twenty-first century the computing power we have access to is absurdly amazing, but it still can't solve complex problems - yet. A complex machine (think of any human being you have a relationship with) is not understandable.
From: https://books.google.fr/books?id=TtSIDwAAQBAJ&pg=PT49&dq=%22Complicated%22+means+something+that+is+knowable+is+understandable.&hl=en&sa=X&ved=0ahUKEwj72Mnd2q7pAhUR_KQKHZbXDkkQ6AEIJzAA#v=onepage&q=%22Complicated%22%20means%20something%20that%20is%20knowable%20is%20understandable.&f=false
=== According to GL and SebO
- complex = cannot be divided into subtasks
- complicated = can be divided into subtasks
- (1232)What is the information gain?
As Frank says, there is a lot of literature on line about information gain,
but here are some key points to get you started.
H(Class) refers to the entropy of the class variable. That is the
uncertainty associated with guessing which class a pattern might belong to
regardless of the pattern. In your example, it measures the uncertainty
associated with Class alone, regardless of the value of Attribute.
It is a function of the distribution of probabilities of the output class.
If that distribution is uniform (each class has an equal probability of
appearing in the training data), then there is a lot of uncertainty, so H()
is high. If some classes are far more common than others, then the entropy
H() is lower as there is less uncertainty. You could be right more often
simply by guessing that a pattern belongs to the most common output class.
Now, H(Class | Attribute) is the conditional entropy of the output class,
given the value of a chosen attribute. It measures the same thing as the
entropy described above, but conditional on the value of the chosen
attribute. That is, "If we know the value of Attribute, what is the entropy
of Class". If the attribute has any predictive power over the class, then
the conditional entropy will be lower than the entropy of the class alone.
This difference is H(Class) - H(Class | Attribute).
Example: If I tell you I am thinking of an animal and ask you to guess what
it is, then entropy H(animal) is high as there is a lot of uncertainty. If
I tell you how many legs it has, then that narrows the range of guesses, so
H(animal | number of legs) < h(animal). The difference between the two is
the information gain, or how much knowledge about animal identification is
contained in the number of legs they have.
From: http://list.waikato.ac.nz/pipermail/wekalist/2014-May/060917.html
- (1160)How to start with weka?
Java Intro
mindprod.com/jgloss/jcheat.html
http://mindprod.com/jgloss/jgloss.html
http://www.jmdoudoux.fr/accueil_java.htm (French)
Weka Reference Book
http://www.amazon.com/Data-Mining-Practical-Techniques-Management/dp/0123748569/ref=dp_ob_title_bk = http://libgen.org/get?md5=9A6D03BFDDC08770B4CE7BDF6F975471+1&open=0 (remove +1 in MD5 to get actual link. I'm providing this link since it's better to have a searchable pdf always at hand than a heavy paper copy. PLEASE NOTE that since you're interested in this topic, you're probably a researcher in an institution, so at least ask your institution's library to buy the book if you can't afford it yourself!)
Weka Intro
https://www.youtube.com/channel/UCXYXSGq6Oz21b43hpW2DCvw
http://downloads.sourceforge.net/project/weka/documentation/3.7.x/WekaManual-3-7-10.pdf
http://weka.wikispaces.com/Frequently+Asked+Questions
Weka General Documentation Pages
http://www.cs.waikato.ac.nz/ml/weka/documentation.html
http://www.cs.waikato.ac.nz/ml/weka/help.html
http://weka.wikispaces.com/
Weka Development
http://weka.wikispaces.com/Use+WEKA+in+your+Java+code
http://weka.sourceforge.net/doc.stable/
http://weka.sourceforge.net/doc.dev/
Weka Clustering
http://micans.org/mcl/
Weka Specifics and other tools
- Working with Text
http://weka.wikispaces.com/Text+categorization+with+Weka
http://www.esp.uem.es/jmgomez/tmweka/index.html
http://jmgomezhidalgo.blogspot.com.es/2013/04/a-simple-text-classifier-in-java-with.html
http://jmgomezhidalgo.blogspot.com.es/2013/02/text-mining-in-weka-revisited-selecting.html
- Search Engine / Reranking
http://lemurproject.org/components.php
http://www.uni-marburg.de/fb12/kebi/research/software/WEKA-LR-PAGE
http://fantail.quansun.com/ (ranking prediction, multi-target regression, label ranking and metalearning)
- Graphs
http://micans.org/mcl/
- BigData
https://mahout.apache.org/
- Other ML tools
http://java-ml.sourceforge.net/ (Data manipulation, Clustering, Feature selection, Classification, Databases: Bayes, MCL, KD-tree, DTW...)
http://mallet.cs.umass.edu/ (document classification, sequence tagging, topic modeling, numerical optimization: LDA, GRMM, CRF...)
http://www.spagobi.org/ (Business Intelligence: OLAP, KPI, data visualization, geospatial analytics...)
http://cran.r-project.org/web/views/MachineLearning.html (all sorts of algorithms in R)
From: http://permalink.gmane.org/gmane.comp.ai.weka/33153
http://weka.8497.n7.nabble.com/Rage-against-the-Multilayer-Perceptron-SMO-amp-Multi-Class-Seeking-a-volunteer-td29580.html#a29582
and other discussions on the weka mailing list
- (1159)How to keep Memory Use Low in Weka?
There is a little bit of general info on using WEKA with bigger datasets:
http://www.cs.waikato.ac.nz/ml/weka/bigdata.html
http://wiki.pentaho.com/display/DATAMINING/Handling+Large+Data+Sets+with+Weka
If you are running short of memory, avoid using the Explorer. If you do use the Explorer, make sure you delete
old results in the "Result list" panel when you no longer need them. Also, under "More options..." in the
"Classify" panel, turn off "Store predictions for visualization" if that's not needed. If the model is
huge (e.g. an ensemble), turn off "Output model" under "More options...". Note that you can also specify
default values for the Explorer settings in a props file:
http://weka.wikispaces.com/weka_gui_explorer_Explorer.props
One very simple method of dealing with large datasets that often works surprisingly well in practice is to
use weka.classifiers.meta.Dagging to build an ensemble classifier based on disjoint subsets of the
full dataset. You can then also use Dagging as a base learner in boosting, etc!
When your data is sparse (i.e. has lots of zeroes), make sure you use sparse instances to represent it.
Making a list of classifier configurations that require little memory (relatively speaking) would be
very useful, but is quite a big task. It's not just the model that's used, but also the algorithm used to
build it. For example, if you build a logistic regression model using
weka.classifiers.functions.Logistic, you have the option to switch from BFGS optimization to
conjugate gradient descent (in WEKA 3.7). The former requires space that's quadratic in the number of
attributes, the latter requires space that's linear in the number of attributes.
From: http://permalink.gmane.org/gmane.comp.ai.weka/33144
- (1151)Weka Tips&Tricks
If you want to use your trees for a task other than classification, e.g. class probability estimation, then it can sometimes be better to turn collapsing off.
From: http://permalink.gmane.org/gmane.comp.ai.weka/33023
- (1123)Explanations of NN/MLP
[A] fit of the network training to the actual values [of] about r = 0.75 [...] is not too bad of a correlation.
One way to think of the weights is like a slope value. A high [positive] weight means a high correlation between the variable and the outcome. A high [negative] weight means a high negative correlation. A near zero weight means that variable has little or no effect on the outcome.
[If X] and [Y] seem to have nearly the same weight and sign in all the neurons. So these are two highly correlated variables. You might be able to drop one or make a combined variable of the two if that is meaningful to the problem at hand.
You want to get the threshold neurons to be close to zero and randomly [positive] or [negative] in sign, in order to insure that the data you are using really does predict the outcome.
If you get an 80% or better correlation [when using the trained network called on the testing set], then you can use this network with your unknown data.
From: http://list.waikato.ac.nz/pipermail/wekalist/2014-February/059881.html
- (1447)How to easily/graphically Manipulate/Vizualize data in GNU/Linux?
What software to do datamining/visualization?
- Java
Weka
http://www.cs.waikato.ac.nz/ml/weka/
MEKA http://meka.sourceforge.net/
MULAN:
http://mulan.sourceforge.net/
- R
Rattle
http://rattle.togaware.com/
Ggobi
http://www.ggobi.org/
Ggplot2
http://ggplot2.org/
- Python
Pandas
http://pandas.pydata.org/
SciKit-Learn
http://scikit-learn.org/stable/index.html
- R+Python+JS
Plot.ly
https://plot.ly/python/
- Commandline
vd <csv_file>
https://www.visidata.org/docs/
Also, on the command line you have the classical Unix tools:
4.2.1. The grep family
- These elegant utilities are used to search files for patterns of text called regular expressions (aka *regex*) and can select or omit a line based on the matching of the regex. The most popular of these is the basic *grep*.
- Another variant which behaves similarly but with one big difference is *agrep*, or *approximate grep* which can search for patterns with variable numbers of errors, such as might be expected in a file resulting from an optical scan or typo�s.
- Baeza-Yates and Navarro�s nrgrep is even faster, if not as flexible (or differently flexible), as agrep.
A grep variant would be used to extract all the lines from a file that had a particular phrase or pattern embedded in it.
4.2.2. cat
cat (short for concatenate) is one of the simplest Linux text utilities. It simply dumps the contents of the named file (or files) to STDOUT, normally the terminal screen. However, because it dumps the file(s) to STDOUT, it can also be used to concatenate multiple files into one.
4.2.3. more & less
These critters are called pagers - utilities that allow you to page thru text files in the terminal window. less is more than more in my view, but your mileage may vary. These pagers allow you to queue up a series of files to view, can scroll sideways, allow search by regular expression, show progression thru a file, spawn editors, and many more things.
4.2.4. head & tail
These two utilities perform similar functions - they allow you view the beginning (head) or end (tail) of a file. Both can be used to select contiguous ends of a file and pipe it to another file or pager. tail -f can also be used to view the end of a file continuously (as when you have a program continuously generating output to a file and you want to watch the progress).
4.2.5. cut & *scut*
These are columnar slicing utilities, which allow you to slice vertical columns of characters or fields out of a file, based on character offset or column delimiters. cut is on every Linux system and works very quickly, but is fairly primitive in its ability to select and separate data.
*scut* is a Perl utility which trades some speed for much more flexibility, allowing you to select data not only by character column and single character delimiters, but also by data fields identified by any delimiter that a regular expression (aka regex) can define. It can also *re-order columns* and sync fields to those of another file, much like the join utility see below.
4.2.6. *cols*
*cols* is a very simple, but arguably useful utility that allows you to *view the data of a file aligned according to fields*. Especially in conjunction with less, it�s useful if you�re manipulating a file that has 10s of columns especially if those columns are of disparate widths.
4.2.7. *paste*
*paste* can *join 2 files side by side* to provide a horizontal concatenation. ie:
bash > cat file_1
aaa bbb ccc ddd
eee fff ggg hhh
iii jjj kkk lll
bash > cat file_2
111 222 333
444 555 666
777 888 999
bash > paste file_1 file2
aaa bbb ccc ddd 111 222 333
eee fff ggg hhh 444 555 666
iii jjj kkk lll 777 888 999
Note that paste inserted a TAB character between the 2 files, each of which used spaces between each field.
4.2.8. *join*
*join* is a more powerful variant of paste that acts as a simple relational join based on common fields. join needs identical field values to finish the join. See that scut described above can also do this type of operation. For much more powerful relational operations, SQLite is a fully featured relational database that can do this reasonably easily (see below).
4.2.9. pr
*pr* is actually a printing utility that is mentioned here because for some tasks especially related to presentation, it can join files together in formats that are impossible to do using any other utility.
For example if you want the width of the printing to expand to a nonstandard width or want to columnize the output in a particular way or modify the width of tab spacing, pr may be able to do what you need.
From: http://moo.nac.uci.edu/~hjm/ManipulatingDataOnLinux.html
https://jeroenjanssens.com/dsatcl/
- (1488)How to circumvent RWeka's classifier "$terms" being stored as an invalid "call" object (a.k.a. how to get the list of attributes used to build a model in a useable vector)?
## Converts (R)Weka's list of attributes used by the model (stored as
## an invalid "call") into a usable vector
predvars2Vector <- function(predvarsAttr) {
## Transform the (invalid) call into a list
l <- as.list(attr(predvarsAttr,"predvars"))
## Remove the string "list"
l <- paste0(l)[-1]
l <- gsub("`", "", l)
return(l)
}
predvars2Vector(wekaClassifiers$terms)
- (1515)What are the problems (& solution) encountered in real-life Machine Learning?
DB
-> find good features + their metric (Count occurences vs. Binary True/False IsPresent)
-> find acceptable ranges for their values (String/Numerical/Nominals, Normalize/Standardize)
-> treat NAs: ignore vs. special value vs. algo knows what to do
-> eliminate badly classified examples: find outliers (LOF), Vizualisation
PREPROCESSING
-> get equilibrated DB: Sampling
LEARNING
-> Should it be incremental (online/always-learning or offline/static-once-and-for-all)
-> take advantage of various algos capabilities: Bagging?/Stacking?
-> improve learning: Boosting? (re-train algo on its own errors)
-> improve learning: remove noise/reduce dimensions: Feature Selection (supervised: GreedySMO/unsupervised:BestFirstCFS)/Dimension Reduction (PCA/SVD/ICA/t-SNE?...)
-> MultiClass?
EVALUATION
-> use CrossValidation on OwnDB to get first estimation + evaluate on independent TestingBase
-> take costs into accounts: Cost Sensitivity
-> find good metric: kappa/precision-recall/TP-FN...
- (1547)Cool Small Computers to buy for DIY projects
https://www.raspberrypi.org/
http://shop.udoo.org/
https://www.olimex.com/Products/OLinuXino/open-source-hardware
http://www.numerama.com/magazine/33234-chip-un-ordinateur-presque-complet-a-moins-de-9-euros.html
- (1564)How to improve predictions in case of imbalanced classes?
[If data is imbalanced these tips can help:]
A] In the "Classify" panel, you can try "weka.classifiers.meta.FilteredClassifier" in conjunction with "e.g., J48" (as a base classifier of FilteredClassifier), and "weka.filters.supervised.instance.*ClassBalancer*" (as a filter of FilteredClassifier).
B] You can use the *CostSensitiveClassifier* and specify an appropriate cost matrix to achieve what you want. You might want to look at *kappa* rather than percent correct. It shows you how much you actually improve on a random predictor. In addition to J48, I would also try RandomForest or another ensemble learning approach.
From: http://weka.8497.n7.nabble.com/German-football-league-Predict-wins-td35144.html
- (1565)What are the steps to solve a ML problem?
0. Determine problem precisely
- What is the *exact* question we want to answer?
- Is it a classification/clustering/regression problem?
1. Look at data
- The raw "text" file: determine type of data (String-Factors, Numerical, Nominals), find erroneous entries, see quantity of '?'/0s/..., find simple outliers
- Compute some basic stats: nb. of '?'/0s, class imbalance, importance of attributes,, MIN/MAX/stdev/quantiles/..., find simple outliers
- Display some basic drawings: Histograms, Pairs, ParallelPlots, Radial-SpiderWeb
- Determine if normalization, standardization, discretization, nominalization, binarization, ... would help.
- Are we confronted to time series? (=> realign-DTW, compute deltas, ...)
2. Determine a class of algo
- According to the type of data: Linear, Partially Linear, Gaussians, etc.
3. Prepare dataset for learning
- Clean data: treat erroneous/unknown/outliers
- Split into Train/Tests/Validation sets
4. Do learn
- Run ZeroR to determine a minimal evaluation & check previous steps (class imbalance?)
- Run basic algos:
-> classification: Rules (OneR), Tree (J48, RandomTree, RandomForest), Bayesian (NaiveBayes), Lazy (NearestNeighbour-IBk), Functional (NN/SVM), Association Rules (APriori, FPGrowth), Fuzzy (?), Gaussian (GMM), ...
-> clustering: KMeans, EM, Hierarchical, IsoPAM, SOM, DBSCAN, CLOPE, CobWeb
- Analyze results to improve steps 3
5. Evaluate & Improve results
- Use Cross-Validation/Leave-One-Out
- Compute various metrics :
-> classification: %correct-ErrorMatrix, Precision/Sensitivity, Kappan, ROC
-> clustering: Int-ExtDistances, RandIndex, qDunnIndex, JaccardIndex,
-> regression: MeanSquared
6. Improve
- Attribute Selection (PCA, SVD, etc.)
- Use Bagging?
- Use a mixture of models? (Use Boosting, Stacking?)
- (1566)What are the various ensemble methods in ML (a.k.a what is Bagging, Boosting and Stacking)?
These are different approaches to improve the performance of your model (so-called meta-algorithms):
Bagging (stands for Bootstrap Aggregation) is the way decrease the variance of your prediction by generating additional data for training from your original dataset using combinations with repetitions to produce multisets of the same cardinality/size as your original data. By increasing the size of your training set you can't improve the model predictive force, but just decrease the variance, narrowly tuning the prediction to expected outcome.
Boosting is a an approach to calculate the output using several different models and then average the result using a weighted average approach. By combining the advantages and pitfalls of these approaches by varying your weighting formula you can come up with a good predictive force for a wider range of input data, using different narrowly tuned models.
Stacking is a similar to boosting: you also apply several models to you original data. The difference here is, however, that you don't have just an empirical formula for your weight function, rather you introduce a meta-level and use another model/approach to estimate the input together with outputs of every model to estimate the weights or, in other words, to determine what models perform well and what badly given these input data.
As you see, these all are different approaches to combine several models into a better one, and there is no single winner here: everything depends upon your domain and what you're going to do. You can still treat stacking as a sort of more advances boosting, however, the difficulty of finding a good approach for your meta-level makes it difficult to apply this approach in practice.
From: http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning#19053
=========================================
Simpler explanation:
- Bagging: often considers *homogeneous weak learners*, learns them independently from each other in parallel and combines them following some kind of deterministic *averaging* process.
- Boosting: often considers *homogeneous weak learners*, learns them *sequentially* in a very adaptative way (*a base model depends on the previous ones*) and combines them following a deterministic strategy.
- Stacking: often considers *heterogeneous weak learners*, *learns them in parallel* and *combinesthem by training a *meta-model* to output a prediction based on the different weak models predictions
From: https://towardsdatascience.com/ensemble-methods-bagging-boosting-and-stacking-c9214a10a205
- (1567)What are the Training/Test/Validation set in ML?
Training set: a set of examples used for learning: to fit the parameters of the classifier In the MLP case, we would use the training set to find the “optimal” weights with the back-prop rule
Validation set: a set of examples used to tune the parameters of a classifier In the MLP case, we would use the validation set to find the “optimal” number of hidden units or determine a stopping point for the back-propagation algorithm
Test set: a set of examples used only to assess the performance of a fully-trained classifier In the MLP case, we would use the test to estimate the error rate after we have chosen the final model (MLP size and actual weights) After assessing the final model on the test set, YOU MUST NOT tune the model any further!
Why separate test and validation sets? The error rate estimate of the final model on validation data will be biased (smaller than the true error rate) since the validation set is used to select the final model After assessing the final model on the test set, YOU MUST NOT tune the model any further!
source : Introduction to Pattern Analysis,Ricardo Gutierrez-OsunaTexas A&M University, Texas A&M University
From: http://stats.stackexchange.com/questions/19048/what-is-the-difference-between-test-set-and-validation-set
- (1716)What is the meaning of the "v"/"*" in the output of Weka's Experimenter?
The annotation v or * indicates that a specific result is statistically better (v) or worse (*) than the baseline scheme
From: http://imagej.net/Trainable_Weka_Segmentation_-_How_to_compare_classifiers
- (1762)How to evaluate a classification model?
It’s important to always check whether a classification model
outperforms ZeroR. If it doesn’t, you haven’t actually learned
anything useful from the data. A classification accuracy of 90% is
trivial to achieve if 90% of the instances belong to the majority
class. That’s one reason to look at statistics such as kappa or the
area under the ROC when evaluating a classifier.
From: http://weka.8497.n7.nabble.com/Weka-classify-no-attribute-heaving-instances-this-very-misleading-td37214.html#a37236
- (1795)A (sub)list of good feeds/news/blogs about DataScience
https://www.reddit.com/r/machinelearning
https://www.reddit.com/r/statistics
https://www.reddit.com/r/datascience
https://www.reddit.com/r/bigdata
http://www.datatau.com/news
http://dataelixir.com/
http://www.oreilly.com/data/newsletter.html
http://blog.kaggle.com/
http://blog.yhathq.com/
http://simplystatistics.org/
http://fastml.com/
https://github.com/rushter/data-science-blogs
https://data36.com/feed/
http://101.datascience.community/feed/
http://feeds.dzone.com/ai
http://feeds.dzone.com/big-data
http://www.r-exercises.com/
http://www.win-vector.com/blog/
http://fivethirtyeight.com/
http://www.dataschool.io/
https://advanceddataanalytics.net/
http://blog.smola.org/
http://blog.sense.io/
https://annalyzin.wordpress.com/
http://beautifuldata.net/
http://www.becomingadatascientist.com/
https://bigishdata.com/
https://yerevann.github.io/atom.xml
http://blog.cloudera.com/blog/category/data-science/
http://www.datasciencebowl.com/data-science-insights/
http://datalab.lu/
http://blog.insightdatalabs.com/
http://blog.data-miners.com/
http://www.dataminingblog.com/
http://datamining.typepad.com/data_mining/
http://blog.ethanrosenthal.com/
https://research.facebook.com/blog/datascience/
https://www.codementor.io/data-science/tutorial
https://datasciencevademecum.wordpress.com/
https://dataaspirant.com/
http://blog.okcupid.com/
https://www.dataiku.com/blog/
http://www.datakind.org/blog
http://blog.datalook.io/
https://datanice.wordpress.com/
http://datascopeanalytics.com/blog/
https://twitter.com/LearnDataSci
http://deeplearning.net/feed/
http://timdettmers.com/
http://deepdish.io/
https://fullstackml.com/
http://www.joyofdata.de/blog/
http://www.kdnuggets.com/
http://bickson.blogspot.fr/
http://lazyprogrammer.me/
https://learnanalyticshere.wordpress.com/
http://learningwithdata.com/
http://www.machinalis.com/blog/
https://charlesmartin14.wordpress.com/
http://hunch.net/
http://alexhwoods.com/
http://machinelearningmastery.com/blog/
http://yaroslavvb.blogspot.fr/
http://www.machinedlearnings.com/
https://peadarcoyle.wordpress.com/
http://nuit-blanche.blogspot.fr/
https://aimatters.wordpress.com/
http://blog.plot.ly/
https://rdatamining.wordpress.com/
http://www.r-bloggers.com/
http://startup.ml/blog
http://swanintelligence.com/
https://www.datacamp.com/community/
http://blog.thedataincubator.com/
https://datasciencelab.wordpress.com/
http://www.martingoodson.com/
https://shapeofdata.wordpress.com/
http://www.unofficialgoogledatascience.com/
http://www.pythonweekly.com/
http://pbpython.com/
From: https://github.com/rushter/data-science-blogs
- (1812)How to apply affine transformation to images?
The general affine transformation is commonly written in homogeneous
coordinates as shown below:
|x2| |x1|
|y2| = A * |y1| + B
By defining only the B matrix, this transformation can carry out pure
*translation*:
|1 0| |b1|
A= |0 1| , B = |b2|
Pure *rotation* uses the A matrix and is defined as (for positive
angles being clockwise rotations):
|cos(teta) -sin(teta)| |0|
A= |sin(teta) cos(teta)| , B = |0|
Here, we are working in image coordinates, so the y axis goes
downward. Rotation formula can be defined for when the y axis goes
upward.
Similarly, pure *scaling* is:
|a11 0| |0|
A= |0 a22| , B = |0|
(Note that several different affine transformations are often combined
to produce a resultant transformation. The order in which the
transformations occur is significant since a translation followed by a
rotation is not necessarily equivalent to the converse.)
Since the general affine transformation is defined by 6 constants, it
is possible to define this transformation by specifying the new output
image locations (x2,y2) of any three input image coordinate (x1,y1)
pairs. (In practice, many more points are measured and a least squares
method is used to find the best fitting transform.)
From: http://homepages.inf.ed.ac.uk/rbf/HIPR2/affine.htm
- (1819)What are the pitfalls of innovation?
- Hide Complexity: Be User-Friendly
- Avoid Fixation: Explore Largely / Break Barriers
-
Thanks AM (presentation about magic & innovation)
- (1840)Tips for Object Oriented Design Interview
- Clarify the scenario, write out user cases
* Use case is a description of sequences of events that, taken
together, lead to a system doing something useful. Who is going to
use it and how they are going to use it. The system may be very
simple or very complicated.
* Special system requirements such as multi-threading, read or write
oriented.
- Define objects
* Map identity to class: one scenario for one class, each core object
in this scenario for one class.
* Consider the relationships among classes:
+ certain class must have unique instance,
+ one object has many other objects (composition),
+ one object is another object (inheritance).
* Identify attributes for each class: change noun to variable and action to methods.
* Use design patterns such that it can be reused in multiple applications.
http://sourcemaking.com/design-patterns-and-tips
From: https://github.com/checkcheckzz/system-design-interview
- (1846)How to code clearly?
- Write clearly -- don't be too clever.
- Say what you mean, simply and directly.
- Use library functions whenever feasible.
- Avoid too many temporary variables.
- Write clearly -- don't sacrifice clarity for efficiency.
- Let the machine do the dirty work.
- Replace repetitive expressions by calls to common functions.
- Parenthesize to avoid ambiguity.
- Choose variable names that won't be confused.
- Avoid unnecessary branches.
- If a logical expression is hard to understand, try transforming it.
- Choose a data representation that makes the program simple.
- Write first in easy-to-understand pseudo language; then translate into whatever language you have to use.
- Modularize. Use procedures and functions.
- Avoid gotos completely if you can keep the program readable.
- Don't patch bad code -- rewrite it.
- Write and test a big program in small pieces.
- Use recursive procedures for recursively-defined data structures.
- Test input for plausibility and validity.
- Make sure input doesn't violate the limits of the program.
- Terminate input by end-of-file marker, not by count.
- Identify bad input; recover if possible.
- Make input easy to prepare and output self-explanatory.
- Use uniform input formats.
- Make input easy to proofread.
- Use self-identifying input. Allow defaults. Echo both on output.
- Make sure all variables are initialized before use.
- Don't stop at one bug.
- Use debugging compilers.
- Watch out for off-by-one errors.
- Take care to branch the right way on equality.
- Be careful if a loop exits to the same place from the middle and the bottom.
- Make sure your code does "nothing" gracefully.
- Test programs at their boundary values.
- Check some answers by hand.
- 10.0 times 0.1 is hardly ever 1.0.
- 7/8 is zero while 7.0/8.0 is not zero.
- Don't compare floating point numbers solely for equality.
- Make it right before you make it faster.
- Make it fail-safe before you make it faster.
- Make it clear before you make it faster.
- Don't sacrifice clarity for small gains in efficiency.
- Let your compiler do the simple optimizations.
- Don't strain to re-use code; reorganize instead.
- Make sure special cases are truly special.
- Keep it simple to make it faster.
- Don't diddle code to make it faster -- find a better algorithm.
- Instrument your programs. Measure before making efficiency changes.
- Make sure comments and code agree.
- Don't just echo the code with comments -- make every comment count.
- Don't comment bad code -- rewrite it.
- Use variable names that mean something.
- Use statement labels that mean something.
- Format a program to help the reader understand it.
- Document your data layouts.
- Don't over-comment.
From: https://en.wikipedia.org/wiki/The_Elements_of_Programming_Style
- (1908)How to build a strong "Brand Foundation"?
[NOTE1: To be done/contructed with the participation of whole team of
workers]
[NOTE2: At first pass, note everything that is said, the in a second
pass, filter only the agreed/shared/most importants elements]
* Anchorage (origins of the company)
Where do I come from? What is the founding principle? What makes
me unique in my history?
* Skills
Who am I? What do I do? What market do I address? What are my
skills, expertises, particular talents?
* Differenciation
What are my key competitive advantages? What is my unique way of
doing things?
* Ideal client
Who's the client I'd like to have? What are his needs, his
expectencies, his desires, his dreams with respect to the market I
address? What does it mean, for him, to be my client rather that
the one of another brand?
* Personnality
How would I define myself has a person (sex, etc.)? What describes
best my character? How do I want to be perceived as a person?
* Combat (external & internal)
Why do I fight? What is my commitment with respect to my clients?
* Values
What do I fight for? Right upstream, above my objectives, what are
the values that inspire me?
* Strategic concept (the "universe" of the company. Can be given to a graphist as a frame to design the logo)
The unique proposition visionary, inspired of the brand, which, in
a few words, distinguishes it and makes it better?
[NOTE1: If, at first, it seems too hard to find it, first review
and filter the responses to the previous responses]
[NOTE2: It's not necessarily the "motto" of the company!]
Thx (Anthony Gutmann/Remix)
--- Other version
How to co-define/construct the "Brand Foundations" of your company/NGO/... with your colleagues?
I] Anchor
- Q1: where do we come from?
- History, why/how did you rich the conclusion that the entity (company/NGO/...) must be created?
- What is the initial/underlying need?
II] Domain of competence
- Q2: what do we do?
- What does the entity do/will do/produce/sell/develop?
III] Specificities
- Q3: What makes us different?
- What are the similar entitiies?
- What makes your entity different from those?
IV] Ideal Client/Member
- Q4: who am i for?
- What is your À quoi ressemble ideal client/member?
- What are his/her expectations/needs/...?
V] Personnality of the brand
- Q5: what am i like as a person?
- If the brand was a person, who would she be? (Man/Woman/Other, what would she/he wear, how would she/he behave,...)
VI] Combat
- Q6: what do I fight for?
- What for ideas/concepts/ideologies is the brand fighting?
VII] Values
- Q7: what do I value?
- What are the values that the brand currently/will adhere to?
VIII] Strategic Concept
- Q8: Define the "strategic concept"
- In a single sentence, what does the brand do?
The meeting processes as follows:
- Everybody in the entity participate
- One after the other, each of these points are reviewed
- We talk *no more* than 10 minutes max. on each item (we have to be strict on this point)
- Everyone throws freely her/his ideas with no shame, no creativity limits, no criticism, etc. at worst, there is a (quick) discussion/objections/reformulation
- Someone (preferably someone that is not part of the debates) notes every pronounced sentence on a paper board (or balck board, but the idea is to hide one subject once it has been discussed, while keeping the possibility to come back on the notes later).
- Once all points have been debated, in 10 min max, we all review all the answers on each point one-by-one, selecting one ONE(THREE?) single answer.
- In the end, we all try to write a sentence that qualifies the "raison d'être" of the entity. It is often difficilt to distinguish the sentence from the "strategic concept", but this can be done.
Thanks Anthony@Remix
http://www.queue.ca/images/brandfoundation.gif
http://images.google.fr/imgres?imgurl=http%3A%2F%2Fimage.slidesharecdn.com%2Fddb-springboard-150321210758-conversion-gate01%2F95%2Fddb-v-m-hnh-springboard-12-638.jpg%3Fcb%3D1426972324&imgrefurl=http%3A%2F%2Fpt.slideshare.net%2Fbrandsvietnam%2Fddb-v-m-hnh-springboard&h=479&w=638&tbnid=jufL8dYkcAXiNM%3A&vet=1&docid=HIi2U9sbNBZE1M&itg=1&ei=Q_F_WIvNJoaJaOfatugI&tbm=isch&iact=rc&uact=3&dur=9&page=0&start=0&ndsp=26&ved=0ahUKEwjL-pj548zRAhWGBBoKHWetDY0QMwgcKAIwAg&bih=742&biw=1438
- (1909)What are the 4 steps of innovation?
* inventeurs/innovators (engineers): create a new product/service
* imitateurs (financiers): massively spread the product/service
* imbecils: sell snake oil, once the buzz is past
* innocents: pay the piper ("payer les pots cassés")
Thanks to GE presenter@presans' raout 2016, extension of Warren Buffett's expression.
- (1910)How to conceive a good product/software for your users (UX design methodology)?
[NOTE1: 10 min max on each step]
[NOTE2: to be done with the devs, the users and a few external persons]
* What is the tools of your dreams? (goal, what it will be used for, etc.)
* How is the current tool used?
** what do the users do before/after using the tool? (=> are there lacking features?)
* 4 Post-Its:
** 3 first Post-Its: 3 most used/important fonctionnalities
** 4th Post-It: THE most important lacking feature
Thx to Marine@Geeksters
- (1924)What is the difference between DataAnalyst/DataScientist?
- DataAnalyst
-> Break large problems into smaller ones, to better understand what happened
-> What happen*ed* so forth?
-> Roles: Data architect / DB admin / Analytics Eng. / Operations
-> Competences: DataWarehouse, BusinessIntelligence, SQL, Hadoop (HBase/Hive/MapReduce), DataStoring & Architecture, ETL (data connectors: import/transform/map), DecisionMaking
-> More domain knowledgeable
- DataScientist
-> Business point of view
-> *Predictive* analysis
-> Statistical in nature
-> Roles: Data Researcher / Data Devp / Data Creative / Data Business
-> Competences: DB, Java, Python, MapReduce/Mahout, Analytical functions, Maths/Stats, ML
From: https://youtu.be/GiWqKE-yznE
- (1929)What is the difference between MLP vs. RBF types of Neural Networks?
Les réseaux utilisant des neurones de type perceptron sont dits MLP
pour MultiLayer Perceptron, alors que ceux utilisant des neurones à
fonction d'activation gaussienne sont dit RBF (pour Radial Basis
Function).
From: L'Intelligence Artificielle pour les développeurs - Concepts et implémentations en C#
- (1947)Neat packages to have installed in R for MachineLearning (a.k.a. My own Machine-Learning CheatSheet/CardRef in R)
# Prerequisites Linux distro packages
apt-get install g++ gfortran apt-get install libgtk2.0-common libgtk2.0-dev ggobi
apt-get install r-base-core r-cran-rgtk2 r-cran-massr-cran-nnet r-cran-amore
# GUIs
rattle # https://rattle.togaware.com/
fggobi # https://github.com/ggobi/rggobi
rkward # https://rkward.kde.org/
deduceR # https://www.deducer.org/
Rcmdr # https://socialsciences.mcmaster.ca/jfox/Misc/Rcmdr/
esquisse # https://github.com/dreamRs/esquisse
# http://r.analyticflow.com/en/
Also See Tip#3532
### Help
base # ? ?? RSiteSearch() help.search() vignette(pkg)
sos # sos::findFn()
### Scientific Reproductibility
set.seed(int) # Set the random seed to be able to redo the exact same experiment
### Link with other languages
rJava # .jcall() J() toJava()
Rcpp # cppFunction() evalCpp() sourceCpp()
### DB connection / Data input
base # read.csv(stringsAsFactors=c(T,F)) read.csv2()
RJDBC / RODBC # dbConnect() dbDisconnect() dbSendQuery()
foreign # read.arff() write.arff()
jsonlite # fromJSON() toJSON() prettify() minify()
XML # xmlParse() htmlarse() xpathApply()
htmltools # htmlEscape()
### DataSets
base # data() - Get currently available dataset
mlbench # library(mlbench); data() - Artificial and real-world machine learning benchmark problems
clusteval # sim_data(family=c("uniform","normal","student")) sim_normal() sim_student() sim_unif() - Generate Clusters
clusterSim # cluster.Gen() shapes.blocks3d() shapes.circles2() shapes.circles3() shapes.two.moon() shapes.worms() - Generate Clusters
clusterGeneration # genRandomClust() - Generate Clusters
MixSim # MixSim(BarOmega/*AvgOverlap*/, MaxOmega/*MaxOverlap*/) simdataset() - Generate Mixtures of Gaussian Clusters
ForImp # rancatmat()
### Table manipulation
# Manipulate df
cbind()/rbind() # Concatenate data.frames by col/row
aggregate()/merge() # GroupBy/Join-like operations on data.frames
intersect()/setdiff() # Compute Differences between df
apply()/lapply() # apply a function on df/lists
# Packages
dplyr # filter() slice() select() sample_n() - DB operations on data.frames
plyr?
gtable?
data.table?
xtable?
### Visualization
base # plot(df) - Scatterplot
mclust # clPairs() - Scatterplot
MASS # parcoord() - Parallel coordinate plot
plotrix # radix.plot() pie3D() color2D.matplot() fan.plot() diamondplot() pyramid.plot() polar.plot() - Radial plots
stats # heatmap()
d3heatmap # d3heatmap()
gplots # heatmap.2()
heatmap.plus # heatmap.plus()
spatstat # plot(density(...)) - HeatMap
fields # image.plot() - HeatMap
shiny # Data visualization on a WebPage
rggobi # Data visualization local client
rattle # Graphical interface for data mining - IDE very similar to Weka
plotly # plot_ly() ggplot_ly()
ggplot2 # ggplot() radviz2d() - Complex but highly customizable plots
altair # https://www.rdocumentation.org/packages/altair/versions/4.2.1 https://altair-viz.github.io/gallery/index.html
ggvis # Interactive Graphics=ggplot2+shiny+vega
corrplot # corrplot() - graphical display of a correlation matrix
wordcloud # wordcloud()
rCharts # require(devtools); install_github('rCharts', 'ramnathv') hPlot() nPlot()/*d3js*/ mPlot() rPlot() xPlot() Leaflet$new() Rickshaw$new()
### PreProcessing
### PreProcessing / Data Cleaning - Sampling
# Detect/Change type
class()/typeof() # Determine current type of data
factor() # Transforms strings into factors
levels() # Lists the factors for a given attribute
Encoding() # Get encoding of input string
# Check value
base # is.finite() is.na()
# Sample
sample() # Randomly split into train/test/validation sets
# Packages
stats # ...(na.rm=T) na.omit() na.action() - Remove NAs
lubridate # dmy() - Homogenize date formats
stringr # str_trim() toupper() tolower() str_pad() - Clean Strings
editrules # editset() editfile() violatedEdits(set,data) plot(editset) localizeErrors() - Detect Inconsistencies based on ExpertKnowledge
deducorrect # correctionRules() correctWithRules() correctRounding() correctSigns() correctTypos() deduInput() - Correct Inconsistencies based on ExpertKnowledge
base # df[is.na(df)]<-mean(df,na.rm=T) - Basic Data Imputation ("Guessing")
Hmisc # input(data,fun) - Value Imputation ("Guessing")
e1071 # impute(data,what=c("median","mean"))
imputation # lmImpute()
VIM / VIMGUI # VIMGUI() kNN() scattmatrixMiss() histMiss() barMiss() spineMiss() scattMiss() scattJitt() parcoordMiss() mosaicMiss() mapMiss() growdotMiss() matrixplot() marginmatrix() pbox(...,selection=c("all","any","none")) marginplot()
rspa # adjustRecords(editrules,data,tolerance,adjust=matrix())
Amelia # amelia() ameliagui()
BaBooN # dmi() rowimpPrep() BBPMM() MI.inference()
ForImp # missingness() ForImp() ld() meanimp() medianimp() missingmat() missingmat2() modeimp()
mi # missing_data.frame() change() mi() mipply() Rhats() pool() complete() bayesglm()?
mice # mice.impute.* - Framework for Imputation
robCompositions # constSum() aDist() impKNNa() impCoda(method=c("lm","ltsReg")) robVariation() alr() clr() ilr()
StatMatch # pw.assoc() NND.hotdeck() RANDwNND.hotdeck() rankNND.hotdeck() mixed.mtc() harmonize.x() comb.samples() Frechet.bounds.cat()
yaImpute # applyMask() correctBias() ensembleImpute() foruse() impute.yai() plot.yai()
zoo # na.aggregate(data,...,FUN)
RWeka / RWekajars # make_Weka_filter() Discretize() Normalize()
impute # (oudated in R>3.1?)
## PreProcessing / Image manipulation
EBImage # display() show() image() thresh() affine() erode() rotate() translate() propagate() normalize() dilate() bwlabel() - Image manipulation: convolution filters, segmentation, etc.
## PreProcessing / Signal Processing
stats # fft() - Discrete Fourier Transform
fftwtools # fftw() - FFT: Fast Fourrier Transform
dtw # dtw(ts) - align 2 time series taken at different/varying frequencies
wavelets # dwt(ts) mra(ts) align(ts) - wavelet transform of time series
## PreProcessing / AttributeSelection
base # svd() - Singular Value Decomposition
stats # quantile() prcomp() princomp() biplot() - Principal Component Analysis=disperse elements as much as possible / factanal() - Exploratory Factor Analysis
FSelector # best.first.search() exhaustive.search() greedy.search() hill.climbing.search() cfs() chi.squared() consistency() correlation() cutoff() entropy.based() relief() random.forest.importance() oneR() - Framework to compare AttrSel methods
RWeka / RWekajars # make_Weka_evaluator() GainRatioAttributeEval() InfoGainAttributeEval()
penalizedSVM # svm.fs(x,y,fs.method=c("scad","1norm","scad+L2","DrHSVM")...)
ade4 # dudi.pca() - Principal Component Analysis
FactoMineR # PCA() MFA() DMFA() MCA() GPA() HMFA() HCPC()
psych # principal()
caret # preProcess(data,method=c(...,"pca"))
e1071 # ica() lca() skewness()
fastICA # fastICA() - Independent Component Analysis
tsne # tsne() - tSNE=projection that keeps local elements together
Rtsne # Rtsne()
mclust # MclustDR() - Dimensionality Reduction with GMM
RoughSets # FS.*
Boruta # res<-Boruta(formula,data,doTrace=2); print(res); plot(res); stats<-attStats(res); print(stats)
Hmisc # redun() varclus()
yaImpute # varSelection()
### Outliers detection
grDevices # boxplot.stats()$out - Trivial Outliers
outliers # outlier() scores() rm.outliers()
DMwR # lofactor()
Rlof # lof() - parallel computation of LOF
dbscan # lof()
agop # owa() wam() - Ordered Weighted Average
randomForest # outlier()
yaImpute # notablyDifferent() notablyDistant()
### Distances
utils # adist() - Levenshtein distance
stats # dist(x=data,method=c("euclidean","maximum","manhattan","canberra","binary","minkowski")) mahalanobis()
e1071 # hamming.distance()
bioDist # euc() man() mutualInfo() cor.dist() spearman.dist() tau.dist()
RecordLinkage # levenshteinDist()
stringdist # stringdist(method=c("osa","lv"/*Levenshtein*/,"dl","hamming","lcs","qgram","cosine","jaccard","jw"/*Jaro-Winker*/,"soundex"))
Biostrings # stringDist() - Levenshtein
### Statistical/ChaosTheory Tests
base # cumsum()
strucchange # monitor() breakpoints() sctest(method=c("Fstats"/*linear regression models*/, "efp"/*empirical fluctuation processes in linear models*/, "gefp"/*generalized empirical fluctuation processes in parametric models*/)) efp() mefp() gefp() Fstats()/*Chow-test*/
stats # chisq() cor() kruskual.test() pairwise.t.test() pairwise.wilcox.test() power.anova.test() power.t.test() shapiro.test() t.test() wilcox.test()
tseriesChaos # lyap_k(series) lyap(dsts) - Lyapunov Exponent (<0 => converge, >0 => deterministic chaos)
fNonlinear # lyapunovPlot() - Plot max Lyapunovplot Exponent
### Classification / Regression / Association Rules / FuzzySets
OneR # OneR(data,formula) - Basic Benchmarking/Baseline classifier (ifthenelse one the 1 attr that best predict classes)
stats # loess() lowess()
yaImpute # ann() yai() newtargets() compare.yai() predict.yai() - kNN (for imputation)
randomForest # randomForest() - Breiman Random Forest
arules # apriori() eclat() summary() inspect() - Association Rules
arulesViz #
pdfCluster # pdfClassification() - Nonparametric density estimation
LiblineaR # heuristicC() LiblineaR(data=in,labels=out,type=c(0:7/*MultiClass*/,11:13/*Regression*/))
RWeka / RWekajars # make_Weka_associator() Apriori() Tertius() make_Weka_classifier() AdaBoostM1() Bagging() CostSensitiveClassifier() DecisionStump() IBk() J48() JRip() LBR() LinearRegression() LMT() Logistic() LogitBoost() M5P() M5Rules() MultiBoostAB() OneR() PART() SMO() Stacking() - Wrapper for Weka's ML algorithms/tools
e1071 # svm() best.randomForest() naiveBayes()
mlr # list possible learners: listLearners()$class makeLearner(c("classif.JRip","classif.lda","classif.J48","classif.svm","classif.lvq1","classif.naiveBayes","classif.nnTrain","classif.randomForest","classif.IBk","classif.knn","classif.logreg","classif.mlp","classif.OneR","cluster.Cobweb","cluster.XMeans","cluster.EM","cluster.SimpleKMeans","cluster.dbscan","cluster.kkmeans","regr.ksvm","regr.nnet","regr.randomForest","regr.IBk","surv.*"))
caret # list methods=names(getModelInfo()) train(formula,data,method=c("J48","C5.0","JRip","LogitBoost","knn","rf","rlda","lda2","lvq","mlp","neuralnet","svmLinear","svmPoly","svmRadialSigma","adaboost","bag","glmboost","rqlasso","pls","rda"))
mclust # MclustDA(data,output,modelType="EDDA") - Gaussian finite mixture model
glmnet # glmnet(x,y)/*GuassianLinearModel=LeastSquares returns multiple models*/ cv.glmnet(x,y,standardize=T)/*returns best model by CV*/ predict() - Lasso/Generalized Linear Models
## Classification - DeepLearning
nnet # nnet(formula, data, weights...) - Basic single-hidden-layer neural network
neuralnet # fit<-neuralnet(fromula,data,hidden=c(nbh1,...nbhx),threshold...)
deepnet # fit<-nn.train(X=data,Y=outputs,hidden=c(nbh1,...nbhx),learningrate,momentum,activationfun,output="linear",numepochs,hidden_dropout,visible_dropout)
RSNNS # fit<-mlp(x=data,y=outputs,size=c(nbh1,...nbhx),initFunc,learnFunc,updateFunc,hiddenActFunc="Act_Logistic",linOut=TRUE)
# fit<-elman(inputs,ouputs,size=c(nbh1,...nbhx),learnFuncParams,maxit) - Recurrent With Hidden Layer
# fit<-jordan(inputs,ouputs,size=nb,learnFuncParams,maxit) - Recurrent With Output Layer
AMORE # fit<-newff(n.neurons=c(nbi,nbh1,...nbhx,nbo),learning.rate.global,momentum.global,error.criterium="LMLS",hidden.layer="sigmoid",output.layer="purelin",method="ADAPTgdwm") - MLP / ADAPTgd=gradient-descent ADAPTgdwm=gradient-descent-with-momentum
autoencoder # autoencode(X.train,X.test,nl,N.hidden,unit.type="logistic",lambda=1e-5,beta=1e-5,rho=.3,epsilon=.1,max.iterations,optim.method=c("BFGS"),rel.tol=.01,rescale.flag=T,rescaling.offset=.001) - AutoEncoder: #Outputs=#Inputs
SAENET # SAENET.train(X.train=data,n.nodes,unit.type="logistic",lambda,beta,rho,epsilon,max.iterations,optim.method,rescale.falg=T) - Stacked AutoEncoder (#Inputs--decrease-->#Outputs)
RcppDL # StackedDenoisingAutoenc=Rsda(inputs,outputs,hidden=c(nbh1,...nbhx)) StackedDenoisingAutoenc=RdA(in) BoltzmannMachine=Rrbm(in) DeepBeliefNetwork=Rdbn(in, out,hidden)
## Classification - TextMining
tm # termFreq() getTokenizers() stopwords()
stringdist # printable_ascii() phonetic() qgrams() seq_qgrams() seq_sim() string_dist() string_sim()
lda # lexicalize() lda.collapsed.gibbs.sampler() top.topic.words()
RWeka / RWekajars # make_weka_filter() IteratedLovinsStemmer() LovinsStemmer() AlphabeticTokenizer() NGramTokenizer() WordTokenizer()
## Classification/Clustering - Fuzzy
FuzzyNumbers # plot() value() expectedValue() trapezoidalApproximation() piecewiseLinearApproximation() - FuzzyNumbers Representation/Manipulation
RoughSets # RI.indiscernibilityBasedRules.RST() RI.CN2Rules.RST() RI.LEM2Rules.RST() RI.AQRules.RST() predict.RuleSetRST() - (Fuzzy) RoughSet
anfis # LSE() predict() plotMF() evaluateMF() getRules() - Fuzzy Inference System
CNORfuzzy # CNORwrapFuzzy()
e1071 # cmeans()
fuzzyforest # fuzzyforest() ff() wff() predict.fuzzy_forest()
frbs # frbs.learn() ANFIS() DENFIS() FH.GBML() FIR.DM() FRBCS.CHI() FRBCS.W() FS.HGD() GFS.FR.MOGUL() GFS.GCCL() GFS.LT.RS() GFS.Thrift() HyFIS() SBC() SLAVE() WM()
sets # fuzzy_logic(c("Zadeh","drastic","product","Lukasiewicz","Fodor","Frank","Hamacher";"Schweizer-Sklar","Yager","Dombi","Aczel-Alsina","Sugeno-Weber","Dubois-Prade","Yu"));.N.(x);.T.(x, y);.S.(x, y);.I.(x, y) fuzzy_*interval_* gset_* fuzzy_inference() fuzzy_rule() fuzzy_system() fuzzy_partition() fuzzy_variable() x%is%y plot()
fclust # Fclust() Fclust.index(index=c("PC","PE","MPC","SIL","SIL.F","XB","ALL")) FKM() VAT() VCV() VCV2()
Mfuzz # mfuzz() mfuzz.plot() Mfuzzgui()
FuzzyStatProb # fuzzyStationaryProb()
CFL # (outdated with R>3.1?)
fuzzySim # ???
## Classification - Evaluation
base # table() round(cor(fit$results, outputs)^2,6) - Basic statistics on Algo perf
stats # anova() manova() - Analysis of Variance of a model
Metrics # mse() rmse() auc() logLoss() msle() rmsle() ScoreQuadraticWeightedKappa() MeanQuadraticWeightedKappa()
plotROC # ggroc() shiny_plotROC()
analogue # plot.roc()
Epi # ROC()
epicalc # lroc()
TeachingDemos # roc.demo() - Demonstrate ROC curves by interactively building one
### Clustering
stats # cutree(hclust()) dendrogram() kmeans()
cluster # agnes() clara() daisy() diana() fanny() mona() pam()
RWeka / RWekajars # make_Weka_clusterer() Cobweb() DBScan() FarthestFirst() SimpleKMeans() XMeans()
pmclust # em.step() em.update.class() - High dimensional large data
clusterSim # cluster.Gen() cluster.Sim() -- Find best params for a set of algos
isopam # isopam()
dbscan # dbscan() kNN()
pvclust # pvclust()
mclust # Mclust() - Gaussian Mixture Models + EM algorithm
e1071 # bclust()
bclust # bclust() - Bayesian clustering
trimcluster / tclust # trimmed k-means
flexclust # k-centroid
pdfCluster # pdfCluster() - Nonparametric density estimation
EMCluster # init.EM(data,method=c("em.EM","Rnd.EM")) emgroup(data) - EM-absed clustering
kohonen # som() - Self-Organizing Map
som # som()
mcclust # maxpear() medv() minbinder()
fpc # plotcluster()
## Clustering - Evaluation
fpc # cluster.stats() clujaccard() - dist intra/inter-cluster + Calinski-Harabasz + DunnIndex + RandIndex
clv # clv.Dunn() confusion.matrix() similarity.index() std.ext() - RandIndex + Jaccard-coef
mclust # mclustBIC() mclustICL()
mcclust # arandi() vi.dist() - Adjusted RandIndex / Variation of Information
clValid # clValid(data,clMethods=c("hierarchical","kmeans","pam"...),validation=c("dunn","stability","BHI","BSI")) - Framework to compare methods
clusteval # cluster_similarity(...,similarity=c("jaccard", "rand")) clustomit(...,similarity) comembership() comembership_table() intraclass_cov() jaccard_indep() rand_indep()
clusterSim # index.DB() index.G1() index.G2() index.G3() index.Gap() index.H() index.KL() index.S()
MixSim # overlapGOM() RandIndex()
cvTools # cvSelect() summary.cv() bwplot.cv() densityplot.cv() dotplot() plot.cv() xyplot.cv() - Framework for Model selection through CV
#### TimeSeries
stats # window() lag() frequency() deltat() cor(x,y,method="kendall") cor.test(x,y,method="kendall") ar() arima() acf() pacf() ccf() plot.ts() ts.plot() tsdiag() month.plot() lag.plot() Box.test() - Manipulation/Tests/Plots of TimeSeries
quantmod # Lag() - Add the lagged values to the input data
tsoutliers # tso()
forecast # ma() tsclean() tsdisplay() Arima() arfima() forecast.lm() forecast.mlm()
timeDate # manages time zones and daylight savings
tis # "ti" class for time/date information
xts # uniform handling the various time-based data classes
tseries # irts() surrogate() arma() adf.test() garch() kpss.test() po.test() terasvirta.test() white.test() shapiro.test() jarque.bera.test()
wmtsa # wav*() - Wavelets for TimeSeries
lmtest # dwtest() grangertest()
MSBVAR # granger.test()
egcm # egcm() -Engle-Granger Cointegration Model
DescTools # KendallTauA() KendallTauB() StuartTauC()
HMM # initHMM(states,symbols,startProbs,transProbs,emissionProbs) forward(hmm,observations)
==== NOTE: script to extract this list in a format suitable to instert into 'install.packages()' command in R
cut -d " " -f 1 "/tmp/pkgs.text" | sort | uniq | grep -v '(' | grep -Fv '#' | sed 's/?//g' | sed '/^\s*$/d' | tr '\n' "," | sed 's/,/","/g'
From: Personal experience + https://cran.r-project.org/web/views/
https://cran.r-project.org/doc/contrib/de_Jonge+van_der_Loo-Introduction_to_data_cleaning_with_R.pdf
https://cran.r-project.org/doc/contrib/YanchangZhao-refcard-data-mining.pdf
https://cran.r-project.org/doc/contrib/Ricci-refcard-ts.pdf
https://cran.r-project.org/doc/contrib/Ricci-refcard-regression.pdf
https://github.com/soulmachine/machine-learning-cheat-sheet
https://github.com/soulmachine/machine-learning-cheat-sheet/raw/master/machine-learning-cheat-sheet.pdf
https://github.com/jrvlima/RefCardz/blob/master/rc158-010d-MachineLearning_1.pdf
- (1951)What are the various types of text/string distances?
For an extensive description and references, see:
- Van der Loo (2014)
- Review papers of Navarro (2001)
- Review papers of Boytsov (2011)
As defined in R's stringdist package, the most common string
distances(a,b) are:
- The Hamming distance: counts the number of character substitutions
that turns b into a. If a and b have different number of characters
the distance is Inf.
- The Levenshtein distance: counts the number of deletions, insertions
and substitutions necessary to turn b into a. This method is
equivalent to R’s native adist function.
- The Optimal String Alignment distance is like the
Levenshtein distance but also allows transposition of adjacent
characters. Here, each substring may be edited only once. (For
example, a character cannot be transposed twice to move it forward
in the string).
- The full Damerau-Levensthein distance is like the optimal string
alignment distance except that it allows for multiple edits on
substrings.
- The longest common substring is defined as the longest string that
can be obtained by pairing characters from a and b while keeping the
order of characters intact. The lcs-distance is defined as the
number of unpaired characters. The distance is equivalent to the
edit distance allowing only deletions and insertions, each with
weight one.
- A q-gram is a subsequence of q consecutive characters of a
string. If x (y) is the vector of counts of q-gram occurrences in a
(b), the q-gram distance is given by the sum over the absolute
differences |xi?yi|. The computation is aborted when q is is
larger than the length of any of the strings. In that case Inf is
returned.
- The cosine distance is computed as 1?x*y/(||x||*||y||), where x and y
were defined above.
- The Jaccard distance is given by 1?|X?Y |/|X?Y|, where X is the set
of unique q-grams in a and Y the set of unique q-grams in b.
- The Jaro distance (p=0), is a number between 0 (exact match) and 1
(completely dissimilar) measuring dissimilarity between strings. It
is defined to be 0 when both strings have length 0, and 1 when there
are no character matches between a and b. Otherwise, the Jaro
distance is defined as 1?(1/3)(w1*m/|a| + w2*m/|b| +
w3*(m?t)/m). Here,|a| indicates the number of characters in a, m is
the number of character matches and t the number of transpositions
of matching characters. The wi are weights associated with the
characters in a, characters in b and with transpositions. A
character c of a matches a character from b when c occurs in b, and
the index of c in a differs less than max(|a|,|b|)/2?1 (where we
use integer division) from the index of c in b. Two matching
characters are transposed when they are matched but they occur in
different order in string a and b.
- The Jaro-Winkler distance (0<p<=0.25) adds a correction term to the
Jaro-distance. It is defined as d?l*p*d, where d is the
Jaro-distance. Here, l is obtained by counting, from the start of
the input strings, after how many characters the first character
mismatch between the two strings occurs, with a maximum of four. The
factor p is a penalty factor, which in the work of Winkler is often
chosen 0.1.
- For the soundex distance, strings are translated to a soundex code
(phonetic). The distance between strings is 0 when they have the
same soundex code, otherwise 1. Note that soundex recoding is only
meaningful for characters in the ranges a-z and A-Z. A warning is
emitted when non-printable or non-ascii characters are encountered.
From: https://cran.r-project.org/web/packages/stringdist/stringdist.pdf
- (1957)How to get useful information about ElasticSearch Nodes?
* Current status
- hostname
- role (master, data, nothing)
- free disk space
- heap used
- ram used
- file descriptors used
- load
curl -XGET https://localhost:9200/_cat/nodes?v&h=host,r,d,hc,rc,fdc,l
ost r d hc rc fdc l
192.168.1.139 d 1tb 9.4gb 58.2gb 20752 0.20
192.168.1.203 d 988.4gb 16.2gb 59.3gb 21004 0.12
192.168.1.146 d 1tb 14.1gb 59.2gb 20952 0.18
192.168.1.169 d 1tb 14.3gb 58.8gb 20796 0.10
192.168.1.180 d 1tb 16.1gb 60.5gb 21140 0.17
192.168.1.188 d 1tb 9.5gb 59.4gb 20928 0.19
* Shard allocation information
curl -XGET https://localhost:9200/_cat/shards?v
* Cluster stats
curl -XGET https://localhost:9200/_cluster/stats?pretty
* Nodes stats
curl -XGET https://localhost:9200/_nodes/stats?pretty
* Indice stats
curl -XGET https://localhost:9200/_cat/indices?v
curl -XGET https://localhost:9200/someindice/_stats?pretty
From: https://thoughts.t37.net/an-elasticsearch-cheat-sheet-9b92c9211d7b
- (1970)What are the best Podcasts?
- DataScience
http://dataskeptic.com/
https://www.udacity.com/podcasts/linear-digressions
http://www.partiallyderivative.com/
http://radar.oreilly.com/tag/oreilly-data-show-podcast
http://datastori.es/
http://www.learningmachines101.com/
http://www.thetalkingmachines.com/
http://www.ocdqblog.com/podcast/
http://freakonomics.com/radio/freakonomics-radio-podcast-archive/
https://itunes.apple.com/gb/podcast/insights%C2%ADfrom%C2%ADinsight%C2%ADweathering/id605818735?i=358334152&mt=2
http://fivethirtyeight.com/tag/whats%C2%ADthe%C2%ADpoint/
http://simplystatistics.org/category/podcast/
http://blog.pivotal.io/podcasts-pivotal
http://data-informed.com/multimedia/podcasts/
http://www.bbc.co.uk/programmes/p02nrss1
From: https://medium.com/swlh/the-7-best-data-science-and-machine-learning-podcasts-e8f0d5a4a419
http://dataconomy.com/2016/01/top-10-data-science-and-machine-learning-podcasts/
https://www.quora.com/What-are-the-best-data-science-podcasts
- BSD
http://feeds.feedburner.com/Bsdtalk
http://feeds.feedburner.com/BsdNowMp3
- Security
https://www.nolimitsecu.fr/feed/podcast
http://www.leoville.tv/podcasts/sn.xml
- Geek / Science
http://feeds.twit.tv/twit.xml
http://syndication.howstuffworks.com/rss/HSW
http://www.howstuffworks.com/podcasts/fwthinking.rss
http://www.howstuffworks.com/podcasts/stuff-they-dont-want-you-to-know.rss
http://www.howstuffworks.com/podcasts/stuff-mom-never-told-you.rss
http://www.howstuffworks.com/podcasts/stuff-to-blow-your-mind.rss
http://www.howstuffworks.com/podcasts/stuff-you-missed-in-history-class.rss
http://www.howstuffworks.com/podcasts/stuff-you-should-know.rss
http://www.howstuffworks.com/podcasts/techstuff.rss
https://les-technos.lepodcast.fr/rss
- (1971)FOSS Tools to Organize Teams, Communicate within Associations, etc.
* Share "Desktop" with multiple FramaApps (more flexible than TeamView!)
https://framaestro.org/
* Manage projects (SCRUM/Kanban-style)
https://framaboard.org/
https://mattermost.com/boards/ (PlugIn to Mattermost)
* Collaborative team communication (Web-IRC)
https://framateam.org/
* Visioconference
https://framatalk.org/
* Decide together
https://www.framavox.org
* Collaborative text edition
https://framapad.org/
* Collaborative spreadsheet edition
https://framacalc.org/
* Collaborative presentation edition
https://framaslides.org/
* Take (encrypted) notes
https://framanotes.org/
* Organize ideas / Post-Its
https://framemo.org/
* Create online forms/Quizz
https://framaforms.org/
* Shared Agenda
https://framagenda.org/
* Doodle-like
https://framadate.org/
* Create mind maps
https://framindmap.org/
* Manage Mailing Lists
https://framalistes.org/
* Follow the news (Atom/RSS)
https://framanews.org/
* Never miss an article!
https://framabag.org/
* Create custom maps
https://framacarte.org/
* Online storage
https://framadrive.org/
* Share files anonymously
https://framadrop.org/
* Share encrypted data
https://framabin.org/
* Share pictures anonymously
https://framapic.org/
* Vector drawing
https://framavectoriel.org/
* Share code
https://framagit.org/
* Free and anonymous meta search engine
https://framabee.org/
* Short links
https://framalinks.org/
From: https://framasoft.org/
https://framasoft.org/#topPgCloud
- (1975)What is Analytical Thinking according to Edward Tufte?
- Explain
- Discover Mechanisms
- Find causes/effects
- Use verbs, not nouns
- Use "trade-off"/"regression coefficient", not correlation
From: https://www.youtube.com/watch?v=rHUDJ8RyseQ
- (1976)Tips for BigData / Visualisation from Edward Tufte
- Make Smart Comparison ("compared with" is the big question)
- Publish envisioned Methodolgy BEFORE starting Analysis (otherwise tendency to "see" what we want in the collected data)
- Learn how data is collected with domain-expert (do not get trapped into bias introduced by sensors and/or collection procedures)
From: https://www.youtube.com/watch?v=rHUDJ8RyseQ
- (3845)What's "the Third Law of Papers"?
"A bad researcher fails 100% of the time, while a good one fail only 99% of the time"
From: https://youtu.be/_Y1-KlTEmwk?t=340
https://youtu.be/1kV-rZZw50Q?t=380
- (3846)What's "the Second Law of Papers"?
"Everything is connected"
From: https://youtu.be/_Y1-KlTEmwk?t=310
- (3863)How to install CUDA in Linux?
- Verify you have an NVIDIA card:
lsmod | grep nvidia
nvidia-smi
- Get lastest list of packages & versions
sudo apt update
- Get pre-requisites
sudo apt install build-essential
- Verify you have C/C++ compilers
gcc --version ; g++ --version
- Install Official CUDA
sudo apt install nvidia-cuda-toolkit
- Confirm whether CUDA is working
nvcc --version
NOTE: You can use the latest versions from PPA, but be careful to use all the packages that use CUDA (py-xxx-cuda) in sync with the exact CUDA version you installed.
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
sudo apt update
sudo apt full-upgrade
sudo apt install cuda
nvcc --version # may require to set CUDA_HOME & PATH
From: https://linuxhint.com/install-cuda-ubuntu-2004/
- (3874)What does "Regret" means in Reinforcement Learning?
Check out "Kaelbling's Reinforcement Learning: A Survey"
https://www.jair.org/media/301/live-301-1562-jair.pdf
"Regret. A more appropriate measure, then, is the *expected decrease in reward* gained due to *executing the learning algorithm* instead of *behaving optimally from the very beginning*. This measure is known as regret (Berry & Fristedt, 1985). It penalizes mistakes *wherever they occur* during the run."
From: https://qr.ae/pr2p78
https://www.quora.com/What-does-it-mean-by-regret-in-reinforcement-learning
- (3877)How to clear GPU memory after PyTorch model training without restarting kernel (a.k.a. How to free memory used by the Error Stack in an IPython Kernel/Notebook)?
PROBLEM: When you have an error in a notebook environment, the ipython shell stores the traceback of the exception so you can access the error state with %debug. The issue is that this requires holding all variables that caused the error to be held in memory, and they aren't reclaimed by methods like gc.collect(). Basically all your variables get stuck and the memory is leaked.
SOLUTION1:
If you just set object that uses a lot of memory to None like this:
obj = None
And after that you call
gc.collect() # Python thing
This is how you may avoid restarting the notebook.
If you still would like to see it clear from NVIDIA smi or nvtop you may run:
torch.cuda.empty_cache() # PyTorch thing
to empty the PyTorch cache.
For more detail see these references:
https://github.com/ipython/ipython/pull/11572
https://stackoverflow.com/questions/8238360/how-to-save-traceback-sys-exc-info-values-in-a-variable/54295910#54295910
SLOTUION2: Hack
Usually, *causing a new exception* will free up the state of the old exception. So trying something like 1/0 may help. However things can get weird with Cuda variables and sometimes there's no way to clear your GPU memory without restarting the kernel.
From: https://stackoverflow.com/questions/57858433/how-to-clear-gpu-memory-after-pytorch-model-training-without-restarting-kernel
- (1981)Why not use Mechanical Türk?
- Lack of competences: engaged people are not experts in the domain you need (unskilled worker/dogsbody)
- Legal terms: Data is sent to outside of any legal contract (NDA...)
Thks Matthieu
- (2014)What are the best DataScience Competitions?
https://www.datascience.net/
http://www.kaggle.com/
- (2015)What are the best DataScience MOOCs?
* Weka
** http://www.cs.waikato.ac.nz/ml/weka/mooc/dataminingwithweka/
** http://www.cs.waikato.ac.nz/ml/weka/mooc/moredataminingwithweka/
** http://www.cs.waikato.ac.nz/ml/weka/mooc/advanceddataminingwithweka/
* Andrew Ng
** https://www.youtube.com/watch?v=UzxYlbK2c7E&list=PLJ_CMbwA6bT-n1W0mgOlYwccZ-j6gBXqE
* Yann Lecun
** https://www.college-de-france.fr/site/yann-lecun/course-2015-2016.htm
* From renown Universities
** https://www.coursera.org/specializations/jhu-data-science
** https://www.coursera.org/specializations/machine-learning
** https://www.coursera.org/specializations/data-science-python
** https://www.coursera.org/specializations/big-data
** https://www.coursera.org/learn/machine-learning
** https://www.coursera.org/learn/r-programming
** https://www.coursera.org/learn/data-scientists-tools
** https://www.coursera.org/learn/python-data-analysis
** http://www.holehouse.org/mlclass/
** http://online.stanford.edu/course/statistical-learning
** http://work.caltech.edu/telecourse.html
** https://www.udacity.com/course/data-analyst-nanodegree--nd002
** https://www.thinkful.com/courses/learn-data-science-online/
** https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x7
** https://www.coursetalk.com/
** https://github.com/justmarkham/DAT7#bonus-resources
** http://datasciencemasters.org/
** http://www.wolfram.com/broadcast/c?c=99
** http://www.wolfram.com/broadcast/c?c=97
** http://www.wolfram.com/broadcast/c?c=397
* DataSchool
** http://www.dataschool.io/learn/
- (2017)Where to look for jobs as a Developer/Computer Scientist [circa 2017]?
http://www.talent.io
http://www.hired.com
http://www.getkudoz.com
https://www.chooseyourboss.com/
http://www.welcometothejungle.co/
Thanks DL+CL@remix
- (2041)What is the difference between an Epoch and an Iteration in NN?
* one epoch = one forward pass and one backward pass of all the
training examples
* batch size = the number of training examples in one forward/backward
pass. The higher the batch size, the more memory space you'll need.
* number of iterations = number of passes, each pass using [batch
size] number of examples. To be clear, one pass = one forward pass +
one backward pass (we do not count the forward pass and backward
pass as two different passes).
Example: if you have 1000 training examples, and your batch size is
500, then it will take 2 iterations to complete 1 epoch.
From: https://stackoverflow.com/questions/4752626/epoch-vs-iteration-when-training-neural-networks
- (2043)ML for newbies
The first question is What are you trying to achieve?
=> Your output variable will tell you a lot about that.
- Is it a class label?
Then you are probably doing classification
- Is it a number?
So you are doing regression
- Or maybe you don't have one?
And you want a clustering algorithm
On top of that, there are other considerations you might make:
- Does the model need to be human readable?
=> trees and rules are easier to interpret than MLPs, for example.
- How well do you understand the different methods?
=> You might do better on something you are familiar with.
ML/DS is pragmatic rather than theoretical. ML/DS is experimental:
Generally, we try a few different algorithms and look for one that
gives us the best results across a number of validation sets and
evaluation metrics.
From: http://weka.8497.n7.nabble.com/Learning-with-continuous-and-discrete-variables-td39898.html#a39899
- (2056)How to transform a 1-class classifier into a multi-class classifier?
1-against-1 implements the standard pairwise classification strategy, which combines classifier results using voting. (There is an option that enables pairwise coupling if you want to obtain probability estimates instead.)
1-against-all implements the standard one-vs-rest strategy. A classifier is build for each class in turn, treating that class as the positive class and all other classes together as the negative class. At prediction time, it predicts the class that receives maximum probability.
From: **TODO** https://encrypted.google.com/#q=wekalist+%221-against-1+implements+the+standard+pairwise+classification+strategy%22+%221-against-all+implements+the+standard+one-vs-rest+strategy%22
- (2060)Mean vs Median vs Mode
Let's consider the data set { 1, 2, 2, 3, 4, 7, 9 } for the examples below.
(Arithmetic)
Mean = Central tendency
= Sum of values of a data set divided by number of values
Sum over every possible value weighted by the probability of that value
= ∑(1/n*x) = ∑(x*P(x))
e.g. (1+2+2+3+4+7+9)/7 = 4
Median = The median is the value separating the higher&lower halves of a data sample
= If odd number of values => the middle one
If even number of values => mean of the two middle values
e.g. 1 2 2 /3/ 4 7 9 => 3
Mode = The value that appears most often in a set of data
= The value that is most likely to be sampled (discrete probability distribution)
The mode is not necessarily unique
e.g. 1, *2, 2*, 3, 4, 7, 9 => 2
Skewness = when these values are not equal
= Positive Skewness is when the "peak" is more on the left (low values)
= Illustration: https://en.wikipedia.org/wiki/Skewness#/media/File:Relationship_between_mean_and_median_under_different_skewness.png
The basic advantage of the median in describing data compared to the
mean (often simply described as the "average") is that it is not
skewed so much by extremely large or small values, and so it may give
a better idea of a 'typical' value. For example, in understanding
statistics like household income or assets which vary greatly, a mean
may be skewed by a small number of extremely high or low
values. Median income, for example, may be a better way to suggest
what a 'typical' income is.
Because of this, the median is of central importance in robust
statistics, as it is the most resistant statistic, having a breakdown
point of 50%: so long as no more than half the data are contaminated,
the median will not give an arbitrarily large or small result.
From: https://en.wikipedia.org/wiki/Mean
https://en.wikipedia.org/wiki/Median
https://en.wikipedia.org/wiki/Mode
https://en.wikipedia.org/wiki/Skewness
- (2073)How to run Attribute Selection + Classifier induction in a single command line in Weka?
java weka.Run .AttributeSelectedClassifier -E .CfsSubsetEval -S .BestFirst -W .NaiveBayes -t ~/datasets/UCI/iris.arff
From: http://weka.8497.n7.nabble.com/command-line-td40526.html
- (2075)How to manage an Ordered ordinal class in Weka?
Your classes are ordered, so you could try wrapping RandomForest into
OrdinalClassClassifier. That may help.
From: http://weka.8497.n7.nabble.com/Imbalanced-class-td40612.html
- (2076)How to avoid sub-sampling when using RandomForest in Weka?
PROBLEM: when one of the class is represented by too few examples
applying RandomForest (thus subsampling) might be difficult
SOLUTION: RandomForest applies WEKA’s Bagging with default parameters
to build a random forest with RandomTree. Perhaps your smallest class
is too small to be processed effectively by Bagging. You could also
try building a random forest without bagging (i.e., subsampling) by
using RandomCommittee with RandomTree as the base learner.
From: http://weka.8497.n7.nabble.com/Imbalanced-class-td40612.html
- (2077)How to manage Class Imbalance in Weka (a.k.a. weighting vs. Over-/Under-sampling)?
ClassBalancer doesn't do any sampling. It simply reweights the
instances so that all classes have equal weight. It will only produce
useful results when the base classifier implements the
WeightedInstancesHandler interface.
The unsupervised Resample filter allows you to perform oversampling or
undersampling, depending on how you set the percentage. Also,
oversampling is only possible if you use sampling with replacement
(the default). The same applies to the supervised Resample
filter. However, in this case you can also get over/undersampling of
individual classes if you change the sampling bias. (But, again,
oversampling of classes is only possible when you use sampling with
replacement.)
From: http://weka.8497.n7.nabble.com/Sampling-techniques-classification-td40626.html
http://weka.8497.n7.nabble.com/Choosing-Between-ClassBalancer-Resample-and-SpreadSubsample-Filters-td36292.html
- (2078)What is the difference between supervised/unsupervised filters in Weka?
supervised = use the class information [!!! might create a leak or an overestimation of the performance !!!]
unsupervised = does not use the class information
- (2082)Questions à se poser quand on fait des slides/écrit une intro/news/...
* Qui ?
* Quoi ?
* Où ?
* Quand ?
* Comment ?
* Combien ?
* Pourquoi ?
This method is based on the one known as "Five W's":
* Who?
* What?
* Where?
* When?
* Why?
From: https://fr.wikipedia.org/wiki/QQOQCCP
https://en.wikipedia.org/wiki/Five_Ws
- (2107)What is the difference between Information Gain and Symmetric Uncertainty?
*Information gain* is quite strongly biased towards *choosing
attributes with many values* (i.e., it can overfit more
easily).
*Symmetrical uncertainty* is a "normalised" version of information
gain. It *may* give you better results if you are comparing
*attributes with different numbers of values*. However, it’s also just
a heuristic. As (almost) always, experimentation is required.
If all your attributes have the same number of values, I’d use
information gain.
From:http://weka.8497.n7.nabble.com/Attribute-selection-td40960.html
- (2131)How to determine if a dataset is linearly separable?
To date, I use some kind of primitive intuition: if a dataset performs
well with DT but badly with SMO, then I assume the data might not be
(spontaneously) linearly separable.
Another rough approach is to use Perceptron: if a perceptron algorithm
converges, the data is linearly separable
From: http://weka.8497.n7.nabble.com/How-can-I-assess-if-my-data-is-linearly-separable-within-Weka-tc41058.html
- (2132)What evaluation measures to use for Imbalanced Datasets?
If you are dealing with imbalanced class distributions, then measures
such as AUC and AUPRC are more appropriate than accuracy.
From: http://weka.8497.n7.nabble.com/Re-Weka-Spark-tt40981.html#a40985
- (2144)What is Naive Bayes / How to select attributes with NaiveBayes?
Naive Bayes is called naive because it makes strong assumptions regarding the distribution of the data for each class. It assumes that the (predictor) attributes are independent given a particular class. One effect this can have is that NaiveBayes' raw probability estimates may not be suitable for classification (although they often are). AUROC only considers the ranking obtained by the probability estimates: as long as the ranking is good, regardless of the absolute values of the probability estimates, an attribute subset will be considered useful.
From: http://weka.8497.n7.nabble.com/No-selected-attribute-in-WrapperSubsetEval-td41170.html#a41172
---
P(A|B)P(B) = P(A, B) = P(B|A)P(A) => P(A|B) = P(B|A)P(A)/P(B)
Le théorème de Bayes peut être vu comme une superposition des deux arbres de décision ( https://fr.wikipedia.org/wiki/Th%C3%A9or%C3%A8me_de_Bayes#/media/File:Bayes%27_Theorem_2D.svg )
- P(A) = proba "à priori" / "antérieure" (précède toute info sur B) = "proba marginale"
- P(A|B) est appelée la "probabilité conditionnelle" de "A sachant B" / "postérieure", au sens qu'elle dépend directement de B
- P(B|A), pour un B connu, est appelé la "fonction de vraisemblance de A"
https://fr.wikipedia.org/wiki/Th%C3%A9or%C3%A8me_de_Bayes
p(C|F1,...,Fn) = (p(C)p(F1,...,Fn|C)/p(F1,...,Fn)
"postérieure = (antérieure * vraissemblance) / (évidence)"
https://fr.wikipedia.org/wiki/Classification_na%C3%AFve_bay%C3%A9sienne
- (2194)What are the available evaluation metrics for ML algorithms?
1. Confusion matrix: The confusion matrix is the primary method used
to validate a classifier. Most of the model quality and accuracy
metrics are based on the values of the confusion matrix. This matrix
is a table that contains information about the actual and predicted
values for a classifier. It typically looks like the figure below for
a binary classifier.
| Predictions |
| Positive | Negative |
Actuals | Positive | a=TP | b=FN |
| Negative | c=FP | d=TN |
The data in the confusion matrix have the following meaning:
* "a" is the number of positive class predictions that were correctly identified
=> True Positive: elements CORRECTLY detected as POSITIVE
* "b" is the number of incorrect predictions for actual positive cases
=> False Negative: elements INCORRECTLY detected as NEGATIVE
* "c" is the number of incorrect predictions for negative cases
=> False Positive: elements INCORRECTLY detected as POSITIVE
* "d" is the number of negative class predictions that were correctly identified
=> True Negative: elements CORRECTLY detected as NEGATIVE
* Accuracy: Accuracy measures how often the classifier makes a correct
prediction. It is the ratio of the number of correct predictions to
the total number of predictions.
Accuracy = (a+d)/(a+b+c+d) = (TP+TN)/(TP+FN+FP+TN) [NOTE: source is wrong here!!]
* Precision: Precision measures the proportions of true positives that
were correctly identified.
Precision = a/(a+c) = TP/(TP+FP)
* Recall: Recall is also termed "sensitivity" or "true positive rate."
It measures the proportions of true positives out of all observed
positive values of a target.
Recall = a/(a+b) = TP/(TP+FN)
* Misclassification rate: It measures how often the classifier has
predicted incorrectly
Misclassification rate = (c+b)/(a+b+c+d) = (FN+FP)/(TP+FN+FP+TN)
* Specificity: Specificity is also termed a "true negative rate". It
measures the proportions of true negatives out of all observed
negative values of a target.
Specificity = d/(b+d) = TN/(FN+TN)
* ROC (Receiver Operating Characteristic) curve: The ROC curve is used
to summarize the performance of a classifier over all possible
thresholds. The graph for ROC curve is plotted with sensitivity/True
Positive Rate (TPR) in the y axis and (1-specificity)/False Positive
Rate (FPR) in the x axis for all possible cutpoints (thresholds).
* AUC (Area Under Curve): AUC is the area under a ROC curve. If the
classifier is excellent, the sensitivity will increase, and the area
under the curve will be close to 1. If the classifier is equivalent
to random guessing, the sensitivity will increase linearly with the
false positive rate(1 – sensitivity). In this case, the AUC will be
around 0.5. As a rule of thumb, the better the AUC measure, the
better the model.
* Lift: Lift helps measure the marginal improvement in a model's
predictive ability over the average response. For example, for a
marketing campaign, the average response rate is 5%, but a model
identifies segments with a 10% response rate. Then that segment has
a lift of 2 (10%/5%).
* Balanced Accuracy: When the data set is unbalanced, the accuracy
might not be a good measure alone to evaluate a model. A model built
with unbalanced data is biased towards the most occurring
class. Balanced accuracy is a measure calculated on the average
accuracy obtained in either class.
Balanced Accuracy = 0.5*((a/(a+b))+(d/(c+d)) = 0.5*((TP/(TP+FN))+(TN/(FP+TN))
* F1 Score: F1 Score is also considered as a good measure to evaluate
an imbalanced classifier. F1 score is the harmonic mean of precision
and recall. Its value lies in between 0 and 1.
P = a/(a+c) = TP/(TP+FP)
R = a/(a+b) = TP/(TP+FN)
F1 Score = 2*(P*R)/(P+R) = 2*((a/(a+c))*(a/(a+b)))/((a/(a+c))+(a/(a+b)))
= 2*((TP/(TP+FP))*(TP/(TP+FN)))/((TP/(TP+FP))+(TP/(TP+FN)))
From: https://dzone.com/articles/important-evaluation-metrics-for-the-classifiers
https://en.wikipedia.org/wiki/Confusion_matrix
https://en.wikipedia.org/wiki/Accuracy_and_precision#In_binary_classification
- (2198)What are the best people/means to follow in DastaScience/Neuroscience
- DataScience RSS feed
http://www.datatau.com
- NeuroSciencePodCast
http://snrp.utsa.edu/Podcast/rss.xml
http://www.nature.com/neurosci/neuropod/archive.html
- NeuroScience people
https://github.com/marionleborgne
https://github.com/alexandrebarachant
https://www.kaggle.com/alexandrebarachant
http://alexandre.barachant.org/
- NeuroScience Slack
https://neurotechx.herokuapp.com/
http://neurotechx.com/
Thanks Quentin
- (2204)ML & Dev CheatSheets
Dev
https://duckduckgo.com/?q=cheat+sheet+site%3Azeroturnaround.com&t=canonical&ia=web
https://dzone.com/refcardz
ML/IA
https://www.kdnuggets.com/tag/cheat-sheet
https://www.datacamp.com/community/data-science-cheatsheets
https://www.rstudio.com/resources/cheatsheets/
https://github.com/dataprofessor/infographic
- (2210)Notes on agile methods
I] The philosophy behind Agile methods is to commit often/fail quick to get more feedback
Generally, when designing a system, two problems arise:
• Solving the *right problem*. This is requires working with the
Business team/Users to extract their needs.
• Solving the *problem right*. This is a purely technical expertise.
BE AWARE, though, that the order between the two is not trivial. The
power of Agile methods to have shown that working by small
*ITERATIONs* (prototypes/demos) and getting feedback early in the loop
is more efficient than FIRST defining the *right problem* THEN
implementing it the *right way*. Most projects that work in the latter
way fail, because they spend a lot of time in lengthy meetings with
the business team/users to define lengthy specifications, that in the
ends are discovered not to reflect what actually was what the client
wanted.
II] Agile methods are designed to help the team learn how t work together
If you ask a team how much time they will need to make, for the second
time, a product that they already have done once, they'll tell you
that they need between 20% and 70% of the initial time.
That's because the team has learned:
- about each other
- about the true requirements – not just those written down
- how to use the toolset
- how to develop & pratice working (team) & delivering (product) processes
- to cope with idiosyncrasies (=individual temperaments/hypersensitivities)
- to cope with unknowns
Learning (to work as a team) is THE bottleneck of software
engineering. The learning that occurs makes up a significant
percentage of the time spent on the work. That’s the main reason that
Agile practices work so well – they are all about recognizing and
responding to change.
From: https://dzone.com/refcardz/agile-adoption-decreasing-time
- (2249)What are the typical DataScience Trade-Offs?
- overfitting vs underfitting [DT:pruning ; NN: DropOut]
- exploration vs exploitation
- bias vs variance [General: -Variance: Ensemble Learning / Feature Selection / More data ; -Bias: More Features ; NN: -Variance: (L2)Regularization -Bias/+variance: more hidden units ; DT: -Variance: pruning]
- efficiency vs quality/robustness
- accuracy vs interpretability/simplicity [DT: early stopping ; NN: LIME]
- model complexity vs number of examples
- use high number of attributes vs high number of examples (more changes to find needle in haystack, but creates larger search space :{)
- ...
From: https://twitter.com/DataSciFact/status/948596065149898753
- (2250)Typical DataScience Job Interview Questions
* DS Interview Questions
** What are feature vectors
n-dimensional vector of numeric values that represent an object
** Explain the steps in making a decision tree
1. find best split 2. iterate over subsets 3. prune
** What is root cause analysis?
if item removed => no more error then item = root cause
** What is LogisticRegression?
LogisticRegression (aka "Logit") ~ 1 neuron with sigmoïd (= binary prediction based on linear combination of inputs)
** What are Recommender Systems?
Filtering systems that predict user rating/preference for an object
** Explain Cross validation
Split dataset in X subsets, train on X-1, validate on last. Iterate.
Only for evaluation (we always train on all data)
Statistical => less sensitive to bad splits
Prevent Overfitting
** Do gradient descent methodsat all times converge to a similar point?
No because of local minima
** What is the goal of A/B Testing?
Find importance of an element (in a web page) w/r business goal
** What are the drawback of linear model?
Assumption of linearity of errors
Can't be used for count/binary outcomes (XOR)
Overfitting
** What is the Law of Large Numbers?
Performing same experiment large number of times => Base of frequency thinking
mean / variance / stddev converge to what they estimate
** What are confouding variables?
extraneous vars that correlate directly with both dependent&independant vars
** Explain star schema
Lookup (Pivot?) tables that link IDs. Satellites tables contains names ans descriptions
** How regularly an algorithm must be updated?
- Not all data has been seen (training)
- Data Changes are expected over time
- Non-stationarity
** What are eigenvalues and eigenvectors?
Eigenvector: understanding linear transformation. In DS for correlation/covariance matrix
Eigenvalue : directions of the change
** Why is resampling done?
SubSetting: Bootstraping/CrossValidation
(Class Imbalance / Leak)?
** Explain Selective Bias
Problem introduced by using a non-random population
** What are the bias that can occur during sampling?
Selection bias / Undercoverage bias / survivorship bias
** Explain Survivoship bias
Selection of only the population that succeeded a test to find its characteristics => might consider/miss parameters that are/are-not relevant due to ignorance of the population that did not succeed
** How do you work towards a RandomForest?
Multiple weak learners (decision trees) combined into a strong learner
Each split => work only on a random subset of the features (prevents correlation between estimators in the final ensemble)
Prediction = majority rule
** What are the (7) steps of ML project?
- Gathering Data
- Preparing Data
- Choosing a model
- Training
- Evaluation
- Hyperparameters tuning
- Prediction
** What does Bootstrap aggregating (bagging) help reduce
variance (not bias?)
From: https://www.youtube.com/watch?v=EigTlV6xjlU
- (2251)How to improve NN/DeepNet?
0. Keras includes a Data Augmentation function!!!
You can use it to automatically generate the tilted/rotated/zoomed/shifted/fliped versions of your images.
You can also create your own Generator (e.g. to blur the images!)
https://keras.io/preprocessing/image/#imagedatagenerator
1. Model Averaging: Improve your output accuracy by creating several models and using ensemble methods
2. Temp removing of Data Augmentation: retrain your model with data augmentation turned off and decreased LearningRate (0.1->0.001)
3. Customize: replace your final (Dense) Layer by a customized one
4. Layer Unlocking: Train your bottom layers first (while using fixed Top/Convolution Layers, trained on classical DataSets - MNIST/CIFAR/ImageNet/etc.)
[ https://stackoverflow.com/questions/38978972/how-to-reuse-an-existing-neural-network-to-train-a-new-one-using-tensorflow ]
5. Decay Learning Rate: use learning rate that decrease with time (e.g. step decay or exponential decay)
6. Work with streams: Customize Keras' Generator to enable learning from DataSets that do not fit entirely in RAM
7. NVIDIA-docker: Use NVIDIA-Docker to ease installation/maintenance of libs/software that moves computations to GPUs
[ https://github.com/NVIDIA/nvidia-docker ]
8. Mitigate Class Imbalance:
- use Stratify Sampling (Discrete Data: StratBatch / Continuous Data: Percentile Scaling) for your batches
- More augmentation on minority class
9. Hack Your Net : You can change the output layer and for instance get a colorized image instead of a class probability!
10. Use Genetic Algorithms to Optimize/FineTune the (Hyper)Parameters together instead of SGD/DAM/ADAM+Batching (which assume nice Gradient Descent behaviour, which is not the case IRL)
11. Use FMP (Fractional Max Polling) instead of MaxPolling
https://arxiv.org/pdf/1412.6071.pdf
From: https://youtu.be/HZfNlzziICQ?t=969
- (2255)Typical Questions asked in a Job Interview
1. Passion for the Business
Q: Why do you want to work in this industry?
Q: Why would you be particularly good at this business?
Q: How do you stay current?
Q: Why do you think this industry would sustain your interest over the long haul?
Q: Where do you want to be in five years?
Q: Describe your ideal career.
Q: If you had unlimited time and financial resources, how would you spend them?
2. Motivation and Purpose
Q: Tell me something about yourself that I didn't know from reading your resume.
Q: Tell me what you know about this company.
Q: What have you learned about our company from customers, employees, or others?
Q: Why do you want to work here?
Q: What particular aspect of the company interests you most?
Q: What's your favorite product made by our company?
Q: What do you think of our newest product and ads?
Q: Tell me what you think our distinctive advantage is within the industry.
Q: Where do you think we're the most vulnerable as a business?
Q: What would you do differently if you ran the company?
Q: What other firms are you interviewing with, and for what positions?
Q: Do you believe you're overqualified for this position?
Q: Describe our competition as you see it.
Q: What would you do if one of our competitors offered you a position?
Q: Why are you ready to leave your current job?
Q: What do you want out of your next job?
Q: What's your dream job?
Q: What motivates you to do this kind of work?
Q: What salary would you expect for this job?
Q: What new skills or ideas do you bring to the job that other candidates aren't likely to offer?
Q: What interests you most about this job?
Q: What would you like to accomplish that you weren't able to accomplish in your last position?
Q: We have a number of applicants interviewing for this position. Why should we take a closer look at you?
Q: How have your career motivations changed over the past few years?
Q: Why should I hire you?
3. Skills and Experience
Q: What are your key skills?
Q: What sets you apart from the crowd?
Q: What are your strengths?
Q: How is your experience relevant to this job?
Q: What skills do you think are most critical to this job?
Q: What skills would you like to develop in this job?
Q: If you had to stay in your current job, what would you spend more time on? Why?
Q: How could you enrich your current job?
Q: How do you explain your job successes?
Q: Compared to others with a similar background in your field, how would you rate yourself?
Q: How good are your writing abilities?
Q: What computer systems and software do you know?
4. Diligence and Professionalism
Q: Give an example of how you saw a project through, despite obstacles.
Q: Share an example of your determination.
Q: Share an example of your diligence or perseverance.
Q: Describe a time when you tackled a tough or unpopular assignment.
Q: Would your current boss describe you as the kind of employee who goes the extra mile?
Q: How many days were you absent from work last year? Why?
Q: Tell me about a time you didn't perform to your capabilities.
Q: Employees tend to be either concept oriented or task oriented. How do you describe yourself?
Q: What would your colleagues tell me about your attention to detail?
Q: How do you manage stress in your daily work?
Q: How do you regroup when things haven't gone as planned?
Q: How have you prioritized or juggled your workload in your current job?
Q: Describe a professional skill you've developed in your most recent job.
Q: Why is service such an important issue?
Q: Tell me about a time when you had to deal with an irate customer. How did you handle the situation?
Q: Are there any issues from your personal life that might potentially have an impact on your professional career?
Q: When have your skills in diplomacy been put to the test?
Q: How do you manage your work week and make realistic deadlines?
Q: Tell me about a time you had to extend a deadline.
Q: What personal skill or work habit have you struggled to improve?
Q: What books do you keep on your desk?
5. Creativity and Leadership
Q: What color is your brain?
Q: If you got on an elevator where everyone was facing the back, what would you do?
Q: What's the most creative or innovative project you've worked on?
Q: Describe a time when you've creatively overcome an obstacle.
Q: Consider the following scenario: You're working late one evening and are the last person in the office. You answer an urgent telephone call to your supervisor from a sales rep who's currently meeting with a potential client. The sales rep needs an answer to a question to close the sale. Tomorrow will be too late. You have the expertise to answer the question, but it's beyond your normal level of authority. How would you respond?
Q: Why do you think that some companies with good products fail?
Q: How resourceful are you?
Q: Give me proof of your persuasiveness.
Q: What would your last supervisor say about your initiative?
Q: Describe an improvement you personally initiated.
Q: Describe a time in your work experience when the existing process didn't work, and what you did about it.
Q: Describe a time you had to alter your leadership style.
Q: Tell me about a good process that you made even better.
Q: Tell me about a time you persuaded others to adopt your idea.
Q: How would a former colleague or subordinate describe your leadership style?
Q: Do you believe that your job appraisals have adequately portrayed your leadership abilities?
Q: Describe the situations in which you're most comfortable as a leader.
Q: Describe your comfort level working with people of higher rank and people of lower rank.
6. Compatibility with the Job
Q: What were the most rewarding aspects of your most recent job?
Q: What are the limitations of your current job?
Q: What do you want to achieve in your next job?
Q: Describe your ideal job.
Q: What interests you most about this job?
Q: What interests you least about this job?
Q: What aspects of this job do you feel most confident about?
Q: What concerns you most about performing this job?
Q: What skills do you offer that are most relevant to this job?
Q: Considering your own resume, what are your weaknesses in relation to this job?
Q: How did the realities differ from your expectations in your last job?
Q: How would you enrich your current (or most recent) job?
Q: Would you be able to travel as necessary to perform the job?
Q: Why is this a particularly good job for someone with your qualifications?
Q: What's your most productive or ideal work setting?
Q: Do you prefer continuity in structure or frequent change in your daily work?
7. Personality and Cultural Compatibility
Q: What would your friends tell me about you?
Q: Tell me about your relationship with your previous bosses.
Q: Describe your working relationship with your colleagues.
Q: Describe your personality beneath the professional image.
Q: What environments allow you to be especially effective?
Q: Describe an environment that is ineffective for you.
Q: What situations excite and motivate you?
Q: How would your last employer describe your work habits and ethics?
Q: How do you feel your company treats its employees?
Q: Did your customers or clients enjoy working with you?
Q: How will you complement this department?
Q: Whom did you choose as your references, and why?
Q: Can we call all of your references?
Q: Tell me what you learned from a recent book.
Q: Tell me about a work group you really enjoyed.
Q: Describe a time when you had to assist a coworker.
Q: Are you most productive working alone or in a group?
Q: Tell me about a situation in which it was difficult to remain objective.
8. Management Style and Interpersonal Skills
Q: Tell me about an effective manager, supervisor, or other person in a leading role you've known.
Q: What type of management style do you think is effective?
Q: Describe your personal management style.
Q: What type of people do you work with most effectively?
Q: What things impress you in colleagues?
Q: What are some of the things your supervisor did that you disliked?
Q: How do you organize and plan for major projects?
Q: Describe a time when you've worked under intense pressure.
Q: How do you manage your time on a typical day?
Q: Describe a time when you acted on someone's suggestion.
Q: Tell me about a time when you had to defend an idea to your boss.
Q: What aspect of your management style would you like to change?
Q: Have you ever felt defensive around your boss or peers?
Q: Tell me about a learning experience that affected your management style.
Q: Have you patterned your management style after someone in particular?
Q: Describe a leader you admire.
Q: What personal characteristics add to your effectiveness?
9. Problem-Solving Ability
Q: How have your technical skills been an asset?
Q: Describe a situation in which you've applied technical skills to solve a problem.
Q: How do your technical skills, combined with other skills, add to your effectiveness on the job?
Q: Describe how you've used a problem-solving process.
Q: How do you usually go about solving a problem?
Q: How do you measure the success of your work?
Q: How practical or pragmatic are you?
Q: How do you balance your reliance on facts with your reliance on intuition?
Q: What was your greatest problem in your last job?
Q: Tell me about a problem that you failed to anticipate.
Q: Have you ever resolved a long-standing problem?
Q: Describe a time you found it necessary to make an unpopular decision.
Q: Tell me about the most difficult problem you've ever dealt with.
Q: Describe a time when a problem wasn't resolved to your satisfaction.
Q: Tell me about a time when there was no rule or precedent to help you attack a problem.
Q: When do you have difficulty making choices?
Q: Describe an opportunity in which you felt the risks far outweighed the rewards.
10. Accomplishments
Q: Tell me about a major accomplishment.
Q: Talk about a contribution you've made to a team.
Q: Talk about a special contribution you've made to an employer.
Q: Tell me about an organization outside of work that's benefited from your participation.
Q: Give me an example of a time you delivered more than was expected.
Q: What accomplishment is your greatest source of pride?
Q: If I hired you today, what would you accomplish first?
Q: What accomplishment was the most difficult for you to achieve?
Q: Tell me about a time you saved money for an employer or an organization.
Q: What's your greatest achievement to date?
Q: Tell me about a person or group you had to work with to achieve something important.
Q: Tell me about something you accomplished that required discipline.
Q: What situations do your colleagues rely on you to handle?
Q: Tell me about a need you fulfilled within a group or a committee.
Q: Tell me how you've supported and helped attain a corporate goal.
Q: Tell me about a quantifiable outcome of one of your efforts.
Q: Describe an ongoing problem you were able to overcome.
Q: Tell me about a project you completed ahead of schedule.
11. Career Aspirations
Q: Where do you hope that your career will have progressed to in the next few years?
Q: What are your long-term career plans?
Q: Since this will be your first job, how do you know you'll like the career path?
Q: Why is this job right for you at this time in your career?
Q: What are your aspirations beyond this job?
Q: What new challenges would you enjoy?
Q: If you could start all over again, what direction would your career take?
Q: What achievements have eluded you?
Q: How long do you think you'd continue to grow in this job?
Q: What career path interests you within the company?
Q: Compare this job to others you're pursuing.
Q: Have you progressed in your career as you expected?
Q: Tell me about your salary expectations.
Q: What do you reasonably expect to earn within five years?
Q: Have you ever taken a position that didn't fit into your long-term plan?
12. Personal interests and Hobbies
Q: Other than work, tell me about an activity you've remained interested in over several years.
Q: What do you do in your spare time?
Q: Do you have a balanced lifestyle?
Q: What outside activities complement your work interests?
Q: Tell me about a time you were in a recreational setting and got an idea that helped in your work.
Q: How is your personality reflected in the kinds of activities you enjoy?
Q: What kinds of leisure activities help you perform your work better?
Q: What do you do to relax?
Q: If you found yourself getting burned out, what would you do to revitalize your energy?
Q: Our company believes that employees should give time back to the community. How do you feel about it?
Q: What community projects that can use your professional skills are particularly interesting to you?
Q: If you had unlimited leisure time, how would you spend that time?
Q: Describe how a sport or hobby taught you a lesson in teamwork or discipline.
Q: When you aren't at work, do you prefer to stick to a schedule, or do you prefer to be spontaneous? Why?
Q: Tell me about an interest that you outgrew.
Q: Describe a movie you've seen that really inspired you.
——
Q: Tell me about a project in which you were disappointed with your personal performance.
Q: What would you do if I told you that I thought you were giving a very poor interview today?
Q: Tell me about your most difficult work or personal experience.
Q: If this were your first annual review with our company, what would I be telling you right now?
Q: Give an example of a time when you were asked to accomplish a task but weren't given enough information. How did you resolve this problem.
Q: Describe a time when you failed to resolve a conflict.
Q: How have you handled criticism of your work?
Q: What aspects of your work are most often criticized?
Q: Tell me about the last time you put your foot in your mouth.
Q: What might your current boss want to change about your work habits?
Q: Tell me about two or three aspects of your last job you'd never want to repeat.
Q: Tell me about a situation that frustrated you at work.
Q: Tell me about one of your projects that failed.
Q: Tell me about a time when your employer wasn't happy with your job performance.
Q: Have you ever been passed up for a promotion that you felt you deserved?
Q: Have you ever been fired?
Q: Why have you changed jobs so frequently?
Q: Why did you stay in your last job so long?
Q: Tell me about a problem you've had getting along with a work associate.
Q: Tell me about your least-favorite manager or professor.
Q: Who's the toughest employer you've ever had, and why?
Q: Have you ever had to work with a manager who was unfair to you, or who was just plain hard to get along with?
Q: Time management has become a necessary factor in productivity. Give an example of a time-management skill you've learned and applied at work.
Q: How do you handle tension with your boss?
Q: What would you say are the broad responsibilities of an editorial assistant?
Q: What is your current salary?
Q: Would you be willing to relocate to another city?
Q: Does the frequent travel required for this work fit into your lifestyle?
Q: Would you be able to work extended hours as necessary to perform the job?
Q: Sell me this stapler.
Q: How do you feel when things go wrong with a project? How do you handle it?
Q: Prove to me that your interest is sincere.
Q: Tell me about yourself.
Q: What is your biggest weakness?
Q: You have seven minutes to convince me why you're the best candidate for this position. Go.
Q: How would you respond to a defaulted form Z-65 counterderivative renewal request if your manager ordered you to do so, and if the policy under which the executive board resolves such issues were currently under review?
-- Students
Q: Why weren't your grades better?
Q: Why did you decide to major in history?
Q: Was there a course that you found particularly challenging?
Q: Why didn't you participate more in extracurricular activities?
-- Carrier change
Q: Why do you want to leave your current position?
Q: Why would you want to leave an established career at an employment agency for an essentially entry-level position in marketing?
-- Back after being unemployed
Q: Your resume doesn't list any job experience in the past few years. Why not?
Q: I see you've been out of work for a while. What difficulties have you had in finding a job that's compatible with your interests?
Q: Your resume indicates that you've been working for the past two years as a part-time clerk at Reliable Insurance Brokers. How will this experience help you in your banking career?
-- Illegal
Q: What religion do you practice?
Q: How old are you?
Q: Are you married?
Q: Do you have children?
Q: Do you plan to have children?
From: 250 Interview questions book
- (2261)What is important for a job interview?
- Prepare!
- Get info about the company & interviewers (google: "site:LinkedIn.com <name>"/"XYZ company news"/rapportive/images.google.com/etc.)
- Know each experience on your CV on tongue (create a MindMap/)
- Apparence
- Take notes
- Ask questions
- Re-contact after interview (Thanks+Show Motivation+Next interview?)
From: https://www.youtube.com/watch?v=d6iy-Cyn35A
https://www.youtube.com/watch?v=WkZDCWJ5pJg
- (2262)What questions to ask at the end of a job interview with regards to the interlocutor?
- Boss: business strategy
- How is the company organized? What are the departments (& their responsabilities)?
- What is the turnover (="Chiffre d'Affaires") and its expected evolution?
- What is the size of the market?
- What are the typical clients?
- What are the next expected clients?
- What are the competitors?
- Are you planning the creation of a DS team?
- Is there a company culture: is there a motto? How often it changes? Are there annual/weekly parties, etc?
- Can we access the office at night/on WE?
- How do you see the DS job (what missions)/place of DS in the company? What do you expec from a DS?
- RH: perspectives
- Is the company planning the creation of a DS team?
- What kind of DS/computer scientists do you have/seek?
- What are the advantages (Tickets RU/Cantine? CE/Syndicats? 1% logement? Sport structures/Douche?)
- Internal mobility (if company has several sites)?
- Are there/What are the typical work timetable?
- Operational
- (Size) How much data?
- (Format/Holes) Type/Format of data?
- (Bias) Collection process?
- (Appliable methods:Supervised/Unsupervised? / Evaluation) Access to experts in the domain? How much processing power?
- Already tried models? Which ones? Metrics? Success rate? Problems faced?
- What is your technical environment (Agile-Redmine-Jenkins/IDE-IntelliJ/Language-Java-R/Frameworks...)
- Day-to-day activities (What is your typical day?)
- What is your typical work timetable?
- Where do you live? How do you come to the working place (Douches?)?
- Can we access the office at night/on WE?
- How do you see the DS job? What is the place of a DS in the company?
From: https://youtu.be/WkZDCWJ5pJg?t=180
- (2263)Comment écrire un Elevator Pitch ("parlez-moi de vous") pour un entretien d'embauche?
- Typical Elevator Pitch (= "parlez-moi de vous?" / "Présentez-moi votre parcours" / "Je vous écoute")
- Attention :
- Doit être bref (1 à 3 min) pour ne pas décrocher l'interviewer dès les premières questions
- Garder l'essentiel pour faire passer les messages implicitement ("je vais travailler en équipe ou tout seul", "je suis très calé en info", etc.)
- Erreur :
- NE PAS réciter son CV : c'est long et ennuyeux
- NE PAS faire trop chronologique : on risuqe de parler longuement de sujets qui ne sont plus d'actualité ou pas pertinents pour le futur employeur
- Peut prendre 3 formes :
- Par Thème : "je suis XXX" "le cœur de ma compétence est YYY" "avec 3 piliers: AAA / BBB / CCC"
- Par Objectifs : "je suis XXX" "Mon objectif aujourd'hui c'est YYY" "à l'appui de cet objectif j'ai 3 piliers: AAA / BBB / CCC"
[NOTE: forme pratique pour les changements de fonction: cas où l'on n'a pas grand-chose dans le CV pour justifier une candidature sur un poste un peu décaler]
- Par Plan d'Actions "je suis XXX" "spécialiste YYY" "si demain vous faites le choix de me recruter" "voilà ce que je vais vous amener: 1) je suis en mesure de AAA / 2) BBB / 3) CCC"
- Quelle que soit la forme, il faut présenter :
- Formation : nom de l'école / Mentions & prix obtenus
- Expérience : combien d'années d'expérience, quelles entreprises, quels postes
- Réalisations : Use Cases / Technos-Méthodos utilisées / Impact Business
- Pour chaque expérience, il faut être *synthétique* => Story telling:
- Contexte/Décor : Boîte/Fonction-Poste/Taille Équipe
- Problème
- Résolution : Étapes/Technos/Méthodos
- Résultats : chiffrés pour l'aspect business
- Chaque expérience en 1 minute max
Mon elevator pitch (raconter):
"Bonjour, je suis Guillaume MULLER"
- Origine motivation: "Je suis ce qu'on peut appeler un «Geek»: je suis passionné d'informatique depuis tout petit : depuis la 3ème, je voulais être programmeur"
- Formation :
- "Après un Bac scientifique, j'ai fait tout un cursus en informatique à la fac" : DEUG->Maîtrise(=MasterI) Info
- "C'est là que j'ai découvert et que je me suis passionné pour les liens info/bio et notamment l'IA" => MasterII IA (Robotique+IA) + Thèse en IA (SMA OD)
- Expériences :
- "De là à commencé ma carrière professionnelle en 2 temps : 1) en sortant de thèse, je voulais être enseignant/chercheur en info"
- 1ère partie : je voulais être enseignant info => thèse + Enseignant-Chercheur@AcademicLabs
--> Lien1: académique = trop théorique, manque de cas concrets (ex: CEA)
--> Lien2: "pour différentes raisons, je n'ai pas eu de poste. La principale étant que j'ai été assez naïf pour croire qu'on me jugerait uniquement sur mes compétences scientifiques, donc j'ai complètement mis de côté d'autre aspects, comme le networking" => "c'est de là qu'à commencé la 2ème partie de ma carrière, de datascientist en startup."
- 2ème partie : data science@startups
- "Et sinon, niveau personnel, j'aime bcp le sport et la nature, donc je mixe souvent l'un avec l'autre en faisant du Trail et de l'Escalade"
From: https://www.youtube.com/watch?v=8i4BaK9tUws
- (2264)What is DataScience?
It's the combination of 3 domains <=> Crossing of 3 circles:
+--> Maths (particularly Stats)
| ^
Stats| | Machine Learning
R&D | v
/ | Computer Science (DevOps: both programming & installing clusters/softs)
| ^
Trad.| | Data Processing / Traditional Software
R&D | v
+--> Business (domain expertise + communication skills: from DataScientist/IT dept to Business Units)
From: http://www.prooffreader.com/2016/09/battle-of-data-science-venn-diagrams.html
https://4.bp.blogspot.com/-0cbXveb1J_0/V-FtjJZ4rqI/AAAAAAAAMHM/bS32Pio2a1IFOyp5T86S0jiyB-3KAN1iwCEw/s1600/download%2B%25281%2529.png
https://1.bp.blogspot.com/-ju4m6PBOrgo/V-E5qz99SaI/AAAAAAAAMF0/gle0zsZz_nIBEMVg0EdZHoGJhjlnBzv1gCLcB/s640/moz-screenshot-3-729576.png
https://www.huffingtonpost.com/shelly-palmer/are-you-ready-for-data-sc_b_6844032.html
https://www.quantmetry.com/data-scientist-livre-blanc
https://s3.amazonaws.com/assets.datacamp.com/blog_assets/DataScienceEightSteps_Full.png
http://i.imgur.com/4ZBBvb0.png
http://edison-project.eu/edison/edison-data-science-framework-edsf
- (2265)Slides/Presentation Checklist
- Significance
- Why does it matter?
- How do I grab their attention?
- What do I want them to do?
- Structure
- Convincing
- Memorable
- Scalable
- Simplicity
- 1 point per slide
- Images whenever possible (no icons)
- Few matching colors
- Very few fonts
- Rehearsal
- Present it aloud
- Get Feedback
- Check Room and Equipment
From: "Death by PowerPoint (and how to fight it)" by Alexei Kapterev
https://www.slideshare.net/thecroaker/death-by-powerpoint
- (2268)What is the employer seeking when he interviews you?
- Why are you interested in this field of activity?
- Why are you interested in this kind of job?
- Why are you interested in this company?
- Why are you interested in our data?
- Why are you interested in this particular job offer?
- Why would I recruit you rather than another candidate?
If you don't know an answer, don't panic, turn it into positive:
"that's an interesting/awesome question, I'd like to do more research
and put together an answer for you"
From: https://youtu.be/WkZDCWJ5pJg?t=160
- (2269)What are the 7 ingredients of (scientific) creation?
1. Documentation (know previous works, "rest on giants' shoulders")
2. Motivation
3. Environement/Culture
4. Exchange (discussions with other people)
5. Constraints (find/seek the constraints that will help you)
6. Inspiration/Unexpected Stall(="décrochage incongru"/"déclic") (Systematic Thinking-Reflexion)
7. Chance (Persevere)
From: Cédric Villani / https://youtu.be/SpXDv3ewDGs?t=1130
- (2270)What software is avaible to prepare/clean data?
https://www.datacamp.com/courses/cleaning-data-in-r
https://www.trifacta.com/products/wrangler/
http://openrefine.org/
- (2273)When to use FilteredClassifier in Weka (a.k.a. What is the difference between [Un-]/Supervised filters)?
The rule is that whenever you need to apply a (supervised) filter to a classification or regression problem in WEKA, use the FilteredClassifier.
From: http://weka.8497.n7.nabble.com/Discretizing-data-and-cross-validation-issue-td42166.html#d1513566940000-339
- (2287)Dataviz Tips
* Books:
- "Looking Good in Print", Roger Parker
- "The Visual Display of Quantitative Information"/"Beautiful Evidence"/"Envisioning Information", Edward Tufte
- "Show me the numbers", Stephen Few
* General Building Rules
- Visualization is not "good" or "bad", it aims to be an "effective communication"
- Know the data you're using
- Know the type of graph you're using
- Know how your audience understands the data you're using
- Know how your audience understands the type of graph you're using
- Explicit the message you're trying to communicate
- The audience must see what you see
- KISS principle
=> keep message&visualization simple (remove unnecessary data & visual clutter)
=> direct attention to imortant stuff
=> no more than 5-7 items at once
- DataViz is an iterative process (what works/when to use each type of graph)
* Line charts
- Displays trends over time
- X-axis for time series
- Y-axis for the value to show
- Use 0 as the Y-axis baseline, apart if you want to emphasize the slopes (in this case, show the emphasis in a zoom window)
* Area chars
- DO NOT use them
- RATHER DO split your chart in X independent single-area charts stacked on top of one another
- Problems:
- It's too difficult to see if areas are cumulative or independent
- When the first area fluctuates a lot, then all areas will also appear to fluctuate
* Pie charts
- DO NOT use them: "They communicate information poorly" (Stephen Few)
- RATHER DO use a sorted horizontal histogram
- Problems:
- It's difficult to see if the whole sums up to 100%
- If one irrelevant category (e.g. "others") is too large, it blurs the main message
- It cannot display more than 3/5 categories clearly
- It cannot show a ranking
- It is difficult to compare between pie charts
* Bar charts
- DO NOT use stacked bar charts, it's too difficult to see if areas are cumulative or independent ; and to compare between 2 bars
- DO rather use grouped bar charts (bars with different colors next to one another)
- Vertical bar charts compare categories / Horizontal bar charts display for rankings
- (value displaying)-axis must start at 0
- Vertical bar charts with more than 10 categories are difficult to read
- When using a category "other" is needed, ensure it represents a low percentage
- If you want to show a trend, use line chart ; if you want to show a specific value use bar charts
- General Graphical Rules
- Use white space between the bars
- Keep bar of the same color
- If labels are too long, scwitch to an horizontal bar chart
* Geo-spatial charts
- Only use them if the geography is important e.g. if you want to show neighborhood info, etc
(if you want to show most important countries where your website users come from, use a ranking horizontal bar chart!)
- Geo-spatial charts can be used to display areas or pin point locations
- GeoBubble charts can add a 3rd dimension to the displayed information
* Graph types gallery
https://www.census.gov/dataviz/
* DataViz for Art
http://www.informationisbeautiful.net/
From: http://analytics.ncsu.edu/sesug/2015/RV-104.pdf
- (2288)How to learn R from wihtin R?
http://swirlstats.com/
TODO: put in DSBOOK!
- (2295)What is the difference between Normalize and Standarsize (in Weka)?
- The Normalize filter rescales attributes so that they are in [0:1].
df <- (df-min(df)) / ((max(df)-min(df))
- Standardize (="z-score nomalization") rescales attributes so that they have zero mean and unit variance. The mean of the new values is 0 and their std dev is 1.
df <- (df-mean(df)) / sd(df)
NOTE: Neither .unsupervised.attribute.Standardize nor Normalize perform row normalisation. They both operate on a per-column basis.
For row normalisation, there is a separate package with a filter:
http://weka.sourceforge.net/doc.packages/normalize/
From: https://list.waikato.ac.nz/hyperkitty/list/wekalist@list.waikato.ac.nz/thread/RGOXSCNNDHAKDUZ6XN6I7LTCO2IX5IR4/
http://weka.8497.n7.nabble.com/How-does-WEKA-normalize-data-with-the-filterType-command-td42897.html#a42900
http://list.waikato.ac.nz/pipermail/wekalist/2015-January/063041.html
https://stats.stackexchange.com/questions/7757/data-normalization-and-standardization-in-neural-networks/231330#231330
- (2301)What is TF/IDF?
* Term Frequency - tf(t,d)
** finding most commonly used words
** raw count of a term in a document
* Inverse Term Document Frequency - idf(t,D)
** finding words that are rarely used, but also important
** whether the term is common or rare across all documents
* TF-IDF = tf(t,d)*idf(t,D)
A high weight in tf–idf is reached by a high term frequency (in the given document) and a low document frequency of the term in the whole collection of documents;
From: https://www.r-bloggers.com/hardwired-for-tidy-text/
- (2326)How to hire free[lance] datascientists?
- Push data & propose competitions on Kaggle & Stack Exchange
- Hire directly freelance data scientists and consultants through Kolabtree and Experfy.
https://www.kolabtree.com/find-an-expert/subject/data-analysis
https://www.experfy.com/
From: https://www.kdnuggets.com/2018/01/nonprofits-data-science.html
- (2314)How does an independent variable differ from a dependent variable?
- An independent variable is manipulated and controlled by the researcher.
- A dependent variable is the variable that the researcher watches and/or measures.
- (2315)What is a double-blind study?
What is a double-blind study?
In a double-blind study, neither the subjects of the experiment nor the persons administering the experiment know the critical aspects of the experiment. This method is used to guard against both experimenter bias and placebo effects.
From: https://books.google.fr/books?id=k1skS4rEueUC&pg=PA3&lpg=PA3
- (2316)How does deductive reasoning differ from inductive reasoning?
- Deductive reasoning, often used in mathematics and philosophy, uses general principles to examine specific cases.
- Inductive reasoning is the method of discovering general principles by close examination of specific cases.
From: https://www.papertrell.com/apps/preview/The-Handy-Science-Answer-Book/Handy%20Answer%20book/How-does-deductive-reasoning-differ-from-inductive-reasoning/001137021/content/SC/52cafed282fad14abfa5c2e0_default.html
- (2317)What is "Occam's Razor"?
Occam's Razor is the scientific doctrine that states that "entities must not be multiplied beyond what is necessary"; it proposes that a problem should be stated in its basic and simplest terms. In scientific terms, it states that the simplest theory that fits the facts of a problem should be the one selected. This concept is also known as the principle of parsimony or the economy principle.
From: https://www.papertrell.com/apps/preview/The-Handy-Science-Answer-Book/Handy%20Answer%20book/What-is-Occam-s-Razor/001137021/content/SC/52cafed582fad14abfa5c2e0_default.html
- (2320)When to use Tree-based algos?
A tree structure will not work well if your data is very high-dimensional with
many weakly relevant attributes.
- (2375)How to do Deep Learning on Text data with Weka?
You usually represent your text input as a sequence of word embeddings
when training deep networks on text data.
The high-dimensional sparse vectors you get with StringToWordVector
are more suitable for linear models.
I suggest taking a look at the following example for training deep
networks for textual data with Weka:
https://deeplearning.cms.waikato.ac.nz/examples/classifying-imdb/
From: https://list.waikato.ac.nz/pipermail/wekalist/2018-April/072293.html
- (2376)When to use DeepLearning vs. DecisionTrees?
- Are your attributes highly correlated, like pixels in an image or
parts of an audio signal? Then, you might want to give deep learning a
try.
- If the data is highly structured, consisting of attributes that are
fairly abstract, then you might just want to stick to boosted decision
trees or similar methods that perform well on this kind of data.
From: https://list.waikato.ac.nz/pipermail/wekalist/2018-April/072291.html
- (2380)What is a good resource for time series preprocessing & classification?
http://www.timeseriesclassification.com/algorithm.php
- (2433)What are Decision Tree algorithms limits?
A tree structure will NOT work well if your data is very high-dimensional with many weakly relevant attributes.
From: http://weka.8497.n7.nabble.com/Question-re-deterministic-vs-probabilistic-classifiers-and-their-use-in-ensemble-methods-td42578.html#a42580
https://stackoverflow.com/questions/5751114/nearest-neighbors-in-high-dimensional-data#5773066
- (2437)Quels sont les impacts de l'IA sur le travail?
Les compétences transversales semblent importantes pour assurer une
bonne complémentarité entre les machines et les travailleurs (capacité
à communiquer avec les autres, capacité à transférer des compétences
et des savoir-faire organisationnels, capacité à gérer des aléas...).
From: fs-dossier-presentation-intelligence-artificielle-travail-28-03-2018.pdf
fs-rapport-intelligence-artificielle-28-mars-2018_0.pdf
- (2440)How to hire free[lance] datascientists?
- Push data & propose competitions on Kaggle & Stack Exchange
- Hire directly freelance data scientists and consultants through Kolabtree and Experfy.
https://www.kolabtree.com/find-an-expert/subject/data-analysis
https://www.experfy.com/
From: https://www.kdnuggets.com/2018/01/nonprofits-data-science.html
- (2441)Most important tools for ML in Python/R
=== GUIs
See Tip#3532
=== Python
- SumUp (Python Packages to install)
IDE: spyder3, INotebook/jupyter
Tables: numpy, scipy, pandas
Learn: keras, tensorflow, torch, scikit-learn, statsmodels
Images: scikit-image
Visualization: matplotlib, plotly, bokeh, seaborn
Text: NLTK
Web: scrapy
Misc: gensim
- IDE
https://jupyterlab.readthedocs.io
http://www.jetbrains.com/pycharm/
https://pythonhosted.org/spyder/
https://docs.python.org/3/library/idle.html
- Data Manipulation
https://pandas.pydata.org/
http://www.numpy.org/
https://www.scipy.org/
https://en.wikipedia.org/wiki/SymPy
https://spark.apache.org/docs/0.9.0/python-programming-guide.html
-Text
https://docs.python.org/3/library/re.html
https://pypi.python.org/pypi/textmining/1.0
http://www.nltk.org/
https://pypi.python.org/pypi/word2vec
- Feature Selection / Machine Learning
http://scikit-learn.org/stable/index.html
https://pypi.python.org/pypi/python-weka-wrapper3
- NN
https://keras.io/
https://www.tensorflow.org/
http://www.deeplearning.net/software/theano/
http://pytorch.org/
- Visu
https://seaborn.pydata.org/
https://bokeh.pydata.org/en/latest/
http://ggplot.yhathq.com/
http://vispy.org/
https://plot.ly/
https://altair-viz.github.io/
http://pyqtgraph.org/
https://matplotlib.org/
https://python.libhunt.com/project/goopycharts
- All in one
https://www.anaconda.com/distribution/
- Evaluation
http://www.statsmodels.org/stable/
- Interactive web apps / Dashboards
https://plot.ly/products/dash/
https://github.com/dgrtwo/gleam
https://github.com/adamhajari/spyre
https://github.com/stitchfix/pyxley
https://github.com/jwkvam/bowtie
https://streamlit.io/ ( https://www.youtube.com/watch?v=cuoPma70qac&list=PLtqF5YXg7GLkn2FNYA20y4D3DZKotdtmo&index=6 )
- Notebook
https://jupyter.org/
=== R
- SumUp (R packages to install)
IDE: RStudio, rattle, rggobi, shiny, gephi
Tables: dplyr/plyr, purrr, tidyr, magrittr, zoo, reshape2, data.table, sqldf, lubridate, stringr/stringi, jsonlite
Learn: tidyverse, keras, e1071, randomForest, nnet, mlr, caret, forecast, Boruta, arules, tree, glmnet, RWeka, FactoMineR, rminer, h2o, sparklyr
Images: EBImage, imageR
Visualization: ggplot2, plotly
Evaluation: ROCR, CORElearn, SuperLearner
Text: tm, tidytext, openNLP, stringdist
Misc: rmarkdown, mboost
- IDE
https://www.rstudio.com/
- Data Manipulation
http://purrr.tidyverse.org/
http://magrittr.tidyverse.org/
http://dplyr.tidyverse.org/
https://cran.r-project.org/web/packages/data.table/index.html
https://cran.r-project.org/web/packages/xts/index.html
https://spark.apache.org/docs/latest/sparkr.html
https://cran.r-project.org/web/packages/lubridate/index.html
https://cran.r-project.org/web/packages/tis/index.html
https://cran.r-project.org/web/packages/tseries/index.html
https://cran.r-project.org/web/packages/wavelets/index.html
-Text
https://cran.r-project.org/web/packages/stringr/index.html
http://text2vec.org/
https://cran.r-project.org/web/packages/tidytext/index.html
https://cran.r-project.org/web/packages/openNLP/index.html
https://cran.r-project.org/web/packages/tm/index.html
https://cran.r-project.org/web/packages/languageR/index.html
https://cran.r-project.org/web/packages/tokenizers/index.html
https://cran.r-project.org/web/packages/monkeylearn/index.html
https://cran.r-project.org/web/packages/wordnet/index.html
https://cran.r-project.org/web/packages/stringdist/index.html
https://cran.r-project.org/web/packages/udpipe/index.html
- Feature Selection
https://cran.r-project.org/web/packages/Boruta/index.html
- Machine Learning
http://www.tidyverse.org/
https://cran.r-project.org/web/packages/RWeka/index.html
https://cran.r-project.org/web/packages/caret/index.html
https://cran.r-project.org/web/packages/mlr/index.html
https://cran.r-project.org/web/packages/e1071/index.html
https://cran.r-project.org/web/packages/SuperLearner/index.html
https://cran.r-project.org/web/packages/CORElearn/index.html
https://cran.r-project.org/web/packages/ElemStatLearn/index.html
https://cran.r-project.org/web/packages/rminer/index.html
https://cran.r-project.org/web/packages/h2o/index.html
- NN
http://mxnet.io/
https://keras.rstudio.com/
https://tensorflow.rstudio.com/
- ARules
https://cran.r-project.org/web/packages/arules/index.html
- TimeSeries
https://cran.r-project.org/web/packages/forecast/index.html
https://cran.r-project.org/web/packages/zoo/index.html
https://cran.r-project.org/web/packages/tsoutliers/index.html
https://cran.r-project.org/web/packages/tseriesChaos/index.html
https://cran.r-project.org/web/packages/dtw/index.html
- Visu
https://gephi.org/
http://www.ggobi.org/
https://rattle.togaware.com/
http://ggvis.rstudio.com/
http://ggplot2.org/
https://plot.ly/
https://cran.r-project.org/web/packages/GGally/index.html
https://cran.r-project.org/web/packages/googleVis/index.html
- All in one
https://conda.io/docs/user-guide/tasks/use-r-with-conda.html
- Evaluation
https://cran.r-project.org/web/packages/caret/index.html
https://cran.r-project.org/web/packages/mlbench/index.html
https://cran.r-project.org/web/packages/e1071/index.html
https://cran.r-project.org/web/packages/ROCR/index.html
https://cran.r-project.org/web/packages/OneR/index.html
https://cran.r-project.org/web/packages/NbClust/index.html
- Interactive web apps / Dashboards
http://shiny.rstudio.com/
https://www.gradio.app/
- Notebook
http://rmarkdown.rstudio.com/r_notebooks.html
https://jupyterlab.readthedocs.io
Based on :
https://www.infoq.com/fr/presentations/quelles-bibliotheques-choisir-pour-votre-projet-data-science-anastasia-lieva
https://www.dataquest.io/blog/python-vs-r/
https://www.datacamp.com/community/data-science-cheatsheets
- (2485)Questions à poser en fin de soutenance de projet?
- Quel a été le plus gros problème que vous avez rencontré ?
- Qu'avez-vous appris pendant ce projet (qui n'était pas dans les cours/TP) ?
- S'il ne fallait retenir qu'une chose de ce projet, quelle serait-elle ?
- Quand vous avez été confronté à un problème dont vous n'aviez pas la solution, comment avez-vous procédé ? (bibliothèque? prof référents? internet?)
- Reste-t-il des choses que vous n'avez pas comprises ?
- Qu'avez-vous appris dans ce projet que vous pensez vous sera utile dans votre vie professionnelle ?
- Si le projet était à refaire, que changeriez-vous ?
II] Organisation
- Comment estimez-vous la répartition des tâches entre les différents membres ?
- Quelles sont les contributions majeures de chacun d'entre vous ?
- Comment l'équipe était-elle organisée ? (temps, planning, répartition des tâches, entente, etc.)
III] Auto-évaluation
- S'il fallait définir un critère de réussite à ce projet quel serait-il et estimeriez-vous que vous avez réussi le projet ?
- Est-ce que vous vous êtes amusés en faisant ce projet ?
- Quelle partie vous a le plus/moins plu/motivé dans le projet ?
IV] Travail pour le prof
- Si vous deviez proposer un sujet similaire pour l'année prochaine, quel sujet choisiriez-vous ?
- Quelles sont les connaissances qui vous ont manqué (bloquantes/qui auraient permis d'aller plus vite, en termes de techno/méthode d'organisation) ?
- Combien d'heures au total pensez-vous avoir passées sur le projet ?
V] Technique
- Pourrait-on (et comment) accélérer le code ?
- Pourrait-on (et comment) réduire le nombre de lignes de code ?
- Quelles parties du code produit pourrait-on réuitiliser si on changeait XXX?
VI] Futur
- Qu'est-ce que tu vas faire après ce stage ?
- (2510)Summary of Machine Learning Yearning book from Andrew Ng
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
=== SumUp Andrew Ng's Machine Learning Yearning ===
* MOOC to do
** https://www.coursera.org/learn/machine-learning
*** GM: has a part on detecting bounding-boxes! (& multiple objects at once?)
* Prerequisites
** Factors that influence good performance
*** Train Large NN
*** Have huge dataset
*** The NN architecture
*** With small datasets, the hand-engineering of features might be more important, thus NNs might not be the best algorithm
* Setting Up Dev/Test environment
** You'll need:
*** *Training set* => to train the algorithm (DOES NOT need to be drawn from same distribution as Dev/Test sets)
**** *Training-Dev set*: (smaller than training set, *needs* to be drawn from *same* distribution as Dev/Test sets)
*** *Dev(eloppement) set* ("Hold Out Cross Validation set") => to tune parameters, select features
**** *Eyeball Dev set*: the sub part on which human expert will perform manual error analysis.
**** *Blackbox Dev set*: the remaining examples.
*** *Test set* => to evaluate performance, but NO decision regarding the algorithm are based on this set
** Dev & Test sets MUST reflect data you ultimately expect to do well on.
** Dev & Test sets MUST come from the same distribution.
*** Having mismatched Dev and Test sets makes it harder to figure out what is and is not working.
*** [Example] Suppose you have a system that works well on the Dev set but not the Test set. If your Dev and Test sets had come from the same distribution, then you would have a very clear diagnosis of what went wrong: You have overfit the Dev set. The *obvious cure* is to *get more Dev set data*.
** The Dev set should be large enough to detect differences between algorithms that you are trying out.
** Establish a single-number evaluation metric
*** https://en.wikipedia.org/wiki/F1_score
*** F1 = 2/((1/Precision)+(1/Recall))
*** Precision = TP/(TP+FP) = (/(+)
*** Recall = TP/(TP+FN) = (/[+(
*** https://en.wikipedia.org/wiki/File:Precisionrecall.svg
** Combining metrics
*** averaging multiple metrics (GM: OWA)
*** satisfying (thresholding) some metrics, then optimizing (ranking) others
**** [Example] to minimize the false negative rate (*optimizing* metric), subject to there being no more than one false positive every 24 hours of operation (*satisfying* metric).
** Changing the learning environment
*** If the actual distribution you need to do well on is different from the Dev/Test sets, update them.
*** You have overfit the Dev set, change the Dev set
**** If you find that your Dev set performance is much better than your Test set performance, it is a sign that you have overfit to the Dev set. In this case, get a fresh Dev set.
**** But NEVER use the test set to make any decisions regarding the algorithm
*** If the metric is measuring something other than what the project needs to optimize, change the evaluation metric
*** If you ever find that the Dev/Test sets or metric are no longer pointing your team in the right direction, it's not a big deal! Just change them and make sure your team knows about the new direction.
** Takeaways
*** Choose *Dev and Test sets* from a *distribution* that reflects *what* data *you expect* to get in the future and want to do well on. This may not be the same as your training data's distribution.
*** Choose *Dev and Test sets* from the *same distribution* if possible.
*** Choose a *single-number evaluation metric* for your team to optimize. If there are *multiple goals* that you care about, consider *combining them* into a single formula (such as *averaging* multiple error metrics) or defining *satisfying* and *optimizing* metrics.
*** The *old heuristic of a 70%/30%* Train/Test split *DOES NOT apply* for problems where you have a *lot of data*; the Dev and Test sets can be much less than 30% of the data.
*** Your *Dev set* should be *large enough to detect meaningful changes in the accuracy of your algorithm*, but not necessarily much larger. Your *Test set* should be big enough to give you a *confident estimate of the final performance* of your system.
*** If your Dev set and metric are no longer pointing your team in the right direction, quickly change them: (i) If you had *overfit the Dev set*, get *more Dev set data*. (ii) If the *actual distribution you care* about is *different* from the *Dev/Test set* distribution, get *new Dev/Test set* data. (iii) If your *metric* is *no longer measuring* what is most important to you, *change the metric*.
* Error Analysis
** *Error Analysis* = process of looking at *misclassified examples*. Error Analysis refers to the process of examining *Dev set examples* that your algorithm *misclassified*, so that you can understand the *underlying causes* of the errors. This can help you *prioritize projects* and *inspire new directions*.
** Build first simple system quickly, then iterate
** It is not uncommon to start off tolerating some mislabeled Dev/Test set examples, only later to change your mind as your system improves so that the fraction of mislabeled examples grows relative to the total set of errors.
** If you have a large Dev set, and cannot perform error analysis on its entirety, split it into two subsets
*** *Eyeball Dev set*: the one we are looking at it with our eyes.
*** *Blackbox Dev set*: the remaining examples.
** The lower your classifier's error rate, the larger your Eyeball Dev set needs to be in order to get a large enough set of errors to analyze.
** The Eyeball Dev set is more important (assuming that you are working on a problem that humans can solve well and that examining the examples helps you gain insight).
** The model must perform well on the Training set BEFORE you can expect to perform well on the Dev/Test sets.
** Takeaways
*** Don't start off trying to design and build the perfect system. Instead *build and train* a *basic system* as *quickly as possible*. Then use *error analysis* to help you identify the *most promising directions* and iteratively improve your algorithm.
*** Carry out *error analysis* by *manually examining* ~100 *Dev set examples* the algorithm *misclassifies* and *counting* the *major categories of errors*. Use this information to *prioritize* what types of errors to work on fixing.
*** The *Eyeball Dev set* should be *big enough* so that your algorithm *misclassifies enough examples* for you to analyze.
* Bias & variance & learning Curves
** [GM: Bias = darts fell out of the center, Variance = darts spread large around the board]
** *Bias* = the algorithm's *error* rate on the *Training set*.
*** If the algorithm is able to learn something
** *Variance* = *how much worse* the algorithm does on the *Dev (or Test) set* than the *Training set* (difference Dev-Train set errors).
*** If the algorithm is able to generalize
*** Small Bias + High variance = overfitting
*** High Bias + Low Variance = underfitting
** Bias/Variance trade-off
*** Techniques for reducing bias
**** Increase Model Size (#neurons/#layers/...). If this increases variance => use regularization
**** Modify Input Features (adding more features can increase variance) => use feedback from error analysis (i.e. input more human/expert knowledge in the system)
**** Reduce/Eliminate regularization (L2, L1, drop-out) => increases variance
**** Modify Model architecture => affects both bias & variance
** Techniques for reducing variance
**** Add more training data
**** Add regularization (L2, L1, drop-out)
**** Add early stopping => this increases bias (similar effect as regularization)
**** Decrease number of input features (= Feature/Attribute Selection) => might increase bias
**** Decrease the model size => might increase bias
***** !!!ATTENTION!!! prefer using regularization
***** pro: also decreases computational cost
**** Modify input features (i.e. introduce human/expert knowledge) => might reduce both bias & variance
**** Modify Model architecture => affects both bias & variance
** Diagnosing bias & variance
*** Drawing a *learning curve*: plot the *evolution of the chosen metric* (Dev set error) with the growing of the *size of the Training set*.
*** This provide an idea of what we can expect from the algorithm in a glimpse.
*** If [and only if] the curves are too noisy too see the trend
**** => Train several models (on subsets of the Training using sampling with replacement) and plot the averages of the Training/Dev errors.
***** *Sampling with replacement* = select X examples for the original set, and iterate, without removing the previously selected examples from the original set.
***** If your Training set is skewed towards one class, or if it has many classes, choose a "balanced" subset. Respect the same skewness/proportions as the original dataset.
*** Adding the Training set error & desired error rate on the plot helps quickly diagnose the learning problems
**** Training set error usually behaves the converse of Dev set error: it increases as the Training set grows
*** On such plot we can quickly diagnose Bias & Variance:
**** Bias = Height between desired performance curve that goes up (Training Error).
**** Variance = Height between 2 curves: the one that goes up (Training) and the one that goes down (Dev).
* Comparing to Human-level performance
* Training & Testing on different distributions
** *ALWAYS choose a Dev and Test sets that reflect data you expect to get in the future and want to do well on.*
** In the modern era of powerful, flexible learning algorithms — such as large neural networks — it is preferable to train on lots of data, even if the Train/Test distribution diverge, than train on fewer data.
** But if you do not have a big enough neural network (or another highly flexible learning algorithm), then you should pay more attention to your Training set matching your Dev/Test set distribution.
** Weighting data
*** Using squared error as an optimization objective is NOT a good choice for a classification task.
*** *Re-weighting* instances is needed only when you suspect the additional data has a *very different* distribution than the Dev/Test set, or if the *additional data* is *much larger* than the data that came from the same distribution as the Dev/Test set.
** Generalizing from the Training set to the Dev set
*** Problems that can occur
**** The algorithm does not do well on the Training set. This is the problem of high (avoidable) bias on the Training set distribution.
**** The algorithm does well on the Training set, but does not generalize well to previously unseen data, drawn from the same distribution as the Training set. This is high variance.
**** *Data Mismatch*: The algorithm generalizes well to new data drawn from the same distribution as the Training set, but not to data drawn from the Dev/Test set distribution. We call this problem *data mismatch*, since it is because The Training set data is a poor match for the Dev/Test set data.
*** Further splitting of the datasets
**** *Training set* This is the data that the algorithm will *learn from*. This *does not* have to be *drawn from the same distribution* as what we really care about (the Dev/Test set distribution).
**** *Training-Dev set* This data is *drawn from the same distribution as the Training set*. This is usually *smaller* than the Training set; it only needs to be large enough to evaluate and track the progress of our learning algorithm.
**** *Dev set* This is drawn from the *same distribution* as the *Test set*, and it reflects the distribution of data that *we ultimately care about doing well on*.
**** *Test set* This is drawn from the *same distribution* as the *Dev set*.
*** Armed with these four separate datasets, we can now evaluate:
**** *Training error*, by evaluating on the *Training* set.
**** The algorithm's *ability to generalize* to new data drawn from the Training set distribution, by evaluating on the *Training-Dev* set.
**** The algorithm's *performance on the task we care* about, by evaluating on the *Dev* and/or *Test* sets.
** How to detect bias/variance/data mismatch
**** You can write a table like:
|------------------|----------------|
| "maximum data" | "desired" |
| Distribution | Distribution |
|------------------|----------------|
Human level | "Human level error" (0%) | <-
| | | Bias
Error on Train Exples | "Training error" | <-
| | | Variance
Error on new Exples | "Train-Dev" err | "Dev/Test" err | <-
|------------------|----------------|
^-----^
data mismatch
** Techniques to address Data Mismatch
*** Try to understand what properties of the data differ between the Training and the Dev set distributions.
**** The purpose of error analysis is to understand the significant differences between the Training data and the Dev set.
*** Try to find more Training data that better matches the Dev set examples that your algorithm has trouble with.
*** Look a "domain adaptation" research domain
** Artificial Data Synthesis
*** Artificial Data Synthesis allows you to create a huge dataset that reasonably matches the Dev set.
*** Challenge: create data that appears realistic to the computer, not the human, so that the learning algorithm cannot overfit on the added noise (hard to spot).
*** Try to avoid giving the synthesized data properties that makes it possible for a learning algorithm to distinguish synthesized from non-synthesized examples.
* Debugging Inference Algorithms
**Reinforcement learning a.k.a. The Optimization Verification Test
*** You can apply the *Optimization Verification test* when, given some input x, you know how to compute Score_x(y) that indicates how good a response y is to an input x. Furthermore, you are using an approximate algorithm to try to find argmax_y Score_x(y), but suspect that the search algorithm is sometimes failing to find the maximum.
*** Suppose y* is the "correct" output, but the algorithm instead outputs y_out. Then the key test is to measure whether Score_x(y*) > Score_x(y_out).
**** If this inequality holds, then we blame the optimization algorithm for the mistake.
**** Otherwise, we blame the computation of Score_x(y).
* End-to-End Deep Learning
** An end-to-end learning algorithm take as input a raw information, and directly tries to recognize the output.
*** - Works better if labeled data is abundant.
*** + Requires less injection of human/expert knowledge
*** + You can work directly with various data types at both end (e.g. from picture to sentences/pix2pix vs. xxx to class number)
** The other approach (non end-to-end) generally consists in splitting the problem in sub-problems (famous AI motto: "Divide & Conquer") and building a pipeline of simpler problems that are easier to learn or have direct solutions.
*** + Works better if data is scarce.
*** + As sub-problems are "simpler", it is easier to get data on each of them.
**** One definition of simplicity is the Kolmogorov Complexity: "the complexity of a learned function is the length of the shortest computer program that can produce that function." (not very practical in AI!)
https://en.wikipedia.org/wiki/Kolmogorov_complexity
*** + Using error analysis on simpler tasks, you can quickly prioritize & focus your team's efforts
*** - Requires more injection of human/expert knowledge (splitting in sub-problems+design of pipeline).
*** - Weakest Link problem: this approach is more sensitive to errors in the design of any single component (error accumulates along the pipeline) and the whole pipeline (every component can have perfectly learned, but still the whole pipeline behave poorly).
*** - Requires more "intermediate" labeling of data.
**** But you can use Amazon's Mechanical Turk [not recommended by some Data Scientists]
** If you are working on a machine learning problem where the *Training set is very small*, most of your algorithm's knowledge will have to *come from your human insight* (i.e., from "hand engineering" components).
* Error Analysis by parts
- (2520)List of My Wikibooks
https://en.wikipedia.org/wiki/User:LI_AR/Books/Cracking_the_DataScience_Interview
https://en.wikipedia.org/wiki/User:LI_AR/Books/10_Minutes_Stats_Book
https://en.wikipedia.org/wiki/User:LI_AR/Books/Cracking_the_Coding_Interview
https://en.wikipedia.org/wiki/User:LI_AR/Books/SoftwareDesignLaws
https://en.wikipedia.org/wiki/User:LI_AR/Books/ComputerArchitectureTSE
https://en.wikipedia.org/wiki/User:LI_AR/Books/QuantumMechCompML
- They can be found with:
https://en.wikipedia.org/w/index.php?search=LI+AR%2FBooks%2F&title=Special:Search&fulltext=1&ns2=1
- (2558)Wikibook: Quantum Mechanics/Computer/Machine Learning
Stored at: https://en.wikipedia.org/wiki/User:LI_AR/Books/QuantumMechCompML
Quantum
[TOREAD]
https://github.com/rigetti/pyquil
[[Quantum_Fourier_transform]]
https://qiskit.org/
https://hub.mybinder.org/user/qiskit-qiskit-tutorial-zlm4uf1c/notebooks/index.ipynb
https://www.dwavesys.com/quantum-computing
https://www.microsoft.com/en-us/quantum/default.aspx
https://ai.google/research/teams/applied-science/quantum-ai/
https://ionq.co/
https://courses.edx.org/courses/course-v1:MITx+8.370.1x+1T2018/course/
https://medium.com/@_NicT_/quibbling-over-qubits-f2ca1b87f470
https://www.youtube.com/results?search_query=scott+aaronson
https://www.youtube.com/results?search_query=mickael+nielsen
https://www.youtube.com/results?search_query=john+preskill+quantum+computing
[[Shor%27s_algorithm]]
[[Grover%27s_algorithm]]
[[Quantum_algorithm_for_linear_systems_of_equations]]
[[Quantum_information_science]]
[[Category:Post-quantum_cryptography]]
[[Quantum_logic_gate]]
https://www.nist.gov/programs-projects/itl-quantum-information-program
4Babies
https://www.youtube.com/watch?v=dksWoLwU56w
https://www.youtube.com/watch?v=5o_BGbF3S0I
Algorithms
[[Shor%27s_algorithm]]
[[Grover%27s_algorithm]]
[[Deutsch%E2%80%93Jozsa_algorithm]]
[[Quantum_error_correction]]
http://quantumalgorithmzoo.org/
https://arxiv.org/abs/1307.0401
[[Quantum_optimization_algorithms#Quantum_data_fitting]]
https://arxiv.org/abs/1602.04799
https://arxiv.org/abs/1307.0471
https://www.epiqc.cs.uchicago.edu/quantum-algorithms-and-applications
Blogs
https://medium.com/@_NicT_/quibbling-over-qubits-f2ca1b87f470
https://www.epiqc.cs.uchicago.edu/
Books
http://booksdescr.org/item/index.php?md5=A355D6CD9A9F2571_TOREMOVE_0441508CC160FD04
http://booksdescr.org/item/index.php?md5=D61C836C22DF4DD3_TOREMOVE_C29431D6021EC964
http://booksdescr.org/item/index.php?md5=d35451ef9b45e684_TOREMOVE_c8fcf306fb9505f4
http://booksdescr.org/item/index.php?md5=082AF57FC6A4E618_TOREMOVE_C497374CEF0048C9
http://booksdescr.org/item/index.php?md5=EEE17F96ACD3DFA0_TOREMOVE_4074D69F1B985715
Computing
[[Reversible_computing]]
Gates
[[Quantum_logic_gate]]
[[Quantum_logic_gate#Hadamard_(H)_gate]]
[[Quantum_logic_gate#Pauli-X_gate]]
[[Controlled_NOT_gate]]
[[Fredkin_gate]]
Games
https://www.youtube.com/watch?v=LWsMWpQIobI
Limits
https://www.scientificamerican.com/article/the-fundamental-physical-limits-of-computation/
https://www.quantamagazine.org/gil-kalais-argument-against-quantum-computers-20180207/
https://www.researchgate.net/publication/323597573_Loading_Classical_Data_into_a_Quantum_Computer
https://oqp.iqoqi.univie.ac.at/can-classical-big-data-be-loaded-fast-enough-to-achieve-linear-algebra-based-quantum-machine-learning-speed-ups
https://oqp.iqoqi.univie.ac.at/open-quantum-problems
Machines-Code
Working
IBM-Q
https://quantumexperience.ng.bluemix.net/qx/editor
https://quantumexperience.ng.bluemix.net/qx/tutorial?sectionId=beginners-guide&page=introduction
https://quantumexperience.ng.bluemix.net/qx/tutorial?sectionId=full-user-guide&page=introduction
https://nbviewer.jupyter.org/github/Qiskit/qiskit-tutorial/blob/master/index.ipynb
https://docs.microsoft.com/en-us/quantum/?view=qsharp-preview
https://github.com/rigetti/pyquil
https://qiskit.org/
https://www.dwavesys.com/quantum-computing
WIP
https://www.microsoft.com/en-us/quantum/default.aspx
https://ai.google/research/teams/applied-science/quantum-ai/
https://ionq.co/
https://www.hpcwire.com/2019/03/27/quantum-bits-ibm-tackles-noisy-machines-ionq-issues-benchmarks-d-wave-expands-leap/
https://www.networkworld.com/article/3341304/10-hot-quantum-computing-startups-to-watch.html
https://arxiv.org/pdf/1608.03355.pdf
Maths
[[Tensor_product]]
ML
[[Quantum_machine_learning]]
[[Quantum_neural_network]]
[[Quantum_clustering]]
MOOCs
https://www.edx.org/course/quantum-information-science-i
https://www.youtube.com/results?search_query=scott+aaronson
https://www.youtube.com/results?search_query=mickael+nielsen
https://www.youtube.com/results?search_query=john+preskill+quantum+computing
https://www.youtube.com/results?search_query=Talia+Gershon+quantum
https://www.epiqc.cs.uchicago.edu/qc-introduction
https://www.doc.ic.ac.uk/~nd/surprise_97/journal/vol4/spb3/
http://www.quiprocone.org/Protected/DD_lectures.htm
https://homepages.cwi.nl/~rdewolf/qc19.html / vids: https://vimeo.com/album/5701568 PASS: yjD3
https://www.youtube.com/playlist?list=PLOFEBzvs-VvpzQnlazij7cL1mjKvJTAwk
https://www.youtube.com/watch?v=lZ3bPUKo5zc&list=PLUl4u3cNGP61-9PEhRognw5vryrSEVLPr
https://www.youtube.com/watch?v=kEry1TaN4-k
https://www.youtube.com/watch?v=5R6k2mEacZo
https://www.youtube.com/channel/UCmZtinDlBrzAwiQc8LpPexQ/videos
https://www.youtube.com/results?search_query=MichelDevoret
Notation
https://www.epiqc.cs.uchicago.edu/1qubit
Papers
https://arxiv.org/abs/quant-ph/9508027
https://arxiv.org/abs/1703.10302
https://www.sciencemag.org/news/2016/12/scientists-are-close-building-quantum-computer-can-beat-conventional-one
https://www.nobelprize.org/prizes/physics/1945/pauli/lecture/
https://www.sciencemag.org/news/2017/09/quantum-computer-simulates-largest-molecule-yet-sparking-hope-future-drug-discoveries
https://arxiv.org/abs/1702.03061
https://arxiv.org/abs/1408.7005
http://axon.cs.byu.edu/papers/ventura.icannga99.pdf
https://www.apc.univ-paris7.fr/apc_cs/conferences/cosmograv2018/talks/gia_talk_paris_cosm.pdf
https://arxiv.org/abs/quant-ph/0312059
https://www.researchgate.net/publication/228109669_A_Single_Quantum_Cannot_be_Cloned
https://espace.library.uq.edu.au/view/UQ:142788/UQ142788_OA.pdf
https://www.researchgate.net/publication/252923968_Quantum_computations_Algorithms_and_error_correction
https://arxiv.org/abs/1710.05867
https://arxiv.org/pdf/1512.02206v1.pdf
https://ec.europa.eu/digital-single-market/en/news/european-commission-will-launch-eu1-billion-quantum-technologies-flagship
https://www.research.google.com/pubs/archive/45919.pdf
https://arxiv.org/abs/1203.5813
People
https://fr.wikipedia.org/wiki/Thomas_Young
[[Richard_Feynman]]
[[John_Preskill]]
[[Peter_Shor]]
[[David_Deutsch]]
[[Alain_Aspect]]
[[Albert_Einstein]]
[[Boris_Podolsky]]
[[Nathan_Rosen]]
[[John_Stewart_Bell]]
[[Bohr]]
[[Werner_Heisenberg]]
[[Max_Planck]]
[[Erwin_Schr%C3%B6dinger]]
[[Wolfgang_Pauli]]
[[Sandu_Popescu]]
[[Fritz_Rohrlich]]
[[Michel_Devoret]]
[[John_von_Neumann]]
[[Rolf_Landauer]]
Physics
[[Ultraviolet_catastrophe]]
[[Schr%C3%B6dinger%27s_cat]]
[[Wave_function]]
[[Uncertainty_principle]]
https://fr.wikipedia.org/wiki/Fentes_d%27Young
[[Double-slit_experiment]]
[[Bell%27s_theorem]]
https://fr.wikipedia.org/wiki/Paradoxe_EPR
[[Eigenvalues_and_eigenvectors]]
[[Quantum_entanglement]]
[[Quantum_tunnelling]]
[[Quantum_annealing]]
[[Pauli_exclusion_principle]]
[[Josephson_effect]]
[[Quantum_superposition]]
[[Quantum_entanglement]]
[[Quantum_decoherence]]
[[No-cloning_theorem]]
[[Wave_interference#Quantum_interference]]
[[Quantum_foundations]]
[[No-communication_theorem]]
[[Simon_problems]]
[[Bra%E2%80%93ket_notation]]
[[Ansible]]
[[Ancilla_bit]]
[[Homodyne_detection]]
[[Bloch_sphere]]
QBits
[[Superconducting_quantum_computing]]
[[Trapped_ion_quantum_computer]]
[[Linear_optical_quantum_computing]]
[[Quantum_dot]]
[[Topological_quantum_computer]]
[[Silicon-vacancy_center_in_diamond]]
[[Nitrogen-vacancy_center]]
Zines
https://www.epiqc.cs.uchicago.edu/zines
- (2653)How to write an Associate Professor (Maître de Conférence) application file?
* LES BONS ÉLÉMENTS D'UN CURRICULUM VITAE :
Les publications
Pour un poste d'ATER, il semble qu'il faille une publication dans une bonne conférence. Pour un poste de maître de conférence, un article dans un journal (pensez aux délais et jugez quand vous devrez commencer à le rédiger) et/ou deux ou trois bonnes conférences et/ou un logiciel diffusé et utilisé semblent être la norme.
Le post-doctorat
Il semble de plus en plus difficile d'obtenir un poste permanent directement après la thèse, il faut alors envisager un poste d'ATER ou un stage post-doctoral (les deux ne s'excluant pas) dans une autre équipe de recherche. Il faut y penser et s'y préparer suffisamment tôt.
L'enseignement
Pour candidater sur un poste de maître de conférence, il semble qu'un exigence reconnue par beaucoup de commissions de spécialistes soit d'avoir enseigné de l'ordre de 150 heures. Cependant un bon dossier de recherche peut compenser un dossier d'enseignement faible et vice-versa. Cependant une absence complète à ce niveau peut être rédhibitoire. Dans beaucoup d'endroits c'est aussi important qu'un bon dossier de recherche.
Expliquez les incohérences
Un dossier peut comporter des éléments hors de la norme habituelle, plutôt que d'essayer de cacher ce que le rapporteur saura découvrir, expliquez ces faits et montrez-en les aspects positifs ; en voici deux exemples.
Les trous
Par exemple, si vous êtes une mère de famille et qu'il s'agit de la naissance d'un de vos enfants, il faut le dire, s'il s'agit d'un problème plus personnel difficile à présenter, le directeur de recherche pourra l'évoquer discrètement dans sa lettre de présentation.
Les réorientations thématiques ou géographiques
Comme il s'agit a priori d'éléments positifs, il faut absolument les expliquer.
* Taille du dossier (pour un Maître de conférences)
Activités de recherche 2-6 pages
Activités d'enseignement 1-4 pages
Projet de recherche et d'enseignement 1-3 pages
Activités d'animation 10 lignes
Échéances
Temps de préparation > 15 heures
Délai avant bouclage - 15 jours
Version provisoire - 40 jours
Demande des recommandations - 60 jours
Article
Entre début écriture et envoi 3-6 mois
Entre envoi et acceptation 6-12 mois
Entre acceptation et publication 12-24 mois
From: http://perso.ens-lyon.fr/pierre.lescanne/TEXTS/candidater.html#VousMemes
- (2669)What is a "monoid"?
It's when you apply recursively an operator to "reduce" a complex data structure:
sum(x:list)=first(x)+sum(rest(x))
From: https://en.wikipedia.org/wiki/Monoid#Monoids_in_computer_science
- (2690)What is a ROC (Receiver operating characteristic)?
The ROC curve is created by plotting the true positive rate (TPR) against the false positive rate (FPR) at various threshold settings.
The true-positive rate is also known as sensitivity, recall or probability of detection in machine learning.
The false-positive rate is also known as the fall-out or probability of false alarm and can be calculated as (1 − specificity).
See Tip#976 and Tip#2194
From: https://en.wikipedia.org/wiki/Receiver_operating_characteristic
- (2700)What's the difference between the conversion/coercion/casting forms of type conversions?
- *conversion* refers to either implicitly or explicitly changing a value from one data type to another, e.g. a 16-bit integer to a 32-bit integer.
- *coercion* is used to denote an implicit conversion.
- *cast* typically refers to an explicit type conversion (as opposed to an implicit conversion), regardless of whether this is a re-interpretation of a bit-pattern or a real conversion.
From: https://stackoverflow.com/questions/8857763/what-is-the-difference-between-casting-and-coercing/8857796#8857796
https://en.wikipedia.org/wiki/Type_conversion
- (2737)What is a MultiAgent System (MAS)?
It is a paradigm (way to see/conceive the world) that is inspired from nature.
It can be used to model (e.g. ants hill, companies, human body...) or programming (network packet transmission...)
It is similar with OOP, but Agents are more than (passive) Objects. They are:
- Situated (in an Environment)
- Autonomous (work without the help of external entity, be it Human/Agent)
- Active & Pro-active (take decisions and act on their own behalf)
- Social (work in collaboration/competition with other Agents)
Also, MAS (MultiAgent Systems) can be "Holonic" (https://fr.wiktionary.org/wiki/Discussion:holonique), i.e. an Agent is a MAS is a MAS in itself.
Example: Humans are Agents in a Company, but also are themselves a MAS (where Agents are their Organs - which, in turn, can be viewed as a MAS of Cells, which can be viewed as a MAS of Atoms...)
There are several models:
- AGR Model:
[Ferber, 1995] J. Ferber, "Les systèmes multi-agents : vers une intelligence collective", InterEditions, Paris, 1995
- Who are the Agents?
- What are the Groups they are organized in?
- What Roles each Agent plays in each Group?
- Voyelles
[Demazeau, 1995] Y. Demazeau, "From interactions to collective behaviour in multi-agents systems", First European Conference on Cognitive Science, Saint-Malo, France, 1995.
- A: Who are the Agents?
- E: What is the Environment?
- I: What are the interactions between the Agents?
- O: What is the Organization of the Agents?
- (U: What is the place of the User (Human-in-the-Loop: User = 1 Agent of the System or External Entity, or...) <- Added later
- MOISE+
[Hubner, 2002] Jomi Fred Hübner, Jaime Simao Sichman, Jean-Marc Andreoli, Olivier Boissier. "MOISE+: towards a structural, functional, and deontic model for MAS organization",
First international joint conference on Autonomous agents and multiagent systems : AAMAS '02, Jul 2002, Bologne, Italy. pp. 501-502.
- (2738)What are the paradoxes of the (Standard) Deontic Logic?
[Meyer ] J.-J. Ch. Meyer, F.P.M. Dignum, and R.J. Wieringa. "The paradoxes of deontic logic revisited: a computer science perspective." Technical Report UU-CS-1994-38, Utrecht University, Utrecht, The Netherlands, 94
proposes the 12 following paradoxes (p.7):
1. Empty Normative System
O(p) with p a tautology, e.g. O(p or not(p))
2. Ross's Paradox
O(p) -> O(p or q)
3. No Free Choice Paradox
(P(p) or P(q)) <-> P(p or q)
4. Penitent's Paradox
F(q) -> F(p or q)
5. Good Samaritan Paradox
p -> q |- O(p) -> O(q)
6. Chisholm's Paradox
(Op and O(p->q) and (not(p)->O(not(q))) and not(p) ) -> _|_
7. Forrester's Paradox of Gentle Murder
(F(p) and (p -> O(q)) and (q->p) and p) |- _|_
8. Conflicting Obligations
not(O(p) and O(not(p)))
O(p) -> P(p)
9. Derived Obligation
O(p) -> O(q -> p)
F(q) -> O(q -> p)
not(p) -> (p -> O(q))
10. Deontic Detachment
(O(p) and O(p->q)) -> O(q)
11. Kant's Ought implies can
O(p) -> diam(p)
12. Epistemic Obligation
OK(p) -> O(p)
From: https://www.researchgate.net/publication/50237191_The_Paradoxes_of_Deontic_Logic_Revisited_A_Computer_Science_Perspective
- (2741)How to write a PhD?
https://web.archive.org/web/20100401051449/http://www.uq.edu.au/student-services/phdwriting/
- (2773)How to interpret error measures?
PROBLEM: at the end of running a algorithm, we get something like:
Correlation coefficient 0.3305
Mean absolute error 11.6268
Root mean squared error 46.8547
Relative absolute error 89.2645 %
Root relative squared error 94.3886 %
Total Number of Instances 36441
SOLUTION:
Let:
+ *y* denote the *true value* of interest
+ *ŷ* denote the value *estimated using ML algorithm*
+ *Correlation* tells you how much y and ŷ are related. It gives values between -1 and 1, where 0 is no relation, 1 is very strong, linear relation and -1 is an inverse linear relation (i.e. bigger values of y indicate smaller values of ŷ, or vice versa). You can find an illustrated example of correlation at:
https://i.stack.imgur.com/28woj.gif (from http://www.mathsisfun.com/data/correlation.html)
+ *Mean absolute error*
MAE=1/N*∑{i=1,N}|ŷi-yi|
+ *Root mean square error*
RMSE=sqrt(1/N*∑{i=1,N}(ŷi-yi)^2)
+ *Relative absolute error*
RAE=∑{i=1,N}|ŷi-yi|/∑{i=1,N}|ȳ-yi|
where ȳ is the mean value of y
+ *Root relative squared error*
RRSE=sqrt(∑{i=1,N}(ŷi−yi)^2/∑{i=1,N}(ȳ−yi)^2)
As you see, all the statistics compare true values to their estimates, but do it in a slightly different way. They all tell you "how far away" are your estimated values from the true value of y. Sometimes square roots are used and sometimes absolute values - this is because when *using square roots* the *extreme values have more influence on the result* (see https://stats.stackexchange.com/questions/118/why-square-the-difference-instead-of-taking-the-absolute-value-in-standard-devia).
+ In MAE and RMSE you simply look at the "average difference" between those two values - so you interpret them comparing to the *scale of your valiable* (i.e. MSE of 1 point is a difference of 1 point of y between ŷ and y).
+ In RAE and RRSE you divide those differences by the *variation* of y, so they have a *scale from 0 to 1* and if you multiply this value by 100 you get similarity in 0-100 scale (i.e. *percentage*). The values of ∑(ȳ-yi)² or ∑|ȳ-yi| tell you how much y differs from it's *mean value* - so you could tell that it is about *how much y differs from itself* (compare to variance). Because of that the measures are named *"relative"* - *they give you result related to the scale of y*.
See also https://www.cs.waikato.ac.nz/~abifet/523/Regression-Slides.pdf
From: https://stats.stackexchange.com/questions/131267/how-to-interpret-error-measures/131273#131273
- (2801)What is "one-hot" encoding?
It's the simplest encoding possible:
- order & count the possible values
- encode the value by creating a bit-field (of size #count) where all values are 0, but the position of value in the order
This also correspond to associating each value to a value equals to 2^(position in the ranking, where ranking starts at 1).
Example:
Values/Binary Gray code One-hot
1rst value-> 000 000 00000001
^ 1rst position set to 1, others to 0
001 001 00000010
3rd value-> 010 011 00000100
^ 3rd position set to 1, others to 0
011 010 00001000
100 110 00010000
101 111 00100000
110 101 01000000
8th value-> 111 100 10000000
^ 8th position set to 1, others to 0
Thanks Benjamin Charlier & Ghislain Durif for their presentation about KeOps @ SciDoLySE
From: https://en.wikipedia.org/wiki/One-hot
https://www.quora.com/What-is-one-hot-encoding-and-when-is-it-used-in-data-science
- (2833)What is an inverse problem?
An inverse problem in science is the process of calculating from a set of observations the causal factors that produced them.
E.g. source reconstruction in acoustics.
It is called an inverse problem because it starts with the effects and then calculates the causes. It is the inverse of a forward problem, which starts with the causes and then calculates the effects.
From: https://en.wikipedia.org/wiki/Inverse_problem
- (2834)What is the difference between probability and statistics?
Probability is the mathematical language of randomness which enables
you to reason about or *make predictive statements* about outcomes of
physical systems or processes that have randomness or uncertainty.
Statistics works the other way: it *describes and summarizes
characteristics of observed outcomes*, or data, extracts patterns from
it, and makes statements about underlying mechanisms or intrinsic
structures of the physical systems or processes.
From: https://www.quora.com/What-is-the-difference-between-probability-and-statistics
- (2841)What's the difference Web 1.0, Web 2.0, Web 3.0
- Web 1.0 = one way interaction : serveur shares info with user
- Web 2.0 = two way interaction : user also shares info (social media, comments)
- Web 3.0 = thre way interaction : computer adds "smartness" to server & user insteraction
Web 3.0 is related to Semantic Web, as the latter is a prerequisite for the computer to understand the servers' content
From: https://www.youtube.com/watch?v=oZQd1c3YVuI
- (2846)What are bias and variance and how are they related to over/underfitting?
Bias = diff y'/y on same dataset
Variance = diff between 2 datasets: train & test
High Bias <=> under-fitting
High Variance <=> over-fitting
Also see Tip#2510
From: https://towardsdatascience.com/breaking-the-curse-of-small-datasets-in-machine-learning-part-1-36f28b0c044d
https://miro.medium.com/max/935/1*dUR71DbSGdBBa3jKzCvfUA.png
- (2874)Is genetic algorithm considered a supervised or non supervised algorithm?
Depends on how you evaluate fitness.
- If you evaluate fitness by comparing to known answers, that's supervised.
- If you evaluate fitness by testing the individuals' abilities to perform some task, it's reinforcement.
From: https://www.quora.com/Is-genetic-algorithm-considered-a-supervised-or-non-supervised-algorithm
- (2875)Are Association Rules considered supervised or unsupervised learning?
In text books (e.g. Weka), they are considered a separate kind.
It depends how you look at the problem:
- If you consider supervised = when the input/training set is a tagged set, Association Rules are unsupervised, as there are no labels in the input/training set.
- If you consider that the Association Rules' goal is to find associations, and that the input/training set is indeed a list of (sometimes multiple) associations, then you might consider the input/training set is indirectly tagged, thus that Association Rules are supervised.
My own interpretation, also see: provided
- (2889)What are the advantages and disadvantages of Word2vec and GloVe?
== Word2vec
+ Advantages:
- The idea is very intuitive, which transforms the unlabelled raw corpus into labelled data (by mapping the target word to its context word), and learns the representation of words in a classification task.
- The data can be fed into the model in an online way and needs little preprocessing, thus requires little memory.
- The mapping between the target word to its context word implicitly embeds the sub-linear relationship into the vector space of words, so that relationships like “king:man as queen:woman” can be inferred by word vectors.
- It is simple for a freshman to understand the principle and do implementation.
+ Disadvantages:
- The sub-linear relationships are not explicitly defined. There is little theoretical support behind such characteristic.
- The model could be very difficult to train if use the softmax function, since the number of categories is too large (the size of vocabulary). Though approximation algorithms like negative sampling (NEG) and hierarchical softmax (HS) are proposed to address the issue, other problems happen. For example, the word vectors by NEG are not distributed uniformaly, they are located within a cone in the vector space hence the vector space is not sufficiently utilized.
== Glove
+ Advantages:
- The goal of Glove is very straightforward, i.e., to enforce the word vectors to capture sub-linear relationships in the vector space. Thus, it proves to perform better than Word2vec in the word analogy tasks.
- Glove adds some more practical meaning into word vectors by considering the relationships between word pair and word pair rather than word and word.
- Glove gives lower weight for highly frequent word pairs so as to prevent the meaningless stop words like “the”, “an” will not dominate the training progress.
+ Disadvantages:
- The model is trained on the co-occurrence matrix of words, which takes a lot of memory for storage. Especially, if you change the hyper-parameters related to the co-occurrence matrix, you have to reconstruct the matrix again, which is very time-consuming.
Both Word2vec and Glove do not solve the problems like:
- How to learn the representation for out-of-vocabulary words.
- How to separate some opposite word pairs. For example, “good” and “bad” are usually located very close to each other in the vector space, which may limit the performance of word vectors in NLP tasks like sentiment analysis.
From: https://www.quora.com/What-are-the-advantages-and-disadvantages-of-Word2vec-and-GloVe
- (2898)What are P/NP/NP-Complete/NP-Hard?
Decision problem: A problem with a yes or no answer.
Now, let us define those complexity classes.
== P
P is a complexity class that represents the set of all decision problems that can be *solved* in polynomial time.
That is, given an instance of the problem, the answer yes or no can be decided in polynomial time.
Example
Given a connected graph G, can its vertices be coloured using two colours so that no edge is monochromatic?
Algorithm: start with an arbitrary vertex, color it red and all of its neighbours blue and continue. Stop when you run out of vertices or you are forced to make an edge have both of its endpoints be the same color.
== NP
NP is a complexity class that represents the set of all decision problems for which the instances where the answer is "yes" have proofs that can be *verified* in polynomial time.
This means that if someone gives us an instance of the problem and a certificate (sometimes called a witness) to the answer being yes, we can check that it is correct in polynomial time.
Example
Integer factorisation is in NP. This is the problem that given integers n and m, is there an integer f with 1 < f < m, such that f divides n (f is a small factor of n)?
This is a decision problem because the answers are yes or no. If someone hands us an instance of the problem (so they hand us integers n and m) and an integer f with 1 < f < m, and claim that f is a factor of n (the certificate), we can check the answer in polynomial time by performing the division n / f.
== NP-Complete
NP-Complete is a complexity class which represents the set of all problems X in NP for which it is possible to reduce any other NP problem Y to X in polynomial time.
Intuitively this means that we can solve Y quickly if we know how to solve X quickly. Precisely, Y is reducible to X, if there is a polynomial time algorithm f to transform instances y of Y to instances x = f(y) of X in polynomial time, with the property that the answer to y is yes, if and only if the answer to f(y) is yes.
Example
3-SAT. This is the problem wherein we are given a conjunction (ANDs) of 3-clause disjunctions (ORs), statements of the form
(x_v11 OR x_v21 OR x_v31) AND
(x_v12 OR x_v22 OR x_v32) AND
... AND
(x_v1n OR x_v2n OR x_v3n)
where each x_vij is a boolean variable or the negation of a variable from a finite predefined list (x_1, x_2, ... x_n).
It can be shown that every NP problem can be reduced to 3-SAT. The proof of this is technical and requires use of the technical definition of NP (based on non-deterministic Turing machines). This is known as Cook's theorem.
What makes NP-complete problems important is that if a deterministic polynomial time algorithm can be found to solve one of them, every NP problem is solvable in polynomial time (one problem to rule them all).
== NP-hard
Intuitively, these are the problems that are at least as hard as the NP-complete problems. Note that NP-hard problems do not have to be in NP, and they do not have to be decision problems.
The precise definition here is that a problem X is NP-hard, if there is an NP-complete problem Y, such that Y is reducible to X in polynomial time.
But since any NP-complete problem can be reduced to any other NP-complete problem in polynomial time, all NP-complete problems can be reduced to any NP-hard problem in polynomial time. Then, if there is a solution to one NP-hard problem in polynomial time, there is a solution to all NP problems in polynomial time.
Example
The halting problem is an NP-hard problem. This is the problem that given a program P and input I, will it halt? This is a decision problem but it is not in NP. It is clear that any NP-complete problem can be reduced to this one. As another example, any NP-complete problem is NP-hard.
My favorite NP-complete problem is the Minesweeper problem (http://web.mat.bham.ac.uk/R.W.Kaye/minesw/ordmsw.htm).
== P = NP?
This one is the most famous problem in computer science, and one of the most important outstanding questions in the mathematical sciences. In fact, the Clay Institute is offering one million dollars for a solution to the problem (Stephen Cook's writeup on the Clay website is quite good: http://www.claymath.org/sites/default/files/pvsnp.pdf).
It's clear that P is a subset of NP. The open question is whether or not NP problems have deterministic polynomial time solutions. It is largely believed that they do not. Here is an outstanding recent article on the latest (and the importance) of the P = NP problem: The Status of the P versus NP problem (http://cacm.acm.org/magazines/2009/9/38904-the-status-of-the-p-versus-np-problem/fulltext).
The best book on the subject is Computers and Intractability by Garey and Johnson.
From: https://stackoverflow.com/questions/1857244/what-are-the-differences-between-np-np-complete-and-np-hard#1857342
- (2902)How to solve "ValueError: No data provided for “input_1”. Need data for each key" in Keras/R?
This error generally occurs in 3 cases (In R):
- The input data does not have the same dimension as was declared in the first layer
- The input data includes missing values
- The input data is not a matrix (for example, a data frame)
Hint: Use summary(model) or print(model) to see the sizes of the layers
From: https://stackoverflow.com/questions/42379138/keras-valueerror-no-data-provided-for-input-1-need-data-for-each-key/50666476#50666476
- (2956)What is the difference between URI/URN/URL?
URI -- Uniform Resource Identifier
URIs are a standard for identifying documents using a short string of numbers, letters, and symbols. T
URL -- Uniform Resource Locator
Contains information about how to fetch a resource from its location. URLs always start with a protocol (http) and usually contain information such as the network hostname.
Example: http://example.com/mypage.html
URN -- Uniform Resource Name
Identifies a resource by a unique and persistent name, but doesn't necessarily tell you how to locate it on the internet.
Example: urn:isbn:0451450523 to identify a book by its ISBN number.
From: https://www.youtube.com/watch?v=vpYct2npKD8
https://stackoverflow.com/questions/176264/what-is-the-difference-between-a-uri-a-url-and-a-urn/28865728#28865728
- (3030)What are LSTM & GRU?
Those are two evolution of Recurrent Neural Networks, that are easier to train (they address the "vanishing gradient" problem that occurs in Deep Networks. And since recurrent networks are "unrolled" during training, they are indeed deep!).
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
* Sources
** (LSTM+GRU 4 n00bs) https://www.youtube.com/watch?v=8HyCNIVRbSU
** (LSTM 4 n00bs) https://www.youtube.com/watch?v=QciIcRxJvsM
** (LSTM Maths) https://www.youtube.com/watch?v=9zhrxE5PQgY
** Blog
*** http://www.wildml.com/2015/09/recurrent-neural-networks-tutorial-part-1-introduction-to-rnns/
*** http://www.wildml.com/2015/09/recurrent-neural-networks-tutorial-part-2-implementing-a-language-model-rnn-with-python-numpy-and-theano/
*** http://www.wildml.com/2015/10/recurrent-neural-networks-tutorial-part-3-backpropagation-through-time-and-vanishing-gradients/
*** http://www.wildml.com/2015/10/recurrent-neural-network-tutorial-part-4-implementing-a-grulstm-rnn-with-python-and-theano/
* LSTM : computes 2 values : new output & new hidden state
** Ct-1 = input value
** Ht-1 = input hidden state ("memory"/previous computed value)
** Ct = new computed value
** Ht = new computed hidden state (memory)
** Tanh in [-1,+1] => normalizes its input value
** Sigm in [0,+1] + multiplication => decides % of its input value to keep
*** This is what is called a "Gate"
** FGT = "FORGET Gate" [selects which amount of the memory is kept]
** IN = "INPUT Gate" [computes the "normal NN output" from inputs]
** OUT = "OUTPUT Gate" [select which amount of the computed output (memory+"normal NN output") is kept in memory (Hidden State)]
#+BEGIN_SRC ditaa :file ./lstm.png
|-- FGT --||---- IN ----| |---- OUT ----|
[-2,+2]
Ct-1 ->+------[X]----------[+]---------------+--------------> Ct
| ^ ^ |
| | | |
| | +--->[X] |
| Sigm | ^ (Ĉt) |
| ^ | | [-1,+1] v
| | Sigm TanH Tanh
| | ^ ^ | [-1,+1]
v | | | v
+------>+----->+-----+------>Sigm--->[X]
^ |
| v
Ht-1 ->+-------------------------------------+--------------> Ht
#+END_SRC
#+RESULTS:
[[file:./lstm.png]]
* GRU
** Ct-1 = input value
** Ct = new computed value
** Ht = new computed hidden state (memory)
** Tanh in [-1,+1] => normalizes its input value
** Sigm in [0,+1] + multiplication => decides % of its input value to keep
*** This is what is called a "Gate"
** RST = "RESET Gate" [selects which amount of the past input info is kept]
** UPD = "UPDATE Gate" [balances between the computed "normal NN output" & memory]
#+BEGIN_SRC ditaa :file ./gru.png
|--- UPD ---|
Ct-1 ->+--------+--------[x]--------[+]---------> Ct
| | ^ ^
| | [1-] |
| | | |
| | +-------->[X]
v | | |
+--------------->Sigm |
| | | --
+--Sigm | | |
^ | v | | RST
| +->[X]---------------->TanH |
| --
|
Ht-1 ->+--------------------------/
#+END_SRC
#+RESULTS:
[[file:./gru.png]]
- (3045)DataScience Feeds to Follow
#+STARTUP: showall indent
#+TODO: TODO(t) DEAD(d) | DONE(o) + C-c C-c
* Proposed Tags
** Source
- Academic :: From an academic Group
- Company :: Might sell its stuff
- Collective :: Syndicates various sources
- Personnal :: Personnal feed of a "datascientist"
** Content -- Coarse Grained
- Basics :: Provides basic knowledge
- Research :: Provides advanced/up-to-date information
- Business :: Provides information about the DS market
** Content -- Fine Grained / Topics
- Tips :: Provides useful Tips & Tricks
- Books :: Advises (free) Books
- MOOC :: proposes Courses
- Tuto :: proposes Tutorials
- Ask :: Questions asked to the community
- Job :: Talks about the DS Job Market
- Maths :: Talks about Maths
- Stats :: Talks about statistics/probabilities
- Deep :: Deep Learning
- Bayes :: Bayesian approach
- RL :: Reinforcement LEarning
- AI :: Artificial Intelligence in General
- Image :: Image/Vidéo Processing
- MAS :: Multi-Agent Systems
** Format
- Interviews :: Consists mainly in interviews
- Long :: provides long articles
- Short :: provides short articles
** Frequency
- Fast :: frequent updates
- Slow :: slow updates
- Dead :: does not get updated anymore
** Programming Languages/Libraries
- R :: Talks about R language
- Python :: Talks about Python language
* Blogs & Social Media
** Google :Company:Research:Long:
http://ai.googleblog.com/
http://feeds.feedburner.com/blogspot/gJZg
** Facebook :Company:Research:Long:
https://research.fb.com/feed
** Oracle :Research:Company:Long:
https://blogs.oracle.com/datascience/rss
** AnalytiXon :Research:
https://analytixon.com/feed/
** Distill.pub :Research:Long:InteractivePublishing:
https://distill.pub/rss.xml
** KDNuggets :Top:Basics:General:Books:Tips:Tuto:Short:
https://www.kdnuggets.com/feed
** R Bloggers :Top:R:Books:Tips:Tuto:Short:
https://www.r-bloggers.com
http://feeds.feedburner.com/RBloggers
** R DataMining :Top:R:Tuto:
https://rdatamining.wordpress.com/feed/
** Data Camp :Company:MOOC:
https://www.datacamp.com/community/rss.xml
** Analytics Vidhya :Company:MOOC:
https://www.analyticsvidhya.com/feed
** Sub-Reddit :Ask:
https://www.reddit.com/r/datamining/.rss
https://www.reddit.com/r/datascience/.rss
https://www.reddit.com/r/textdatamining/.rss
** Command line tips :Tips:R:Python:Short:Tutos:
http://cmdlinetips.com/feed/
** YHat :Dead:
http://blog.yhat.com/rss.xml
** Data Aspirant :Basics:Job:
https://dataaspirant.com/feed/
** Becoming a DataScientist :Basics:Job:
http://www.becomingadatascientist.com/feed/
** Data Elixir :Basics:
https://dataelixir.com/issues.rss
** Revolution Analytics
https://blog.revolutionanalytics.com/atom.xml
** Analytics Insight
http://feeds.feedburner.com/analyticsinsight/ijEZ
** Data Floq
https://datafloq.com/read/feed.rss
** 101 DataSCience :Basics:Tuto?:
https://101.datascience.community/feed/
** DataHut
https://blog.datahut.co/feed/
** Data Politan
https://blog.datapolitan.com/feed/
** DataScience Dojo
https://blog.datasciencedojo.com/rss/
** Domino DataLab
https://blog.dominodatalab.com/feed/
** Floyd Hub :Personal?:
https://blog.floydhub.com/rss
** Insight DataScience
https://blog.insightdatascience.com/feed
** The Data Incubator
https://blog.thedataincubator.com/feed/
** Medium :Collective:Long:
https://medium.com/feed/analytics-and-data
https://medium.com/feed/kaggle-blog
https://medium.com/feed/topic/data-science
** Data Science Central :Collective:Long:
http://feeds.feedburner.com/FeaturedBlogPosts-DataScienceCentral
** UCSD :Academic:
http://compbio.ucsd.edu/outreach/data-science-blog/feed/
** Berkley :Academic:
https://datascience.berkeley.edu/blog/recent.atom/?format=xml
** NIH :Academic:
https://datascience.nih.gov/blog/rss
** SMU :Academic:
https://datascience.smu.edu/blog/recent.atom/?format=xml
** UTSA :Academic:
http://snrp.utsa.edu/Podcast/rss.xml
** Belgium :Academic:
https://datasciencebe.com/feed/
** Evan Miller :Personnal:
https://www.evanmiller.org/news.xml
** John D Cook :Personnal:R:Tips:Basics:
https://www.johndcook.com/blog/applied-statistics/
** 365 Data Science :Business?:
https://365datascience.com/feed
** TODO
http://www.dataplusscience.com/RSSfeed.xml
http://www.datascienceassn.org/blog/feed
http://www.dssgfellowship.org/feed/
http://www.foxydatascience.com/1/feed
http://www.randalolson.com/feed/
https://advanceddataanalytics.net/feed/
https://data-science-blog.com/en/feed/
https://datamites.com/blog/feed
https://datasciencereview.com/feed
https://datasciensediary.tumblr.com/rss
https://dimensionless.in/feed
https://districtdatalabs.silvrback.com/feed
https://hevodata.com/blog/feed/
https://mlwhiz.com/atom.xml?format=xml
https://ujjwalkarn.me/feed/
https://www.codementor.io/community/topic/data-science/feed
https://www.dataquest.io/blog/feed/
https://www.datarobot.com/blog/feed
https://www.dataversity.net/category/data-topics/data-science-data-topics/feed/
https://www.deep-data-mining.com/feeds/posts/default?alt=rss :Deep:
https://www.littlemissdata.com/blog?format=RSS
https://www.smartdatacollective.com/feed/
https://www.win-vector.com/blog/feed/
https://yodalearning.com/feed
** OptaPlanner :Planning:Company:
https://www.optaplanner.org/blog/news.atom
* Twitter :Short:
** @DataSciFact :Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40DataSciFact
** @AnalysisFact :Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40AnalysisFact
** @BasicStatistics :Stats:Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40BasicStatistics
** @ProbFact :Stats:Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40ProbFact
** @AlgebraFact :Maths:Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40AlgebraFact
** @TopologyFact :Maths:Basics:Tips:Short:
https://queryfeed.net/twitter?q=%40TopologyFact
* PodCasts
** Learning Machines 101 :Top:Basics:
http://learningmachines101.libsyn.com/rss
** Talking Machines :Top:Basics:
https://rss.art19.com/talking-machines
** Data Skeptic
https://dataskeptic.com
https://dataskeptic.libsyn.com/rss
** Data Stories :Interviews:
https://datastori.es/feed/podcast/
** Data Science Imposters :Interviews?:
https://datascienceimposters.com/feed/podcast/
** Voices in AI :AI:Interviews:
https://voicesinai.com/show/voices-in-ai/podcast-feed/
** Linear Digressions :Stats?:
http://lineardigressions.com/
** Partially Derivative :Stats:
http://partiallyderivative.com
http://feeds.feedburner.com/PartiallyDerivative
** Simply Statistics :Stats:
http://www.biostat.jhsph.edu/~rpeng/podcast/simplystatistics_audio.xml
** OCDQ :Dead:Stats:
http://www.ocdqblog.com/home/?category=OCDQ+Radio&format=rss
** Data Informed :Dead?:
http://data-informed.com/multimedia/podcasts/feed/
** Vault Analytics
https://vaultanalytics.com/feed/podcast/
** SuperDS
http://feeds.soundcloud.com/users/soundcloud:users:253585900/sounds.rss
** Startup Data Science
http://feeds.soundcloud.com/users/soundcloud:users:314178205/sounds.rss
** FutureOfData
http://feeds.soundcloud.com/users/soundcloud:users:242891380/sounds.rss
** This Week in ML (TWiML)
http://feeds.soundcloud.com/users/soundcloud:users:228427508/sounds.rss
** O'Reilly Data Show :Company:Books:
http://feeds.podtrac.com/IOJSwQcdEBcg
** Pivotal Software :Company:
http://pivotalsoftwarepodcast.libsyn.com/rss
* YouTube Channels
** NOTE: to get the feed URL from the channel URL: replace https://www.youtube.com/channel/XXX with https://www.youtube.com/feeds/videos.xml?channel_id=XXX
** 3 Blue 1 Brown :Basics:
https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw/videos
** Science4All :Bayes:
https://www.youtube.com/channel/UC0NCbj8CxzeCGIF6sODJ-7A/videos
** 2 Minutes Paper :Top:Deep:RL:AI:Image:MAS:
https://www.youtube.com/channel/UCbfYPyITQ-7l4upoX8nvctg/videos
** Arxiv Insights :Top:Research:
https://www.youtube.com/channel/UCNIkB2IeJ-6AmZv7bQ1oBYg/videos
** Siraj Rawal :Top:Image:IA:
https://www.youtube.com/channel/UCWN3xxRkmTPmbKwht9FuE5A/videos
** Code Emporium
https://www.youtube.com/channel/UC5_6ZD6s8klmMu9TXEB_1IA/videos
** Weights & Biases :Top?:
https://www.youtube.com/channel/UCBp3w4DCEC64FZr4k9ROxig/videos
** Orange Data Mining :OrangeLib?:
https://www.youtube.com/channel/UClKKWBe2SCAEyv7ZNGhIe4g/videos
** Computerphile :Computers:
https://www.youtube.com/user/Computerphile/videos
- (3068)Rules of ML (a.k.a. Tips&Tricks for production ML)
== Before Machine Learning
Rule #1: Don’t be afraid to launch a product without machine learning.
Rule #2: Make metrics design and implementation a priority.
Rule #3: Choose machine learning over a complex heuristic.
== ML Phase I: Your First Pipeline
Rule #4: Keep the first model simple and get the infrastructure right.
Rule #5: Test the infrastructure independently from the machine learning.
Rule #6: Be careful about dropped data when copying pipelines.
Rule #7: Turn heuristics into features, or handle them externally.
== Monitoring
Rule #8: Know the freshness requirements of your system.
Rule #9: Detect problems before exporting models.
Rule #10: Watch for silent failures.
Rule #11: Give feature sets owners and documentation.
== Your First Objective
Rule #12: Don’t overthink which objective you choose to directly optimize.
Rule #13: Choose a simple, observable and attributable metric for your first objective.
Rule #14: Starting with an interpretable model makes debugging easier.
Rule #15: Separate Spam Filtering and Quality Ranking in a Policy Layer.
== ML Phase II: Feature Engineering
Rule #16: Plan to launch and iterate.
Rule #17: Start with directly observed and reported features as opposed to learned features.
Rule #18: Explore with features of content that generalize across contexts.
Rule #19: Use very specific features when you can.
Rule #20: Combine and modify existing features to create new features in human understandable ways.
Rule #21: The number of feature weights you can learn in a linear model is roughly proportional to the amount of data you have.
Rule #22: Clean up features you are no longer using.
== Human Analysis of the System
Rule #23: You are not a typical end user.
Rule #24: Measure the delta between models.
Rule #25: When choosing models, utilitarian performance trumps predictive power.
Rule #26: Look for patterns in the measured errors, and create new features.
Rule #27: Try to quantify observed undesirable behavior.
Rule #28: Be aware that identical short term behavior does not imply identical long term behavior.
== Training Serving Skew
Rule #29: The best way to make sure that you train like you serve is to save the set of features used at serving time, and then pipe those features to a log to use them at training time.
Rule #30: Importance weight sampled data, don’t arbitrarily drop it!
Rule #31: Beware that if you join data from a table at training and serving time, the data in the table may change.
Rule #32: Reuse code between your training pipeline and your serving pipeline whenever possible.
Rule #33: If you produce a model based on the data until January 5th, test the model on the data from January 6th and after.
Rule #34: In binary classification for filtering (such as spam detection or determining interesting emails), make small short term sacrifices in performance for very clean data.
Rule #35: Beware of the inherent skew in ranking problems.
Rule #36: Avoid feedback loops with positional features.
Rule #37: Measure Training/Serving Skew.
== ML Phase III: Slowed Growth, Optimization Refinement, and Complex Models
Rule #38: Don’t waste time on new features if unaligned objectives have become the issue.
Rule #39: Launch decisions will depend upon more than one metric.
Rule #40: Keep ensembles simple.
Rule #41: When performance plateaus, look for qualitatively new sources of information to add rather than refining existing signals.
Rule #42: Don’t expect diversity, personalization, or relevance to be as correlated with popularity as you think they are.
Rule #43: Your friends tend to be the same across different products. Your interests tend not to be.
From: http://martin.zinkevich.org/rules_of_ml/rules_of_ml.pdf
- (3078)Things to think of when building a course (particularly online/COVID-19)?
1. Keep it simple and low tech.
2. Accessibility is core, not optional.
3. Provide structure using the eLearning Platform.
4. Use what is available.
5. Keep learning active.
6. Chunk content.
7. Have a clear course outline.
8. Be visible online and quickly contactable.
9. Help keep your students on track.
10. Be kind to yourself and empathic to your students.
- Keep it low tech
- Communicate frequently and consistently
- Be inclusive
- Prefer asynchronous learning (NOTE: apart if you want to maintain students' engagement)
- Less is more (during remote session, students work slower, take it into account!)
- Well organised resources
- Give explicit instructions
- Run online "office hours" and be visible online
- Seek student feedback
- Use a limited selection of new tools
- Break down content into short Identifiable topics
- Keep outline and schedules for course in one place
From: https://docs.google.com/document/d/1zPN7XUitOCw75FW6UeqrYAcWl41UqgKoZ_HRoYTKFZI/
https://framablog.org/2020/08/27/quelques-conseils-pour-tele-enseigner/ [French Translation]
- (3079)List of hard-to-find/solve but fun bugs (for Software Engineering classes)
- Tesla that does not start after buying vanilla ice cream
- Train station computer that crashes when train is loaded with cows
- ...
From: http://beza1e1.tuxen.de/lore/index.html
- (3156)Comics explaining ML / Neural Networks / Federated Learning
https://cloud.google.com/products/ai/ml-comic-1
https://cloud.google.com/products/ai/ml-comic-2
https://federated.withgoogle.com/
- (3157)The problem of Model Inversion / ReIdentification with (k-)"anonymized" data
- Re-Identification: by crossing data with another dataset we can recover who is who
e.g. crossing cell phone contracts (provide names) with Uber car positions (with enough regular data, provides Home & Work places - most of departures/ending of travels)
- Attribute Disclosure : if attacker has access to a few attributes about an individual she can exploit to model's learned associations to extract/predict another attribute that might suffice to ReIdentify the individual.
- Model Inversion : by querying the model multiple times, we can cross informations and extract an individual unique data
Frightening figures, 87% of North Americans can be UNIQUELY identified with 3 attributes: Zip code + Gender + Birthday
From: https://www.youtube.com/watch?v=gI0wk1CXlsQ&feature=youtu.be&t=177
- (3165)What is the loss function to use with SoftMax output activation function?
With a softmax output, you want to use cross-entropy as the loss
From: https://classroom.udacity.com/courses/ud185/
- (3166)Why do we use logits in the loss function when softmax activation is used?
We use the logits because softmax gives you probabilities which will often be very close to zero or one but floating-point numbers can't accurately represent values near zero or one (read more: https://docs.python.org/3/tutorial/floatingpoint.html). It's usually best to avoid doing calculations with probabilities, typically we use log-probabilities.
From: https://classroom.udacity.com/courses/ud185
- (3167)Example PyTorch code snippets
#!/usr/bin/env python
################# LOADING DATA #################
import torch
from torchvision import datasets, transforms
data_dir = 'Cat_Dog_data/' # organization: 1 sub-dir for each class
# Define transforms for the training data
train_transforms = transforms.Compose([transforms.Resize(255),
transforms.CenterCrop(224),
#transforms.Grayscale(),
#transforms.FiveCrop(224),
transforms.RandomRotation(30),
transforms.ColorJitter(brightness=0.2, contrast=0.2, saturation=0.2, hue=0.2),
transforms.RandomHorizontalFlip(),
transforms.RandomVerticalFlip(),
transforms.ToTensor()])
#transforms.Normalize([0.5, 0.5, 0.5],
# [0.5, 0.5, 0.5])])
# Define transforms for the testing data BEWARE NOT TO ADD any DataAugmentation!
test_transforms = transforms.Compose([transforms.Resize(255),
transforms.CenterCrop(224),
#transforms.Grayscale(),
transforms.ToTensor()])
#transforms.Normalize([0.5, 0.5, 0.5],
# [0.5, 0.5, 0.5])])
# Load the images & apply transformations
train_data = datasets.ImageFolder(data_dir + '/train', transform=train_transforms)
test_data = datasets.ImageFolder(data_dir + '/test', transform=test_transforms)
# For included datasets
# trainset = datasets.MNIST('~/.pytorch/MNIST_data/', download=True, train=True, transform=train_transforms)
# Generate iterators over the dataset
train_loader = torch.utils.data.DataLoader(train_data, batch_size=8, shuffle=True)
test_loader = torch.utils.data.DataLoader(test_data, batch_size=8)
################# CREATING A NN #################
from torch import nn, optim
import torch.nn.functional as F
class Classifier(nn.Module):
def __init__(self):
super().__init__()
self.fc1 = nn.Linear(224*224*3, 1024)
self.fc2 = nn.Linear(1024, 256)
self.fc3 = nn.Linear(256, 64)
self.fc4 = nn.Linear(64, 10)
self.dropout = nn.Dropout(p=0.2)
def forward(self, x):
# make sure input tensor is flattened
x = x.view(x.shape[0], -1)
x = self.dropout(F.relu(self.fc1(x)))
x = self.dropout(F.relu(self.fc2(x)))
x = self.dropout(F.relu(self.fc3(x)))
x = F.log_softmax(self.fc4(x), dim=1)
return x
model = Classifier()
### Shorter writing:
## model = nn.Sequential(nn.Linear(784, 128),
## nn.ReLU(),
## nn.Linear(128, 64),
## nn.ReLU(),
## nn.Linear(64, 10),
## nn.LogSoftmax(dim=1))
criterion = nn.NLLLoss()
optimizer = optim.Adam(model.parameters(), lr=0.003)
################# TRAINING A NN ################# Note: might be better placed into the NN class!!
epochs = 10
steps = 0
train_losses, test_losses = [], []
for e in range(epochs):
running_loss = 0
for images, labels in train_loader: # For each batch
optimizer.zero_grad() # DO NOT FORGET!!! or the gradients will accumulate!
log_ps = model(images) # Applies the forward pass. Equivalent to model.forward(images)
loss = criterion(log_ps, labels) # Computes the error
loss.backward() # Computes the gradients (backward step)
optimizer.step() # Applies the gradients
running_loss += loss.item()
else: # Computes stats for this batch
test_loss = 0
accuracy = 0
# Turn off gradients for validation, saves memory and computations
with torch.no_grad(): # DO NOT FORGET!!!
model.eval() # Switches model to evaluation mode (probably save computations as well)
for images, labels in test_loader: # Evaluates on test data
log_ps = model(images) # forward pass on batch
test_loss += criterion(log_ps, labels)
ps = torch.exp(log_ps) # Do not forget: model above stops computations at log(output probas) [use of LogSoftMax]
# to ease criterion computation => to get actual proba, we need to exp(results)
top_p, top_class = ps.topk(1, dim=1) # Gets the most probable classes
equals = top_class == labels.view(*top_class.shape) # Computes errors
accuracy += torch.mean(equals.type(torch.FloatTensor))
model.train() # switches back model to training mode (compute gradients, etc.)
train_losses.append(running_loss/len(train_loader))
test_losses.append(test_loss/len(test_loader))
# Print data for current batch of current epoch
print("Epoch: {}/{}.. ".format(e+1, epochs),
"Training Loss: {:.3f}.. ".format(running_loss/len(train_loader)),
"Test Loss: {:.3f}.. ".format(test_loss/len(test_loader)),
"Test Accuracy: {:.3f}".format(accuracy/len(test_loader)))
################# DRAW SOME TRAINING RESULTS #################
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import matplotlib.pyplot as plt
plt.plot(train_losses, label='Training loss')
plt.plot(test_losses, label='Validation loss')
plt.legend(frameon=False)
################# CPUs vs. GPUs #################
# You can write device agnostic code which will automatically use CUDA if it's enabled like so:
# At beginning of the script
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# Then whenever you get a new Tensor or Module
# This won't copy if they are already on the desired device
input = data.to(device)
model = MyModule(...).to(device)
################# TIPS & TRICKS #################
A few things to check if your network isn't training appropriately:
- Make sure you're clearing the gradients in the training loop with optimizer.zero_grad().
- If you're doing a validation loop, be sure to set the network to evaluation mode with model.eval(), then back to training mode with model.train().
- Also see Tip#3171
From: https://classroom.udacity.com/courses/ud185
- (3170)How to move computations to the GPU(s) in PyTorch?
# You can write device agnostic code which will automatically use CUDA if it's enabled like so:
# At beginning of the script
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
# Then whenever you get a new Tensor or Module
# This won't copy if they are already on the desired device
input = data.to(device)
model = MyModule(...).to(device)
From: https://classroom.udacity.com/courses/ud185/
https://github.com/pytorch/pytorch/issues/1668#issuecomment-565755207
- (3171)How to solve "RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #1 ‘mat1’" in PyTorch?
CUDA errors
Sometimes you'll see this error: "RuntimeError: Expected object of type torch.FloatTensor but found type torch.cuda.FloatTensor for argument #1 ‘mat1’"
You'll notice the second type is torch.cuda.FloatTensor, this means it's a tensor that has been moved to the GPU. It's expecting a tensor with type torch.FloatTensor, no .cuda there, which means the tensor should be on the CPU. PyTorch can only perform operations on tensors that are on the same device, so either both CPU or both GPU. If you're trying to run your network on the GPU, check to make sure you've moved the model and all necessary tensors to the GPU with .to(device) where device is either "cuda" or "cpu".
From: https://classroom.udacity.com/courses/ud185
- (3172)How to convert a tensor of from one type to another (e.g. booleans to ints) in PyTorch?
SOLUTION1: directly
t = torch.tensor([True, False, True, False])
t_integer = t.long()
SOLUTION2:
t = torch.tensor([True, False, True, False])
t_integer = t.type(torch.LongTensor)
From: https://stackoverflow.com/questions/62150659/how-to-convert-a-tensor-of-booleans-to-ints-in-pytorch/62150660#62150660
https://classroom.udacity.com/courses/ud185/
- (3186)What is Stochastic Gradient Descent?
SGD replaces the actual gradient (calculated from the entire data set) by an estimate thereof (calculated from a *randomly selected subset of the data*).
This reduces the computational burden, achieving faster iterations in trade for a lower convergence rate (especially in high-dimensional optimization problems).
From: https://en.wikipedia.org/wiki/Stochastic_gradient_descent
- (3191)Where to find datasets?
https://en.wikipedia.org/wiki/List_of_datasets_for_machine-learning_research
https://www.kaggle.com/
https://archive.ics.uci.edu/ml/datasets.php
https://developer.ibm.com/exchanges/data/
https://www.kdnuggets.com/datasets/index.html
https://aws.amazon.com/public-datasets/
https://www.quandl.com/
https://opendata.socrata.com/
https://cloud.google.com/bigquery/public-data/
https://data.world/
https://www.data.gov/
https://www.data.gouv.fr/fr/
https://data.worldbank.org/
http://academictorrents.com/browse.php?cat=6
- (3198)How to find a scientific article that is not publicly available?
https://openaccessbutton.org/
https://addons.mozilla.org/en-US/firefox/addon/unpaywall/
https://libgen.rs
https://sci-hub.st/ [latest url: https://en.wikipedia.org/wiki/Sci-Hub]
- (3201)What are the alternatives during (Stochastic) Gradient Descent (a.k.a. Momentum, Adam, RMSProp)?
- Momentum is when you take into account both the gradient at (t-1) & gradient at (t).
- AdaGrad is when the learning rate is per parameter, with a larger learning rate for sparse data
- RMSProp is when the learning rate is adapted w.r.t the previous updates of the gradients (avg)
- Adam ("Adaptive Moment Estimation") is an improved RMSProp that adapts the learning rate with gradients & 2nd order moments of gradients
From: https://en.wikipedia.org/wiki/Stochastic_gradient_descent
- (3207)What are the characteristics of Big Data (a.k.a. the 5 V's of Big Data)?
- Volume: How much data is being collected/generated?
- Variety: How many features per data item (curse of dimensionality? combinatorial explosion?) ? How many data types & formats (Numbers, Images, Sounds, TimeSeries, Graphs, Free Text...)?
- Velocity: At what rate does new data come in/out of the systems? Are real-time responses expected?
- Veracity: Does the data covers all the cases? Are there necessary and sufficient data to test many different hypotheses? Are we able to create "whole-population analytics"?
- Validity: Is the data clean or full of NANs and erroneous values?
- Value: What is the business importance of these data for the company (ROI)?
- Variability: Do the data evolve over time? Are these data spatio-temporal? time series? seasonal? Do the sources/objectives changes over time?
- Venue: Are the data distributed on multiple platforms, with different formats?
- Vocabulary: Are the schema (structure), data models (syntax), semantics, ontologies, taxonomies (content) different? context-based? Is the provenance the same?
- Vagueness: What actually defines BigData? The Volume (which one)? The Tools used? The hype of a new term for something that already existed?
From: https://web.archive.org/web/20190805191201/https://mapr.com/blog/top-10-big-data-challenges-serious-look-10-big-data-vs/
https://www.kdnuggets.com/2017/04/42-vs-big-data-data-science.html
- (3208)What is pre-training of Neural Networks?
- In the PAST, it meant using autoencoders or RBMs to initialize weights layer by layer.
- CURRENTly it is used rather to refer to ~transfer-learning: using first layers (=latent space computation) of an already existing DL Model (e.g. ImageNet, Inception, GPT3, etc) and re-training the last (classification) part.
From: https://www.quora.com/What-is-pretraining-in-deep-learning-how-does-it-work?share=1
- (3209)Deep Learning Notes from LeCun, Bengio, Hinton (Nature 2015)
Notes: 3-7-13-15-19-21
3. "Deep-learning methods are representation-learning methods with multiple levels of representation, obtained by composing simple but non-linear modules that each transform the representation at one level (starting with the raw input) into a representation at a higher, slightly more abstract level. With the composition of enough such transformations, very complex functions can be learned. For classification tasks, higher layers of representation amplify aspects of the input that are important for discrimination and suppress irrelevant variations."
7. Visual classifiers have to learn to be invariant to many things like background, shading, contrast, orientation, zoom, but also have to be very sensitive to other things (for example, learning to distinguish a german shepard from a wolf)
13. For small datasets, unsupervised pretraining is helpful
14. Convnets for vision.
15. “There are four key ideas behind ConvNets that take advantage of the properties of natural signals: local connections, shared weights, pooling and the use of many layers.”
19. Regular RNNs don’t work so well, LSTM fixes major problems [GM: see GRU & attention too : https://distill.pub/2016/augmented-rnns/]
https://karpathy.github.io/2015/05/21/rnn-effectiveness/
http://colah.github.io/posts/2015-08-Understanding-LSTMs/
21. Although the focus now is mainly on supervised learning, expect that unsupervised learning will become most important in the long term
GM: cf. VAE
From: https://aresearch.wordpress.com/2015/07/06/deep-learning-lecun-bengio-hinton-nature-2015/
- (3232)Example of PyTorch DeepNN in R
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""torch.R
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1NdiN9n_a7NEvFpvjPDvxKTshrSWgxZK5
## Installation
"""
"""### `torch`"""
devtools::install_github("mlverse/torch")
# a quick check if everything's ok
library(torch)
torch_tensor(1, device = "cuda")
"""### `torchvision`"""
# needed to compile magick (needed by torchvision)
system("sudo apt-get install libmagick++-dev")
devtools::install_github("mlverse/torchvision")
"""## Data loading and pre-processing"""
library(torchvision)
dir <- "."
train_ds <- kmnist_dataset(
dir,
download = TRUE,
train = TRUE,
transform = transform_to_tensor
)
test_ds <- kmnist_dataset(
dir,
download = TRUE,
train = FALSE,
transform = transform_to_tensor
)
# the first pair (list) of input and target tensor
train_ds[1]
# shape of first input tensor
train_ds[1][[1]]$size()
train_dl <- dataloader(train_ds, batch_size = 32, shuffle = TRUE)
test_dl <- dataloader(test_ds, batch_size = 32)
train_iter <- train_dl$.iter()
train_iter$.next()
"""## Network"""
net <- nn_module(
"Net",
initialize = function() {
self$conv1 <- nn_conv2d(1, 32, 3)
self$conv2 <- nn_conv2d(32, 64, 3)
self$dropout1 <- nn_dropout2d(0.25)
self$dropout2 <- nn_dropout2d(0.5)
self$fc1 <- nn_linear(9216, 128)
self$fc2 <- nn_linear(128, 10)
},
forward = function(x) {
x %>%
self$conv1() %>%
nnf_relu() %>%
self$conv2() %>%
nnf_relu() %>%
nnf_max_pool2d(2) %>%
self$dropout1() %>%
torch_flatten(start_dim = 2) %>%
self$fc1() %>%
nnf_relu() %>%
self$dropout2() %>%
self$fc2()
}
)
model <- net()
model$to(device = "cuda")
optimizer <- optim_adam(model$parameters)
n_epochs <- 5
for (epoch in 1:n_epochs) {
l <- c()
for (b in enumerate(train_dl)) {
optimizer$zero_grad()
output <- model(b[[1]]$to(device = "cuda"))
loss <- nnf_cross_entropy(output, b[[2]]$to(device = "cuda"))
loss$backward()
optimizer$step()
l <- c(l, loss$item())
}
cat(sprintf("Loss at epoch %d: %3f\n", epoch, mean(l)))
}
"""## Evaluate"""
model$eval()
test_losses <- c()
total <- 0
correct <- 0
for (b in enumerate(test_dl)) {
output <- model(b[[1]]$to(device = "cuda"))
labels <- b[[2]]$to(device = "cuda")
loss <- nnf_cross_entropy(output, labels)
test_losses <- c(test_losses, loss$item())
predicted <- torch_max(output$data(), dim = 2)[[2]]
total <- total + labels$size(1)
correct <- correct + (predicted == labels)$sum()$item()
}
mean(test_losses)
test_accuracy <- correct/total
test_accuracy
From: https://blogs.rstudio.com/ai/posts/2020-09-29-introducing-torch-for-r/
- (3233)Summary of "Guide des Métiers de la Data" from DAP
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:1 ## number of header levels to consider (level below are list items)
#+OPTIONS: num:nil ## use itemize vs. enumerate
GUIDE DES MÉTIERS DE LA DATA - Édition 2019 - ISABELLE BELLIN - Data Analytics Post (DAP)
https://dataanalyticspost.com/wp-content/uploads/2019/03/Guide_metiers_data_DAP.pdf
* CHIEF DATA OFFICER = LE PILOTE STRATÉGIQUE
** C'est le « directeur des données » de l'entreprise. Ce cadre dirigeant participe au pilotage de la stratégie globale de l'entreprise en plaçant les données au cœur de la stratégie et de la culture de l'entreprise, pour que chaque collaborateur devienne « data fluent ».
** Au quotidien
*** Veiller au partage des données entre les équipes ;
*** Définir avec les métiers les actions sur les données, leur cohérence et mise en qualité, leur protection, la promotion de leur usage.
** Compétences
*** Connaissance du secteur d'activité de l'entreprise ;
*** Communication, pédagogie, diplomatie, leadership ;
*** Connaissance des réglementations internationales ;
*** Communication, bon relationnel, vulgarisation.
** Formation
*** Bac + 4 ou 5 en informatique, management, statistiques ou marketing ;
* EXPERT SECURITÉ = L'ANTI CYBERATTAQUES
** Ce spécialiste de la protection des données assure la politique de sécurité de l'entreprise. Il intervient principalement dans les couches informatiques et télécoms de l'entreprise. Il doit anticiper les risques augmentés ou créés par l'utilisation des big data.
** Au quotidien
*** Analyser les risques ;
*** Chercher et repérer les failles des systèmes de l'entreprise ;
*** Rédiger les politiques et les standards de sécurité ;
*** Administrer les droits d'accès au réseau et aux données.
** Compétences
*** Très bonne connaissance informatique (théorie, architecture, protocoles) ;
*** Connaissance de l'organisation et des besoins de l'entreprise ;
*** Organisation, rigueur, communication et pédagogie.
** Formation
*** Ingénieur ou master en informatique, en télécommunications & réseaux, en systèmes d'information, avec une spécialité ou une dominante sécurité ;
* DATA PROTECTION OFFICER = LE PROTECTEUR DES DONNÉES PERSONNELLES
** Ce métier récent prend en compte l'évolution des contraintes réglementaires en matière de gouvernance des données personnelles pour y sensibiliser les collaborateurs de l'entreprise.
** Au quotidien
*** Gérer et améliorer les processus de conformité notamment via des audits ;
*** Garantir la conformité de l'organisme ;
*** Sensibiliser les collaborateurs aux implications juridiques de l'utilisation des données ;
*** Mettre en place des formations, des actions de sensibilisation ;
*** Assurer une veille juridique.
** Compétences
*** Connaissances juridiques (droit NTIC), des règlements et des normes ;
*** Bonne maîtrise de l'informatique ;
*** Communication et pédagogie.
** Formation
*** Diplôme CIL / DPO (comme à Paris Nanterre) pour juristes ou informaticiens ;
* ARCHITECTE BIG DATA = LE VISIONNAIRE TECHNIQUE
** À partir d'un besoin, cet expert du big data conçoit l'infrastructure et les combinaisons technologiques permettant de collecter et de traiter de gros volumes de données de toute nature. Il apporte une vision d'ensemble des technologies big data.
** Au quotidien
*** Concevoir l'architecture de l'infrastructurede gestion des données ;
*** Garantir son fonctionnement ;
*** La faire évoluer selon les besoins.
** Compétences
*** Maîtrise de toutes les technologies big data : bases de données NoSQL (MongoDB, Cassandra ou Redis), infrastructures serveurs (Hadoop, Spark) et stockage de données en mémoire (Memtables) ;
*** Esprit d'équipe ;
*** Curiosité, autonomie, communication.
** Formation
*** Bac + 4 ou 5 en informatique, management, statistiques ou marketing ;
* INGÉNIEUR BIG DATA = L'ACTEUR DU BIG DATA
** Il développe l'infrastructure mise en place par l'architecte big data. Il gère sa maintenance au quotidien et la fait évoluer selon les solutions les plus récentes.
** Au quotidien
*** Gérer l'architecture big data de l'entreprise ;
*** Assurer une veille technologique.
** Compétences
*** Expertise d'internet et des bases de données (SQL, NoSQL) ;
*** Maîtrise des technologies big data (Hadoop, Spark, Hive, Storm, Pig) et des infrastructures serveurs ;
*** Maîtrise des langages de programmation (Java, Scala…).
** Formation
*** Bac+5 big data ;
*** Bac+8 Statistiques ;
* HEAD OF DATA = LE CRÉATEUR DE VALEUR
** Le Head of Data (ou Lead Data Scientist) est responsable de l'équipe data science d'une organisation, en charge de créer un datalab et de le diriger. Il explore les valorisations de données de l'entreprise.
** Au quotidien
*** Encadrer les data scientists et gérer les projets ;
*** Animer la communauté scientifique ;
*** Faire émerger de nouvelles idées de valorisation des données avec les spécialistes des différents métiers de l'entreprise ;
*** Explorer de nouvelles solutions.
** Compétences
*** En sciences de données (analyse de données, modélisation, machine learning) ;
*** Maîtrise de Python, R, Java, Matlab, Spark, écosystème Hadoop ;
*** Bon relationnel, capacités de vulgarisation, aptitude pour le travail en équipe, rigueur, aptitudes managériales.
** Formation
*** Mathématiques, statistiques ou informatique (niveau > bac + 5) selon les enjeux de l'entreprise, de ses problématiques données et de la taille des équipes.
* CHEF DE PROJET DATA = L'EXPERT BUSINESS DE L'ENTREPRISE
** Il définit les cas d'usage et suit les projets data de l'entreprise grâce à ses connaissances des enjeux business de l'entreprise ou d'un de ses secteurs d'activités, ainsi que des enjeux et des problématiques liés au big data.
** Au quotidien
*** Animer les équipes projets ;
*** Faire le pont entre les équipes techniques et business, en interne comme en externe, éventuellement à l'aide de data visualisation ;
*** Assurer une veille technologique.
** Compétences
*** Très bonne connaissance des enjeux data ;
*** Maîtrise de Python, R, Java, Matlab, Spark, écosystème Hadoop ;
*** Très bonne connaissance métier ;
*** Qualités d'écoute, d'analyse et de synthèse ;
*** Communication, esprit d'équipe, leadership, autonomie.
** Formation
*** Ecole d'ingénieur ou de commerce.
* CONSULTANT DATA & ANALYTICS = L'ARTISAN DE LA DONNÉE
** Le consultant data intervient auprès de diverses organisations. Selon les cas, il peut les aider à définir leur stratégie data sur le long terme, mettre en place des business units spécifiques, ou encore développer des outils pour des clients.
** Au quotidien
*** Animer des comités de direction, des ateliers d'émergence de besoin ;
*** Découvrir et comprendre un métier ;
*** Identifier les problèmes sur lesquels la donnée peut ou non aider ;
*** Manipuler les données, coder, tester de nouvelles approches techniques ;
*** Assurer une veille technologique.
** Compétences
*** Bonne connaissance de l'écosystème data ;
*** Compréhension des enjeux métier ;
*** Capacité à structurer des projets (organisation, suivi, rétroplanning) ;
*** Créativité, curiosité.
** Formation
*** École d'ingénieur ou de commerce ;
*** = data scientist/data analyst/ingénieurs big data/architectes big data + communication/synthèse/business
* DATA ANALYST = LE SPÉCIALISTE BUSINESS D'UNE SOURCE DE DONNÉES
** Le data analyst travaille en général sur un type spécifique de données issues d'une source unique et connue, qu'il analyse avec un regard marketing ou finance selon le secteur afin d'orienter les prises de décisions stratégiques de l'entreprise.
** Au quotidien
*** Analyser les données pour les transformer en informations exploitables ;
*** Participe à la stratégie Data-Driven de l'entreprise ;
*** Créer et maintenir les bases de données de l'entreprise ;
*** Élaborer les critères de segmentation.
** Compétences
*** Une certaine expertise en mathématiques et en statistiques ;
*** Maîtrise des bases de données (SQL) ;
*** Maîtrise des outils de visualisation (type Tableau, QlikView) ;
*** Sensibilité aux enjeux business ;
*** Esprit d'équipe, Communication, curiosité, rigueur, aisance rédactionnelle.
** Formation
*** Bac + 4 ou 5 en statistiques, informatique ou marketing ;
* EXPERT DATA VISUALISATION = LE DATA STORYTELLER DE L'ENTREPRISE
** Ce spécialiste data, attaché à une entreprise, est capable d'exploiter les données de l'entreprise et de les mettre dans un contexte simplifié de visualisation pour en explorer le sens et les impacts.
** Au quotidien
*** Développer et concevoir des outils de data visualisation selon les enjeux business de l'entreprise ;
*** Mettre en place des applications pour restituer de larges jeux de données.
** Compétences
*** Maîtrise des outils de visualisation comme Tableau, QlikView, Microsoft Power BI, Excel ;
*** Pour les développeurs web : Javascript, D3.js, Angular.js, Django, html, CSS
*** Pour ceux qui développent les applications de A à Z, technologies de type Node.js, Java ;
*** Curiosité, créativité, sensibilité au design, autonomie, aptitude au travail en équipe, rigueur.
** Formation
*** Développeurs front end & back end.
* DATA JOURNALISTE = L'INVESTIGATEUR DES DONNÉES
** Le data journaliste ou « journaliste de données » est un journaliste qui ne rédige pas nécessairement d'articles. Il propose une visualisation de l'information avec les mêmes outils graphiques que les experts en data visualisation.
** Au quotidien
*** Collecter, nettoyer, vérifier, croiser et analyser des données massives ;
*** Travailler en mode projet avec des développeurs, statisticiens et graphistes.
** Compétences
*** Esprit d'analyse, de synthèse, de hiérarchie des informations ;
*** Goût pour les chiffres ;
*** Maîtrise des outils numériques et logiciels spécifiques ;
*** Curiosité, rigueur, grande culture générale, communication ;
*** Graphisme.
** Formation
*** École de journalisme ;
*** BTS communication.
* DATA SCIENTIST = L'EXPLORATEUR DE DONNÉES COMPLEXES
** Le data scientist est expert en mathématiques, statistique et informatique. Ce métier d'explorateur de la donnée relève, selon les profils – plutôt orientés mathématique ou informatique –, de la recherche, du développement d'algorithmes, voire de l'industrialisation de solutions.
** Au quotidien
*** Explorer de nouvelles pistes dans les ensembles de données et tester des hypothèses
*** Créer de nouveaux modèles de données
*** Concevoir des algorithmes à base de machine learning et les implémenter
** Compétences
*** Maîtrise du machine learning, deep Learning, Random Forests, modèles de Markov cachés, SVM, régression, séries temporelles, traitement du signal… ;
*** Maîtrise des outils Big data ;
*** Maîtrise de Python, R , Java, C, C++, Matlab, écosystème Hadoop, Spark… ;
*** Esprit d'équipe, communication, ouverture d'esprit, créativité, curiosité, transdisciplinarité ;
*** Sensibilité aux enjeux business, notamment dans les secteurs comme le marketing, le web, la publicité…
** Formation
*** Masters ou thèses en informatique, sciences cognitives, statistiques, mathématiques… ;
*** Bac + 4-5 en mathématiques-statistiques ou informatique ;
* DATA INGÉNIEUR = L'ACCOMPAGNATEUR TECHNIQUE DE A À Z
** Ce métier d'expert de la gestion des données – de leur ingénierie au sens propre –, apparu très récemment, est vite devenu indispensable. Polyvalent, le data ingénieur un acteur clé des projets.
** Au quotidien
*** Collecter des données en explorant le système d'information d'un client et ses différentes sources de données, en alimentant une plateforme d'acquisition de données, etc. ;
*** Nettoyer ces données en ajustant leur format, en normalisant les bases de données, en gérant les données manquantes ;
*** Les stocker dans un format homogène.
** Compétences
*** Développeur compétent sur le stockage et le traitement de données volumineuses (Hadoop, Scala, Spark, Kafka…) ;
*** Esprit d'équipe, curiosité, débrouillardise, communication.
** Formation
*** Existe pas encore
*** Écoles d'informatique (comme Epita, Epitech, Enseeiht) ou d'ingénieurs généralistes (comme UTC, UTT, Polytech).
* MACHINE LEARNING INGÉNIEUR = LE DÉVELOPPEUR EN MACHINE LEARNING
** C'est l'un des métiers les plus récemment apparus en sciences de la donnée. Le machine learning ingénieur est au croisement de la data science et du data engineering
** Au quotidien
*** Étudier la faisabilité de solutions de machine learning ;
*** Coder pour mener des tests fonctionnels.
** Compétences
*** Environnements techniques : Spark, HDFS, Zeppelin, Jupyter, Stack ELK, Python, Java, Angularjs ;
*** Connaissances en bases de données (SQL et NoSQL) ;
*** Compétences en développement web (Javascript, HTML/ CSS), analyse de données (Python, R, Scala), statistiques/ probabilités ;
*** Compétences en machine learning et data science ;
*** Notions sur les technologies Hadoop, Spark et Kafka.
** Formation
*** Existe pas encore
*** Les plus adaptées sont des écoles d'informatique (comme Epita, Epitech, Enseeiht) ou d'ingénieurs généralistes.
- (3236)How to be a candidate to a "Maître de Conférence" position in France?
GM: Note that there are few offers in public institutions. As a consequence, there are MANY candidates for each position and many GOOD candidates. So the competition is fierce. Also there might be internal "wars" within the institutions, so be prepared to face hard questions to which you MUST answer calmly and correctly. This also means that sometimes the locally-preferred candidate will be recruited (most of the time, though), other times, internal wars will results in a total stranger being recruited. Sometimes, the teaching experience is the most important, sometimes its the research. Get as much info a priori to evaluate what are your chances & also make yourself known to maximize your chances to be the locally-preferred candidate (THAT'S WHY YOU NEED TO CALL PEOPLE DURING THE PREPARATION). In the end, from the point of view of the candidate, the results of the recruiting process might appear very random (good candidate not being recruited, bad candidate being recruited)...
The whole process is explained here, with interesting Tips & Tricks:
https://perso.ens-lyon.fr/pierre.lescanne/TEXTS/candidater.html
For instance, here are hint for the size & timeline for the application file:
Taille du dossier (pour un Maître de conférences)
Activités de recherche 2-6 pages
Activités d'enseignement 1-4 pages
Projet de recherche et d'enseignement 1-3 pages
Activités d'animation 10 lignes
Échéances
Temps de préparation > 15 heures
Délai avant bouclage - 15 jours
Version provisoire - 40 jours
Demande des recommandations - 60 jours
Article
Entre début écriture et envoi 3-6 mois
Entre envoi et acceptation 6-12 mois
Entre acceptation et publication 12-24 mois
From: https://perso.ens-lyon.fr/pierre.lescanne/TEXTS/candidater.html#VousMemes
- (3249)What are the trends in AI/ML/DeepLearning for 2020?
1. Unsupervised Learning [GM: VAE, Few-Shot]
The dominant paradigm in the world of AI today is supervised learning. In supervised learning, AI models learn from datasets that humans have curated and labeled according to predefined categories.
The fact that humans must label data by hand before machine learning models can ingest it has become a major bottleneck in AI.
Many AI leaders see unsupervised learning as the next great frontier in artificial intelligence.
2. Federated Learning [GM: @LabHC]
One of the overarching challenges of the digital era is data privacy. Because data is the lifeblood of modern artificial intelligence, data privacy issues play a significant (and often limiting) role in AI’s trajectory.
Privacy-preserving artificial intelligence—methods that enable AI models to learn from datasets without compromising their privacy—is thus becoming an increasingly important pursuit. Perhaps the most promising approach to privacy-preserving AI is Federated Learning.
3. Transformers [GM: Atttention Networks]
We have entered a golden era for natural language processing.
OpenAI’s release of GPT-3, the most powerful language model ever built, captivated the technology world this summer.
The key technology breakthrough underlying this revolution in language AI is the Transformer.
[GM/Seb: In Transformers, Attention mechanisms replace links between the steps => even if models end-up being bigger, they are hugely parallelizable (GPUs) => training uses less CPU & RAM]
4. Neural Network Compression [GM: Federated Learning @Edge + Stage CG]
AI is moving to the edge.
There are tremendous advantages to being able to run AI algorithms directly on devices at the edge — e.g., phones, smart speakers, cameras, vehicles—without sending data back and forth from the cloud.
[GM: privacy: Federated Learning + moins de calculs chez l'entreprise et plus chez le client = tout bénéf pour l'entreprise :)]
[GM: quantization, compression, distillation (student/teacher), SciDoLySE: https://www.ec-lyon.fr/contacts/alberto-bosio ]
5. Generative AI [GM: VAE init/debug/eval-FL]
Today’s machine learning models mostly interpet and classify existing data: for instance, recognizing faces or identifying fraud. Generative AI is a fast-growing new field that focuses instead on building AI that can generate its own novel content. To put it simply, generative AI takes artificial intelligence beyond perceiving to creating.
Two key technologies are at the heart of generative AI: generative adversarial networks (GANs) and variational autoencoders (VAEs).
6. "System 2" Reasoning [GM: job EMSE: GNN+WebSem]
In his landmark book Thinking, Fast And Slow, Nobel-winning psychologist Daniel Kahneman popularized the concepts of "System 1" thinking and "System 2" thinking.
[GM: left/right brain - creative/thinking]
System 1 thinking is intuitive, fast, effortless and automatic. Examples of System 1 activities include recognizing a friend’s face, reading the words on a passing billboard, or completing phrases.
System 2 thinking is slower, more analytical and more deliberative. Humans use System 2 thinking when effortful reasoning is required to solve abstract problems or handle novel situations. Examples of System 2 activities include solving a complex brain teaser or determining the appropriateness of a particular behavior in a social setting.
Yoshua Bengio’s 2019 keynote address at NeurIPS explored this exact theme. In his talk, Bengio called on the AI community to pursue new methods to enable AI systems to go beyond System 1 tasks to System 2 capabilities like planning, abstract reasoning, causal understanding, and open-ended generalization.
From: https://www.forbes.com/sites/robtoews/2020/10/12/the-next-generation-of-artificial-intelligence/
https://www.forbes.com/sites/robtoews/2020/10/29/the-next-generation-of-artificial-intelligence-part-2/
- (3254)How to avoid death by PowerPoint (a.k.a. How to make good presentations)?
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
* General remarks
** #minutes per slide / #slides not important !!! => #messages/slide is important
** List of stuff that dis/at-tracts user attention => (use them only on purpose/to convey a message):
*** movement: use animation lightly
*** signaling colors (red/orange/yellow)
*** contrast
*** size
=> use them to focus the user's attention where your discourse needs to
* Good Presentation
1. One message/idea per overlay/slide
2. Working Memory : 6 items => max 6 objects/slide (stuff that attracts attention: words/images/coloring...)
*** less than 6 => listeners "see'" them immediately
*** more than 6 => listeners need to count/focus attention => takes 5 times more time & energy for the listener
*** 1 large image per slide
*** People cannot read & listen at same time => Do NOT put long phrases on sides (put them in slides comments for you only)
*** [GM: NOT OK] Ne pas afficher le slide nb/slide total
*** Make items appear one after the other to control where listener should focus their attention (on only 1 thing at a time!)
3. Size : use smaller font for title of the slide
4. Contrast : Black Background for all slides (users eyes relax), white background dis/at-tracts attention to the screen => listeners will not look/listen to you but read the slides
5. ???
From: https://www.youtube.com/watch?v=Iwpi1Lm6dFo
- (3255)Sites to find latsets papers in DataScience
- From YT
2MinutesPapers
arxiv insights
- From web
KDNuggets
PapersWithCode
Distill.pub
- From GitHub "Awesome" lists
GANAwesomeApplications
GANZoo
- (3259)What is "Model Distillation" (a.k.a. teacher/student model)?
It's a method to reduce the size of a model (related to the field of "model compression").
Developed by Geoffrey Hinton in 2015.
Suppose that someone trains a classifier on lots of labelled data, and that the resulting model is very large.
The idea is to consider this large model as a "teacher" model for a smaller model, the "student". The teacher and student models are fed some data (here we might need a dataset that covers as much as possible the input space) and the students tries to mimic the teacher's output (rather than the original labels).
The point is that the teacher is outputting class probabilities - "soft labels" rather than "hard labels" (like yours). For example, a fruit classifier might say "Apple 0.9, Pear 0.1" instead of "Apple 1.0, Pear 0.0". Why bother? Because these "soft labels" are more informative than the original ones - telling the student that yes, a particular apple does very slightly resemble a pear. Student models can often come very close to teacher-level performance, even while using 1-2 orders of magnitude fewer parameters! Recent work even suggests that students can actually exceed teacher performance.
The trick is that the compressed model (student), is trained to mimic the output of the larger network (teacher), instead of training it on the raw data directly. This has something to do with how the deeper network learns hierarchical abstractions of the features.
This method is also called "model distillation".
This can be useful in Edge/IoT computing, when "porting" large models (e.g. NLP) to Edge/Small devices or in Federated Learning, to transmit as less as possible from the nodes to the aggregator.
From: https://www.quora.com/What-is-a-teacher-student-model-in-a-Convolutional-neural-network
https://www.quora.com/What-is-neural-network-compression
https://www.youtube.com/watch?v=zjaz2mC1KhM
- (3260)What is a GAN (Generative Adversarial Network)?
Generative Adversarial Network.
There are in fact 2 NN: Generator & Discriminator, which are co-trained. The idea is similar to co-evolution of preys/predators in nature/AI/Robotics/GeneticAlgorithms: the more the preys learn to escape predators, the more predators need to improve. In the end (Red Queen Effect) both populations reach a peak of fitness around which they alternate as the apex. Generator and Discriminator contest with each other in a zero-sum game framework.
GANs can be used as a Generative method: then the Generator is the interesting part.
GANs can also be used as an attack against any NN: the Generator tries to find an (Adversarial) example that the Discriminator does not identify correctly.
GANs can are difficult to train: if either the Generator or the Discriminator becomes "too good" before its counterpart, then the counterpart will never succeed in recovering. To avoid this situation arriving too early, sometimes, the Generator & Discriminator are pre-trained separately. Unfortunately, this requires labelled data for both parts. Sometimes, GANs are trained "hierarchically": with low resolution data first (e.g. few pixels wide images), then with increasing resolution until target resolution is achieved (e.g. HD images).
Developed in 2014 by Ian Goodfellow.
--
Generative Adversarial Networks (GANs) is a training methodology where two networks are co-trained. One of the networks generates data, and the other decides if that data is real or fake. For example, you can train a GAN on a corpus of cat pictures (the internet has tons of those). One half of the GAN tries to generate a cat picture, while the other looks at the generated cat picture, and returns an evaluation of how "real" it looks.
Based on the learning signal generated by this step, the generator can get better at making up fake cats, and the discriminator gets better at telling if something really looks like a cat.
There are tons of fiddly pieces to training GANs and multiple failure modes, but when it works, it's amazing.
From: Personal experience + https://www.quora.com/What-is-GANS
https://www.youtube.com/watch?v=9JpdAg6uMXs
https://thispersondoesnotexist.com/
https://thiscatdoesnotexist.com/
https://www.youtube.com/watch?v=Sw9r8CL98N0
https://www.youtube.com/watch?v=O8LAi6ksC80
https://www.youtube.com/watch?v=dCKbRCUyop8
https://www.youtube.com/watch?v=SWoravHhsUU
https://www.youtube.com/watch?v=HvH0b9K_Iro
- (3261)What is a Siamese (Neural) Network?
This is one type of NN used for One-Shot/Few-Shot Learning (i.e. learning with very few examples - of the target class, but potentially a LOT of examples of other classes).
Developed by Bromley and LeCun in early 1990.
The main idea in Few-Shot Learning is, instead of trying to learn to classify each single example of the input set, to try to learn to compare couples/triplets of examples (i.e. learn a "distance" between examples). Using couples/triplets of examples, as inputs, we HUGELY expand the numbers of inputs (=every combination of 2 or 3 examples in the dataset!).
More specifically, the architecture of a Siamese Networks is the following: 1 *duplicated* NN for each input (e.g. 2 images will be fed to the *same* NN) that reaches a given latent space + a distance metric in the latent space. First phase of the training consists in giving pairs/triplets of similar (resp. dissimilar) images and using the metric in the latent space as a LOSS function to force this duplicated NN to learn a good "compression" scheme that places (dis)similar inputs in (dis)similar regions of the latent space. In a second phase of the training, an once a very discriminative latent space is found, then we "plug" a simple NN to the output of one of the Siamese Network and teach it to learn to classify the (very discriminative) representations of the inputs.
Pros:
- Can be more robustl to extreme class imbalance.
- Can be good to ensemble with a classifier.
- Can yield better embeddings.
Cons:
- Training involves Pairwise Learning => quadratic pairs to learn from (in order to see all information available) => slower than Classification (pointwise learning). This can be alleviated by not traing on all pairs but on an intelligently selected subset of pairs.
- Prediction can add a few HyperParameters and can be slightly slower. It does not readily output Class probabilities, but distances from each Class.
From: https://www.quora.com/What-are-Siamese-neural-networks-what-applications-are-they-good-for-and-why
https://www.youtube.com/watch?v=6jfw8MuKwpI
https://www.youtube.com/watch?v=T9yKyZfxUJg
https://www.youtube.com/watch?v=8OsY_UrJo1I
https://www.youtube.com/watch?v=FIjy3lV_KJU
- (3262)What is a VAE (Variational Auto-Encoder)?
Variational Auto-Encoder.
Developed by Diederik Kingma and Max Welling in 2013.
It is a kind of Auto-Encoder, i.e. a symmetric NN that uses the input data as both its inputs & outputs and learn to reconstruct the inputs. The first half, the "Encoder", encodes the data into a latent space (generally of lower dimensions as the inputs), and the second half, the "Decoder", decodes values of the latent space back into the input space. The loss function estimates how good is the reconstruction.
As is is a totally Unsupervised method, it can be used for:
- Unsupervised Dimensional Reduction: we train a full AE, then use only the Encoder part, which is supposed to have learned a compression to a good (=very discriminative) latent space
- Unsupervised ML: again, we use the Encoder + a distance in the latent space (eventually used during training via the LOSS function) to cluster the inputs
- Pre-Training a classification NN: first we use an AE to learn the compression to a good (=very discriminative) latent space, then we drop the Decoder and plug a classical NN to the Encoder, that will "only" have to learn how to classify the (highly discriminative) *representations* of the inputs.
- Anomaly correction/detection: as the latent space is of lower dimension, information is lost during compression (Encoder). Thus, the Encoder finds the most important information to characterize the inputs (their "distribution"). Thus, 1. any new input that does not reconstruct correctly is an input that diverges from the inputs "distribution" == an anomaly; 2. the reconstruction will have all the artifacts removed (Noise Removal)
- ...
Variational AE add a constraint to the latent space: it must be a (normal) distribution (thus latent space is composed of 2 vectors: 1 for the means / 1 for the stdevs of gaussians). The LOSS functions as 2 parts: 1 that evaluates the reconstruction (similar to normal Auto-Encoders), 1 that forces the distributions outputted by the Encoder to match a normal distribution (Kullback–Leibler_divergence). As a consequence, before sending data from the latent space (distribution *parameters*) to the Decoder, we need to insert a layer that draws random numbers from this distribution and feeds them the the Decoder.
The advantage of forcing a distribution & a stochastic process in the middle layer are twofold:
1. The latent space is better exploited to place the various input representations in denser regions (whereas in normal AE, the latent space might have "holes"/unexploited regions)
2. One can use the the Decoder as a generator for new (never seen) data: one only as to draw numbers for normal distributions and feed them to the Decoder.
---
Can be used to Generate Fake Data but resembling initial distribution.
Prasoon Goyal: Intuitively, the encoder of a VAE outputs a distribution (mean + variance) in the latent space, and the decoder outputs a distribution in the input space. An autoencoder can be thought of as a special case of VAE, which assumes that these distributions have all the mass concentrated at one point. It turns out that explicitly modelling the variance helps in some cases — for instance, with hand-written digits, there is little variance for ‘3’ while ‘7’ can be written in multiple ways.
From: https://www.quora.com/Why-is-VAE-variational-autoencoder-better-for-anomaly-detection-than-AE-autoencoder-for-image-data
https://www.quora.com/What-is-the-difference-between-Generative-Adversarial-Networks-and-Autoencoders
https://www.youtube.com/watch?v=9zKuYvjFFS8
https://www.youtube.com/watch?v=fcvYpzHmhvA
https://www.youtube.com/watch?v=7mRfwaGGAPg
https://www.youtube.com/watch?v=Rdpbnd0pCiI
https://www.youtube.com/watch?v=1icvxbAoPWc
- (3263)What is the difference between Generative Adversarial Networks and (Variational) Auto-Encoders?
An autoencoder compresses its input down to a vector - with much fewer dimensions than its input data, and then transforms it back into a tensor with the same shape as its input over several neural net layers. They’re trained to reproduce their input, so it’s kind of like learning a compression algorithm for that specific dataset.
A GAN looks kind of like an inside out autoencoder - instead of compressing high dimensional data, it has low dimensional vectors as the inputs, high dimensional data in the middle.
Instead of being given a bit of data as input, it’s given a small vector of random numbers. The generator network tries to transform this little vector into a realistic sample from the training data. The discriminator network then takes this generated sample(and some real samples from the dataset) and learns to guess whether the samples are real or fake. Well, more precisely it’s trained to minimize cross entropy between the probability it outputs and a vector of *0s* for fake images and “1”s for real images. The generator learns to make more convincing samples,(or minimize the cross entropy between the discriminators guess about it’s creations and “1”)
Another difference: while they both fall under the umbrella of unsupervised learning, they are different approaches to the problem. A GAN is a generative model - it’s supposed to learn to generate realistic *new* samples of a dataset. Variational autoencoders are generative models, but normal “vanilla” autoencoders just reconstruct their inputs and can’t generate realistic new samples.
From: https://www.quora.com/What-is-the-difference-between-Generative-Adversarial-Networks-and-Autoencoders?share=1
- (3264)What is NN "model compression" (Quantization, Distillation, etc.)?
The idea is to reduce the size of a NN model. For instance to run it in IoT/Edge devices or lighten the messages sent in Federated Learning.
One method is de Tip#3259 about Model Distillation
Another method is "model Quantization":
- "Vector Quantization" typically means selecting *prototypes* from a pool of vectors, keep them and throw away the rest. In model compression, the "Vector" can be a layer of a large NN
- "int8 Quantization" means using "smaller"/les precise types for the storage of the weights of the NN. As modern NN have a VERY large number of weights, reducing a little the storage space of each weights can have a drastic effect on the total size of the model.
In the end, the model requires less space to store than the original model, but it is quite different from the original.
It works because NN are very resilient and generally distribute the storage of information along multiple paths (like our brain), thus degrading a few paths do not break everything.
Sometimes it works well (helps model generalize better), sometimes it simply degrades the model performance. So there is a trade-off to find between compression/quantization level and accuracy (or any other evaluation metric)
From: https://www.quora.com/How-has-Vector-Quantization-been-used-in-Deep-Learning
https://www.mathworks.com/company/newsletters/articles/what-is-int8-quantization-and-why-is-it-popular-for-deep-neural-networks.html
- (3265)What is Attention mechanism for NN?
The attention mechanism can be seen as a continuation of Differentiable/Neural Turing Machines, i.e. a NN that can "compute" like a Turing Machine, but in a stochastic/differentiable way. One of the ideas is to replace the exact indexing for accessing a memory location at time t (i.e. a single index value) by a distribution over all the memory cells representing their relative importance at time t (i.e. vector of probabilities/importance).
With the Attention mechanism, the NN "observes" the all the inputs/memory-cells at every moment & uses them to compute its current output by simply computing something like:
- current output = current input decision vector + current memory cells vector * current mem-cell importance vector
- updating attention
This is similar to LSTM/GRU computing something like:
- current output = current input decision vector * alpha + current history decision vector * (1-alpha)
For Attention mechanisms, there are 4 important parameters, all represented as vectors of (fixed?) size:
- V (values): the (more or less interesting) thing to observe
- K (keys): the indexes of the keys
- Q (queries): this is a distribution over the keys of was it indeed of interest ("where does the network puts its attention")
The advantage of storing data in the form of vectors, is that by simple operations (multiplications): V*K*Q, one can obtain directly/quickly values proportionalized to their importance (https://www.youtube.com/watch?v=iDulhoQ2pro&t=1468)
- Positonnal Encoding: as we embeed our input (e.g. a sentence with GLoVe), with loose the positionnal information of the positions of the elements (e.g. words): which element was the first, what is the distance between two elements... Positionnal Encoding uses a combination of sin()/cos() waves to represent this information so that the attention mechanism can use it. See https://youtu.be/iDulhoQ2pro?t=851
These V/K/Q values act like a HashTable that stores, for each word, which are the words that influence it (or it influences?!?) and the importance of this influence.
From: https://www.youtube.com/watch?v=iDulhoQ2pro
https://www.youtube.com/watch?v=SysgYptB198
https://www.youtube.com/watch?v=0VH1Lim8gL8
https://www.youtube.com/watch?v=W2rWgXJBZhU
- (3266)What is a Transformer?
A Tranformer is a replacement for a RNN/LSTM/GRU, i.e. a NN with memory, that uses Attention mechanism.
Like RNN/LSTM/GRU, they work as a Encoder/Decoder pair, in order to "compress" the sequence input (e.g. a sentence in English) into a numerical latent space on with NN can work, then "decompress" this latent representation into a sequence output (e.g. a sentence in French).
It is a continuation of Differentiable Turing Machines.
Developped by OpenAI/Google in 2017.
The problem with RNN/LSTM/GRU is that to model sequences, they themselves work in sequence. As a consequence, they are very hard to parallelize, as each step depends on the execution of the previous step. Also, long-term dependencies suffer from exploding/vanishing gradient (in long sequences, if you do a lot of multiplications of small/large values/gradients, you quickly end-up reaching the maximum capacity of the type -float/int- you're using to store your data/gradients).
On the contrary, Transformers are not sequential so, even if the Attention mechanism adds a lot of parameters to the NN, they can be hugely parallelized. Thanks to the highly parallel machines of today (Multi-core, GPU, TPU), such large NN can be trained A LOT more quickly than sequential ones!
The idea is, instead of having each step depend on the preceding one, there's an attention mechanism that "observes" ALL the preceding steps at once, and models a *distribution* of the attention for each step over all the inputs. This requires to have a fixed length input for the attention => we need to use an "embedder" first (e.g. for NLP: word2vec, GLoVe, GPT-3...).
See Tip#3265
#+STARTUP: showall indent
#+TODO: TODO(t) LATER(l) CANCELLED(c) DELEGATED(d) | DONE(o) + C-c C-c
#+OPTIONS: title:0
#+OPTIONS: author:nil date:nil
#+TITLE: Transformers, based on https://youtu.be/TQQlZhbC5ps?t=170
#+AUTHOR:
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:1 ## number of header levels to consider (level below are list items)
#+OPTIONS: num:nil ## use itemize vs. enumerate
* Transformers
#+BEGIN_SRC ditaa :file transformer.png
Output
Probabilities
^
|
+-----+-----+
| SoftMax |
+-----+-----+
^
|
+-----+-----+
| Linear |
+-----+-----+
^
|
+-------------+--------------+
| | |
+--------------------+ | +--------+--------+ |
| | | | Add + Norm |<-+ |
+--------------|-----------+ | | +--------+--------+ | |
| | | | | ^ | |
| +-----------------+ | | | | | |
| | Add + Norm | | | | +--------+--------+ | |
| +---------+-------+ | | | | Feed Forward | | |
| ^ | | | +--------+--------+ | |
| | | | | ^ | |
| +-----------------+ | | | +-----------+ |
| | Feed Forward | | | | | |
| +---------+-------+ | | | +--------+--------+ |
| ^ | | | | Add + Norm |<-+ |
| | | | | +--------+--------+ | |
| +--------+--------+ | | | ^ | |
| +->| Add + Norm | | | | | | |
| | +--------+--------+ | | | +--------+--------+ | |
| | ^ | | | | Multi-Head | | |
| | | | | | | Attention | | |
| | +--------+--------+ | | | +----+---+---+----+ | |
| | | Multi-Head | | | | ^ ^ ^ | |
| | | Attention | | | | | | | |
| | +----+---+---+----+ | +---------------------+---+ +-------+ |
| | ^ ^ ^ | | |
| | | | | | | +------------+----+ |
| +-------+---+---+ | | | Add + Norm |<-+ |
| | | | +--------+--------+ | |
+--------------+-----------+ | ^ | |
^ | | | |
| | +-----------------+ | |
Positional ---+ | | Masked | | |
Encoding | | | Multi-Head | | |
| | | Attention | | |
+-----+-----+ | +----+---+---+----+ | |
| Input | | ^ ^ ^ | |
| Embedding | | | | | | |
+-----+-----+ | +---+---+-------+ |
| | | |
Inputs +-------------+--------------+
^
|
+---- Positional
| Encoding
|
+-----+-----+
| Output |
| Embedding |
+-----+-----+
|
Outputs
(Shifted Right)
#+END_SRC
#+RESULTS:
[[file:transformer.png]]
From: https://www.quora.com/What-is-a-transformer-in-deep-learning
https://www.youtube.com/watch?v=TQQlZhbC5ps
https://www.youtube.com/watch?v=4Bdc55j80l8
https://www.youtube.com/watch?v=FWFA4DGuzSc
https://www.youtube.com/watch?v=S27pHKBEp30
https://www.youtube.com/watch?v=0VH1Lim8gL8
- (3267)How does SoftMax work?
Let's say you have a vector of values:
[a1, a2, ..., an]
Basically SoftMax computes:
[e^a1/sum_i(e^i) , e^a2/sum_i(e^i) ,..., e^an/sum_i(e^i)]
- The e^(a1) makes large number even (very) larger and small numbers even (very) smaller
- The sum_i(e^i) normalizes everything
In the end, the one number that was the biggest in the initial vector ends up close to one, and all the other numbers end up close to 0.
So in the end, we almost get the results of the Max() function, but in the differentiable way (\o/ as it is very important for NN).
From: https://www.youtube.com/watch?v=iDulhoQ2pro&t=1295
- (3275)How to know the dates of main AI/ML conferences
https://aideadlin.es/?sub=ML,CV,NLP,RO,SP,DM
- (3274)Tips to vizualize large trees/hierarchies
put leaves on circle, root at center
- (3279)What are L0 / L1 (LASSO) / L2 (Ridge) / ElasticNet norms/regularizations?
Goal of regularization is to prevent the model of overfiting by constraining the "shape" of the model so that it cannot simply memorize the data. In the case of L1/L2 regularizations/norms, the constraints are imposed on the values of the weights of the model (e.g. prefer 0s over very small values ~ pruning).
- L1 Regularization (or Lasso) adds to so-called L1 Norm to the loss value.
+ L1 norm: R(f) = \sum__{i=1}^{n}|w_i|
+ Final loss: L(f(x_i),y_i) = \sum_{i=1}^{n} L(f(x_i),y_i) + \lambda \sum{i=1}^{n}|w_i|
+ Functioning: as loss is minimized, regularization term should be as low as possible => weights will tend to be minimal. As it is contrasted with Accuracy, only marginal modifications will occur, i.e. L1 regularization ~ small weights will be set to 0.
+ Pros:
- L1 Regularization produces sparse models, i.e. models where unnecessary features don’t contribute to their predictive power
+ Cons:
- Lasso does not work that well in a high-dimensional case, i.e. where the number of samples is lower than the number of dimensions
- If you already performed variable selection, thus already have some kind of sparsity, or if information is spread among several variables, adding L1 might drop important information
- L2 Regularization (or Ridge) adds to so-called L2 Norm to the loss value.
+ L2 norm: R(f) = \sum__{i=1}^{n}(w_i)^2
+ Final loss: L(f(x_i),y_i) = \sum_{i=1}^{n} L(f(x_i),y_i) + \lambda \sum{i=1}^{n}(w_i)^2
+ Functioning: Similar to L1/Lasso, but will not drop the features, only set them to a (very) low weight
+ Pros:
- L2 is better in High Dimensional data than L1
+ Cons:
- You may end up with an uninterpretable model if your dataset is high-dimensional (all features are kept but with very low values).
- (Naïve) Elastic Net Regularization
+ It's a linear combination of L1/LASSO and L2/Ridge regularization, and produces a regularizer that has both the benefits of the L1 (sparsity) and L2 (work in high dimension) regularizers.
+ L(f(x_i),y_i) = \sum_{i=1}^{n} L(f(x_i),y_i) + (1-\alpha) \sum_{i=1}^{n} |w_i| + \alpha \sum_{i=1}^{n} (w_i)^2
+ Cons:
- Due to "double shrinkage" (both L1 & L2 tend to make the weights as small as possible), final model accuracy can get lower. [There are "non-Naïve" ElasticNet version that solve this problem]
- Performance can get lower as loss includes many terms
From: https://www.machinecurve.com/index.php/2020/01/21/what-are-l1-l2-and-elastic-net-regularization-in-neural-networks/
https://montjoile.medium.com/l0-norm-l1-norm-l2-norm-l-infinity-norm-7a7d18a4f40c
- (3305)How to protect privacy with Random Projections (a.k.a. How to project data into a smaller space while preserving distances)?
The Johnson-Lindenstrauss Lemma says that it is possible to project a small set of points from a high dimensional (Euclidian) space into a smaller dimensional space while preserving distances.
This is used in the following paper to "scramble" data (so that privacy is preserved) while still allowing ML algorithms to be able to run and offer rich services on top of this data:
https://pdfs.semanticscholar.org/77d7/a7b36abc7cd3cf0ef492183469abb0342cc1.pdf
From: https://fr.wikipedia.org/wiki/Lemme_de_Johnson-Lindenstrauss
https://en.wikipedia.org/wiki/Johnson%E2%80%93Lindenstrauss_lemma
- (3327)What is "Error-runtime-trade-off" for SGD?
TOVERIFY
SGD = Stochastic Gradient Descent. It means you will compute the gradient on a (mini)batch of instances at once instead of on each single instance one after the other.
If you draw the evolution of the loss (==Error) along (Run)time, for several values of the (mini)batch size, you'll notice that the larger the size, the faster the convergence (==smaller Runtime), but probably ending on a higher loss (worse Accuracy). Conversely, with smaller batches, it'll take more time to converge, but the final Accuracy/Loss might end up better. This is the goal of SGD: speed up convergence. But of course (would be too easy otherwise) the gain depends on the data/application.
So in the end, there's a trade-off to find between the size of the batch, the time to converge and the target final accuracy. Hence the name.
From: https://www.researchgate.net/figure/Error-runtime-trade-off-comparison-of-different-SGD-variants-for-logistic-regression-on_fig7_323570655
- (3348)What are Prior & Posterior & Joint Probabilities and the Likelihood?
- Prior = a prior probability distribution (or "prior"), of an uncertain quantity is the probability distribution that would express one's beliefs about this quantity *before some evidence is taken into account*.
p(\theta) : probability of the parameters \theta *before* seeing any evidence.
- Posterior = posterior probability of a random event (or proposition) is the *conditional* probability that is assigned *after the relevant evidence or background is taken into account*.
p(\theta | X) : probability of the parameters \theta *given* the evidence X.
- Joint = the joint probability of two random events is the probability of the co-occurrence of the two events.
p(X,Y) : probability of X and Y occurring together.
- Likelihood =
~p(X | \theta) : ~probability that the *evidence belongs to the model* with parameters \theta.
From: https://en.wikipedia.org/wiki/Prior_probability
https://en.wikipedia.org/wiki/Posterior_probability
https://en.wikipedia.org/wiki/Joint_probability_distribution
https://en.wikipedia.org/wiki/Likelihood_function
- (3349)What is the "Reparametrization trick" in VAE?
A VAE computes gaussians' parameters as latent space, with a sampling step.
Unfortunately, this samplig step is non-differentiable, thus back-propagation is complicated.
The "trick" consists in noting that N(\mu,\sigma) = N(0,1)*\sigma+\mu , thus isolating the sampling step and allowing the computation of the gradient.
From: https://ml-et-alia.gitlab.io/2020/07/03/inference-variationnelle-et-vae/
Thanks RemiE!
- (3350)What is Variational Inference?
- The goal is to find the constituents of a probabilistic model: parameters \theta (set of variables) and latent variables Z.
More or less, parameters \theta correspond to (unknown) *global* things and latent variables to unknown things *that depend on the points*
In the very simple case where we assume points are drawn from a gaussian (normal), parameters are the mean and variance/covarianceand Z is empty.
- In a GMM
- \theta are the Gaussian mix parameters (means & variances + weight of each Gaussian)
- Z tells us to which Gaussian each point belongs to
- For each new observation x_i we can look for the corresponding distribution which estimates how much this new point belongs to each Gaussian (we can "reduce" this distribution when we need to associate the point to a single cluster (*)).
(*) MAP - https://en.wikipedia.org/wiki/Maximum_a_posteriori_estimation
MLE - https://en.wikipedia.org/wiki/Maximum_likelihood_estimation)
- In a VAE
- We do amortization(?):
- \theta (Gaussian parameters) are hidden in derivations (reduced to N(0,1) with re-parametrization trick See Tip#3349) and mostly used for sampling (generating new points/Synthetic data)
- Z are the correspondences between training observations and the gaussians
- Both are learned during training
- The Goal (Loss function) partly consists in minimizing the Kullback-Leibler divergence:
KL(q||p) = E_q[log(q/p)]
= E_q[log(q)] - E_q [log(p)]
# Using log p = log p(\theta,Z|X) + Bayes: p(\theta,Z|X) = p(X|\theta,Z)*p(\theta,Z)/p(X)
= E_q[log(q)] - E_q[log p(\theta, Z)] - E_q[log (X|\theta,Z)]
# => Interpretation: minimize entropy, maximize q/prior correspondance & maximize (log-)likelihood
# Refactoring first part we get:
= KL(q||p(\tehta,Z)) - Eq[log p(X,\theta,Z)]
# => Interpretation: minimize KL(q, prior) at the same time as maximizing log-likelihood (on average on q)
From: https://ml-et-alia.gitlab.io/2020/07/03/inference-variationnelle-et-vae/
Thanks RemiE!
- (3363)How to create a DataLoader from a custom Dataset based on a Pandas DataFrame in Pytorch?
from torch.utils.data import DataLoader, Dataset
class PandasDataSet(Dataset):
def __init__(self, data):
self.data = torch.FloatTensor(data.values.astype('float'))
def __len__(self):
return len(self.data) def __getitem__(self, index):
target = self.data[index][-1]
data_val = self.data[index] [:-1]
return data_val,target
train_dataset = PandasDataSet(Train_data)
valid_dataset = PandasDataSet(Valid_data)
train_loader = DataLoader(train_dataset, batch_size=<size>, shuffle=True, **kwargs)
test_loader = DataLoader(valid_dataset, batch_size=<size>, shuffle=False, **kwargs)
From: https://medium.com/analytics-vidhya/writing-a-custom-dataloader-for-a-simple-neural-network-in-pytorch-a310bea680af
- (3374)WikiBook: Cracking the DataMining/MachineLearning/DataScience interview: Basic stuff to know
======================================================================
======================================================================
[MERGE: 1977] Cracking DS Interview
The format below is the one of the Wikipedia Book at:
https://en.wikipedia.org/wiki/User:LI_AR/Books/Cracking_the_DataScience_Interview
NOTE: Each \":[[<page>]]\" can be accessed directly using with \"https://en.wikipedia.org/wiki/<page>\"
======================================================================
======================================================================
{{saved book
|title=Cracking The Data Science Interview
|subtitle=Basic Stuff To Know
|cover-image=
|cover-color=
|text-color=red
}}
=================== START COPY PASTE HERE !!! ==================================
== Cracking the DataScience Interview ==
=== Basic Stuff To Know ===
; Generic pages
:[[Glossaire_de_l%27exploration_de_donn%C3%A9es]]
:[[Big_data]]
* Inspired from books like:
** \"A collection of Data Science Interview Questions Solved in Python and Spark vol I & II\"
** \"120 real data science interview questions\"
; Tips / Known Limits of DS
* DataScience is (very) experimental (Andrew Ng): https://pbs.twimg.com/media/CBXshmjWgAAgLKa.jpg
:[[Overfitting]]
:[[Bias%E2%80%93variance_tradeoff]] / http://www.ritchieng.com/machinelearning-learning-curve/
:[[Sampling_bias]]
:[[Survivorship_bias]]
:[[Selection_bias]]
:[[Concept_drift]]
:[[Correlation_does_not_imply_causation]]
:[[Curse_of_dimensionality]]
** https://www.kaggle.com/wiki/Leakage
** http://machinelearningmastery.com/data-leakage-machine-learning/
** http://feedproxy.google.com/~r/blogspot/wCeDd/~3/EJB0G6BrbsU/solving-ill-posed-inverse-problems.html
** Neural Networks
:[[Vanishing_gradient_problem]]
; Machine Learning definition and types
:[[Artificial_intelligence]]
:[[List_of_machine_learning_concepts]]
:[[Machine_learning]]
:[[Data_mining]]
:[[Knowledge_extraction]]
:[[Knowledge_extraction#Knowledge_discovery]]
:[[Pattern_recognition]]
:[[Signal_processing]]
:[[Supervised_learning]]
:[[Semi-supervised_learning]]
:[[Unsupervised_learning]]
:[[Reinforcement_learning]]
:[[Online_machine_learning]]
:[[Incremental_learning]]
:[[Q-learning]]
:[[One-shot_learning]] / https://www.quora.com/What-is-zero-shot-learning
:[[Feature_learning]]
:[[Learning_to_rank]]
:[[Similarity_learning]]
:[[Biclustering]]
:[[Natural_language_processing]]
:[[Biomimetics]]
:[[Collective_intelligence]]
:[[Data_stream_mining]]
:[[Sequential_pattern_mining]]
:[[Clickstream]]
:[[Semantics]]
:[[Semantic_Web]]
:[[Speech_recognition]]
:[[Speech_synthesis]]
:[[Collaborative_filtering]]
; Competitions
* https://www.kaggle.com/
* https://www.datascience.net/fr/home/
* http://dreamchallenges.org/
* https://www.drivendata.org/competitions/
* https://www.testdome.com/tests/data-analysis-test/65
* http://www.crowdanalytix.com/
* https://www.topcoder.com/community/data-science/
* https://www.datasciencechallenge.org/
* http://tunedit.org/challenges
* https://datasciencebowl.com/competitions/
* https://www.innocentive.com/ar/challenge/browse
* http://tamids.tamu.edu/2018-tamids-data-science-competition/
* https://hackerearth.com
; Datasets
:[[List_of_datasets_for_machine_learning_research]]
* https://www.analyticsvidhya.com/blog/2018/03/comprehensive-collection-deep-learning-datasets/
* http://www.kdnuggets.com/datasets/index.html
* https://aws.amazon.com/public-datasets/
* https://www.kaggle.com/datasets
* https://data.fivethirtyeight.com
* https://www.quandl.com/
* https://opendata.socrata.com/
* https://cloud.google.com/bigquery/public-data/
* https://github.com/BuzzFeedNews
* https://en.wikipedia.org/wiki/Wikipedia:Database_download
* http://mlr.cs.umass.edu/ml/datasets.html
* https://data.world/
* https://www.data.gov/
* https://www.data.gouv.fr/fr/
* https://data.worldbank.org/
* https://www.reddit.com/r/datasets/top/?sort=top&t=all
* http://academictorrents.com/browse.php?cat=6
* http://www.kdnuggets.com/2015/04/awesome-public-datasets-github.html
* http://www.kdnuggets.com/?s=datasets
* https://www.springboard.com/blog/free-public-data-sets-data-science-project/
* https://www.dataquest.io/blog/free-datasets-for-projects/
* https://github.com/awesomedata/awesome-public-datasets
* https://elitedatascience.com/datasets
* https://blog.journeyofanalytics.com/50-free-datasets-for-data-science-projects/
* https://www.datascienceweekly.org/data-science-resources/data-science-datasets
; Software
* http://www.databaseetl.com/data-mining-tools/
* IDEs / DS-GUI
** R
*** (DS-GUI) :[[Rattle_GUI]] http://rattle.togaware.com/
*** (DS-GUI) https://rkward.kde.org/
*** (DS-GUI) https://www.deducer.org/
*** (DS-GUI) https://socialsciences.mcmaster.ca/jfox/Misc/Rcmdr/
*** (DS-GUI) http://r.analyticflow.com/en/
*** (DS-GUI) https://github.com/dreamRs/esquisse
*** (IDE) :[[RStudio]] https://www.rstudio.com
** Python
*** (DS-GUI) :[[Orange_(software)]] https://orange.biolab.si/
*** (DS-GUI) https://git.launchpad.net/sofastatistics
*** (IDE) :[[Project_Jupyter#Jupyter_Lab]] https://jupyterlab.readthedocs.io
** Java
*** (DS-GUI) :[[Weka_(machine_learning)]] http://www.cs.waikato.ac.nz/ml/weka/
*** (DS-GUI) https://datamelt.org/?id=current
*** (IDE) :[[IntelliJ_IDEA]] https://www.jetbrains.com/idea/ https://github.com/JetBrains/intellij-community
*** (IDE) :[[Eclipse_(software)]] https://www.eclipse.org/ https://git.eclipse.org/c/
** C/C++
*** (DS-GUI) https://www.gnu.org/software/pspp/get.html
*** (DS-GUI) https://jasp-stats.org/
*** (DS-GUI) https://www.jamovi.org/download.html
** Online
*** https://perspective.finos.org/
*** https://jasp-stats.org/download/
*** https://www.jamovi.org/download.html
*** https://github.com/jamovi/jamovi/
*** https://github.com/radiant-rstats/radiant (Shiny App)
*** https://github.com/RamiKrispin/MLstudio (Shiny App)
*** https://github.com/cargomoose/ggraptR (Shiny App)
*** https://www.rollapp.com/launch/jasp
*** https://cloud.jamovi.org/
*** https://www.paraview.org/download/
*** DEAD http://www.gamifiedonlineweka.ga/
** Paid Software
*** (DS-GUI) :[[Minitab]] https://minitab.com/
*** (DS-GUI) :[[Tableau_Software]] https://www.tableau.com/
* R/Packages
** https://cran.r-project.org/
** https://cran.r-project.org/web/views/
** https://cran.r-project.org/web/views/MachineLearning.html
** https://cran.r-project.org/web/views/Bayesian.html
** https://cran.r-project.org/web/views/Cluster.html
** https://cran.r-project.org/web/views/NaturalLanguageProcessing.html
** https://cran.r-project.org/web/views/Survival.html
** https://cran.r-project.org/web/views/TimeSeries.html
* Python
** https://www.python.org/
** :[[Scikit-learn]] http://scikit-learn.org/stable/
* C++
** https://orange.biolab.si/
* Alteryx
** https://www.alteryx.com/ [Commercial]
* Comparison
** http://onlinelibrary.wiley.com/wol1/doi/10.1002/widm.1204/full
* DeepLearning
** https://www.tensorflow.org/
** http://www.deeplearning.net/software/theano/
** http://mxnet.io/
** http://caffe.berkeleyvision.org/
** https://github.com/NervanaSystems/neon
* GANs (Generative Adversial Networks)
** https://github.com/hindupuravinash/the-gan-zoo
** https://github.com/GKalliatakis/Delving-deep-into-GANs
** https://github.com/nashory/gans-awesome-applications
* DataViz
** https://matplotlib.org/
** https://plot.ly/
** :[[GGobi]] http://www.ggobi.org/
** http://ggplot2.org/
** http://ggvis.rstudio.com/
** https://d3js.org/
** https://datascienceplus.com/creating-graphs-with-python-and-goopycharts/
** https://www.kdnuggets.com/2022/12/make-amazing-visualizations-python-graph-gallery.html / https://www.python-graph-gallery.com/
** https://www.tableau.com/ [Commercial]
** http://bokeh.pydata.org/en/latest/ [Python]
** http://pyqtgraph.org/ [Python]
** https://uber.github.io/deck.gl [Uber\'s internal DataViz tool]
** http://rawgraphs.io/
** http://scidavis.sourceforge.net/
** http://home.gna.org/veusz/
** http://jwork.org/dmelt/
* Graphs
** https://gephi.org/
** http://www.graphviz.org/
** http://www.cytoscape.org/
* GUI
** https://www.rstudio.com/products/shiny/
** https://www.gradio.app/
; Data Manipulation
: Annotate examples: https://prodi.gy/
:[[Data_pre-processing]]
:[[Data_cleansing]]
:[[Data_reduction]]
:[[Data_wrangling]]
:[[Data_scrubbing]]
:[[Data_editing]]
:[[Data_scraping]]
:[[Data_curation]]
:[[Data_pre-processing]]
:[[Data_fusion]]
:[[Data_integration]]
:[[Data_binning]]
:[[Sanitization_(classified_information)]]
:[[Extract,_transform,_load]]
:[[Imputation_(statistics)]]
:[[Interpolation]]
:[[Outlier]]
* https://github.com/Quartz/bad-data-guide
* https://en.wikipedia.org/wiki/Oversampling_and_undersampling_in_data_analysis
:[[Local_case-control_sampling#Imbalanced_datasets]]
:[[Sampling_(statistics)]]
:[[Sampling_(statistics)#Stratified_sampling]]
:[[Stratified_sampling]]
:[[Jackknife_resampling]]
:[[Oversampling_and_undersampling_in_data_analysis]]
:[[Oversampling_and_undersampling_in_data_analysis#SMOTE]]
:[[AdaBoost]]
* \"Essay Why Most Published Research Findings Are False\"
** http://robotics.cs.tamu.edu/RSS2015NegativeResults/pmed.0020124.pdf
* \"A Few Useful Things to Know about Machine Learning\"
** https://homes.cs.washington.edu/~pedrod/papers/cacm12.pdf
* Working with text
:[[Unicode_equivalence#Normalization]]
:[[URL_normalization]]
:[[Text_segmentation]]
:[[N-gram]]
:[[Tokenization_(lexical_analysis)]]
:[[Stemming]]
:[[Word2vec]] https://www.tensorflow.org/tutorials/word2vec
* https://google.github.io/seq2seq/
* NLP in Python
https://github.com/explosion/thinc
* Working with spatial data
:[[Spatial_data]]
:[[Trend_surface_analysis]]
:[[Variogram]]
:[[Geary%27s_C]]
:[[Moran%27s_I]]
:[[Spatial_descriptive_statistics#Ripley.27s_K_and_L_functions]]
* Signal processing
:[[Dynamic_time_warping]]
* Signal processing - Images
:[[Normalization_(image_processing)]]
:[[Normalized_frequency_(unit)]]
:[[Image_segmentation]]
; Techniques for Feature/Attribute Selection/Dimensionality Reduction
:[[High-dimensional_statistics]]
:[[Dimensionality_reduction]]
:[[Factor_analysis]]
:[[Principal_component_analysis]]
:[[Independent_component_analysis]]
:[[Singular_value_decomposition]]
:[[Multidimensional_scaling]]
:[[T-distributed_stochastic_neighbor_embedding]]
:[[Autoencoder]]
:[[Deep_learning#Stacked_.28de-noising.29_auto-encoders]]
:[[Elastic_map]]
:[[Linear_discriminant_analysis]]
* Signal processing
:[[Compressed_sensing]]
* Working with spatial data
:[[Spatial_analysis]]
:[[Spatial_analysis#Spatial_dependency_or_auto-correlation]]
; Maths (Stats / Algebra)
* Inspiration for this section: https://github.com/soulmachine/machine-learning-cheat-sheet
:[[Pseudo-random_number_sampling]]
:[[Glossary_of_probability_and_statistics]]
:[[Bijection,_injection_and_surjection]]
:[[Mean]]
:[[Harmonic_mean]]
:[[Median]]
:[[Mode_(statistics)]]
:[[Range_(mathematics)]]
:[[Quartile]]
:[[Interquartile_range]]
:[[Variance]]
:[[Covariance]]
:[[Standard_deviation]]
:[[Collinearity#Usage_in_statistics_and_econometrics]]
:[[ANOVA]]
:[[ANCOVA]]
:[[MANOVA]]
:[[ANORVA]]
:[[Moving_average]]
:[[EWMA_chart]]
:[[Exponential_smoothing]]
* https://stats.stackexchange.com/questions/100019/window-models-in-stream-data-processing
:[[Autoregressive_model]]
:[[Autoregressive%E2%80%93moving-average_model]]
:[[Autoregressive_integrated_moving_average]]
:[[Autocorrelation]]
:[[Cross-correlation]]
:[[Entropy_in_thermodynamics_and_information_theory]]
:[[Moment_(mathematics)]]
:[[Residual]]
:[[Expected_value]]
:[[Likelihood_function]]
:[[Cumulative_distribution_function]]
:[[Probability]]
:[[Probability_mass_function]]
:[[Probability_density_function]]
:[[Prior_probability]] = P(Event) = What we know \"a priori\" about the Event
:[[Posterior_probability]] = P(Event | Data) = What we know \"after seeing the Data/Evidence\" about the Event
:[[Joint_probability_distribution]] = P(Event1, Event2)
:[[Prior_knowledge_for_pattern_recognition]]
:[[Permutation]] https://fr.wikipedia.org/wiki/Arrangement
:[[Combination]] https://fr.wikipedia.org/wiki/Combinaison_(math%C3%A9matiques)
:[[Dependent_and_independent_variables]]
:[[Independence_(probability_theory)]]
:[[Hoeffding%27s_inequality]]
:[[Pareto_efficiency]]
:[[Nash_equilibrium]]
:[[Pareto_principle]]
:[[Tensor]]
:[[Tensor_product]]
:[[Cross_product]]
:[[Taxicab_geometry]]
:[[Norm_(mathematics)#Euclidean_norm]]
:[[Lp_space]]
:[[Norm_(mathematics)]]
:[[Determinant]]
:[[Trace_(linear_algebra)]]
:[[Eigenvalues_and_eigenvectors]]
:[[Projection_(mathematics)]]
:[[Curvature]]
:[[Convolution]]
:[[Hadamard_product_(matrices)]]
:[[Kernel_(statistics)]]
:[[Radial_basis_function]]
:[[Logit]]
:[[Latent_variable]]
:[[Inference]]
:[[Statistical_inference]]
:[[Inductive_reasoning]]
:[[Deduction_and_induction]]
:[[Transduction_(machine_learning)]]
:[[Stochastic]]
:[[Stochastic_process]]
:[[Probability_theory]]
:[[Probability]]
:[[Posterior_probability]]
:[[Statistic]]
:[[Statistics]]
:[[Gaussian_noise]]
:[[Bayesian_inference]]
:[[Bayes_rule]]
:[[Bayes%27_theorem]]
* https://www.analyticsvidhya.com/blog/2017/03/conditional-probability-bayes-theorem/
:[[Bayesian_network]]
:[[Naive_Bayes_spam_filtering]]
:[[Naive_Bayes_classifier]]
:[[Belief_propagation#Approximate_algorithm_for_general_graphs]]
:[[Loss_function]]
:[[Regularization_(mathematics)]]
:[[Normalization_(statistics)]]
:[[Quantile_normalization]]
:[[Nystr%C3%B6m_method]] (+PCA)
:[[Preference_(economics)]]
:[[Delaunay_triangulation]]
:[[Neighbourhood_(mathematics)]]
* Genetic Algorithms
:[[Mutation_(genetic_algorithm)]]
:[[Crossover_(genetic_algorithm)]]
:[[Selection_(genetic_algorithm)]]
:[[Fitness_function]]
:[[Utility#Utility_functions]]
* SVM
:[[Kernel_method]]
:[[Kernel_(image_processing)]]
:[[Kernel_(statistics)]]
* Neural Networks
:[[Rectifier_(neural_networks)]]
:[[Backpropagation]]
:[[Gradient]]
:[[Gradient_descent]]
:[[Stochastic_gradient_descent]]
:[[Gradient_boosting]]
* http://www.wildml.com/deep-learning-glossary/#gradient-clipping
* http://www.wildml.com/deep-learning-glossary/#batch-normalization
* http://www.wildml.com/deep-learning-glossary/#backpropagation
* http://www.wildml.com/deep-learning-glossary/#momentym
* http://www.wildml.com/deep-learning-glossary/#sgd
* https://visualstudiomagazine.com/articles/2015/07/01/variation-on-back-propagation.aspx
:[[Softmax_function]]
** Softmax is a \"discriminant learning metric\": examples for all classes!={i} help learn even for class {i} since sum of evaluations is forced to be 1 (the method creates a link in the evaluations of the classes)
:[[Sigmoid_function]]
:[[Hyperbolic_function#Tanh]]
:[[Dropout_(neural_networks)]]
:[[Radial_basis_function]]
:[[Hebbian_theory]]
* Signal processing
:[[Signal_processing]]
:[[Low-pass_filter]]
:[[High-pass_filter]]
:[[Energy_(signal_processing)]]
:[[Fast_Fourier_transform]]
:[[Wavelet]]
:[[Discrete_wavelet_transform]]
:[[Coherence_(signal_processing)]]
:[[Kalman_filter]]
* Time Series
:[[Time_series]]
:[[Decomposition_of_time_series]]
:[[Seasonal_adjustment]]
:[[Seasonality]]
:[[Frequency_domain]]
:[[Time_domain]]
:[[Spectral_density]]
** https://www.analyticsvidhya.com/blog/2016/02/time-series-forecasting-codes-python/
** https://www.analyticsvidhya.com/blog/2015/12/complete-tutorial-time-series-modeling/
* Games
:[[Game_theory]]
:[[A*_search_algorithm]]
:[[Minimax]]
:[[Multi-armed_bandit]]
:[[Zero-sum_game]]
; Distances
:[[Distance]]
:[[Euclidean_distance]] [dim1]
:[[Edit_distance]]
:[[Hamming_distance]]
:[[Manhattan_distance]] [dim1]
:[[Levenshtein_distance]]
:[[Needleman�Wunsch_algorithm]]
:[[Minkowski_distance]] [dim n == generalization]
:[[Mahalanobis_distance]]
:[[Canberra_distance]]
:[[Distance_correlation]]
:[[Angular_distance]]
:[[String_metric]]
:[[Jaro%E2%80%93Winkler_distance]]
:[[Jaccard_index]]
:[[Kendall_tau_distance]]
:[[Chebyshev_distance]]
:[[Tf%E2%80%93idf]] For text
:[[Kullback�Leibler_divergence]] Divergence between 2 probability distributions
:[[Wasserstein_metric]] Distance between 2 probability distributions
:[[Neural_coding]]
* For graphs: http://blog.smola.org/post/33412570425
* https://fr.wikipedia.org/wiki/Algorithme_de_Needleman-Wunsch
* Clouds
:[[Hausdorff_distance]] [between clouds of points, a point and a cloud]
:[[Distance#Distances_between_sets_and_between_a_point_and_a_set]]
; Distributions
* https://blog.cloudera.com/blog/2015/12/common-probability-distributions-the-data-scientists-crib-sheet/
:[[Discrete_uniform_distribution]]
:[[Normal_distribution]]
:[[Bernoulli_distribution]]
:[[Binomial_distribution]]
:[[Poisson_distribution]]
:[[Chi-squared_distribution]]
:[[Log-normal_distribution]]
:[[Pareto_distribution]]
:[[Chi-squared_distribution]]
:[[Gibbs_distribution]]
:[[Weibull_distribution]]
:[[Gamma_distribution]]
:[[Beta_distribution]]
:[[Hypergeometric_distribution]]
:[[Dirac_delta_function]]
* https://ercim-news.ercim.eu/en107/special/robust-and-adaptive-methods-for-sequential-decision-making [Characterization of the simplicity of a distribution: BernsteinExponent+TsybakovMarginCondition]
; Evaluation
:[[Performance_indicator]]
:[[Mean_absolute_percentage_error]]
:[[Mean_absolute_scaled_error]]
:[[Symmetric_mean_absolute_percentage_error]]
:[[Regression-kriging]]
* https://www.kaggle.com/wiki/RootMeanSquaredLogarithmicError
* http://weka.sourceforge.net/packageMetaData/percentageErrorMetrics/index.html
* http://weka.sourceforge.net/packageMetaData/logarithmicErrorMetrics/index.html
:[[Information_gain_ratio]]
:[[Kullback%E2%80%93Leibler_divergence]]
:[[Gini_coefficient]]
:[[Pearson_correlation_coefficient]]
:[[Entropy]]
http://www.cbcb.umd.edu/~salzberg/docs/murthy_thesis/node15.html
:[[Akaike_information_criterion]] https://twitter.com/DataSciFact/status/963129411250933760
:[[Bayesian_information_criterion]]
:[[Brier_score]] == RMSE
:[[Structural_similarity]]
:[[Type_I_and_type_II_errors]]
:[[False_positive_rate]]
:[[False_coverage_rate]]
:[[False_discovery_rate]]
:[[Confusion_matrix]]
:[[Accuracy_and_precision]]
:[[Precision_and_recall]]
:[[F1_score]]
:[[Sensitivity_and_specificity]]
:[[Receiver_operating_characteristic]]
:[[Receiver_operating_characteristic#Area_under_the_curve]]
:[[Discounted_cumulative_gain]]
:[[Cross-validation_(statistics)]]
:[[Errors_and_residuals]]
* If residual is consistantly >0 or <0 on a range of the training set => the model has failed to capture something in the data or we use wrong type of model (e.g. linear reg on parabolic data; DataSkeptic/Heteroskedasticity)
:[[Heteroscedasticity]]
* Clustering
:[[Dunn_index]]
:[[Rand_index]]
:[[Jaccard_index]]
** See also the Calinski-Harabasz Index: http://stats.stackexchange.com/questions/97429/intuition-behind-the-calinski-harabasz-index
:[[Silhouette_(clustering)]]
** Others
:[[Item_response_theory]]
:[[BLEU]]
** http://www.sthda.com/english/articles/29-cluster-validation-essentials/96-determining-the-optimal-number-of-clusters-3-must-know-methods/#elbow-method
; Working with Text
:[[Part_of_speech]]
:[[Semantic_similarity]]
:[[Tf%E2%80%93idf]]
:[[Cosine_similarity]]
:[[Okapi_BM25]]
* See also Mr Gomez page on Weka: http://www.esp.uem.es/jmgomez/tmweka/
:[[Named-entity_recognition]]
:[[Conditional_random_field]]
:[[Latent_Dirichlet_allocation]]
:[[Sentiment_analysis]]
:[[Web_mining]]
:[[Web_crawler]]
:[[Text_mining]]
:[[Document_classification]]
:[[Automatic_summarization]]
; Working with Images
* http://mirror.imagej.net/plugins/mexican-hat/index.html
** If your model seeks to penalize near misses, the Mexican hat function is a good choice.
; Working with concepts (Ontologies)
https://en.wikipedia.org/wiki/YAGO_%28database%29
http://wiki.dbpedia.org/
http://conceptnet.io/
http://cogcomp.org/Data/QA/QC/definition.html
; Visualization
:[[Data_visualization]]
:[[Exploratory_data_analysis]]
:[[List_of_graphical_methods]]
:[[:Category:Statistical_charts_and_diagrams]]
:[[Statistical_graphics]]
:[[Visual_perception]]
:[[Heat_map]]
:[[Misleading_graph]]
:[[Pareto_chart]]
* Need to develop \"critical thinking\":
** https://www.nytimes.com/column/whats-going-on-in-this-graph
** https://www.nytimes.com/column/learning-whats-going-on-in-this-picture
; (Statistical) tests
:[[A/B_testing]]
* Evaluating an hypothesis
:[[Statistical_power]]
:[[Statistical_hypothesis_testing]]
:[[P-value]]
:[[Student%27s_t-test]]
:[[Chi-squared_test]]
:[[Type_I_and_type_II_errors]]
* Detecting abrupt changes in time series
:[[Stationary_process]]
:[[Structural_break]]
:[[Chow_test]]
:[[Kruskal%E2%80%93Wallis_one-way_analysis_of_variance]]
:[[F-test]]
:[[F-statistics]]
:[[Pairwise_summation]]
:[[CUSUM]]
* MOSUM: https://cran.r-project.org/web/packages/strucchange/vignettes/strucchange-intro.pdf
* Time series / Chaos
:[[Lyapunov_exponent]]
:[[Kolmogorov_complexity]]
; Machine Learning Techniques
:[[Statistical_classification]]
:[[One-class_classification]]
:[[Binary_classification]]
:[[Multiclass_classification]]
:[[Multi-label_classification]]
:[[Structured_prediction]]
:[[Cluster_analysis]]
:[[Elbow_method_(clustering)]]
:[[Nearest_neighbor_search#Approximate_nearest_neighbor]]
:[[Regression_analysis]]
:[[Linear_regression]]
:[[Logistic_regression]]
:[[Ridge_regression]]
:[[Kriging]]
:[[Multivariate_adaptive_regression_splines]]
:[[Association_rule_learning]]
:[[Apriori_algorithm]]
:[[Survival_analysis]]
:[[Monte_Carlo_method]]
:[[Monte_Carlo_algorithm]]
:[[Multinomial_logistic_regression]]
:[[Lasso_(statistics)]]
:[[Expectation%E2%80%93maximization_algorithm]]
:[[Markov_chain_Monte_Carlo]]
:[[Hidden_Markov_Models]]
:[[Viterbi_algorithm]]
:[[Convolutional_code]]
:[[Forward�backward_algorithm]]
:[[Markov_random_field]]
:[[Mean_field_theory]]
:[[Mean_field_particle_methods]]
:[[CART]]
:[[Decision_tree_learning]]
:[[Decision_tree]]
:[[Pruning_(decision_trees)]]
:[[ID3_algorithm]]
:[[C4.5_algorithm]]
:[[Random_forest]]
:[[Support_vector_machine]]
:[[Support_vector_machine#Support_vector_clustering_.28SVC.29]]
:[[Support_vector_machine#Regression]]
:[[Conditional_random_field]]
:[[Latent_semantic_analysis]]
:[[Genetic_algorithm]]
:[[Evolutionary_algorithm]]
:[[Evolutionary_computation]]
:[[Voronoi_diagram]]
:[[Local_outlier_factor]]
:[[Ordered_weighted_averaging_aggregation_operator]]
:[[Support_vector_machine]]
* Neural Networks
** History: http://www.chronicle.com/article/The-Believers/190147/
** The various types of NN as a picture: http://www.asimovinstitute.org/wp-content/uploads/2016/09/neuralnetworks.png
:[[Types_of_artificial_neural_networks]]
:[[Comparison_of_deep_learning_software/Resources]]
:[[Artificial_neural_network]]
:[[Perceptron]]
:[[Feedforward_neural_network]]
:[[Multilayer_perceptron]]
:[[Radial_basis_function_network]]
:[[Long_short-term_memory]]
:[[SNNS]]
:[[Time_delay_neural_network]]
:[[Recursive_neural_network]]
:[[Recurrent_neural_network]]
:[[Hopfield_network]]
:[[Content-addressable_memory]]
:[[Boltzmann_machine]]
:[[Self-organizing_map]]
:[[Learning_vector_quantization]]
:[[Long_short-term_memory]]
:[[Liquid_state_machine]]
:[[Autoassociative_memory]]
:[[Convolutional_neural_network]]
:[[Autoencoder]]
:[[Neuroevolution]]
:[[Neuroevolution_of_augmenting_topologies]]
:[[Deep_learning]]
:[[Deep_learning#Deep_neural_network_architectures]]
:[[Deep_belief_network]]
:[[Generative_adversarial_networks]]
** https://stackoverflow.com/questions/4752626/epoch-vs-iteration-when-training-neural-networks
:[[Neural_Turing_machine]]
** http://spinningbytes.com/demos/
:[[Early_stopping]]
:[[ADALINE]]
:[[Memristor]]
:[[Instantaneously_trained_neural_networks]]
:[[Spiking_neural_network]]
* Signal Processing
:[[Optical_character_recognition]]
* Fuzzy Logic
:[[Fuzzy_logic]]
:[[Inference_engine]]
:[[Fuzzy_logic]]
:[[Type-2_fuzzy_sets_and_systems]]
:[[T-norm_fuzzy_logics]]
:[[Adaptive_neuro_fuzzy_inference_system]]
:[[Fuzzy_control_system]]
* Working with spatial data
:[[Spatial_association]]
; Ensemble Techniques
* Weak learner: https://stats.stackexchange.com/questions/82049/what-is-meant-by-weak-learner#82063
:[[Ensemble_learning]]
:[[Ensembles_of_classifiers]]
:[[Ensemble_learning#Implementations_in_statistics_packages]]
* Ensemble Learning = Boosting, Bagging or Stacking: http://stats.stackexchange.com/questions/18891/bagging-boosting-and-stacking-in-machine-learning#19053
* Applying Bagging should help reduce variance and overfitting.
:[[Bootstrap_aggregating]]
:[[Boosting_(machine_learning)]]
:[[Gradient_boosting]]
:[[Committee_machine]]
; Applications
:[[Bayesian_spam_filtering]]
:[[Root_cause_analysis]]
:[[Inpainting]]
* https://github.com/phillipi/pix2pix
* https://www.youtube.com/user/keeroyz
* Chatbots
** Personality
*** https://en.wikipedia.org/wiki/Big_Five_personality_traits
; Experimentation framework
* Goal: test various parameters on various algorithms to determine the best model(s)
* Weka\'s \"Experimenter\" mode: http://weka.sourceforge.net/manuals/ExplorerGuide.pdf
* AutoWeka: http://www.cs.ubc.ca/labs/beta/Projects/autoweka/
* R::mlrMBO: https://github.com/mlr-org/mlrMBO
; Coding / Exposing API to the rest of the application
:[[Microservices]]
; BigData
:[[Data_lake]]
:[[Streaming_algorithm]]
:[[Star_schema]]
:[[OLAP_cube]]
:[[Solid-state_drive]]
:[[MongoDB]]
* Map-Reduce framework
:[[Apache_Hadoop]] https://hadoop.apache.org/
* Scrapping
:[[Apache_Flume]] http://flume.apache.org/
* Storage
:[[Apache_Hadoop#HDFS]] https://hadoop.apache.org/docs/r1.2.1/hdfs_design.html
:[[Apache_HBase]] http://hbase.apache.org/
:[[Apache_Hive]] https://hive.apache.org/
* Transfers - to/from RelationalDB
:[[Sqoop]] http://sqoop.apache.org/
* Transfers - serialization/streaming
:[[Apache_Avro]] http://avro.apache.org/
:[[Apache_Kafka]] https://kafka.apache.org/
* Storage - In memory
:[[Apache_Spark]] https://spark.apache.org/
:[[Apache_Flink]] http://flink.apache.org/
* Admin
:[[Apache_ZooKeeper]] http://zookeeper.apache.org/
:[[Apache_Cassandra]] https://cassandra.apache.org
:[[Ambari]] http://ambari.apache.org/
:[[Apache_Oozie]] http://oozie.apache.org/
* Programming
:[[Pig_(programming_tool)]] https://pig.apache.org/
* ML
:[[Apache_Mahout]] http://mahout.apache.org/
:[[Apache_SystemML]] http://systemml.apache.org/
* Working with text
:[[Apache_Lucene]]
:[[Elasticsearch]] https://www.elastic.co/
* Working with text - Data Viz
:[[Kibana]] https://www.elastic.co/products/kibana
* Small/Micro Data
** https://arxiv.org/abs/1610.00946
:[[Small_data]]
; Multi-Agent Systems
:[[Agent-based_model]]
:[[Multi-agent_system]]
:[[Agent-oriented_software_engineering]]
* https://www.researchgate.net/publication/266182243_Agent_Groupe_Role_et_Service_Un_modele_organisationnel_pour_les_systemes_multi-agents_ouverts [JFerber: AGR Methodology]
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.47.7968&rep=rep1&type=pdf [YDemazeau: Vowels Methodology]
:[[Ant_colony_optimization_algorithms]]
; Quantum Machine Learning
:[[Quantum_machine_learning]]
:[[Quantum_tunnelling]]
:[[Quantum_annealing]]
:[[Adiabatic_quantum_computation]]
; Resources
* http://www.wildml.com/deep-learning-glossary/
* http://deeplearning.net
* https://www.datacamp.com
* http://www.learnpython.org
* https://www.codecademy.com/learn/python
* http://www.dataschool.io/how-to-get-better-at-data-science/
* http://simplystatistics.org/2015/03/17/data-science-done-well-looks-easy-and-that-is-a-big-problem-for-data-scientists/
* Social network for DataScientists
** https://data.world/
; Books
* Free Books
** http://probmods.org/
** http://www.thebiganalytics.com/
** https://www.deeplearningbook.org/
https://github.com/janishar/mit-deep-learning-book-pdf
** http://neuralnetworksanddeeplearning.com/
** http://deeplearning.net/tutorial/deeplearning.pdf
** https://cours.etsmtl.ca/sys843/REFS/Books/ebook_Haykin09.pdf
** http://hagan.ecen.ceat.okstate.edu/nnd.html
** http://www.dkriesel.com/en/science/neural_networks
** https://torres.ai/research-teaching/tensorflow/first-contact-with-tensorflow-book/
** https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/DeepLearning-NowPublishing-Vol7-SIG-039.pdf
** http://camdavidsonpilon.github.io/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/
** http://www.greenteapress.com/thinkstats/thinkstats.pdf
** http://www.greenteapress.com/thinkbayes/thinkbayes.pdf
** http://www.greenteapress.com/thinkpython/thinkpython.pdf
** http://r4ds.had.co.nz/
** https://web.stanford.edu/~hastie/Papers/ESLII.pdf
https://web.stanford.edu/~hastie/ElemStatLearn/printings/ESLII_print10.pdf
** http://www-bcf.usc.edu/~gareth/ISL/ISLR%20Sixth%20Printing.pdf
http://www-bcf.usc.edu/~gareth/ISL/ISLR%20Seventh%20Printing.pdf
** https://web.stanford.edu/~hastie/CASI_files/PDF/casi.pdf
** http://www.cs.huji.ac.il/~shais/UnderstandingMachineLearning/
** https://www.cs.cornell.edu/jeh/book.pdf
** http://infolab.stanford.edu/~ullman/mmds/book.pdf
http://infolab.stanford.edu/~ullman/mmds/booka.pdf
** http://www.guidetodatamining.com/
http://www.guidetodatamining.com/assets/guideChapters/Guide2DataMining.pdf
** http://www.mlyearning.org/
https://github.com/ajaymache/machine-learning-yearning
* Paid Books
** \"Artificial Intelligence for Humans, Volume 1: Fundamental Algorithms\", Jeff Heaton, 2013, ISBN:9781493682225
** \"Artificial Intelligence for Humans, Volume 2: Nature-Inspired Algorithms\", Jeff Heaton, 2014, ISBN: 978-1499720570
** \"Artificial Intelligence for Humans, Volume 3: Deep Learning and Neural Networks\", Jeff Heaton, 2015, ISBN: 978-1505714340
** \"Introduction to Machine Learning (Adaptive Computation and Machine Learning)\", E. Alpaydin, MIT Press, 2004, ISBN: 978-0262012430
** \"Machine Learning: An Artificial Intelligence Approach\", R.S. Michalski, J.G. Carbonell, T.M. Mitchell, Symbolic Computation, 1983, ISBN:978-3540132981
** \"A collection of Data Science Interview Questions Solved in Python and Spark vol I & II\", Antonio Gulli, CreateSpace, 2015, ISBN:978-1517216719
** \"Artificial Intelligence a Modern Approach\", Stuart Russell and Peter Norvig, Prentice Hall, 1995, ISBN:978-0131038059
** \"An Introduction to MultiAgent Systems\", Michael Wooldridge, John Wiley & Sons, 2009 (2nd ed), ISBN:978-0470519462
** \"Data Mining: Practical Machine Learning Tools and Techniques\", Ian H. Witten, Eibe Frank, Mark A. Hall, Christopher J. Pal, Morgan Kaufmann, ISBN:978-0128042915
** \"Agent Intelligence Through Data Mining\", Andreas L. Symeonidis, Pericles A. Mitkas, Springer/Apress, ISBN:978-0387257570
** \"Multiagent Systems: A Modern Approach to Distributed Artificial Intelligence\", Gerhard Weiss, 2000, ISBN:978-0262232036
** \"Data science at the command line\", Janssens, O\'Reilly.
** Also look for MachineLearning, DeepLearning, Spark, Mahout, R, Python, SciKit-Learn, Data/Text Mining, ElasticSearch, Natural Language, Statistics @ O\'Reilly, Packt, Manning/In Action, HeadFirst
* Lists of good books
** https://www.kdnuggets.com/2015/09/free-data-science-books.html
** https://www.kdnuggets.com/2017/04/10-free-must-read-books-machine-learning-data-science.html
** https://www.learndatasci.com/free-data-science-books/
** http://www.wzchen.com/data-science-books
; News/Blogs/RSS
* https://blog.acolyer.org/
* https://www.reddit.com/r/machinelearning
* https://www.reddit.com/r/statistics
* https://www.reddit.com/r/datascience
* https://www.reddit.com/r/bigdata
* http://www.kdnuggets.com/
* http://www.becomingadatascientist.com/
* https://rdatamining.wordpress.com/
* http://www.r-bloggers.com/
* https://dataaspirant.com/
* http://www.joyofdata.de/blog/
* https://www.dataiku.com/blog/
* https://www.datacamp.com/community/
* http://beautifuldata.net/
* http://www.datatau.com/news
* http://dataelixir.com/
* http://www.oreilly.com/data/newsletter.html
* http://blog.kaggle.com/
* http://blog.yhathq.com/
* http://simplystatistics.org/
* http://fastml.com/
* http://www.win-vector.com/blog/
* http://fivethirtyeight.com/
* http://www.dataschool.io/
* https://research.facebook.com/blog/datascience/
* http://deeplearning.net/feed/
* http://learningwithdata.com/
* http://blog.plot.ly/
* https://datasciencelab.wordpress.com/
* https://shapeofdata.wordpress.com/
* http://datalab.lu/
* http://www.pythonweekly.com/
* http://pbpython.com/
* https://plus.google.com/communities/105141578068503684401 ( https://plus.google.com/+JaanaNystr%C3%B6m/posts/MKCV3vNsn1g )
* http://blog.revolutionanalytics.com/2012/12/the-most-influential-data-scientists-on-twitter.html
* http://www.kdnuggets.com/2012/12/most-influential-data-scientists-on-twitter.html
* https://journal.r-project.org/
; Podcasts
* http://www.learningmachines101.com/
* http://www.thetalkingmachines.com/
* http://dataskeptic.com/
* http://www.partiallyderivative.com/
* http://www.ocdqblog.com/podcast/
* http://blog.pivotal.io/podcasts-pivotal
* https://www.udacity.com/podcasts/linear-digressions
* http://datastori.es/
* http://radar.oreilly.com/tag/oreilly-data-show-podcast
* http://freakonomics.com/radio/freakonomics-radio-podcast-archive/
* http://simplystatistics.org/category/podcast/
* http://data-informed.com/multimedia/podcasts/
* http://www.bbc.co.uk/programmes/p02nrss1
; YT Channels
* https://www.youtube.com/user/keeroyz
* https://www.youtube.com/channel/UCWN3xxRkmTPmbKwht9FuE5A
* https://www.youtube.com/channel/UCioEIe1o73G-oGR4b34E7Dg
* https://www.youtube.com/channel/UCNIkB2IeJ-6AmZv7bQ1oBYg
* https://www.youtube.com/channel/UC9LfrPNcIyHspci0t2W4T_w
* https://www.youtube.com/channel/UCHBWJGoZMkhJyElgvuN1U1w
* https://www.youtube.com/user/dataschool
* https://www.youtube.com/channel/UCtY8JjMQpzYb5FFvUr2JnUw
* https://www.youtube.com/channel/UCRhUp6SYaJ7zme4Bjwt28DQ
* https://www.youtube.com/user/sentdex
* https://www.youtube.com/user/DataScienceDojo
; MOOCs
* Generic
** http://datasciencemasters.org/
** https://arxiv.org/abs/1601.06862v1
* Weka
** http://www.cs.waikato.ac.nz/ml/weka/mooc/dataminingwithweka/
** http://www.cs.waikato.ac.nz/ml/weka/mooc/moredataminingwithweka/
** http://www.cs.waikato.ac.nz/ml/weka/mooc/advanceddataminingwithweka/
* Andrew Ng
** https://www.youtube.com/watch?v=UzxYlbK2c7E&list=PLJ_CMbwA6bT-n1W0mgOlYwccZ-j6gBXqE
* Yann Lecun
** https://www.college-de-france.fr/site/yann-lecun/course-2015-2016.htm
* Ans Rosling (visualization)
** https://www.youtube.com/results?search_query=ans+rosling
* From renown Universities
** https://www.coursera.org/specializations/jhu-data-science
** https://www.coursera.org/specializations/machine-learning
** https://www.coursera.org/specializations/data-science-python
** https://www.coursera.org/specializations/big-data
** https://www.coursera.org/learn/machine-learning
** https://www.coursera.org/learn/r-programming
** https://www.coursera.org/learn/data-scientists-tools
** https://www.coursera.org/learn/python-data-analysis
** http://www.holehouse.org/mlclass/
** http://online.stanford.edu/course/statistical-learning
** http://work.caltech.edu/telecourse.html
** https://www.udacity.com/course/data-analyst-nanodegree--nd002
** https://www.thinkful.com/courses/learn-data-science-online/
** https://www.edx.org/course/introduction-computer-science-mitx-6-00-1x7
** https://www.coursetalk.com/
** https://github.com/justmarkham/DAT7#bonus-resources
** http://datasciencemasters.org/
** http://www.wolfram.com/broadcast/c?c=99
** http://www.wolfram.com/broadcast/c?c=97
** http://www.wolfram.com/broadcast/c?c=397
* DataSchool
** http://www.dataschool.io/learn/
; Jobs
* https://datajobs.com/
* http://www.analytictalent.com/
* http://www.kdnuggets.com/jobs/index.html
* https://fr.hired.com/
; Teaching
http://edison-project.eu/edison/edison-data-science-framework-edsf
; Curated list of similar pages
https://github.com/search?utf8=%E2%9C%93&q=curated+list+awesome+frameworks&type=
https://github.com/josephmisiti/awesome-machine-learning
https://github.com/onurakpolat/awesome-bigdata
https://github.com/onurakpolat/awesome-analytics
https://github.com/analyticalmonk/awesome-neuroscience
https://github.com/igorbarinov/awesome-data-engineering
https://github.com/quantmind/awesome-data-science-viz
https://github.com/fasouto/awesome-dataviz
https://github.com/qinwf/awesome-R
https://github.com/datascience-python/awesome-datascience-python
https://github.com/caesar0301/awesome-public-datasets
- (3376)What are the \"Kullback-Leibler divergence\" and \"Wasserstein metric\"?
- Kullback-Leibler divergence
- It\'s a measure of the difference between 2 porbability distributions.
- It\'s used in the loss function of VAEs (Variational Auto Encoders) to constrain the latent space to converge towards a distribution.
- It\'s easier to calculate the derivative of this function (thus NN gradients) than for Wasserstein.
From: https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
- Wasserstein metric
- It\'s a measure of distance between 2 probability distributions
- It\'s used in Domain Adaptation (Optimal Transport & Transfer Learning) to enable a NN to pre-train on different but similar dataset.
From: https://en.wikipedia.org/wiki/Wasserstein_metric
- (3377)What are MAP and MLE?
Those are methods to estimate the parameters of a probability distribution.
MAP: maximizes the mode of the posterior distribution (?).
MLE: maximizes a likelihood function, so that under the assumed statistical model, the observed data is most probable.
From: https://en.wikipedia.org/wiki/Maximum_likelihood_estimation
https://en.wikipedia.org/wiki/Maximum_a_posteriori_estimation
- (3398)Gigerenzer’s simple rules
"a simple rule in a complex world can outperform a complex rule in an artificially simplifi*ed* world"
Also see Daniel Kahneman: "Thinking, Fast and Slow 2011/2017.
From: https://www.foundingfuel.com/article/gigerenzers-simple-rules/
- (3430)What are the 'flavors' of AlphaGo?
- https://en.wikipedia.org/wiki/AlphaGo
+ Intial program
+ Trained against humans
+ Plays only go
+ Beat Lee Sedol in 2016
+ Beat Fan Hui in 2015
+ Uses Monte-Carlo Search Trees + Deep NN
- https://en.wikipedia.org/wiki/AlphaGo_Zero
+ Totally self-taught, no human games
- https://en.wikipedia.org/wiki/AlphaZero
+ Plays several games: chess, shogi and go.
+ Within 24 hours of training achieved a superhuman level on these 3 games
- https://en.wikipedia.org/wiki/MuZero
+ Not even the rules where given!
+ Also masters 57 Atari games!
- (3431)The "problems" of current AI and the dangers that AlphaGo & friends revealed...
- Until 2015 (AlphaGo) I was convinced the AI/ML/... would never (at least in my life time) beat humans in a single very complex task, not to say that a so called "General Intelligence" (capable at solving/mastering multiple complex tasks) or "Super Intelligence" (AI > human) would ever exist.
- Since the appearance of AlphaGo & friends, I totally switched my mind (and I'm really afraid of what AI can achieve):
+ AlphaGo showed that *human performance can be beaten in the most complex task we can think of*
+ AlphaGoZero showed that even *without initial human knownledge* it can beat humans and even AlphaGo
+ AlphaGoZero showed that once the "human" level is achieved, *AI can still improves*, and x minutes later be y times better than any human
+ AlphaZero showed that a *single program* can solve *many complex* problems, and beat human perf in all of them
+ MuZero showed that even *without being provided the rules* of the games, it can (i) *beat human performance* (ii) in *multiple complex tasks* (iii) *continue to learn and exceed human performance*
So MuZero IS the first "General AI"/"Super Intelligence"!!!
From: https://en.wikipedia.org/wiki/AlphaGo
https://en.wikipedia.org/wiki/AlphaGo_Zero
https://en.wikipedia.org/wiki/AlphaZero
https://en.wikipedia.org/wiki/MuZero
- (3438)How does Back Propagation work?
- Reminder: the forward pass consists in:
0. Collect Input & Layer Weights
1. Compute Weighted Sum
2. Compute Activation
3/ Compute Error
- The backward pass will reverse these steps, using the chain rule (https://en.wikipedia.org/wiki/Chain_rule):
https://matthewmazur.files.wordpress.com/2018/03/output_1_backprop-4.png?w=525
1. Distribute error/gradient with respect to the layer's output/Activation => gradient'
2. Distribute gradient' with respect to Weighted Sum => gradient''
3a. Distribute gradient'' with respect to Individual Weights => gradient'''
3b. Distribute gradient'' with respect to Inputs => gradient''''
gradient''' = ∂E/∂w_i = ∂E/∂o * ∂o/∂ws * ∂ws/∂w_i, where
+ E = error/gradient backpropagated from next layer
If you use MSE as error metric => derivative explained here: https://sebastianraschka.com/faq/docs/mse-derivative.html
+ o = network output (Activation function)
If you use Sigmoïd as activation => derivative explained here: https://sebastianraschka.com/faq/docs/logisic-sigmoid-derivative.html
+ ws = weighted sum
+ w_i = initial weights
Similarly gradient'''' = ∂E/∂in = ∂E/∂o * ∂o/∂ws * ∂ws/∂in, where in = inputs. Note that we can reuse the 2 first parts ∂E/∂o and ∂o/∂ws!
+ Gradient'''' is what is transfered to previous layer:
https://sebastianraschka.com/images/faq/backprop-arbitrary/backprop-2.png
From: https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example/
https://sebastianraschka.com/faq/docs/backprop-arbitrary.html
- (3440)How to write a research paper?
To put in simple words a research paper is a short explanation of your findings using certain methods for executing the experiment. A research paper/ research article is a research report written within 5 to 6 pages at the maximum. The essence of an original research article consists of these important parts.
- Abstract: It is normally written in 100 words at the maximum which explains what the paper is all about.
GM: Most people will read only this abstract, thus all the points below (including results) should be present here.
- Introduction: it gives the background of research and gives a description of the topic of research.
- Literature review: A short review is done normally within a paragraph or two which can either be included in the introduction or given in a separate title. The literature review normally concludes by identification of missing links in the research or some extension that is possible.
- Objective: The objective is normally a product or process that is being proposed by the researcher.
- Proposed methodology: The proposed methodology describes what the method you are going to execute or what the new product that is to be obtained by which method.
- Results/Observations: By executing the proposed methodology the observations made are listed in this section.
- Interpretation of results: The interpretation of the observed results are done in this section. If the interpretation is going to be small, it can be combined with the conclusion. If the interpretation is going to be large, it can be separated from the conclusion.
- Conclusion: It describes what you learnt from the particular experiment conducted after interpreting the results and giving the concluding remarks for the research.
- References: References are an important section for the research paper as you would have considered one of the already published paper to identify the shortcomings in that research or you would have clubbed a process of one outcome with another process and identify the net outcome. So it is important to quote the research articles in your paper whereever necessary.
GM: MUST include "background" works (works from which you borrowed ideas, e.g. math theory that you reuse in CS paper) & "previous" works (works that have attempted a similar goal as yours, but have failed or solve in a limited scope - you should OBJECTIVELY explain what are their limits in the litterature review section) & "(current) competitive" works (those that are currently trying to reach the same goal as yours, you need to explain what you are doing differently - ≠goal?/≠method?/≠results? - in the litterature review section)
NOTE: If you are introducing a new Model/Theory, you need to show it works (if not mathematically, at least in a few practical examples), thus introduce the application domain & use case and their relevance for society.
Also Read: https://spie.org/samples/9781510619142.pdf
From: https://www.quora.com/What-is-a-research-paper-and-how-do-I-write-one/answer/Ajai-Vaidyanathan
- (3441)How to overcome the feeling that "everything as already been done in the domain" when doing research?
PROBLEM:
- If you do too much reading, you might end up thinking that everything has already been done in the domain. Your brain will switch from active mode, where it's constantly trying to make connections between the ideas in the papers and your research problems, to passive mode, where you read the text, and understand the text, but your brain is too tired to do anything more.
SOLUTION:
- Write notes when reading papers [Emacs::org-mode is nice for that!]
+ This will help "offload" your (often partial) ideas and leave more space to your brain to do creative thinking
- *Revisit your notes* from time to time. When your relaxed mind will read all these ideas together, it will starts making connections again between them.
From: https://www.quora.com/How-do-you-come-up-with-new-ideas-for-PhD-research-or-research-in-general/answer/Saurav-Muralidharan
- (3442)How to generate new ideas for research?
- Crowdsourcing: Discuss with others
+ Go outside normal circles
- Discuss with more / less graduated people in the same domain
- Discuss with people from other domains
+ Join Slack/Mattermost/Discord channels
+ Join Meetups & Attend Conferences
- Observe/Read & Take notes + re-read them from time to time
+ Read Books
+ Randomly surf the web
- Semi Randomly: remove/add/change a few keywords from your normal queries to access to broaden/narrow/displace your focus
- Totally Randomly
- Use "structured exercices"
+ Rapid Ideation/McCormick's Game
- Set a timer (ten minutes)
- With a partner
- Come up with 42 ideas on a specific topic or problem
- Defer judgement
- Encourage weird, wacky, and wild ideas
- Aim for quantity
- Be visual
+ Brainstorming
- https://simplyeducate.me/2012/11/10/brainstorming-tips/
- Quantity is more important than quality
- Do it regularly: https://nesslabs.com/mindframing
- Choose a technique:
+ Combinational creativity
+ Exploratory creativity
+ Transformational creativity
- Use following process
+ Set your focus
+ Gather new material
+ Generate ideas
+ Test ideas
+ Select & refine ideas
+ Analytic Brainstorming
- Create a MindMap
+ Reverse Brainstorming
- Find ways to *cause* the problem instead of solving it
+ Gap Filling
- Write a statement of where you are and one of where you'd like to be
- Fill the gap
+ Drivers Analysis (similar to reverse):
- Try to find "what is driving" the various actors of the problem (clients/competitors/...)
+ SWOT Analysis
- Identify Strengths, Weaknesses, Opportunities and Threats
- https://business.tutsplus.com/articles/take-a-swot-at-better-planning-for-your-consulting-business--fsw-33251
+ The Five Whys:
- Start with a problem.
- "Ask why is it happening?"
- Continue asking the question on the answer to the previous answer, 4 more times.
+ Braindump / Brainwriting / Brainwalking
- https://www.interaction-design.org/literature/article/learn-how-to-use-the-best-ideation-methods-brainstorming-braindumping-brainwriting-and-brainwalking
From: https://www.researchgate.net/post/How_to_come_up_with_Research_Ideas3#58530ca4dc332d4a147b2bc4
https://www.inc.com/kevin-daum/7-ways-to-generate-great-ideas.html
https://simplyeducate.me/2013/03/19/generate-your-research-topic/
https://nesslabs.com/brainstorming
https://business.tutsplus.com/articles/top-brainstorming-techniques--cms-27181
https://www.collegebasics.com/blog/5-ways-to-brainstorm-ideas-for-your-research-paper/
- (3461)Common mistakes when writing a scientific paper
- Not emphasising on "why" the problem you are trying to solve is important (for society)
- Weakly structuring the paper
- Citing the sources incorrectly
- Not enriching with appropriate figures and tables
- Forgetting the Reader (Who, What, When, Where, Why, How)
- Not Writing the Perfect Abstract
- Not Mastering English Grammar
- Using Passive Voice
- Not Vary Enouh Your Word Choices
- Not Reading the Works of Others
- The research question is not specified
- The stated aim of the paper is tautological (e.g. ‘The aim of this paper is to describe what we did’) or vague (e.g. ‘We explored issues related to X’)
- The structure of the paper is chaotic (e.g. methods are described in the Results section)
- The manuscripts does not follow the journal’s instructions for authors
- The paper much exceeds the maximum number of words allowed
- The Introduction is an extensive review of the literature
- Methods, interventions and instruments are not described in sufficient detail
- Results are reported selectively (e.g. percentages without frequencies, P-values without measures of effect)
- The same results appear both in a table and in the text
- Detailed tables are provided for results that do not relate to the main research question
- In the Introduction and Discussion, key arguments are not backed up by appropriate references
- References are out of date or cannot be accessed by most readers
- The Discussion does not provide an answer to the research question
- The Discussion overstates the implications of the results and does not acknowledge the limitations of the study
- The paper is written in poor English
From: https://blog.typeset.io/4-common-research-writing-mistakes-and-how-to-fix-them-87fa1ca2b513
https://www.fresheyesediting.com/2018/03/19/avoid-these-common-scientific-writing-mistakes/
https://academic.oup.com/intqhc/article/16/3/191/1814554
- (3462)What is a typical structure for a scientific paper?
- Introduction
  - State why the problem you address is important
  - State what is lacking in the current knowledge
  - State the objectives of your study or the research question
- Methods
  - Describe the context and setting of the study
  - Specify the study design
  - Describe the ‘population’ (patients, doctors, hospitals, etc.)
  - Describe the sampling strategy
  - Describe the intervention (if applicable)
  - Identify the main study variables
  - Describe data collection instruments and procedures
  - Outline analysis methods
- Results
  - Report on data collection and recruitment (response rates, etc.)
  - Describe participants (demographic, clinical condition, etc.)
  - Present key findings with respect to the central research question
  - Present secondary findings (secondary outcomes, subgroup analyses, etc.)
- Discussion
  - State the main findings of the study
  - Discuss the main results with reference to previous research
  - Discuss policy and practice implications of the results
  - Analyse the strengths and limitations of the study
  - Offer perspectives for future work
From:
- (3476)How to One-hot encode a Pandas Dataframe?
df = pd.DataFrame({'country': ['russia', 'germany', 'australia','korea','germany']})
pd.get_dummies(df["country"],prefix='country',drop_first=True)
From: https://queirozf.com/entries/one-hot-encoding-a-feature-on-a-pandas-dataframe-an-example
- (3493)List of DataScience Notebooks
https://jupyter.org/try
https://deepnote.com/
https://colab.research.google.com/
https://www.kaggle.com/code
https://cocalc.com/
https://mybinder.org/
https://codalab.org/
https://replit.com/
[Following need registration?]
https://www.paperspace.com/
https://datalore.jetbrains.com/
https://visualstudio.microsoft.com/vs/features/notebooks-at-microsoft/
- (3532)GUI tools for visual Data Processing/Data Science/Machine Learning
#+TITLE: Data Processing GUIs
#+AUTHOR: Guillaume MULLER
* Java
- Weka (Java)
https://www.cs.waikato.ac.nz/ml/weka/
- DataMelt (Java)
https://datamelt.org/?id=current
* Python
- Orange3/orange-canvas (Python)
https://orangedatamining.com/
- SOFA
https://launchpad.net/sofastatistics
https://git.launchpad.net/sofastatistics
* R
- Rattle / [r]ggobi (R)
https://rattle.togaware.com/
https://github.com/ggobi/rggobi
- RKWard (R)
https://rkward.kde.org/
- DeduceR (R)
https://www.deducer.org/
- Rcmdr (R)
https://socialsciences.mcmaster.ca/jfox/Misc/Rcmdr/
- R Analytic Flow (R/Java)
http://r.analyticflow.com/en/
- Esquisse (R - mostly graphs)
https://github.com/dreamRs/esquisse
* C/C++
- PSPP (C)
https://www.gnu.org/software/pspp/get.html
http://git.savannah.gnu.org/cgit/pspp.git
- JASP (C/JS)
https://jasp-stats.org/
https://github.com/jasp-stats/jasp-desktop
- Jamovi (C/JS)
https://www.jamovi.org/download.html
https://github.com/jamovi/jamovi/
- ParaView
https://www.paraview.org/download/
* Online (FLOSS)
https://perspective.finos.org/ (PowerBI/Tableau-like)
https://github.com/radiant-rstats/radiant (Shiny App)
https://github.com/RamiKrispin/MLstudio (Shiny App)
https://github.com/cargomoose/ggraptR (Shiny App)
https://www.rollapp.com/launch/jasp
https://cloud.jamovi.org/
* Commercial
https://www.perceptilabs.com/
https://wandb.ai/site
https://jasp-stats.org/download/
* Resources
- https://alternativeto.net/list/2063/guis-to-save-from-typing-r-code/
- (3536)How to present quantified results in a scientific paper (e.g. to compare multiple ML models performances)?
- Generate results over *multiple repetitions* of the "simulation" (e.g. 10 or 100 times)
- Put the results in a table: average *and stdev*
- Highlight the best model for each criteria. To determine if the difference between 2 models is significant, use a statistical test:
- Generally a "Student t-Test" is sufficient
- If there are outliers, prefer the "Wilcoxon" test
Thanks ChL
- (3539)How to interpret the loss of a VAE?
As the Sampling can be interpreted as creating Bubbles in the lattent space (vs creating Points in an classical AE).
The VAE can be interpreted as creating a "bubble-of-bubbles", and the VAE loss can be interpreted as follows:
VAELoss = C + V + U, where:
- C : prevents bubbles from overlaping
- V : limits the size of the bubbles
- U : decreases the distance between the bubbles
From: https://www.youtube.com/watch?v=7Rb4s9wNOmc
https://www.youtube.com/watch?v=ZaVP2SY23nc
https://twitter.com/alfcnz/status/1118363717635399683?lang=en
https://atcold.github.io/pytorch-Deep-Learning/en/week07/07-3/
https://atcold.github.io/pytorch-Deep-Learning/en/week08/08-3/
https://atcold.github.io/pytorch-Deep-Learning/
- (3557)What is weakly supervised learning?
Types of Weak Supervision
4.1. Incomplete Supervision
In this type, only a subset of the training data is labeled. In most cases, this subset is correctly and accurately labeled but not sufficient for training a supervised model.
4.2. Inexact Supervision
The given labels in this type are imprecise (Thinks Multi-label supervision where we have only 1 of the labels).
4.3. Inaccurate Supervision
In this type, there are wrong or low-quality labels.
From: https://www.baeldung.com/cs/ml-weakly-supervised-learning
- (3576)What is the Micro-F1 score?
Micro F1-score (short for micro-averaged F1 score) is used to assess the quality of multi-label binary problems.
It measures the F1-score of the aggregated contributions of all classes.
Micro F1-score​ = ​2∗(Micro-precision * Micro-recall​​)/(Micro-precision + Micro-recall)
Micro-recall = TP_sum​​/(TP_sum​ + FN_sum​)
Micro-precision= TP_sum​​/(TP_sum​ + FP_sum​)
Where X_sum is the sum of 'X's for all classes. E.g., TP_sum is the sum of TP for all classes.
From: https://peltarion.com/knowledge-center/documentation/evaluation-view/classification-loss-metrics/micro-f1-score
- (3580)How does a Kalman filter works?
https://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/
- (3623)A good article on the problems of public sector in France (also valid for French Research)?
« Excel m'a tué » : comment la bureaucratie a asphyxié notre système hospitalier
https://www.nouvelobs.com/sante/20220129.OBS53836/excel-m-a-tue-comment-la-bureaucratie-a-asphyxie-notre-systeme-hospitalier.html
- (3626)How to anonymize Data?
Methods:
- k-Anonimization (not robust if you possess another dataset which you can cross with the anonymized one)
https://en.wikipedia.org/wiki/K-anonymity
- l-diversity
https://en.wikipedia.org/wiki/L-diversity
- Differential Privacy
https://en.wikipedia.org/wiki/Differential_privacy
https://www.cis.upenn.edu/~aaroth/Papers/privacybook.pdf
- Random projections
https://en.wikipedia.org/wiki/Random_projection
https://www.ijcai.org/Proceedings/2019/395
Attacks:
- https://en.wikipedia.org/wiki/Data_re-identification
Tools:
- https://arx.deidentifier.org/
- https://github.com/Nuclearstar/K-Anonymity
https://en.wikipedia.org/wiki/Privacy_engineering
https://en.wikipedia.org/wiki/Data_anonymization
- (3631)Where to get powerful FLOSS tools for work (free VMs with GitLab, Mattermost, ShareLaTeX, etc.)?
https://humanid.huma-num.fr/
https://plm-doc.math.cnrs.fr/
https://www.reseau-canope.fr/
And, of course:
https://status.framasoft.org/
https://www.chatons.org/
- (3642)What is the Mel scale?
The mel scale (after the word melody)[1] is a perceptual scale of pitches judged by listeners to be equal in distance from one another.
The reference point between this scale and normal frequency measurement is defined by assigning a perceptual pitch of 1000 mels to a 1000 Hz tone, 40 dB above the listener's threshold. Above about 500 Hz, increasingly large intervals are judged by listeners to produce equal pitch increments.
NOTE: this scale can be used to pre-process (music-like) data before sending it to a ML algorithm (e.g. it is used by google for classifying songbirds: https://ai.googleblog.com/2022/01/separating-birdsong-in-wild-for.html).
From: https://en.wikipedia.org/wiki/Mel_scale
- (3676)What are the techniques for data anonymisation?
- There are 3 classes of approaches:
-> by Suppressing data
-> by Randomizing data
-> by Generalizing data
- De-Identification (Removal of nominative/sensitive attributes) [Suppressing]
=> does not work, there are plenty of re-identification techniques
- either from other features from the same dataset (e.g. there might be only one person paying taxes in a large area, so removing her name is not sufficient, since reducing the area for which we query information can reveal information about this single individual)
- or from crossing with other data from the same dataset (e.g. in a small medical datasets, there is a very low probability that data attached to a same weight/height/age combination belongs to 2 different persons)
- or from crossing several datasets (e.g. by finding patterns in pathes regularly by people in the Uber dataset, one can find pathes from home to work by a single individual. By crossing with phone "fadettes" or house ownership data one can recover the name of this person).
- K anonymity [Generalizing?]
https://en.wikipedia.org/wiki/K-anonymity
- L diversity [Generalizing?]
https://en.wikipedia.org/wiki/L-diversity
- ɛ-Differential privacy [Randomizing]
https://en.wikipedia.org/wiki/Differential_privacy
- Artificial data Synthesis [Generalizing]
https://libgen.li/edition.php?id=1405__TOREMOVE__13818 [Generative AI with Python and TensorFlow 2]
https://libgen.li/edition.php?id=1407__TOREMOVE__38903 [Deep Generative Modeling]
https://en.wikipedia.org/wiki/Variational_autoencoder
https://en.wikipedia.org/wiki/Generative_adversarial_network
Thanks Maxime
- (3677)How to find research topics on which to work (e.g. for master students)?
- Read the Abstract & Conclusion of papers, they often propose extensions to their work that they will never do :)
Thanks Kamal
- (3678)What could be considered an anonymized dataset?
- Individualization
-> it must not be possible to identify a person (i.e. link initial data to a given instance/name)
- Correlation
-> it must not be possible to link 2 distinct datasets about a single person
- Inference
-> it must not be possible to deduce (new) information about a single person
- (3695)What are the differences between Collaboration, Cooperation & Coordination?
===
- Coordination
+ *Workers' actions are directed* by a coordinator in order to achieve common goals
+ The coordinator *assigns tasks* => hierarchical or role-based system
+ The coordinator develops processes and assignments
+ Participants' tasks are *aligned* (least amount of waste)
+ Coordination is about *efficiency*
+ *Individual* workers might *not* be fully *aware* of the *macro-level goal*
+ Requires *Communication*: focused on assignment and status of tasks (i.e. *coordinator <-> workers*)
- Cooperation
+ Each have their *own goals* (don't necessarily have to be aware of the other users' goals)
+ Behave in such a way as to *not interfere* with each other
+ Example: Two children independently coloring separate pictures, but with a shared box of crayons.
+ Requires *Communication*: particularly when *goals overlap* (potential for conflict)
+ Requires (initial) establishment of Shared rules
+ Example: The children agree to return crayons to the box when they are not actively drawing with them, so they will be available to the other child. If one child needs a particular crayon that is in use, that child can let the other child know he needs it.
- Collaboration
+ *Shared creation*
+ Workers *share high-level* shared vision of the *goals* (but may not fully understand how to get there)
+ Each worker comes with *different skill sets*/world views/ideas about how to achieve their shared goals
+ Ideally: workers will *complement* their skill sets => create something of higher quality than what any of the individual would have created alone
+ Collaboration values *ideation and creation over process and efficiency*
+ Requires *Communication*: Iterative process / *continuous refinement*
From: https://convergencelabs.com/blog/2018/01/the-four-cs-communication-coordination-cooperation-and-collaboration/
===
- Collaboration is when a group of people come together and work on a project in support of a *shared objective*, outcome, or mission.
E.g.: a photographer working with a designer to create a cover image
- Cooperation is when a group of people work in support of another's goals.
E.g.: when two people move a box together, one because is it in her way, the other because she wants to climb on it to reach some higher point.
From: https://blog.jostle.me/blog/collaboration-vs-cooperation
===
- Coordination
+ *Planning* / proper order or relationship
+ Balanced and effective interaction of harmonious functioning
- Cooperation (think *co-*operate)
+ Collective action for a *common purpose*
+ *Willingness to assist*
+ Requires Consensus
- Collaboration
+ Work with another on a joint project with *shared purpose*
+ Work, usually willingly, *with an enemy*
+ Deep, collective determination to reach an *identical objective*
+ Collaboration requires leadership (even if decentralized)
From: https://medium.com/teal-for-startups/coordination-cooperation-and-collaboration-d75e89d828a7
- (3705)Best article on Research Metrics (citations) criticism/bias
https://link.springer.com/content/pdf/10.1007/s00283-021-10146-x.pdf
- (3711)How to scrape Google Scholar Papers within a particular conference?
See https://dev.to/dmitryzub/scrape-google-scholar-papers-within-a-particular-conference-in-python-3h79
- (3712)What's "the First Law of Papers"?
"Research is a process: do not look at where we are, look at where we will be two more papers down the line"
From: https://youtu.be/_Y1-KlTEmwk?t=284
https://www.youtube.com/watch?v=9JZdAq8poww&t=491s
- (3713)What's SELU activation function?
Normalized outputs seem to be really helpful in stabilizing the training process. That’s the main reason behind the popularity of BatchNormalization. SELU is a way to output the normalized activations to the next layer.
- (3721)Good short intro to Deep NN pruning
https://towardsdatascience.com/neural-network-pruning-101-af816aaea61
- (3737)What is the difference btween Explainability & Interpretability for Machine Learning Models?
- Interpretability is an intrinsic property of the model (e.g. DecisionTrees are interpretable), it simply means that the model can be read/understood by a human
- Explainability means that we need/can run an external process to answer why an algorithm produces the responses it produces.
- You can try to explain why the whole model behaves in a given way
- You can try to explain a single prediction
- There are explainability processes based on:
+ linking output to inputs/features (e.g. "heatmaps" on images, feature maps/shapeley/lime values)
+ providing examples
+ providing internal representations, mostly for NNs (e.g. Google DeepDreams)
+ distillation to an interpretable model
+ ...
From: https://prevision.io/blog/explainability-versus-interpretability-of-machine-learning-models/
- (3762)Where to find examples of graphs it is possible to draw in Python?
https://www.python-graph-gallery.com/
- (3770)What's the difference between similarity measure and distance measure?
A distance function, mathematically, has certain important properties but there is no equivalent rigorous definition of similarity. Thus the terms are not simply interchangeable as the complements of each other.
To be a proper distance, a function d must have the following properties:
- positivity:
d(x,y) >= 0
- symmetry:
d(x,y) = d(y,x)
- identity-discerning:
d(x,y) = 0 => x = y
- triangle inequality:
d(x,z) <= d(x,y) + d(y,z)
It's reasonable to talk for example about the cosine similarity coefficient in a vector space, as the cosine of the angle between two vectors which is efficient to calculate and neatly bounded in [0,1], but it’s technically incorrect to talk about a cosine distance as being 1 minus this coefficient, because that function *doesn't have the triangle inequality property*. The term "divergence" is sometimes used for functions like this, but that also has other meanings. However other well-known similarity measures, such as the Jaccard similarity coefficient, are the complement of a proper distance function, so it's quite correct to talk about Jaccard distance as the complement of Jaccard similarity. But you need to know your function really quite well before doing this!
The easy answer is that "similarity measure" can be used quite safely for any numeric function that correlates with some notion of similarity, but you need to be careful before you call something a "distance measure".
From: https://www.quora.com/Whats-the-difference-between-similarity-measure-and-distance-measure
- (3771)What are the most classical types of similarity and dissimilarity measures used in data science?
- L1 norm == Manhattan, or Taxicab, or City Block distance
https://en.wikipedia.org/wiki/Taxicab_geometry
- L2 norm == Euclidean distance
https://en.wikipedia.org/wiki/Euclidean_distance
- Lp norm == Minkowski distance
https://en.wikipedia.org/wiki/Minkowski_distance
- L∞ norm, Chebyshev distance, maximum distance
https://en.wikipedia.org/wiki/Chebyshev_distance
- Hamming distance
https://en.wikipedia.org/wiki/Hamming_distance
- Mahalanobis distance
https://en.wikipedia.org/wiki/Mahalanobis_distance
- Cosine similarity
https://en.wikipedia.org/wiki/Cosine_similarity
- Chi-square divergence (difference between two probability distributions) Also See Tip#3376
https://en.wikipedia.org/wiki/Chi-squared_divergence
- Jensen-Shannon divergence (idem)
https://en.wikipedia.org/wiki/Jensen%E2%80%93Shannon_divergence
- Wasserstein metric (idem)
https://en.wikipedia.org/wiki/Wasserstein_metric
- Kullback-Leibler divergence (idem)
https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
- Sørensen–Dice coefficient (between two samples)
https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient
- Jaccard/Tanimoto index (between sets)
https://en.wikipedia.org/wiki/Jaccard_index
- Pearson Correlation coefficient (idem)
https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
- Spearman correlation (between ranks)
https://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficient
- Levenshtein distance (between strings) Also See Tip#1951
https://en.wikipedia.org/wiki/Levenshtein_distance
- Canberra distance (between pairs of points)
https://en.wikipedia.org/wiki/Canberra_distance
From: https://towardsdatascience.com/17-types-of-similarity-and-dissimilarity-measures-used-in-data-science-3eb914d2681
- (3777)What is the best dataset for learning the datascience process?
I like the Datazaurus Dozen because all the datasets share the same statistics, but they *look* very different:
https://juliasilge.com/blog/datasaurus-multiclass/featured.png
=> teaches students that human vision is very good at extracting patterns from visualizations
=> thus, it is important to use visualization techniques as soon as possible in the datascience process (EDA phase) to understand ASAP what will be possible to do/learn automatically from the data.
From: https://www.rdocumentation.org/packages/datasauRus/versions/0.1.6
- (3804)What are Shallow Neural Networks?
In short, "shallow" neural networks is a term used to describe NN that usually have *only one hidden layer* as opposed to deep NN which have several hidden layers, often of various types.
https://pdfs.semanticscholar.org/f594/f693903e1507c33670b89612410f823012dd.pdf
Both shallow and deep networks are capable of approximating any function. For the same level of accuracy, deeper networks can be much more efficient in terms of computation and number of parameters. Deeper networks are able to create deep representations, at every layer, the network learns a new, more abstract representation of the input.
From: https://www.researchgate.net/post/Why_Are_Deep_Networks_Better_Than_Shallow_Ones/5d57e15d4921ee528a555a52/citation/download
- (3821)Simple cartoonish intro to ReInforcement Learning
https://hackernoon.com/_next/image?url=https%3A%2F%2Fcdn.hackernoon.com%2Fhn-images%2F1*JJ3Dx4O3blc_haCUjv5Y5A.jpeg&w=1200&q=75
- (3828)How to train for a Job Interview?
https://dev.to/areedev/google-launched-the-best-interview-preparation-tool-24n9
- (3882)Where to find information about papers/author/reviewer's reputation?
Papers that are retracted are listed here:
https://retractionwatch.com/
For instance: A whole conference did not respect Peer Review => all papers where retracted:
https://retractionwatch.com/2022/12/06/publisher-retracts-400-papers-at-once-for-violations-of-peer-review-process-policies/
- (3889)Where to find grants/funding opportunities for research?
https://www.grantway.com/
- (3907)List of Open Science sites/tools
https://www.ccsd.cnrs.fr/en/category/hal-en/
https://about.zenodo.org/
https://academictorrents.com/
- (3909)What are Pre-Attentive Attributes (a.k.a. How to draw attention to specific parts of your presentations/visualizations)?
It's a visual technique to help your audience focus its attention on what you want on your presentation slides/data visualizations.
- Line Length
- Line Thickness
- Orientation
- Added Marks
- Enclosure ("entourer" in .fr)
- Shape
- Size
- Color
- Saturation
- 2D Position
- Motion
From: https://www.youtube.com/watch?v=l1Ym-F7gqQw
- (3910)What are most prominent Machine Learning Model flaws?
| Name | Methodology | What’s right | What’s wrong | |
| Bayesian Learning | You specify a prior probability distribution over data-makers, P(datamaker) then use Bayes law to find a posterior P(datamaker | x) . True Bayesians integrate over the posterior to make predictions while many simply use the world with largest posterior directly. | Handles the small data limit. Very flexible. Interpolates to engineering. | Information theoretically problematic. Explicitly specifying a reasonable prior is often hard. Computationally difficult problems are commonly encountered. Human intensive. Partly due to the difficulties above and partly because “first specify a prior” is built into framework this approach is not very automatable. |
| Graphical/generative Models | Sometimes Bayesian and sometimes not. Data-makers are typically assumed to be IID samples of fixed or varying length data. Data-makers are represented graphically with conditional independencies encoded in the graph. For some graphs, fast algorithms for making (or approximately making) predictions exist. | Relative to pure Bayesian systems, this approach is sometimes computationally tractable. More importantly, the graph language is natural, which aids prior elicitation. | Often (still) fails to fix problems with the Bayesian approach. In real world applications, true conditional independence is rare, and results degrade rapidly with systematic misspecification of conditional independence. | |
| Convex Loss Optimization | Specify a loss function related to the world-imposed loss fucntion which is convex on some parametric predictive system. Optimize the parametric predictive system to find the global optima. | Mathematically clean solutions where computational tractability is partly taken into account. Relatively automatable. | The temptation to forget that the world imposes nonconvex loss functions is sometimes overwhelming, and the mismatch is always dangerous. Limited models. Although switching to a convex loss means that some optimizations become convex, optimization on representations which aren’t single layer linear combinations is often difficult. | |
| Gradient Descent | Specify an architecture with free parameters and use gradient descent with respect to data to tune the parameters. | Relatively computationally tractable due to (a) modularity of gradient descent (b) directly optimizing the quantity you want to predict. | Finicky. There are issues with paremeter initialization, step size, and representation. It helps a great deal to have accumulated experience using this sort of system and there is little theoretical guidance. Overfitting is a significant issue. | |
| Kernel-based learning | You chose a kernel K(x,x’) between datapoints that satisfies certain conditions, and then use it as a measure of similarity when learning. | People often find the specification of a similarity function between objects a natural way to incorporate prior information for machine learning problems. Algorithms (like SVMs) for training are reasonably practical— O(n 2 ) for instance. | Specification of the kernel is not easy for some applications (this is another example of prior elicitation). O(n 2 ) is not efficient enough when there is much data. | |
| Boosting | You create a learning algorithm that may be imperfect but which has some predictive edge, then apply it repeatedly in various ways to make a final predictor. | A focus on getting something that works quickly is natural. This approach is relatively automated and (hence) easy to apply for beginners. | The boosting framework tells you nothing about how to build that initial algorithm. The weak learning assumption becomes violated at some point in the iterative process. | |
| Online Learning with Experts | You make many base predictors and then a master algorithm automatically switches between the use of these predictors so as to minimize regret. | This is an effective automated method to extract performance from a pool of predictors. | Computational intractability can be a problem. This approach lives and dies on the effectiveness of the experts, but it provides little or no guidance in their construction. | |
| Learning Reductions | You solve complex machine learning problems by reducing them to well-studied base problems in a robust manner. | The reductions approach can yield highly automated learning algorithms. | The existence of an algorithm satisfying reduction guarantees is not sufficient to guarantee success. Reductions tell you little or nothing about the design of the base learning algorithm. | |
| PAC Learning | You assume that samples are drawn IID from an unknown distribution D . You think of learning as finding a near-best hypothesis amongst a given set of hypotheses in a computationally tractable manner. | The focus on computation is pretty right-headed, because we are ultimately limited by what we can compute. | There are not many substantial positive results, particularly when D is noisy. Data isn’t IID in practice anyways. | |
| Statistical Learning Theory | You assume that samples are drawn IID from an unknown distribution D . You think of learning as figuring out the number of samples required to distinguish a near-best hypothesis from a set of hypotheses. | There are substantially more positive results than for PAC Learning, and there are a few examples of practical algorithms directly motivated by this analysis. | The data is not IID. Ignorance of computational difficulties often results in difficulty of application. More importantly, the bounds are often loose (sometimes to the point of vacuousness ). | |
| Decision tree learning | Learning is a process of cutting up the input space and assigning predictions to pieces of the space. | Decision tree algorithms are well automated and can be quite fast. | There are learning problems which can not be solved by decision trees, but which are solvable. It’s common to find that other approaches give you a bit more performance. A theoretical grounding for many choices in these algorithms is lacking. | |
| Algorithmic complexity | Learning is about finding a program which correctly predicts the outputs given the inputs. | Any reasonable problem is learnable with a number of samples related to the description length of the program. | The theory literally suggests solving halting problems to solve machine learning. | |
| RL, MDP learning | Learning is about finding and acting according to a near optimal policy in an unknown Markov Decision Process. | We can learn and act with an amount of summed regret related to O(SA) where S is the number of states and A is the number of actions per state. | Has anyone counted the number of states in real world problems? We can’t afford to wait that long. Discretizing the states creates a POMDP (see below). In the real world, we often have to deal with a POMDP anyways. | |
| RL, POMDP learning | Learning is about finding and acting according to a near optimaly policy in a Partially Observed Markov Decision Process | In a sense, we’ve made no assumptions, so algorithms have wide applicability. | All known algorithms scale badly with the number of hidden states. | |
From: https://web.archive.org/web/20220509074248/https://hunch.net/?p=224
- (3921)(Chat)GPT Alternatives
+ https://news.ycombinator.com/item?id=34445873
+ https://github.com/blinkdl
+ https://towardsdatascience.com/run-bloom-the-largest-open-access-ai-model-on-your-desktop-computer-f48e1e2a9a32
+ https://www.numerama.com/tech/1246474-voici-les-meilleures-alternatives-gratuites-a-chatgpt.html
+ https://writier.io/
+ https://writesonic.com/chat
+ https://transformer.huggingface.co/doc/distil-gpt2
+ https://huggingface.co/docs/transformers/model_doc/t5
+ https://huggingface.co/docs/transformers/model_doc/albert
+ https://huggingface.co/docs/transformers/model_doc/bert
+ https://www.deepl.com/fr/translator
+ https://github.com/features/copilot/
+ https://www.zdnet.com/article/best-ai-writer/
+ https://www.jasper.ai/
+ https://you.com/search?q=who+are+you&tbm=youchat
+ https://writesonic.com/chat
+ https://play.google.com/store/apps/details?id=com.google.socratic&hl=en_US&gl=US
+ https://lifearchitect.ai/models/
+ https://app.aleph-alpha.com/login?redirect=%2Fplayground%2Fcompletion
+ https://app.cedille.ai/
+ https://app.inferkit.com/demo
+ https://ask-rbg.ai/
+ https://beta.openai.com/playground
+ https://dashboard.cohere.ai/playground/generate?model=large
+ https://galactica.org/
+ https://geo-not-available.blenderbot.ai/
+ https://github.com/XiangLi1999/Diffusion-LM
+ https://github.com/amazon-science/alexa-teacher-models
+ https://github.com/bigscience-workshop/xmtf
+ https://github.com/facebookresearch/fairseq/tree/nllb/
+ https://github.com/facebookresearch/metaseq/tree/main/projects/OPT-IML
+ https://github.com/microsoft/PACT
+ https://github.com/yandex/YaLM-100B
+ https://goose.ai/playground
+ https://huggingface.co/BlinkDL
+ https://huggingface.co/facebook/opt-30b
+ https://huggingface.co/google/flan-t5-xxl
+ https://huggingface.co/sberbank-ai/mGPT
+ https://huggingface.co/spaces/THUDM/GLM-130B
+ https://huggingface.co/spaces/facebook/incoder-demo
+ https://huggingface.co/spaces/huggingface/bloom_demo
+ https://huggingface.co/spaces/togethercomputer/GPT-JT
+ https://huggingface.co/ykilcher/gpt-4chan/discussions/4
+ https://macaw.apps.allenai.org/
+ https://muse.lighton.ai/home
+ https://neox.labml.ai/case/3c7e3581145811edb8160a0721174c74
+ https://nlp.baidu.com/special/plato/englishDemo#/index
+ https://playground.helloforefront.com/models/free-gpt-j-playground
+ https://russiannlp.github.io/rugpt-demo/
+ https://studio.ai21.com/sign-up
+ https://textsynth.com/playground.html
+ https://transformer.huggingface.co/doc/gpt
+ https://transformer.huggingface.co/doc/gpt2-large
+ https://unified-io.allenai.org/
+ https://vimalabs.github.io/
+ https://welm.weixin.qq.com/docs/playground/
+ https://www.forefront.ai/
+ https://www.youtube.com/watch?v=aUSSfo5nCdM
+ https://www.youtube.com/watch?v=l9FJm--ClvY
From: https://news.ycombinator.com/item?id=34445873
https://www.numerama.com/tech/1246474-voici-les-meilleures-alternatives-gratuites-a-chatgpt.html
https://www.zdnet.com/article/best-ai-writer/
https://lifearchitect.ai/models/
- (3931)Explanation of Reinforcement Learning (RL) / RL with Human Preferences/Feedback
It's the technique used to improve GPT-3/make a ChatBot of GPT-3
https://huggingface.co/blog/rlhf
https://openai.com/blog/deep-reinforcement-learning-from-human-preferences/
https://openai.com/blog/openai-baselines-ppo/
- (3942)What’s the Difference Between an Ontology and a Knowledge Graph?
A knowledge graph is created when you apply an ontology (data model) to a set of individual data points. It is a set (graph) of instances of the ontology.
ontology + data = knowledge graph
- 3 main components of an ontology:
+ Classes: the distinct types of things that exist in our data.
+ Relationships: properties that connect two classes.
+ Attributes: properties that describe an individual class.
e.g.
- Ontology level:
Book → has author → Author
Book → has publisher→ Publisher
Book → published on → Publication date
Book → is followed by → Book
Author → works with → Publisher
Publisher → located in → Location
Location → located in → Location
- KG level
"To Kill a Mockingbird" -> has author -> "Harper Lee"
"To Kill a Mockingbird" -> published on -> "1960"
...
From: https://enterprise-knowledge.com/whats-the-difference-between-an-ontology-and-a-knowledge-graph/
- (3957)What is "Action Research"?
It's when you simultaneously perform the process of taking action (concrete and transformative field actions) and doing research (knowledge acquisition), which are linked together by critical reflection
From: https://en.wikipedia.org/wiki/Action_research
https://fr.wikipedia.org/wiki/Recherche-action
- (3980)Some resources about AI (ChatGPT) for teaching
- AI-in-the-Classroom_-10-Tools-for-Teachers
https://ditchthattextbook.com/wp-content/uploads/2023/02/AI-in-the-Classroom_-10-Tools-for-Teachers.pdf
- SSkrabut-80 Ways to Use ChatGPT in the Classroom
https:// oceanofpdf .com/authors/stan-skrabut/pdf-epub-80-ways-to-use-chatgpt-in-the-classroom-download/
- Matthieu - Outils IA
https://outilia.fr/
- Guide de l'enseignant L'usage de ChatGPT « ce qui marche le mieux »
https://drive.google.com/file/d/1abyxcXEZu7xXzp0weAIwBlULL4rIeOnb/view
- AI4Teacher
https://www.ai4t.eu/book/ai-for-teachers-an-open-textbook-version-1-english/index
https://www.ai4t.eu/book/ia-pour-les-enseignants--un-manuel-ouvert-1/index
- ChatGPT_60_DataScience_Prompts
https://github.com/travistangvh/ChatGPT-Data-Science-Prompts
- ChatGPT AI and Educational Policy
https://lib.usf.edu/edlibreport/2023/02/06/chatgpt-ai-and-educational-policy/
- For research
https://www.elicit.org
https://www.consensus.app
https://www.researchrabbit.ai
- (4044)Websites where to find scientific articles/papers (PDF and BibTeX entries)?
+ Generic
https://scholar.google.com/
https://www.semanticscholar.org/
+ Specific to Computer Science
https://dblp.org/
https://citeseerx.ist.psu.edu/
+ Healthcare
https://www.ncbi.nlm.nih.gov/pmc/
+ Community-based
https://www.researchgate.net [high profiling/tracking]
+ Open Science
https://hal.science/
+ Not all Peer-Reviewed
https://arxiv.org/
+ Behind PayWalls
https://ieeexplore.ieee.org/Xplore/home.jsp
https://dl.acm.org/
https://link.springer.com/search
https://www.mendeley.com/
https://www.academia.edu/ [high profiling/tracking]
+ Not Tested
https://paperity.org
https://scholar.archive.org/
https://core.ac.uk/
See Also: https://en.wikipedia.org/wiki/List_of_academic_databases_and_search_engines
- (4045)IA-based websites where to find scientific articles/papers
- Papers similar to a given Research Question
https://elicit.com/
- Papers similar to other papers (+ shared collections)
https://www.researchrabbit.ai/
- (4046)Where to find tools based on AI/ML to increase your work efficiency?
https://theresanaiforthat.com/
- (4048)What are the differences between RDF / OWL / Turtle?
- RDF = Graphes = triplets
- OWL = Ontologies = *Classes (concepts) / Individuals (Instances) / Attributes / Relations* / Restrictions / Rules / Axioms / …
- Turtle 100% compatible with RDF-XML but not with OWL as there is a change in paradigm
Thanks AZ
- (4050)Simple exercises to propose during an intern interview for DS/ML/Research position?
Ideas for quick exercises:
- GM Imbalanced dataset (e.g. wine) without telling it at the beginning: asking to compute generic stats, training model then explaining strange results
- GM "Same stats, different graphs" without visualization (e.g. Datazaurus, Anscombe's quartet) without telling it at the beginning: asking to compute generic stats, training model then explaining strange results
- SebO Ask to read a scientific paper in advance, then discuss about it during interview
+ https://github.com/JianshuZhang/WAP
+ https://github.com/JianshuZhang/TAP
+ GM article SLIDE / Molnar's book on explainability
- GM Similar but simpler: what is the last scientific paper you read? What is the scientific paper that had the most impact on you?
- (4052)What is the difference between Standardization vs. Normalization in ML?
In machine learning, both standardization and normalization are techniques used to scale the input features of a dataset. Standardization scales the features such that they have a mean of zero and a standard deviation of one, while normalization scales the features to a range between 0 and 1.
The choice between standardization and normalization depends on the nature of the data and the machine learning algorithm being used. Standardization is preferred when the data follows a Gaussian distribution, while normalization is useful when the data has varying scales or when there are outliers in the data.
Standardization can help improve the performance of machine learning algorithms that rely on distance measures, such as k-nearest neighbors (KNN) and support vector machines (SVM) 1. However, blindly standardizing data without understanding why it is necessary can lead to poor performance of machine learning models.
Normalization can be useful when dealing with image data or text data, where pixel values or word frequencies can have varying scales. Normalization can also help improve the convergence of optimization algorithms in deep learning models.
In summary, both standardization and normalization are useful techniques for scaling input features in machine learning. The choice between them depends on the nature of the data and the machine learning algorithm being used.
From: https://builtin.com/data-science/when-and-why-standardize-your-data
https://www.geeksforgeeks.org/normalization-vs-standardization/
https://stackoverflow.com/questions/51841506/data-standardization-vs-normalization-vs-robust-scaler
https://www.analyticsvidhya.com/blog/2020/04/feature-scaling-machine-learning-normalization-standardization/
- (4107)List of useful AI tools (ChatGPT/Copilot/DallE-like, GPTs, ...)
https://theresanaiforthat.com/
https://www.futuretools.io/
- (101)Moving from one home to another
- Banques : socgen / BICS / Nef / Crédit Coopératif
- Impôts : https://www.changement-adresse.gouv.fr
- Carte grise
- Assurances : MGEN / MAIF
- Courrier : LaPoste
- Militaire : https://www.changement-adresse.gouv.fr
- EDF : https://www.changement-adresse.gouv.fr
- Assedics : https://www.changement-adresse.gouv.fr
- Magasines : MISC / canard
- Listes électorales
- Employeur : LORIA-paie
- Passeport / CNI
- Noter compteur eau/gaz/électricité
- (CAF / écoles, si on a des gamins)
- Commandes & livraisons : Play-asia
- (122)Loi de Murphy
"Loi de l'emm... maximum (LEM). « S'il y a deux façon de faire quelque chose, et que l'une d'elles conduit à une catastrophe, alors quelqu'un le fera ». C'est la version originale de Edward A. Murphy, Jr. ingénieur au projet MX981 de l'USAF (US Air Force), chargé de tester la tolérance humaine à l'accélération. Il y avait 16 accéléromètres pouvant être montés de deux façons différentes, et quelqu'un les brancha tous méthodiquement à l'envers..."
Source: http://www.linux-france.org/prj/jargonf/M/Murphy.html
- (123)La loi de Godwin
"Plus une discussion sur l'Usenet est longue, plus la probabilité d'y trouver une comparaison avec les nazis ou Hitler approche de un". Il est de bon ton de clore immédiatement une discussion lorsqu'on rencontre une telle comparaison, qui tient de l'insulte : celui qui la fait n'a plus d'argument valide, il a perdu. Au passage, il a gagné un point Godwin. Évidemment, cette loi ne peut en aucun cas être invoquée dans une discussion, car cela reviendrait très précisément à faire la même chose que l'insulte qu'elle prétendrait dénoncer, en cherchant à jeter le discrédit sur l'interlocuteur...
Source: http://www.linux-france.org/prj/jargonf/G/Godwin.html
- (188)How to behave when interviewed (French)
http://www.lestrucsdunjournaliste.com/2009/09/comment-se-comporter-en-interview-1.html
http://www.lestrucsdunjournaliste.com/2009/09/comment-se-comporter-en-interview-2.html
- (198)Where to find some sheets to organize yourself (à la "GTD" from David Allen)'
http://www.diyplanner.com/templates/official/classic
- (232)Things to take for a rollerskate competition
- Obligatoire : casque, carte d'identité, un peu d'argent mais pas trop, le T-shirt officiel de l'équipe, banderole de l'équipe, 4/6 épingles pour accrocher le dossard
- Course : chronomètre/montre
- Matos bricolage : Clef Allen(lines)/Clef 8 (quads), tournevis, couteau suisse avec scie métaux, ficelle (pour relai)
- Pharmacie : Sparadrap/Pansements/Compeed + crème solaire + amplâtre américain
- Hygiène : 1 rouleau de papier toilettes/sopalin/mouchoirs, ongles de pieds bien coupés
- Vêtements : Pull + K-way + lunettes
- Bouffe : bananes, barres de céréales, biscuit "petit déj", chocolat, sandwiches, pâtes (sucres rapides et sucres lents, mais pas trop de gras)
- Boisson : coca (GM: 4l pour 6 heures), eau, sirop, jus fruits, café/thé (pas trop), bouilloire électrique
- Camping : Sac de couchage, glacière, chaises, table, tente, lit de camp, multiprise, rallonge, micro-onde
- (246)List of FOSS development tools
- C++ : code::Blocks http://www.codeblocks.org/
- Java, C++ : Eclipse http://www.eclipse.org/
- C# : monodevelop http://monodevelop.com/
- (329)What is the difference between "Salaire Brut" and "Salaire Net"?
Salaire Net = salaire qu'on touche vraiment (impôts déduits)
Salaire Net ~= 77% Salaire Brut
Salaire Net ~= (1-.23)*SalaireBrut
From: http://www.salairebrutnet.fr/
- (345)Free Software promotion sites
> > "1540 logiciels libres dans l'annuaire Framasoft"
> > http://www.framasoft.net/
> >
> > FramaDVD Ecole
> > http://framadvd.org/framadvd_ecole.php
:
http://www.tice.ac-versailles.fr/logicielslibres/
Logiciels libres et enseignements
http://www.educoo.org/
Contenu pédagogique libre
http://fr.wikipedia.org/wiki/Ressources_%C3%A9ducatives_libres
Ressources éducatives libres
U
> >
-----------------------------------------------------------------------
> > Musique
http://www.boxson.net/
Diffusion et hébergement de musique sous licences libres (licences
Art-Libre ou Creative Commons).
http://www.dogmazic.net/
Diffusion et hébergement de musique sous licences libres (licences
Art-Libre ou Creative Commons)
http://altermusique.org/
Altermusique.org est un label de musique libre. Production, diffusion et
promotion d'artistes qui ont choisis d'ouvrir leur musique à leur public.
http://www.revolutionsoundrecords.org/
L?association «collectif Revolution Sound Records (RSR)» est née du
désir et de la volonté d'artistes de rendre la culture libre et
accessible à tous, désireux de permettre au public de découvrir
gratuitement et légalement les oeuvres d'artistes non standardisés.
http://www.oxyradio.net/
Webradio libre, musique et émissions
---------------------------------------------------------------------
Livres :
http://www.framabook.org/
Une collection de livres libres sur le logiciel libre
http://www.inlibroveritas.net/
Lire et écrire librement
http://fr.wikibooks.org/wiki/Accueil
La bibliothèque de livres pédagogiques libres que chacun peut améliorer.
http://www.gutenberg.org/browse/languages/fr
Le projet Gutenberg
http://petits-venusiens.be/site/
Conte pour tous petits, sous LAL, à lire et colorier, disponible en 15
langues !
http://www.audiocite.net/
Catalogue de livres audio à télécharger gratuitement et légalement :
Roman, nouvelle, poème d'auteur classique ou contemporain.
-----------------------------------------------------------------------
Vidéos :
http://www.kassandre.org/
Kassandre réunit les cinéastes ayant fait le choix de partager librement
leurs créations (licences Art-Libre ou Creative Commons)
http://entropy.tuxfamily.org/
Films uniquement sous licence libre
http://www.open-video.org/
Vidéos libres de droits indexées par thème (histoire, education...)
durée, format, couleur etc.
-----------------------------------------------------------------------
Photos/Créations graphiques :
http://www.openclipart.org/
Collections de dessins vectoriels (Creative Commons, licence Art Libre,
domaine public)
http://www.flickr.com/creativecommons/
Photos, créations graphiques sous Creative Commons
-----------------------------------------------------------------------
Divers :
http://artlibre.org/
Indexation d'auteurs ayant opté pour la Licence Art Libre
http://fr.creativecommons.org/
Moteur de recherche et publication d'oeuvres sous Creative Commons.
http://www.sites-cc.infini.fr/index.php/Accueil
Liste de 500 sites francophones sous Creative Commons ou licence libre.
Matériel libre :
http://fr.wikipedia.org/wiki/Mat%C3%A9riel_libre
Le matériel libre (en anglais open hardware) définit les ordinateurs et
le matériel électronique développés selon des principes de la culture libre.
-----------------------------------------------------------------------
Jeux :
http://live.linux-gamers.net/
Une distribution linux orientée jeux.
http://ultimateedition.info/
Ubuntu Ultimate Gamers Edition, une autre distribution orientée jeux.
http://www.jeuxlinux.fr/liste_des_jeux_licence.html#Libre
Liste de jeux libres
http://asso.lanpower.free.fr/
Création et diffusion de compilations de jeux libres et portable (sur
clé USB), organisation de Lan Party.
---
Ah oui, côté programmation, on peut mentionner Scratch, logiciel de
programmation pour les enfants à partir de 7/8 ans, développé par le
MIT. Le slogan étant "Imagine·Programme·Partage !" :
http://scratch.mit.edu/
Dans la même lignée, on peut également citer Squeak :
http://community.ofset.org/index.php/Squeak
---
Une partie triee et selectionnee est disponible sur ma page LL et education :
http://science.physique.free.fr/softs/
- (347)List of sites to DL books/music/movies/softs...
http://www.ebooksbay.org/
http://www.filestube.com/
http://library.nu/ (gigapedia)
http://libgen.io
http://ebook-dl.com
http://ebooks-it.org
http://minhateca.com.br
http://mega.co.nz
http://www.filemare.com
http://avaxhome.ws/
http://fileshunt.com/
http://rapidlibrary.com/
http://www.4shared.com/
http://gen.lib.rus.ec/ (library genesis)
http://www.ebooksgratis.it/ (fr)
http://www.filediva.com/ / http://6123p.com/
http://filetram.com
http://alluc.to / http://alluc.ee
http://keep2share.com / http://keep2share.cc
http://sharedir.com
http://filenewz.com / http://filenewz.xyz/
http://rapid4me.com
http://filespart.com
http://filespr.com / http://filespr.com
http://general-search.com
http://filewatcher.com
http://byfiles.com / http://filepoch.com/
http://fileboom.me
- (348)List of WebComics for Geeks
http://www.phdcomics.com/
http://www.bouletcorp.com/blog/
http://xkcd.com/
http://danstonchat.com/
http://geektionnerd.net/
http://www.nojhan.net/geekscottes/index.php?strip=0
http://lepiredup2p.blogspot.com/
http://www.userfriendly.org/
http://itmanagement.earthweb.com/cnews/article.php/3857336/Tech-Comics-The-Geek-and-the-User-part-2.htm
http://www.geekherocomic.com/2009/11/13/outside/
http://www.taoofgeek.com/
http://www.thewebcomiclist.com/browse.php?genre=5
http://geekandpoke.typepad.com/geekandpoke/
http://www.hypexr.org/comics.php
http://maliki.com/strip.php?strip=252
http://hackles.org/archives-2001.html
http://folk.uio.no/hpv/linuxtoons/
http://www.martybucella.com/cartoonstore.html
http://www.mikeshapirocartoons.com/main.php
http://folk.uio.no/hpv/linuxtoons/m-linux/
http://blog.admin-linux.org/geek/bd-de-geek-2
http://www.gocomics.com/?ref=comics
http://gucomics.com/comic/
http://darky-ben.fr/Xut/
http://www.joystiq.com/tag/webcomic/
http://aulas.pierre.free.fr/chr_fen_01.html
- (349)Sites for reading news about FOSS
http://linuxfr.org/
http://toolinux.com/
http://www.theopensourcerer.com/
http://www.planet-libre.org/
http://www.zeropaid.com/
http://tootella.org/
http://toolinux.org/Wikio-les-meilleurs-blogs-sur-les
http://www.generation-nt.com/
http://www.maitre-eolas.fr/
BSD:
http://www.gcu-squad.org/
http://www.undeadly.org/
http://bsdmag.org/magazine/
- (350)Sites for reading/listening to news of the world
http://www.listenlive.eu/france.html
http://www.rue89.com/
http://www.mediapart.fr/
http://lecanardenchaine.fr/
http://www.lemonde.fr/
http://www.folha.uol.com.br/
http://avaxnews.com/
- (351)Survival books
The Complete Worst-Case Scenario Survival Handbook.pdf
The_Worst_Case_Scenario_Survival_Handbook.pdf
SAS Survival Guide How To Survive Anywhere, On Land Or At Sea.pdf
The.Survival.Handbook.-.Essential.Skills.for.Outdoor.Adventure.pdf
US Army Special Forces Medical Handbook.pdf
SAS_Survival_Guide.pdf
The_Survival_Handbook.pdf
Wild Plants With Edible Tubers, Bulbs Or Roots.pdf
FM 21-76 US ARMY SURVIVAL MANUAL.pdf
Memento de Survie en Milieu Naturel (http://www.alpharubicon.fr/index.php/mediatheque/livres/306-memento-de-survie-en-milieu-naturel)
There are also lots of files here:
https://nopanic.fr/bookbank/
- (407)Natural products that solve common problems?
Vinaigre blanc => contre calcaire
Econazole => contre les odeurs/bactéries dans les chaussures
Pierre Alun => contre transpiration et coupure de rasoir
Purin d'orties => contre les petites bêtes du jardin
- (496)Restaurants in Paris
- Discounts / Rankings
http://www.lafourchette.com/
http://www.lefooding.com/
https://www.dojoapp.fr/
== Best restaurants
- Cosi [home-made bread filled with italian anti-pasti-like food - classical music]
54 Rue de Seine
75006 Paris
01 46 33 35 36
- Le Jardin des Pâtes [home-made italian/french noodles]
4 Rue Lacépède
75005 Paris
01 43 31 50 71
- Café de l'Industrie [french food]
16 Rue St Sabin
75011 Paris
01 47 00 13 53
- Scop Le Temps des Cerises ["cantine" french food]
18 Rue Butte aux Cailles
75013 Paris
01 45 89 69 48
- Aux Délices du Liban [libanese food]
3 Rue Estrapade
75005 Paris
01 44 07 29 99
- Godjo [ethiopian food - unique plate shared by everyone]
8 Rue de l'École Polytechnique
75005 Paris
01 40 46 82 21
- Chez Gladines ["Basque" food]
30 Rue des Cinq Diamants
75013 Paris
01 45 80 70 10
- Les 5 Saveurs d'Anada [vegetarian/organic food] DEAD!
72 Rue du Cardinal Lemoine
75005 Paris
01 43 29 58 54
- Delibay [Chinese/Hong-Kong food] DEAD!
121 Avenue Maine
75014 Paris
01 71 50 99 17
- Oroyona/Chilecito [Very small&cheap "crèperie" owned&frequented by south americans]
36 Rue Mouffetard
75005 Paris
01 43 36 60 46
- Carnet de Voyage [Chinese food]
4 rue de Budapest
75009 Paris
01 48 78 24 50
- Crèperie "Franboise" [Crèperie]
7 rue de Ponthieu
75008 Paris
01 74 64 02 79
- Sakura Ramen [japanese food] ATESTER
109 ave du Maine
75014 Paris
01 42 18 15 65
- [Senegalese] ATESTER?
6, Rue Elzévir
75003 Paris
http://www.lepetitdakar.com/notrecarte.html
- Restaurant Ile de la Réunion [food from reunion island]
96, rue Daguerre
75014 Paris
- Chez Guan (Chinese - Chendong - Nicole)
13, Rue D'aligre
75012 Paris
- COSMO [Hamburgers]
40 rue Notre Dame de Nazareth
75003 Paris
- Nanashi (bento, Japanese)
57 rue Charlot
75003 Paris
- [Chinese from center] (Zheng) ATROUVER
dans le 9eme
- Le Goyavier [Reunion Island] ATESTER
4, rue Saint-Bernard vers Faidherbe-Chaligny
http://www.restoaparis.com/fiche-restaurant-paris/le-goyavier.html
- Zen Zoo [Chinese?] ATESTER
2 Rue Cherubini
75002 Paris
01 42 96 27 28
- Sukhothaï [Thaï food] ATESTER
12 Rue Père Guérin
75013 Paris
01 45 81 55 88
- Foyer Vietnamien [Vietnamese food - run by a student association to promote their culture!]
80 Rue Monge
75005 Paris
France
01 45 35 32 54
- Mansouria [Morocan - Tajine - very expensive]
11 rue Faidherbe
75011 Paris
- L'Atelier de Joel Robuchon (French food?) ATESTER
5, Rue de Montalembert
75007 Paris
France
01 42 22 56 56
- Chez Mademoiselle ATESTER
16 Rue Charlemagne
75004 PARIS
France
http://www.restaurantchezmademoiselle.fr/
- Inajiku [Japonais] ATESTER
rue des Bernardins
14,rue de Pontoise, Paris, France
01 43 54 70 07
- Tonkazu [Japonais] ATESTER
14 rue de l'Arrivée
75015 Paris
France
01 42 22 61 83
- Chez Josselin [crèperie]
67 rue du Montparnasse
75014 Paris
France
01 43 20 93 50
- La crèperie bretonne [crèperie]
32 rue du Montparnasse
75014 Paris
France
- Laffitte (midi seulement) ATESTER
43 rue Laffitte
75009 Paris
France
01 42 80 07 66
- ?? [vietnamese food] ATROUVER
Rue lacépède/Place de la contrescarpe
75005 Paris
- L'Autre Café [South French food - Cassoulet]
62, rue Jean-Pierre Thimbaud
75011 Paris
- La Papaye Verte [Thaï food]
4 Bis Rue Archange
91400 Orsay
01 69 29 93 02
- Les 4 amis [very spicy asian food!]
29 rue de charenton
75012 Paris
France
09 82 28 09 17
- Avesta [Kurdish food]
15 Rue d'Enghien
75010 Paris
France
+33 1 47 70 47 71
http://parisianavores.paris/avesta-la-cuisine-kurde-rue-denghien/
- La Massara [Truely Italian Pizzas]
70 rue de Turbigo
75003 – Paris
01 42 74 13 94
http://www.la-massara.fr/
- New World [Chinese Raviolis/DimSum] ATESTER
15 Avenue De Choisy
75013 Paris
+33 9 84 35 42 36
- Restaurant Raviolis Chinois [Chinese Raviolis/DimSum] ATESTER
33 rue Caillaux
75013 Paris
+33 9 83 85 52 13
- Raviolis Nord-Est [Chinese Raviolis/DimSum - very cheap]
115 Rue Saint-Denis
75001 Paris
+33 9 81 17 19 09
- Chez Marcel [French food] ATESTER
7 rue Stanislas
75006 Paris
France
01 45 48 29 94
- Chez Nenesse [French Food - Bistrot]
17, rue Saintonge
75003 Paris
France
01 42 78 46 49
- Rachel's Bakery [Good Cheesecake]
25 Rue du Pont aux Choux
75003 Paris
France
01 44 61 69 68
- Churrasqueira Galo [Portuguese/Brazilian food]
69 rue de Dunkerque
75009 Paris
France
+33 1 48 74 49 40
- Les Pâtes Vivantes [Chinese food - similar to HappyNouilly but much more "classy"]
3 Rue De Turbigo
75001 Paris
France
+33 1 40 13 08 04
- Aki [Okonomiyaki="omelette vivante"]
11 bis rue Sainte-Anne
75001 Paris
France
+33 1 42 97 54 27
== Best bars
- Le Syndicat [Bar with cocktails with old-school alchool - ATESTER]
51 Rue du Faubourg Saint-Denis
75010 Paris
France
- Lock Groove [Plays music from Vinyls + good - but small - bugers+home-made chips]
15 rue Roger
75014 Paris
+33 1 43 22 77 52
- Le troll café [bar à bière]
27 Rue de Cotte, Paris vers Place Aligre
- Au Trappiste [bar à bière]
4 Rue Saint-Denis, 75001 Paris
- Falstaff [bar à bière]
39 Rue du Montparnasse, Paris
- Académie de la bière [bar à bière]
88 Boulevard de Port-Royal, Paris
- Teddy's Bar
3 Rue Thouin
75005 Paris
01 43 54 63 66
- Mayflower
49 rue Descartes
75005 Paris
01 56 24 27 21
== Best Chocolotes in Paris
From: http://www.chocoparis.com/best-chocolate-shops-in-paris/
- Christian Constant
37, rue d’Assas, 75006 Paris
- Debauve & Gallais
30, rue des Saints-Pères, 75007 Paris
- François Pralus
35, rue de Rambuteau
- Gérard Mulot
76, rue de Seine, 75006 Paris
- Jacques Genin - Chocolates Thx FredBasset
133, rue de Turenne, 75003 Paris
(0)1 45 77 29 01
- Jean-Charles Rochoux
16, rue d’Assas, 75006 Paris
- Jean-Paul Hévin - Chocolates Thx MorganeGal
231, rue Saint Honoré, 75001 Paris
41 rue de Bretagne, 75003 Paris
+33 (0)1 44 61 94 43
3 rue Vavin, 75006 Paris
+33 (0)1 43 54 09 85
- La Maison du Chocolat
225, rue du Faubourg Saint-Honoré, 75008 Paris
- Michel Chaudun
149, rue de l’Université, 75007 Paris
- Michel Cluizel
201, rue Saint-Honoré, 75001 Paris
- Patrick Roger
108, boulevard Saint-Germain, 75006 Paris
- Pierre Hermé - Macarons Thx Carmen
72, rue Bonaparte, 75006 Paris
18 rue Sainte-Croix-de-la-Bretonnerie, 75004 Paris
+33(0)1 43 54 47 77
- Pierre Marcolini
89, rue de Seine, 75006 Paris
- Richart
258, boulevard Saint-Germain, 75007 Paris
- Angelina - hot chocolate
226 rue de Rivoli 75001 Paris
+33 1 42 60 82 00
http://www.angelina-paris.fr/fr/
- (474)What plants can help for kidney stone?
Nigelle (candies)
- (475)What diet can help for kidney stone?
Aliments à manger moins afin d'éviter les calculs rénaux (ou les soigner)
Notons qu'il n'est pas interdit de manger les aliments suivants, seulement de les consommer en modération pour éviter d'augmenter la sécrétion de l'oxalate. L'idée de base reste, nous le répétons, de ne pas en consommer en quantités excessives. Pas tout le monde n'est concerné par ces conseils alimentaires non plus, ils sont surtout destinés à ceux qui sont prédisposés à développer des calculs rénaux.
1) Certaines boissons
La formation de lithiase rénale est favorisée par la consommation de grandes quantités de thé noir ou de thé glacé (haute teneur en oxalate), sodas (très acides) et bières (en boire trop augmente l'excrétion de l'acide oxalique et de l'acide urique, haussant le risque de formation de calculs dans les urètres). Lisez aussi : Soda : effets négatifs des sodas sur votre santé.
Rappelons que l'excrétion est l'action par laquelle des substances sécrétées d'un organisme vivant sont expulsées (sous forme de solides, liquides, gaz ou mucus).
2) Certains fruits, légumes et noix
Certains fruits et légumes augmentent l'excrétion urinaire du citrate (qui inhibe les calculs). La consommation d'aliments à haute teneur en oxalate (épinards, rhubarbe, betterave, bette, noix, cacahuètes) devrait toujours être réduite au minimum ou combinée simultanément à des aliments apportant beaucoup de calcium (combiner par exemple les épinards avec un gratin de fromage). Lisez aussi : Alimentation riche en calcium, effets du manque de calcium.
D'autres fruits et légumes à teneur moyenne en oxalate devraient également être évités : les raisins, les framboises, les fraises, la canneberge, la confiture, les gâteaux aux fruits, le gombo, les patates douces, les poivrons verts, le céleri. Evitez également le jus de pamplemousse. Lisez aussi : Quelles couleurs de fruits et légumes santé consommer prioritairement ?.
Combiner de la sorte empêche l'absorption de grandes quantités d'oxalate par l'intestin (ce qui aurait mené à une augmentation de son excrétion dans l'urine, donc du risque de formation des calculs).
3) Viandes, volaille, poissons
Une consommation excessive de protéines à partir de viandes (boeuf, porc), blancs d'oeuf et de poissons accroît le risque de formation de calculs, parce que l'urine est trop acidifiée et l'excrétion de l'oxalate, du calcium et de l'acide urique augmente, tandis que l'excrétion de citrate (qui apporte une protection contre la formation de calculs) diminue. Lisez aussi : Alimentation à haute teneur en protéine.
La consommation de viandes, volailles et poissons doit donc être réduite quand vous souffrez de calculs rénaux. Attention, il ne faut pas arrêter d'en consommer, seulement en manger avec modération. Parlez à votre médecin ou diététicien si vous souhaitez connaître avec certitude la quantité de protéines dont vous avez besoin et la meilleure manière d'en consommer. Lisez aussi : Choses à savoir sur le mercure dans les poissons.
4) Sel
Le sodium contenu dans le sel de table (chlorure de sodium) peut augmenter le risque de formation de calculs, probablement en augmentant l'excrétion de calcium via la voie urinaire (ce qui augmente le risque de formation de calculs). D'un autre côté, une réduction drastique de sel provoque une diminution du volume urinaire (ce qui n'est pas conseillé parce que les calculs minuscules ne peuvent plus passer régulièrement). Lisez aussi les 10 aliments les plus riches en sodium.
Une légère réduction de la consommation de sel (6 g maximum par jour, soit 2 à 3 g de sodium par jour) est donc recommandée, plutôt qu'un arrêt total de consommation. Il est conseillé de manger moins de hot dogs, de charcuteries, de choucroute, de nourritures vendues en conserve, de soupes sèches, de cornichons, ainsi que des plats prêt-à-manger qui contiennent souvent une quantité élevée de sodium. Lisez aussi : Sodium : bienfaits santé, risques et symptômes du manque de sodium.
5) Bonbons
Une consommation excessive d'aliments riches en sucre augmente l'excrétion urinaire de calcium et ainsi potentiellement le risque de calculs rénaux. Probablement plus important encore est le fait que le chocolat, les pralines et d'autres aliments contenant du cacao contiennent beaucoup d'oxalate. Lisez aussi : Cacao : bienfaits santé, le cacao aide-t-il à maigrir ?.
6) D'autres aliments riches en oxalate
Les germes de blé, le son de blé, les crackers au soja, le gruau d'avoine, le foie, les haricots.
7) Les aliments très riches en vitamine C
Veillez à ne pas consommer trop d'aliments à haute teneur en vitamine C (comme les oranges). L'acide ascorbique peut inhiber le pH urinaire (qui réduit le citrate urinaire, un inhibiteur naturel de calculs rénaux). Lisez aussi : Orange : un fruit rempli de bienfaits santé, nutriments des oranges.
> Aliments à consommer plus souvent pour éviter les calculs rénaux (ou les soigner)
1) Eau et autres liquides non alcoolisés
Buvez beaucoup d'eau pour expulser les calculs hors de votre voie urinaire quand elle n'est pas bouchée. Si vous avez des calculs rénaux, il est recommandé de boire entre 2 et 3 litres d'eau chaque jour. Boire 4 litres d'eau est nécessaire dans certains cas (consultez votre médecin pour connaître le volume d'eau précis à boire), surtout si vous faites beaucoup de sport. Lisez aussi : 12 trucs pour boire assez d'eau tous les jours.
Il est important de boire régulièrement sur la durée des 24 heures qui composent une journée. Divisez le volume d'eau à parts égales autant que possible sur les 24 heures. Pensez à boire avant d'aller au lit parce qu'une urine nocturne trop concentrée encourage la cristallisation et la formation de calculs.
Même si l'eau est la meilleure boisson, presque toutes les boissons peuvent convenir. L'eau minérale riche en bicarbonate et en calcium ainsi que des jus de fruits 100% naturels (sans sucre ajouté) sont particulièrement bénéfiques. Evitez simplement le jus de pamplemousse. Vous pouvez boire de la limonade faite à partir de vrais citrons (et non d'arômes de citron). Cette boisson est riche en citrate, qui peut aider à prévenir les calculs rénaux. Lisez aussi : Alimentation riche en eau à adopter.
2) Lait et produits laitiers
Contrairement à ce que vous pourriez le croire (et à ce que les experts pensaient il y a quelques décennies), une restriction en calcium n'est plus recommandée. De grandes études réalisées sur des dizaines de milliers de personnes souffrant de calculs rénaux ont clairement montré qu'avec une consommation de calcium accrue jusqu'à 1 200 mg par jour, le risque de formation de calculs baisse significativement (et n'augmente pas comme les experts le croyaient auparavant).
Une étude co-réalisée par l'hôpital "Brigham and Women" (Boston, Etats-Unis) et l'école de médecine de l'Université de Harvard (Boston, Etats-Unis), sur plus de 90 000 femmes, a montré que les femmes qui consomment beaucoup de calcium ont moins de risque de développer des calculs rénaux que celles qui consomment insuffisamment de calcium. Selon les chercheurs, cela se produit parce que le calcium alimentaire s'attache à l'oxalate, alors il ne peut être absorbé par les reins pour fabriquer des calculs. Lisez aussi : Boire du lait pour perdre du poids ?.
Une consommation de calcium de 1 200 mg par jour au total, sur lesquels 800 mg devraient provenir de produits laitiers est ainsi recommandée pour éviter ou soigner les calculs rénaux.
Evitez de prendre des suppléments de calcium et de vitamine D car ils ne sont pas absorbés facilement par le corps. L'étude de l'Université de Harvard montre que la prise de suppléments de calcium augmente légèrement le risque de lithiase rénale. Les chercheurs supposent que cela se produit parce que les suppléments ne sont pas pris en conjonction des repas, limitant la capacité du calcium à neutraliser l'absorption d'oxalate.
From: http://www.regimesmaigrir.com/actualites/article.php?id=1143
- (479)The various phases of classical music?
Musique des origines
Musique grecque ancienne
Musique de la Rome antique
Musique médiévale
Musique de la Renaissance
Musique baroque
Musique de la période classique
Musique romantique
Musique moderne
Musique contemporaine
- (549)Contropétrie nooobs
Elle compile le C
- (591)What Politeness formula to use (French) in which situation?
http://www.lettresenligne.com/articles/read.php?article_id=6
http://www.abc-lettres.com/formule-politesse.html
- (596)Special numbers for mobile phones
#31# => cache le numéro
#*06# => IMEI
666 => répondeur FreeMobile
- (614)Flowers that I like (in flourishing order?)
- Glycine
- Robiner faux accacia
- Lilas
- Églantiers / Roses
- Jasmin
- Tilleuls
- (631)Places to go with (girl) friends?
concerts jazz rue resto jap (Mr Prince)?
concerts jazz à côté schola cantorum
concerts duc des lombards, etc.
http://www.lebelcanto.com/
- (634)How to learn how to repair a car?
Look for books of the "Haynes" series
- (637)Restaurants in Strassbourg
1- Mon resto bio préféré (vegetarien et poisson):
Une fleur des champs
http://www.restaurant-naturel-et-biologique-67.com/contact.php
C'est dans le centre, à côté de la place Broglie (près de l'opéra)
2- Les bars sympas de Strasbourg
- Bars branché à côté de la place St Etienne:
Mudd Club: http://www.mudd-club.fr/
Le phonographe:http://www.qype.fr/place/1553945-Le-Phonographe-Strasbourg-
- Bar un peu roots/hippie situé dans la Grand Rue (propose des quiches bio, planchettes fromages bio aussi):
L'artichaut: http://www.lartichaut.fr/
- Bar proposant des planchettes fromages:
Jeannette et les cycleux:
http://www.lenetdejeannette.com/
3- Pour boire un verre en terrasse:
Péniches du quai des bâteliers:
Atlantico: http://www.cafe-atlantico.net/
Terrasses de la Place du marché Gayot:
http://www.qype.fr/place/375230-Place-du-Marche-Gayot-Strasbourg-
4- Tartes flambées:
Au brasseur: http://www.aubrasseur.fr/
5- Parcs:
- Ne pas rater le parc de l'orangerie! Et surtout regarder en l'air car les cigognes offrent un spectacle magnifique
- Pour les lacs, il est possible d'accéder au Baggersee par le tram A (puis prévoir après 5/10 min de marche):
http://maps.google.fr/maps?hl=fr&client=firefox-a&hs=gAq&rls=org.mozilla:fr:official&bav=on.2,or.r_gc.r_pw.r_qf.,cf.osb&biw=1280&bih=605&um=1&ie=UTF-8&q=baggersee&fb=1&gl=fr&hq=baggersee&hnear=0x4796c8495e18b2c1:0x971a483118e7241f,Strasbourg&ei=6AbVT4ubC4LJhAeM0LDPAw&sa=X&oi=local_group&ct=image&ved=0CAYQtgM
6- Pour le vin, il faudrait faire la route des vins (ça vaut vraiment la peine).
Sinon il est toujours possible de faire des dégustations à Strasbourg.
Il y a les hospices de l'hôpital civil qui propose des dégustations avec fromage dans leur cave:
http://www.vins-des-hospices-de-strasbourg.fr/
7- Pour danser:
La Péniche Latino (quai des pêcheurs aussi) propose des soirées salsa le samedi soir:
http://www.barcolatino.fr/
8- Pour les bons plans concert: penser à aller à la boutique culture juste en face de la cathédrale, ils savent tout ce qui se passe à Strasbourg!
From: A.M. Duarte
- (721)Simple Tips&Tricks for home usage - 1
- vis dont la tête est foutue => placer un bout d'elastique plat dessus et utiliser le tourne-vis normalement
- peinture sur la peau => frotter avec un muchoir imbibé d'huile d'olive
- calcaire sur la pomme de douche => mettre du vinaigre blanc dans un zip-bag et l'attacher avec un élastique autour de la pomme. Laisser tremper un moment
- fenêtres sales et pas de produit => utiliser du cola, l'acide citrique va nettoyer
- ouvrir une enveloppe sans déchirer => la mettre au freezer 30 min
- attaques de mouches/moustiques => mettre une "Dryer sheet" dans la poche (lingette nettoyante ? lingette assouplisseur?)
- votre éponge pue ? => mettre un peu de produit vaisselle et eau + passer au micro onde
- Chiottes sont sale => 2/3 pastilles d'alca-setzer
From: http://www.youtube.com/watch?v=AclA-7YntvE
- (722)Simple Tips&Tricks for home usage - 2
- batteries trop petites => combler avec du papier d'alu
- chaussurent puent => mettre dans un zipbag + passer au freezer
- connaitre la quantité de gaz restante dans une bonbonne => verser de l'eau chaude dessus puis passer le doigt de haut en bas. Là où c'est froid c'est la limite (le propane absorbe la chaleur)
- ranger ses affaires optimalement dans un sac de voyage => les rouler
- votre pièce pue ? => verser de l'huile essentielle sur les ampoules
- votre stylo à bille est bloqué => chauffer la pointe au briquet
- le bouchon de votre bocal est impossible à ouvrir => perser la capsule avec un couteau
From : http://www.youtube.com/watch?v=ImTvDDbSZys
- (723)Simple Tips&Tricks for home usage - 3
- pas de tire-bouchon => visser une vis et tirer avec la partie "retire clou" d'un marteau (ou autre)
- Les oignons vous font pleurer => les passer au frigo 50 minutes
- Éviter les débordement de casserole quand l'eau bout => poser une cuiller en bois sur le dessus de la casserole
- Tester la fraîcheur d'un oeuf => il est bon s'il coule dans un verre d'eau
- Besoin d'un entonoir => couper un coin dans un zip-bag
- Faire des beaux glaçons => bouillir l'eau avant
- nettoyer un micro-onde => préparer un bol mi-eau mi-vinaigre blanc et le laisser bouillir qq minutes dedans
- pas de fer à repasser => couvrir le fond d'une casserole avec du papier alu, la faire chauffer sur la plaque, la prendre pas le manche et s'en servir comme d'un fer à repasser ;)
From: http://www.youtube.com/watch?v=VnHLKKQgSMY
- (724)What to look for when buying an apartment in France?
- Frais d'agence = ~5% ("Frais F.A.I." = Frais d'Agence Inclus dans le prix affiché)
- Frais de notaire = ~7.5%
PREMIÈRE VISITE
- Tout visiter (inclus cave, combles, etc.)
- Se renseigner sur le bruit (écoles, aéroport, etc.)
- Se renseigner sur la présence de nuisibles (fourmis, termites, etc.)
- Se renseigner sur les PLU (constructions de métros, zones inondables, etc.)
COMPROMIS VENTE
- Une fois signé => rétractation possible pendant 7 jours
- Normalement dans les locaux de l'agence
- Se signe en présence de l'agence/vendeurs/acheteurs
VENTE DÉFINITIVE
- Re-visiter le logement juste avant la vente définitive pour :
- Faire un RELEVÉ DES COMPTEURS EDF/GDF/EAU
- RÉCUPÉRER l'ancien numéro de téléphone des vendeurs
- vérifier que rien n'a changé/été cassé, lors du départ des vendeurs
- vérifier que les meubles prétenduement vendus par les vendeurs sont bien là
- Normalement, dans les locaux du notaire du vendeur
- Se signe en présence de l'agence/vendeurs+leur notaire/acheteurs+leur notaire
- En tant qu'acheteur, prévoir au moins 2 chèques pour le remboursement des Charges et de la taxe foncière (ATTENTION: officiellement on ne la rembourse au prorata!) aux vendeurs
- Notaire de l'acheteur collecte les sous de l'acheteur et paie le vendeur le jour de la vente définitive
- Notaire de l'acheteur débloque les fonds du crédit et les reçoit sur un compte à lui réservé
- Notaire de l'acheteur reçoit l'appart personnel de l'acheteur sous la forme d'un chèque de banque le jour de la vente définitive
- PENSER à appeler un assureur pour assurer le logement le jour même de la vente (dégât des eaux, feu, etc.)
APRÈS LA VENTE
- Mettre en place un suivi de courrier de LaPoste
- Faire le changement d'adresse auprès :
- Employeur
- Impôts
- Opérateur Internet : Free/FT/Bouygues?
- Opérateur Téléphonie Fixe/Mobile (FT/Free?)
- Assurances (MAIF/Radiance?)
- EDF/GDF
- Banques (même celle du crédit !)
ASSURANCES
- Elles peuvent être différentes de celles de la banque qui fait le prêt (d'ailleurs, il vaut généralement mieux faire appel à des extérieures car la banque passe des accords avec la sienne et se sert au passage, ce qui fait le coût total final plus cher pour le souscripteur)
PRÊTS
- Si on passe par un courtier (e.g. Meilleur-taux.com) => NE PAS faire de simulation avec sa propre banque, sinon ce dernier ne pourra pas le faire
- Normalement le courtier est gratuit, il se sert sur ce qu'il négocie avec la banque
- Faire retirer du prix les meubles laissés par le vendeur => évite les frais de notaire dessus
- Prêts relais et prêts à taux variable = DANGEREUX
- Demander/Négocier le remboursement anticipé sans frais (bien vérifier que TOUT sera gratuit, même les éventuelles nouvelles simulations)
- Quand la banque envoie la proposition de contrat, il faut respecter un délai de 11 jours MINIMUM pour l'étudier
- Faire attention aux conditions générales vs. spécifiques (ce sont ces dernières qui priment en cas de conflt)
- PTZ+ (Prêt à Taux Zéro) dépend de :
- Qualité énergétique du bien acquis
- Apport Personnel
- Montant du crédit
- ATTENTION: chez Crédit Agricole et Banque Populaire, chaque agence est indépendante => faire crédit dans une agence pratique/proche de chez soi.
- Plus tard, si les taux changent, il est toujours possible de renégocier le taux de son propre prêt avec sa banque, voire de faire racheter son prêt par une autre banque.
- (725)What are the steps of an international delivery?
- Posting
- Outward office of exchange
- Handed over to Air Carrier
- Arrival at inward office of exchange (=customs)
- Departure from inward office of exchange (in the US you won't have to pay fees, but they still inspect packages)
- Arrival at delivery office (your PO)
- Delivery
- (817)How to listen to French radios on the internet?
- Get the playlist of the corresponding radio:
http://www.listenlive.eu/franceinfo.m3u
- Use Mplayer or VLC or Audacious or any player you like :)
- Google Earth of world radios available on the web :)
http://radio.garden
- (820)How to remove bicycle grease from your hans?
First wash your hands with a drop of table butter, then wash them normally with soap!!!
- (972)Roller Skating sites
- Fédérations/Ligues
http://ffroller.fr/
http://cdrs91.fr/
http://www.roller-idf.org/
- Les randos parisiennes
http://pari-roller.com/ (vendredi)
http://www.rollers-coquillages.org/ (dimanche) http://321bastille.blogspot.fr/ (patineurs confirmés) http://www.planetroller.com/Rando-de-la-Lune.html (ambiance chaleureuse)
- Les randos locales
http://www.sqyrollers.fr/
http://www.csb-roller.net/
- Des sites de news :
http://www.rollerenligne.com
http://www.rollerfr.net/ (mort ?)
- Des Tips&Tricks pour entretenir ses rollers :
http://lesroulettescarrees.fr/assoce/techniques_bis.htm
- Pour les magasins :
http://www.hawaiisurf.com/
http://www.lamaisondupatin.fr/ (plutôt spécialisé Hockey/Danse) http://www.nomadeshop.fr et évidemment GoSport et Décathlon en moins spécialisés
- Des roues MadeInFrance !
http://www.spoconcept.com/nouveautes.php
- Un agenda des courses (pour 2013, on doit pouvoir jouer sur l'adresse pour avoir le mois en cours) :
http://ffroller.fr/ffroller/comp%C3%A9titions/calendrier.html#year=2013&month=5&day=29&view=month
- La plus belle course :
http://www.transroller.com/
- Le site des Voies Vertes (y'a notamment celle de Troyes et d'Évreux) http://www.voiesvertes.com/
- Pour la course des 6h de carole où j'étais il y a 2 semaines et qu'on peut citer comme ma participation en tant que CSX :
http://6hrollercarole.over-blog.com/ (site très pourri...) et les résultats (j'étais dans le duo Air Gif One, on a fait 25ème au scratch et 6ème parmis les Duos !) :
http://www.yaka-events.com/doc/Resultat/2013/6H%20CAROLE_2013_SCRATCH.pdf
http://www.yaka-events.com/doc/Resultat/2013/6H%20CAROLE_2013_CATEGORIE.pdf
- Tips&Tricks pour apprendre à rouler/freiner/slalomer
http://www.kompakombo.com/plan-site-kompakombo/liste-des-figures-de-slalom-roller-sur-kompakombo
http://www.rollerenligne.com/apprendre-le-roller
- (1374)How to convert cups to gramms?
* Butter
1 cup = 8 ounces = 8*28.34 grams = 227 grams
1/4 cup of butter = 57 g
1/3 cup of butter = 76 g
1/2 cup of butter = 113 g
* Dry Goods
- All-Purpose Flour and Confectioners' Sugar
1/8 cup = 16 g (= 2 Tablespoons)
1/4 cup = 32 g
1/3 cup = 43 g
1/2 cup = 64 g
2/3 cup = 85 g
3/4 cup = 96 g
1 cup = 128 g
- Bread Flour
1/4 cup = 34 g
1/3 cup = 45 g
1/2 cup = 68 g
1 cup = 136 g
- Rolled Oats
1/4 cup = 21 g
1/3 cup = 28 g
1/2 cup = 43 g
1 cup = 85 g
- White Sugar (Granulated)
2 Tbsp = 25g
1/4 cup = 50g
1/3 cup = 67g
1/2 cup = 100g
2/3 cup = 134g
3/4 cup = 150g
1 cup 201 g
- Packed Brown Sugar
1/4 cup = 55g
1/3 cup = 73g
1/2 cup = 110g
1 cup = 220g
* Honey, Molasses & Syrup
2 Tbsp = 43g
1/4 cup = 85g
1/3 cup = 113g
1/2 cup = 170g
2/3 cup = 227g
3/4 cup = 255g
1 cup = 340g
From: http://allrecipes.com/howto/cup-to-gram-conversions/
http://allrecipes.com/HowTo/Baking-Ingredient-Conversions/Detail.aspx
- (1332)Principaux noeuds d'escalade / Techniques d'alpinisme
From: http://www.emhm.terre.defense.gouv.fr/memento/alpinisme/fiches/liv-noeuds-c3m.pdf -> https://cupdf.com/document/liv-noeuds-c3m.html
https://assa-escalade.fr/wp-content/uploads/2014/04/liv-encordement-c3m.pdf
https://www.emhm.terre.defense.gouv.fr/index.php/fr/dossiers/163-memento-des-techniques-de-l-alpinisme-2022
http://thierry2311.free.fr/Memento%20techniques%20Alpinisme/Memento_des_techniques_d_alpinisme.pdf
http://www.ffme.fr/fiches-ffme-techniques/page/les-fiches-techniques-ffme.html
- (1300)Comment se débarrasser des acariens?
- Virer les Tapis / Rideaux en tissus
- Mettre du plastique autour des matelas/oreillers/literie
- Déshumidifier l'air / aérer souvent
- Refroidir les pièces à 18/19°C
- Faire le ménage souvent : passer aspi 1/semaine en général et 1/jour
sur les tapis
- Faire la poussière avec un chiffon humide
- Mettre les literies/peluches/rideaux au congélateur 48h
- Laver les literies/peluches/rideaux très chaud > 60°C
- Enlever le linge/literies/peluches/livres de la chambre
- Éviter les étagères ouvertes pour le linge/livres
- Répendre du bicarbonate de soude/alimentaire sur la literie, dans
l'aspirateur, dans l'air (spray d'eau tiède saturée en bicarbonate) et
dans la lessive
- Ne collez pas vos meubles contre les murs mais laissez 3 ou 4
centimètres entre le meuble et le mur.
- Pour vous débarrasser d'une allergie aux acariens, faites un séjour
de montagne : les acariens résistent rarement à l'altitude (plus de
1300 m.)
Achats
- Houses en plastique
- Déshumidificateur d'air
- Aspirateur à vapeur d'eau ?
Sprays
- Mélangez 1,5 litre d'eau + - 2 jus de citrons + - 2 cuillères à café
d'huiles essentielles (HE d'eucalyptus, de lavande, de menthe).
Vaporisez et laissez sécher.
- Le bicarbonate de soude serait un produit acaricide. Contre les
acariens, saupoudrez votre literie ou vos tapis de bicarbonate. C'est
facile et très peu cher.
---
En pulvérisation ou dans la lessive: Le bicarbonate est aussi très
efficace contre les acariens lorsqu'il est dilué dans de l'eau. Le
plus efficace est dans ce cas de préparer ce qu'on appelle une
solution saturée de bicarbonate, qui consiste à ajouter du bicarbonate
dans de l'eau tiède jusqu'à ce que les grains ne se dissolvent plus,
puis de le pulvériser sur le support à traiter contre les acariens.
Mais attention, après séchage, des traces blanches pourront
apparaître. Ces traces blanches disparaîtront facilement au lavage. Le
gros avantage de la pulvérisation de la solution aqueuse, c'est que la
répartition est bien homogène. Si la surface est intégralement
humectée, il y aura de très fins cristaux de bicarbonate partout après
séchage. Et alors là, les acariens n'ont plus une chance de lui
échapper ! Dans le cas du lavage à la machine, le fait d'ajouter du
bicarbonate à l'eau de rinçage retardera la réapparition des acariens.
--
From: http://www.les-remedes-naturels.com/2011/12/acariens-comment-sen-debarrasser.html
http://www.consoglobe.com/20-astuces-combattre-acariens-sans-toxiques-cg
http://www.monbicarbonate.fr/blog/2013/09/11/traitement-anti-acariens-bicarbonate-de-soude-allergies-lit-matelas/
http://www.planetesante.ch/Mag-sante/Ma-sante-au-quotidien/Comment-eliminer-les-acariens
http://www.allodocteurs.fr/actualite-sante-allergies-aux-acariens-comment-assainir-une-chambre-d-enfant--13035.asp?1=1
http://www.immunoctem.fr/produits.php#housses
http://sante-medecine.commentcamarche.net/contents/22-allergie-aux-acariens
- (1008)Bricolage / Montage de roller : Comment faire quand une vis (par exemple celle au fond de la chaussure quand on monte des quads) tourne en même temps que l'écrou ?
Le plus simple est de mettre une goutte de colle (super glue/frein filet) sur la vis, la visser dans la godasse, attendre un peu et ensuite une fois qu'elle ne tourne plus mettre l'écrou.
Thanks Romu!
- (1032)How to convert Wh into mah?
mAh = Wh × 1000 / V
From: http://www.rapidtables.com/convert/electric/wh-to-mah.htm
- (1282)CLimbing Knots
Cabestan : 2 boucles on les pose l'une sur l'autre avec les bouts qui
doivent sortir vers l'intérieur, chacun d'un côté
http://www.animatedknots.com/
- (1283)Height of summits I've reached
Grand Paradis - 2012 - 4061m - https://en.wikipedia.org/wiki/Gran_Paradiso - https://fr.wikipedia.org/wiki/Refuge_Victor-Emmanuel_II
Mont Blanc, Refuge Vallot - 2013 - 4362m - https://en.wikipedia.org/wiki/Mont_Blanc / http://fr.wikipedia.org/wiki/Refuge_Vallot - https://en.wikipedia.org/wiki/Refuge_Vallot - https://fr.wikipedia.org/wiki/Refuge_du_Go%C3%BBter
Aiguille du Midi - 2013 - https://fr.wikipedia.org/wiki/Refuge_des_Cosmiques
Monviso - 2014 - 3841m - https://en.wikipedia.org/wiki/Monviso - (IIIsup?) / https://www.youtube.com/watch?v=4Vuj_PUwUsk - http://www.refuges.info/point/1288/refuge-garde/queyras/refuge-du-viso
Vignemale - 2014 - 3298m - https://en.wikipedia.org/wiki/Vignemale - https://fr.wikipedia.org/wiki/Refuge_Bayssellance
Aneto - 2014 - 3404m - https://en.wikipedia.org/wiki/Aneto - (IIsup? - "Pas de Mahomet") / https://www.youtube.com/watch?v=QU4qGzHLwkg - https://fr.wikipedia.org/wiki/Refuge_de_la_Rencluse
Col Infranchissage - 2015 - 3349m - https://fr.wikipedia.org/wiki/Col_Infranchissable https://fr.wikipedia.org/wiki/Refuge_des_Conscrits
Aiguille de la Bérangère - 2015 - 3425m - https://fr.wikipedia.org/wiki/D%C3%B4mes_de_Miage
Dent Parrachée - 2022 - 3695m - https://fr.wikipedia.org/wiki/Dent_Parrach%C3%A9e / https://www.camptocamp.org/routes/48247/fr/dent-parrachee-par-le-versant-s-du-col-de-la-dent-parrachee-voie-normale- / https://www.altituderando.com/La-Dent-Parrachee-3697m (Facile Techniquement mais Difficile Physiquement : Montée Raide dans Pierrier & Fort Engagement: beaucoup de gaz + petit passage à la "Pas de Mahomet")
via Pointe de la Fournache - 2022 - 3642m - https://frn.wikipedia.org/wiki/Pointe_de_la_Fournache
- (1229)How to know which way to dig when buried by an avalanche?
Just spit: the saliva follows gravity, just dig the opposite way.
- (1199)How to solve the itching sensation and prevent scratching (and cure?) eczema crisis?
After trying with salt (which provides the same relief as scratching, but does not help in fine - since it hurts the skin as much as scratching), I recently discovered that "burning" the skin with (gradually) hot(ter) water until is actually burns, gives the same pleasure/sensation as scratching, but does not hurt the skin, thus helping in healing faster. However, it dries up the skin, so its is better to regenerate the skin right after the burning process, by applying some oil (I've tried Tea Tree/Lavender dilued in edible Olive/Sunflower Oil and "CrimpOil", with no difference) or non-greasy cream (like the La Roche-Posay's Lipikar cream, or Nivea or Neutrogena). Also I noted that it is better to wash again the hands later (1h or 2h) to remove to oil film from the skin to help it "breath" again.
And while searching on the internet, I found that I'm not the only one that this technique helps!!!!
--
I had really bad ecezema that was actually driving me crazy, I couldn't sleep. It was behind my elbows and my knees. I tried every cream and crazy idea but most made things worse.
So my theory ran that ecezma is a rash that spreads by scratching, from the edge of the rash outwards. When you scratch the skin damages and thickens. This makes it itchy so you scratch and it goes on. The more you scratch the more it itches. So the key is to break the cycle. It's not practical to say 'just don't scratch', ask anyone with eczema, you might as well have bugs on your skin. So I thought to trick my brain into thinking I was scratching by doing something else that would remove parasites (the trigger of the primal urge to scratch).
The trick is heat. You can use a hair dryer but hot water from a shower works best as a hair dryer can leave the skin feeling sore. As soon as you start to get 'that itch', point the shower head at the rash. Starting at the edges hold the shower head to the water points at the rash and then gradually increase the heat until it is unbearable - then hold it for a couple of seconds. The itching will stop at that area. Do this for the entire rash and at all locations you have it. You will notice the skin looks a bit red and feels soft if you've done it right.
Everytime you get an itch only do this - or use a hair dryer. Because your not scratching you're not damaging the skin so it slowly heals and the skin thins. The itching becomes less intense as you go as well. Never be tempted to scratch, even once it's gone your not safe for a few weeks and as I found it can return. Looking at my skin now you would never know how bad it was.
---
Some other people in the forum say that these also help:
- Evening Primrose Oil (capsules)
- Turmeric (capsules)
- Fish oil (couple of capsules a week)
- Tea Tree Oil (ointment)
- Zinc (apparently better in ointment than capsules: http://www.livestrong.com/article/494803-zinc-oxide-to-treat-eczema/)
PS: note that all traditional medecine doctors told me to never use oil... Whereas it actually works better than their creams!
From: http://www.godlikeproductions.com/forum1/message1652730/pg1
- (1164)What are the good/bad stations for skiing ni France?
Briançon ++ (good black slopes, easy access/transfert between slopes, high altitude) - end feb/early march is best
---> TO SAVE MONEY ASK A TRAIN TICKET TO Oulx!!!
Tignes ++ (good black slopes, easy access/transfert between slopes, high altitude)
Arc ++ (good black slopes, easy access/transfert between slopes, high altitude)
La Plagne - (some black slopes, domain splitted if not so much snow => large transfert times, high altitude)
- (1140)Things to take when going to ski?
- Petit sac à dos pour porter le sandwich du midi+l'eau
- Crème Solaire
- Serviette de toilette / Trousse de toilette
- Combinaison / Bonnet / Gants / Masque ou Lunettes / Collant / Grosses Chaussettes
- Couteau Suisse / Lampe (frontale)
- Courses (moins cher en vallée qu'en altitude) :
- pates
- lait
- bieres
- sauce tomate bolognaise x2 ou 3
- chocolat nesquick
- 1 éponge
- sopalin
- PQ
- 1 torchon qui peut servir
- sacs poubelle
- 1 savon pour les mains ou ton liquide vaisselle histoire de pas en acheter et le laisser sur place (idem pour l'éponge et le torchon)
- produit pr lave vaisselle
- saucisson - cornichons - chips
- jambon
- steacks haché
- 2 douzaines d'oeufs
- coca
- jus d'oranges
- yaourt
- sucre - sel - poivre
- fromage rapé
- céréales pour qui veut ou gateau je sais pas pour le 4h ou casse croute
- nutella - beurre - pain de mie
- lingettes nettoyantes
Thanks Meï
- (1150)Things to take when going to bouldering day
- Crashpad
- Chaussons
- Brosse (à dents/ongles) pour prises
- Pof + sac
- Topos
- Beaucoup d'eau
- Alimentation sucrée
- PQ
- Sacs poubelle
- Trousse à pharmacie
- Strap / Sparadrap
- (1121)Climbing Tips
- Clipser niveau BASSIN/TÊTE
- Clipser BRAS TENDU et JAMBES FLÉCHIES (les jambes portent le poids)
- Une fois clipsé, monter les pieds AVANT les bras (les jambes lèvent le poids)
- arqué (consomme ++ énergie) / semi-arqué (consomme ~ énergie) / tendu (consomme -- énergie)
- crochet talon : tirer dessus pour mettre le poids sur la prise. Pas besoin de sortir la pointe vers l'extérieur
- "relancer" = prendre la PROCHAINE PRISE avec la MÊME MAIN que la dernière
- quand on prend une PINCE, généralement on consomme moins d'énergie en étant sur la carre EXTERNE
- sur un PLAT => PLAQUER avec les pectoraux (charger le poids du corps avec les bras)
- "engagé" = une fois parti, une seule sortie possible, pas de secours/sécurité en chemin
- @X: se lever pour se ré-équilibrer
- @X: utiliser la pointe du chausson est plus précis, plus sensible et permet de se relever plus haut qu'avec une carre extérne ou interne.
- (1132)What to do if your phone time is wrong (with FreeMobile@SamsungGalaxy)?
1. Go to Parameters -> Wireless Connexions -> Airplane Mode (enable)
2. Go to Parameters -> Date and Time (disable Automatic)
[Wait a few seconds]
3. Go to Parameters -> Date and Time (enable Automatic)
[Wait a few seconds]
4. Go to Parameters -> Wireless Connexions -> Airplane Mode (disable)
- (1108)Simple and efficient Scrabble helper :)
grep <the start of the word present on the board> /usr/share/dict/words | grep <letter you have 1> | grep <letter you have 2> |... | grep <letter you have n>
--
#! /bin/bash
if [ $# -le 0 ] ; then
echo "USAGE: $0 <start of word> <letters you have>"
else
wordStart=$1
letters=$*
letters=`echo $letters | cut -d' ' -f 2-`
endCmdString="grep ${wordStart} /usr/share/dict/words"
for i in $letters; do endCmdString=${endCmdString}" | grep $i" ; done
eval $endCmdString
fi
--
You can add/install the French dictionary with:
# apt-cache search wfrench
wfrench - French dictionary words for /usr/share/dict
From: http://www.macworld.com/article/1041504/jangeekfactor.html
- (1079)List of cool games / Jeux de société sympa
- Images à reconnaître
-> Dobble
http://www.trictrac.net/jeu-de-societe/dobble/infos
-> Bazar Bizarre
http://www.trictrac.net/jeu-de-societe/bazar-bizarre/infos
-> Hands Up
http://www.jeuxdenim.be/jeu-HandsUp
http://www.trictrac.net/jeu-de-societe/hands-up/infos
-> ...
- Expressions inversées
-> Contrario
http://www.trictrac.net/jeu-de-societe/contrario-1/infos
- Mots à deviner
-> Bluffer
http://www.trictrac.net/jeu-de-societe/bluffer-0/infos
-> Linq
http://www.trictrac.net/jeu-de-societe/linq/infos
- Planches/iles
-> River Dragons
http://www.trictrac.net/jeu-de-societe/river-dragons/infos
- Collaboratif/mp3
-> SpaceAlert
http://www.trictrac.net/jeu-de-societe/space-alert-0/infos
- Jeux en équipes
-> Times Up / Jungle speed :)
http://www.trictrac.net/jeu-de-societe/time-s-up-/infos
-> Wanted ! (renégat)
http://www.trictrac.net/jeu-de-societe/wanted-/infos
- Programmation/robot
-> RoboRally
http://www.jeuxdenim.be/jeu-Roborally
- Histoire
-> TimeLine
http://www.trictrac.net/actus/timeline-et-timeline-sont-dans-un-bateau
- Jeux rapides à nombre variable
-> Salade de Cafards
http://www.trictrac.net/jeu-de-societe/salade-de-cafards/infos
-> Mow
http://www.trictrac.net/jeu-de-societe/mow-0/infos
- Conquête de territoires
-> 7 wonders
http://www.trictrac.net/jeu-de-societe/7-wonders/infos
-> Carcassonne
http://www.trictrac.net/jeu-de-societe/carcassonne-2/infos
-> Colons de Catane...
http://www.trictrac.net/jeu-de-societe/les-colons-de-catane/infos
- (1425)How to prepare the annual meeting with the boss (Entretien Annuel) in order to make it useful for everybody?
The goal is to build on our respective strength and address our weaknesses. Although we will speak a little bit about 2014, the spirit is not to evaluate / judge / give blames, but rather to improve for 2015.
In addition, this is meant to be a reciprocal discussion.
Here are the 3 main points we will speak about:
1. Review of the past year
what were the objectives?
what has been done?
what was the value for the company?
2. What are the new objectives for the company?
3. Professional development
what are you good at? what do you like the most (work-wise!)?
what are you not good at?
what is your best day at work?
what is the worst one?
what is the best environment? (time of the day, time with the boss, independence, recognition etc.)
what competences would you like to develop?
what is your learning style?
analysing => classroom
doing => action
watching => shadowing
how can I / the company help you to develop these skills?
what indicators do you suggest to measure the improvement?
have you improved since last year? Why? Why Not?
- (1426)Things to take when going to peak climbing/alpinism?
- Sac à dos 30l++
- Serviette + Trousse Toilette
- Crème Solaire + Trousse Secours
- Keffieh / Écharpe / Buff
- 3 polaires + t-+shirts manches longues "chauffant"
- Un sac poubelle plastic pour garder les fringues au sec
- Parka / K-way
- Matelas + Sac couchage + sur-sac étanche + sous-sac à viande en soie
- Couteau suisse / Pince multi-fonction / Scie survival
- **Briquet** / Kit allumage feu survival
- Poche à eau + Fruits secs
- Gamelle de camping
- Frontale et piles
- Piolet + Casque + Chaussures+Crampons + Baudrier + Corde
- Cartes IGN
Thanks Manu!
- (1446)When to congratulate and blame?
We congratulate in public and blame in private
Thanks AM
- (1514)How to know how google is perceives you and access what it knows about you (a.k.a. special google URLs)?
https://security.google.com/settings/security/activity
https://www.google.com/settings/dashboard
From: http://gawker.com/5879895/how-old-does-google-think-you-are
- (1535)How to manage a sprain (entorse)?
Use the mothodology:
- R(est)I(ce)C(ompression)E(levation)
a.k.a., in French:
- G(lace)R(epos)E(levation)C(compression)
- (1539)Les 4 accords Toltèques
- Avoir une parole impeccable (ne pas dire du mal des autres)
- Ne pas tout prendre pour soi (quand les autres disent du mal de vous)
- Ne pas faire de suppositions (arrêter de trop cogiter)
- Toujours faire de son mieux.
- (1568)Sustainable Alternatives to industrial agriculture
- Permaculture
- Biodynamie
- Agro-écologie
- Agro-foresterie
- Hydroponie
- Aqua-ponie
- (1569)Sustainable Development People
- Bill Mollison (permaculture)
- Geoff Lawton (permaculture)
- Masanobu Fukuoka (permaculture)
- Pierre Rabhi (biodynamie)
- Claude et Lydia Bourguignon (soil biology)
- David Attenborough (biodiversity)
- (1600)Recettes Ghee + Naan + Paratha
- Ghee (Beurre cuit indien qui se conserve plusieurs mois hors du frigo)
https://www.youtube.com/results?search_query=faire+des+paratha
- Les Naans
https://www.youtube.com/watch?v=OWznQj-G0qw
- Les Parathas
https://www.youtube.com/watch?v=PUUFDnhhAn4
- (1604)Progresser en Escalade
- Volume :
-> exos < niveau max, non lesté
-> beaucoup (10+) répétitions, sans arrêt
-> récupération : ???
- Résistance :
-> exos = niveau max, légèrement lesté
-> plusieurs (4 à 6) répétitions, *sans arrêt*
-> récupération 20min entre séries
- Force :
-> exos > niveau max + exos complémentaires (abdos/tractions/...), très lestés
-> quelques (1 à 3) répétitions, avec arrêts possible
-> récupération 20min entre les séries
- Souplesse + Étirements !!!
- (1605)Complément alimentaire naturel
spiroline
- (1634)Commencer par un bon petit déjeuner
- LE MIAM-Ô-FRUITS (France Guillain)
-> 1/2 banane bio moyenne écrasée à la fourchette (elle doit changer de couleur : s’oxyder pour passer de l’état d’amidon à celui de protéines végétales)
–> 2 cuillères à soupe d’huile de colza vierge de première pression à froid bio
–> le jus d’1/2 citron bio pressé (vitamine C)
–> 1 cuillère à soupe de graines de lin (broyées finement, moins de 7 jours avant, conservées sous-vide ; attention, deviennent toxiques après 7 jours ; pour les neurones)
-> 1 cuillère à soupe de graines de sésame (broyées finement, moins de 7 jours avant consommation, conservées sous vide ; pour le calcium)
–> 1 cuillère à soupe d’un mélange d’au moins 3 autres graines oléagineuses bio moulues (amandes, noix, noisettes, graines de tournesol, de courge, cajou, arachide, noix de macadamia, noix de pécan...)
–> 3 fruits frais et crus de saison
-> La préparation
* Dans une assiette, écrasez votre banane et mélangez-y l’huile, puis le jus de citron.
* Rajoutez les graines de sésame et de lin moulues.
* Rajoutez ensuite les graines oléagineuses.
* Parsemez de vos fruits coupés en morceaux.
-> Pensez à manger dans le calme
-> Prenez bien soin de mastiquer chaque bouchée
-> Ne pas mettre d’agrumes, en dehors du jus de citron, car ils ne se digèrent pas au même rythme que le reste.
-> Ne pas mettre non plus de melon ou de pastèque, car ils accélèrent trop le transit et ne permettent donc pas l’assimilation de toutes les bonnes choses absorbées.
- LA CRÈME BUWIG
-> protéines + acides gras essentiels : 1/2 yaourt (yaourt nature, fromage blanc, yaourt de soja, petit suisse...) + 2 cuillerées à café d'huile végétale (lin, sésame, tournesol, amande ou noix)
Il faut bien émulsionner l’huile et le produit laitier.
-> 2 cuillerées à café d'un produit sucrant (sucre roux, miel, sirop d'agave, stevia) ou bien des fruits secs (3 càc de raisins ou 5 fruits de type figue/pruneau/abricot/...) ou 1/2 banane mûre.
-> 1 type de céréales bio et complètes.
–> 2 cuillerées à café de graines (riz, avoine, quinoa, millet ; germé ou moulu) (ATTENTION : pas de blé).
-> 2 cuillerées à café d'1 type d'oléagineuse (noisettes, amandes, lin, tournesol, courge, sésame, pignons, noix de cajou...)
-> Des fruits
* 1/2 citron pressé, mélangé avec le reste
* 150 à 200g de fruits frais crus et de saison, posés sur le reste)
From: http://www.ecoloinfo.com/2010/02/02/le-miam-o-fruits/
http://www.cleacuisine.fr/autres-desserts/la-cr-me-budwig-le-petit-d-j-sant/
- (1635)How to make best cookies?
- 250g sucre (à partager 30% blanc/70% roux)
- 1 sachet sucre vanillé (pas trop parfumé!)
- 2 œufs entiers
- 240g de farine (à partager en farine 70% T45 + 30% froment)
- 1 sachet de levure (éventuellement levure boulanger)
- 125g beurre ramolli
- 300g chocolat noir/caramel/lait (mettre au congèl puis casser au marteaux)
+ Coco rapée
+ Céréales du matin
+ Cardamome
- Tout mélanger dans cet ordre
- des petits tas sur un plat/plaque
- Four 200°C, 5 minutes max (sortir avant qu'ils roussissent)!
- Faire refroidir/durcir dans le plat
Thanks Ade
- (1647)How to repair/fix a broken zipper (a.k.a réparer une fermeture éclair)?
- 1ère solution : la douceur.
On prend juste une pince, et on resserre le curseur en appuyant sur le
dessus et le dessous de sa partie la moins large.
- 2ème solution : on coupe!
On commence par donner un petit coup de ciseaux à l'extrémité de la
fermeture de chaque côté et entre les dents. Cela vous permet de
débloquer le curseur et l'enlever.
On reserre le curseur avec une pince.
On le réinsère sur le zip, un côté puis l'autre.
Et là, il recoulisse nickel!
Il ne reste plus qu'à faire un point de blocage pour que le curseur ne se sauve pas!
From: http://casadolcecasa.canalblog.com/archives/2011/08/31/21908910.html
There are even more tips here: http://fr.wikihow.com/r%C3%A9parer-une-fermeture-%C3%89clair
- (1656)How to keep warm feet in winter?
You can create your own insulating footsole by carving/clipping an "image" of the current footsole of your shoe into a "cheap 1$ store car sunshade"
From: http://www.koreus.com/video/astuce-pied-chaud.html
- (1670)How to draw cartoon faces?
1. Nose (Round/Pointy ; Large/Small)
2. Eyes (Open:66/Closed ; Joined/Spaced ; Glasses ...)
3. Ear (Round/Pointy ; Large/Small ; with internal line)
4. Mouth (Round/Dot ; Filled/Tooth/Empty ; Moustache ;)
5. Hairs (Bald ; Curly ; Sun-rays ; Cloudy ; Sheep-like ; Tintin tuft ; Baby 3-spikes ; Catogan with knot)
6a. Left Neck (From left of mouth, downward, in inverted S shape)
6b. Right Neck (From below the ear, straight downwards)
7a. Collar (Round/V-shape)
7b. Left Shoulder (Round/Straight)
7c. Right Shouler (Round/Straight)
http://www.koreus.com/video/apprendre-dessiner-tedx.html
https://youtu.be/7TXEZ4tP06c
- (1675)Mechanical Tips
- Demultiply speed: use small & big dented wheels (like bike speed)
- Demultiply movement: use a stick with a larger and short edge: short movement up on shorter edge transmits bigger movement down on larger edge (bras de levier)
- Transform round movement to linear une: use wheel with de-axed rotation point (like train locomotive wheel)
- Transform down movement into up movement?
- Transfer force: use a metal wire. On one side, use a pivot that shortens the wire, which transmits the shortening to another point, where it is converted again to pivoting force (like toilet button or old remote camera shutter)
Also see ideas of animal traps in Survival Videos
- (1691)Assocs à qui donner
- Framasoft
- April
- OpenBSD
- Quadrature du net
- EFF
- Librivox
- FSF
- Wikipedia / Wikimedia
- Aaron Schwartz ?
- Amnesty International
- Greenpeace
- MSF (Carmen: no?)
- Médecins du Monde
- ATD quart-monde
- Mandela?
- Abbé Pierre?
--- Achats
- S!lence Mag
- Canard Enchaîné
- Charlie Hebdo
- La Hulotte
--- Banques
- Nef
- Crédit Coopératif
- ZOB-madagascar (Zebus Overseas Bank)
- (1703)Outdoor tips&tricks!
- Primitive Technology Channel
https://www.youtube.com/channel/UCAL3JXZSzSm8AlZyD3nQdBA
- IntenseAngler Channel
https://www.youtube.com/channel/UCkZqmunq1xPgj7IcK7D7X0A
- From SYSK
https://naturalskills.wordpress.com/
- (1725)Comment détecter un AVC?
1. Faire un sourire
2. Dire une phrase simple ("Il fait beau aujourd'hui", "Je suis venu en voiture")
3. Lever les 2 bras en même temps
4. Tirer la langue
From: https://www.youtube.com/watch?v=wR6q6B46DWo
- (1734)Comment skier dans la poudreuse/bosses ?
- serrer les genoux (+tibias+skis)
- pousser sur l'arrière (pour faire ressortir l'avant et "flotter" sur la poudreuse)
- tourner au sommet des bosses
- penser au planté de bâton (permet de faire se baisser/redresser avec un petit mouvement de saut)
- (1765)How to be an organized/efficient person + Softs to reach this goal?
* Méthodes
** GTD
https://fr.wikipedia.org/wiki/GTD
** Pomodo
https://fr.wikipedia.org/wiki/Technique_Pomodoro
** Kanban
https://fr.wikipedia.org/wiki/Kanban
** Matrice de Eisenhower (importance vs. urgence)
http://mathieulaferriere.com/prioriser-importance-urgence-matrice-eisenhower/
+See Tip#1806
** Hannane@Remix+Marine@Geekster: organiser son temps par slots
*** Par mois/semaine/journée
*** Slots de 1h de mails/veille le matin
*** Slots de 2h pour le boulot
**** Tâches pour tous: veille, email, repos (méditation, visualisation, musique, pause café/babyfoot)...
**** Tâches spécifiques: crawling, small code (debug/improvments/Gui/Dashboards, big code (new versions), admin (install DB cleaning/merging/indexing)...
*** Sur interruption (RDV, coup tél, etc.), ne JAMAIS changer les TAILLE des slots, juste les déplacer
* Softs [Also see Tip#1971]
** Gestion tâches
*** Trello
https://trello.com/
*** Slack
https://slack.com/
*** Toggl
https://toggl.com/
*** Scilaps???
*** OpenSource
**** WeCan
https://wekan.io/
**** KanBoard
http://kanboard.net/
**** Exo Platform
https://community.exoplatform.com/portal/intranet/
**** MatterMost
http://www.mattermost.org/
**** ScudCloud
https://github.com/raelgc/scudcloud
**** Taiga
https://taiga.io/
**** TaskBoard
https://taskboard.matthewross.me/
**** Gnome Planner (local-only?)
https://alternativeto.net/software/gnome-planner/
** IA pour soulager prise de RDV
*** JulieDesk
https://www.juliedesk.com/
*** SlackBot
https://get.slack.help/hc/en-us/articles/202026038-Slackbot-your-assistant-notepad-programmable-bot
** Gestion de process
*** MailChimp??? (gestions d'emails: réponses autom, propositions de réponses, etc.)
http://mailchimp.com/
*** HootSuite (réseaux sociaux)
https://hootsuite.com/
** Connection (connect Apps : agenda+emails, etc..)
*** Zapier
https://zapier.com/
*** IFTT
https://ifttt.com/
** Veille/Curation (identifier des sources de contenus, trier les contenus les plus pertinents, présenter sous une forme synthétique)
*** Pocket (offline+share)
https://play.google.com/store/apps/details?id=com.ideashower.readitlater.pro
*** gReader (offline RSS)
https://play.google.com/store/apps/details?id=com.noinnion.android.greader.reader
*** AntennaPod (offline PodCast)
https://play.google.com/store/apps/details?id=de.danoeh.antennapod
** CRM (intégration contacts, agenda, mails, etc.)
*** pipedrive
https://www.pipedrive.com/
*** bestcamp/testcamp???
** Factures/Devis
*** Factomos
http://factomos.com/
*** Incwo
http://incwo.com/site
*** Sellsy
https://www.sellsy.com/
** Paiment
*** Paypal
https://www.paypal.com/fr
*** Stripe
https://stripe.com/fr
** Contacts (stats => relance de ceux qu'on a oubliés)
*** Contactually
https://www.contactually.com/
** Autres
*** Evernote
https://evernote.com/
*** Zotero
https://www.zotero.org/
*** Draw.io (moins limité en taille que GoogleApps, collaboratif)
https://www.draw.io/
*** Mindmaps
https://en.wikipedia.org/wiki/List_of_concept-_and_mind-mapping_software
https://www.mindomo.com/
https://app.wisemapping.com/c/maps/3/try
https://bubbl.us/
https://www.mindmeister.com/
http://mind42.com/
http://www.comapping.com/
https://www.imindq.com/
http://www.mapul.com/
* Livres
** Rework J. Fried, D. H. Hansson 37Signals
- (1770)Restaurants in Rennes
- La Tomate [pizza - very small restaurant]
rue Saint-Georges
Rennes
- (1778)Alternative news/information mailing-lists
- http://www.amnesty.fr/
- http://www.greenpeace.fr
- http://www.arretsurimages.net
- http://avaaz.org
- http://www.agoravox.fr
- http://rue89.nouvelobs.com/
- http://www.slate.fr
- http://www.survivalinternational.org/
- http://www.raoni.com
- (1800)Interesting books
- Économie
- "Petit Traité de Manipulation à l'Usage des Honnêtes Gens" (Robert-Vincent Joule et Jean-Léon Beauvois)
- "Freakonomics" (Steven D. Levitt + Stephen J. Dubner)
- Piketty
- Philosophie / Mode de vie
- "Les quatre accords toltèques" (Miguel Ruiz)
- "Plaidoyer pour l'altruisme" (Matthieu Ricard)
- "Petit guide à l'usage des gens intelligents qui ne se croient pas très doués" (Béatrice Millêtre)
- Éducation
- "J'ai tout essayé !", "Au coeur des émotions de l'enfant", "Il me cherche !" et "On ne se comprend plus" (Isabelle Filliozat)
- Science
- Gut (Giulia Enders)
- Are We Smart Enough to Know How Smart Animals Are?
The Age of Empathy
The Bonobo and the Atheist
Chimpanzee Politics
Our Inner Ape (Frans de Waal)
- Ni homme, ni femme (Julien Picquart)
- Collection "Que sais-je ?"
- Informatique
- O'Reilly
- Addison-Wesley
- Prentice-Hall
- McGraw-Hill
- No Starch Press
- Plantes / Alimentation
- "Permaculture: A Designers' Manual" (Bill Mollison)
- Éditions de Terran
- http://horizonalimentaire.fr/ambassade/manuels-et-outils/le-manuel-de-cuisine-pour-tous
- http://horizonalimentaire.fr/ambassade/manuels-et-outils/le-manuel-des-jardiniers-sans-moyens
- DVD "Les Blés d'or - Un film sur les rencontres des Paysans-Boulangers"
- "Eating Animals" (Jonathan Safran Foer)
- Autre populations / Voyages
- Collapse (Jared Diamond)
- Tristes Tropiques (Claude Lévi-Strauss)
- Jean Malaurie
- Carlos Castaneda
- Théodore Monod
- Alexandra David Néel
- Ella Maillard
- Collection "Terre Humaine"
- Politique
- Collection DVD: "Le Dessous des Cartes"
- Collection "Que sais-je ?"
- "Collapse: How Societies Choose to Fail or Succeed" (Jared Diamond)
- Montagne
- Éditions Guérin
- (1806)How to better organize your tasks with Eisenhower matrices (importance vs. urgency)?
^
Imp | 1 | 2
|_______|________
| |
NonImp | 3 | 4
+---------------->
Urg. NonUrg
AM: 1) de suite ; 2) Plus tard ; 3) Déléguer ; 4) Laisser tomber
Site: "L’importance est un choix et l’urgence est un fait"
=> Prioriser Importance sur Urgence => faire dans l'ordre 1->4
8 questions pour déterminer si vous travaillez sur ce qui est important
Pourquoi faites-vous ceci ?
Quel problème êtes-vous en train de résoudre ?
Est-ce que c’est réellement utile ?
Ajoutez-vous de la valeur ?
Est-ce que cela va entraîner un changement de comportement ?
Est-ce qu’il y a une façon plus simple d’y arriver ?
Quoi d’autres pourriez-vous faire à la place ?
Est-ce que ça vaut réellement l’effort ?
4 comportements qui nuisent à une gestion de temps efficace
Je me précipite dans l’action
Je sous-évalue la durée des tâches
Je dérive et reporte sans arrêt
Je n’anticipe pas suffisamment à moyen et long terme
From: http://mathieulaferriere.com/prioriser-importance-urgence-matrice-eisenhower/ + Thanks AM
https://www.developgoodhabits.com/eisenhower-matrix/
https://www.developgoodhabits.com/wp-content/uploads/2017/05/Eisenhower-Matrix-Diagram.png
- (1814)What's the difference between Left/Right brain?
- Left: serial thinking, sequencing, linear, analytics, reasoning, logic, facts, words, maths...
- Right: parallel thinking, arborecent, art, creativity, intuition, rythm, feeling, non-verbal, visualization, imagination, love...
- (1845)Things that have a name and you didn't know it?
Barm
The foam on beer
Punt
The indent on the bottom of a wine bottle
Griffonage
illegible handwriting
Armscye
The armhole in clothing.
Wamble
A stomach rumble.
Rhinotillexomania
Obsessive nose picking
Petrichor
The smell after rain.
Caruncula
The small triangular bump on the inside corner of your eye.
Apricity
The feeling of being outside on a cold day but feeling the warmth of the sun.
9These Things Actually Have a Name, And You Probably Didn’t Know It
Mondegreen
Misheard lyrics.
Rectal Tenesmus
The feeling of.. um… incomplete defecation.
Grawlix
A string of typographical symbols that is used to indicate profanity.
Feat
A dangly piece of curly hair.
Skeuomorph
A design feature copied from a similar artifact in another item, even
when not necessary. For example, the shutter sound on a digital camera.
Parasthesia
That pins and needles feeling you get when a body part falls asleep.
Peen
The side opposite the hammer’s hitting side.
Muntin
The strip separating window panes.
Semantic Satiation
That feeling when you say a word too many times and it loses it’s meaning.
Acnestis
The area that’s hard to reach between your shoulder blades.
Scroop
The rustling swooshy sound that ball gowns make.
Biblioklept
A compulsive book thief or hoarder.
Zugzwang
When you’re playing chess and every possible move is to your disadvantage.
Desire path
A path created naturally because it’s “the shortest or easiest” way.
Semordnilap (It’s literally “palindromes” backwards.)
A word that reads one way forward and another way backward. For example, “desserts,” “diaper” and “parts.”
Dysania
The difficulty of getting out of bed in the morning.
From: http://izismile.com/2016/07/20/these_things_actually_have_a_name_and_you_probably_didnt_know_it_19_pics_6_gifs.html
- (1858)How to get a nice ASCII-art weather forecast on the console?
wget -O- wttr.in/paris
Also see Tip#2088
From: http://www.commandlinefu.com/commands/view/17709/nice-weather-forecast-on-your-shell
- (1873)How to easily put the cover back on the duvet?
1. Lay the cover inside-out on the bed
2. Lay the duvet on top of it
3. Roll the couple duvet+cover as a burito, starting from the closed end
4. Put your arm into the cover, move to the first corner and grab the duvet corner ; put it inside-out
5. Repeat last step with the other corner
6. Unrool
7. Spread-out/flatten everything
From: http://www.koreus.com/video/duvet-burrito.html
- (1912)How to save time in life, while watching movies?
- Use VLC Player or mplayer to watch your movies.
- Press the "]" to speed everything up by 0.1x for each individual key
press (inversely, press "[" to slow everything down by 0.1x).
- At 1.2x of normal speed, you will rarely notice anything
distracting, but you will see the time stack up.
- For every hour of movies you watch and podcasts you listen to,
you'll save 12 minutes.
- A 2 hour movie will "give" you 24 minutes of free time that you
wouldn’t have had before. I listen to all my podcasts at 1.5x speed
for 30 minutes of free time for each 90 minute podcast.
If you want to preserve the pitch (i.e. voices do not get squeaky):
mplayer -af scaletempo -speed 2.0 mymovie.avi
vlc --audio-time-stretch --rate 2.0 mymovie.avi
From: http://www.kickassfacts.com/5-life-pro-tips-of-the-week-part-59/
https://www.techwalla.com/articles/how-to-change-the-pitch-in-vlc
man mplayer [/pitch /-speed]
man vlc [/pitch /speed]
- (1913)Send cheap mail in the world?
Use "STS" (a.k.a. "Student to Student") in place of the stamp!
Thx Sylvain!
- (1934)How is sex defined?
There are, at least, 5 definitions of sex/gender, none of which
accepts only 2 possibilities:
- Genotypic (does the person possess XX, XY, XXY, XYY... genes?)
- Phenotypic (does the person look like a female/male: tits,
penis/vagina, qty of hairs, size of hips...)
- Hormonal (what proportions of testosteron/œstrogen the person does
generate?)
- Gonadic (does the person have testicles/ovaries/both/none?)
- Social (does the person act like a female/male: dresses with
dresses/pants, likes cooking-hunting-raising kids...)
From: "Ni homme, ni femme : enquête sur l'intersexuation" Julien Picquart
https://fr.wikipedia.org/wiki/Intersexuation#Les_crit.C3.A8res_de_d.C3.A9finition_du_genre
- (1972)How to enter into any too small footwear (shoe, climbing shoe, diving suit)?
Just wrap a plastic bag around your feet, and it will enter the footwear smoothlessly!
From: ArkoseMassy
- (3832)Les meilleures courses dans la Loire/vers Saint-Étienne
+ Trail Bessat
https://www.terrederunners.com/inscriptions-aux-courses/trail-du-bessat-2022/
- 11km / 22km
- 11/09
+ Icio Trail, Usson en Forez
https://ussonsportnature.wixsite.com/iciotrail
- 4km / 10km / 22km / 30km
- 18/09
+ Backyard Cordelle (160D+)
https://www.backyard-cordelle.fr/
- 6.706 km en moins 1h
Cordelloise = mini backyard (5 tours max)
- 30/09
+ UTMJ
https://www.ultra-trail-montagnes-jura.fr/
- 20km / ... / 170km
- 01-02/10
+ Foulées Veauchoises
https://www.fouleesveauchoises.com/foulées-veauchoises-2022/
- 6km / 11km / 21km
- 02/10
+ Marathon de Lyon
https://www.runinlyon.com/en/races/marathon
- 42.195km
- 02/10
+ Trail du haut pilat
https://www.trailduhautpilat.com/
- 7km / 14km / 25km
- 15/10
+ Chartreuse Backyard
https://www.chartreusebackyard.fr/b/
- 6.7 km en moins 1h
- 04/11
+ Trail urbain
http://stu42.fr/
- 11km / 20km / 29km
- 06/11
+ Lieues Foréziennes / Semi de bonson
http://leslieuesforeziennes.over-blog.com/
- 5km / 10km / 21km
- 11/11
+ Trail de Saint Héand
https://www.facebook.com/trail.st.Heand/
- 8km / 12km / 18km 30km
- 13/11
+ Le Puy - Firminy ?
https://clcs-firminy.e-monsite.com/
- 69km
- 19/11 départ minuit
- Villardaire
https://la-villardaire.fr/ https://www.finishers.com/course/la-villardaire
- 10km / 15km / 20km
- 20/11
+ Roanne - Thiers
https://groupemontagnardroannais.fr/
- 03/12
- 32km ou 57km
+ SaintÉ-Lyon
https://www.saintelyon.com/
- 03/12
- 72km
+ Sainté city run
https://www.saintecityrun.com/
- 6km / 12km
- 10/12
+ Montée de Chambles
https://www.finishers.com/course/montee-de-chambles
- 11km
- 31/12
https://www.logicourse.fr/component/flippingbook/book/2/1.html?page=15
https://www.logicourse.fr/component/flippingbook/book/2/1.html?page=16
https://www.logicourse.fr/component/flippingbook/book/2/1.html?page=17
Thanks RL & MG
- (3837)How to join a google groups without a GMail account?
To subscribe to a group via email, send an email to [Group Name]+subscribe@googlegroups.com.
The key is +subscribe, which is appended to the end of group’s email address. [Group Name] is the name of the group, where space is substituted by “-” (hyphen). For example, to join a group called my-digital-life, send an email to my-digital-life+subscribe@googlegroups.com.
Tip: It’s possible to find the group’s email address by visiting the group web page on Google Groups, and click on “About this group” (or “more” on top right corner and select “About” in the drop down menu. Then, look for group email address in the heading of “Group email”, where the line looks like:
Group email my-digital-life@googlegroups.com
Note that you should send the subscribing email from the email address which you want to receive the messages mailing. For some groups, you may need to confirm the subscription request. In addition, for restricted-membership groups, the group owner will need to approve your subscription request before you can join.
From: https://www.mydigitallife.net/how-to-subscribe-or-join-google-groups-without-google-account/
https://groups.google.com/support/bin/answer.py?answer=46606&topic=9244
- (3838)What are the 17 ODD from UN?
| 01 | No poverty | Pas de pauvreté |
| 02 | Zero Hunger | Faim "zéro" |
| 03 | Good Health & Weel Being | Bonne santé & Bien|être |
| 04 | Quality Education | Éducation de qualité |
| 05 | Gender Equality | Égalité entre les sexes |
| 06 | Clean Water & Sanitation | Eau propre et assainissement |
| 07 | Affordable & Clean Energy | Énergie propre et d'un coût abordable |
| 08 | Decent Work & Economic Growth | Travail décent et Croissante économique |
| 09 | Industry, Innovation & Infrastrcture | Industrie, Innovation et Infrastructure |
| 10 | Reduced Inequalities | Inégalités réduires |
| 11 | Sustainable Cities & Communities | Villes & Communautés durables |
| 12 | Responsible Consumption & Production | Consommation et Production responsables |
| 13 | Climate Action | Mesures relatives à la lutte contre les changements climatiques |
| 14 | Life Below Water | Vie Aquatique |
| 15 | Life on Land | Vie Terrestre |
| 16 | Peace, Justice & Strong Institutions | Paix, Justice et Institutions Efficaces |
| 17 | Partnership for the Goals | Partenariats pour la réalisation des Objectifs |
From: https://sdgs.un.org/goals
https://odd17.org/les-17-odd
- (3842)Examples of funny mind blowing CS/Maths/Proba enigmas
- How to code "fizz buzz" game without using conditionals
=> function pointers in an array + activation by modulo counting
- Points rouges/bleus sur front => s'insérer tjs entre 2 personnes de couleur !=
- Prisonniers et boîte => maximiser globalement vs. localement : faire comme une liste chaînée
https://en.wikipedia.org/wiki/100_prisoners_problem
- Hommes avec chapeaux ???
https://www.lecassetete.fr/blogs/blog-casse-tete/top-15-des-enigmes-qui-cassent-la-tete #7
- 2 enfants, dont 1 fille, quelle proba 2 girls => 1/3 (dessiner l'arbre)
https://fr.wikipedia.org/wiki/Paradoxe_des_deux_enfants
https://en.wikipedia.org/wiki/Boy_or_Girl_paradox
- Monty Hall Problem => plus intérêt à changer d'avis
https://en.wikipedia.org/wiki/Monty_Hall_problem
https://fr.wikipedia.org/wiki/Probl%C3%A8me_de_Monty_Hall
https://en.wikipedia.org/wiki/Category:Probability_problems
https://en.wikipedia.org/wiki/Category:Probability_theory_paradoxes
- (3843)What are good (word) games to train your brain?
- Find the word / Wikipedia page based on ML-embeddings distance
https://semantle.com/ (us)
https://cemantix.certitudes.org/ (fr)
-Motus-like
https://sutom.nocle.fr/
https://motchus.fr/ (Marseilles)
- (3844)How to get rid of mold and stop it from coming back?
- From shower
- dish soap, warm water and a scrubbing brush
- rinse and dry afterwards with a microfiber cloth
- you can add white distilled vinegar
- From dry walls
- dish soap and water and apply using a sponge of microfiber cloth
- don't scrub too hard
- you can add diluted bleach
- From wood
- vacuum any loose spores from the surface with a vacuum cleaner
- dish soap and water
- microfiber cloth and a spray bottle
- you can add diluted vinegar
- DO NOT use bleach!!
- From clothes
- bleach (eau de Javel) is your best bet
- wash the item on the highest temperature allowed with regular detergent
- you can also add a cup of vinegar or bleach
- for hard cases: leave the item to soak in hot water mixed with a cup of bleach for a couple of hours prior to machine-washing
From: https://www.tomsguide.com/how-to/how-to-get-rid-of-mold
- (3856)How to create a solid material with any shape?
Create a shape with soft material:
- Baking Soda
- String
- Cotton ball
...
"Fix" it with SuperGlue
From: https://www.youtube.com/watch?v=eP3xJIJ-TbU
https://www.youtube.com/watch?v=QWbaLuY7v_k
https://www.youtube.com/watch?v=UtgTXqRy0xU
- (3873)Quelle différence entre chiffre, nombre et numéro ?
- Seulement 10 chiffres : les chiffres sont des symboles mathématiques de base.
0, 1, 2, 3, 4, 5, 6, 7, 8 et 9.
- Une infinité de nombres : les nombres représentent une quantité ou une valeur. Ils sont écrits à l'aide des dix chiffres à notre disposition.
le nombre 1.483 s'écrit à l'aide des quatre chiffres que sont 1, 4, 8 et 3.
- Des numéros comme codes : Les numéros sont des codes composés d'un chiffre ou d'un (ou plusieurs) nombre(s). Ils portent *un certain nombre d'informations* (numéro de Sécurité sociale, numéro de téléphone, etc.) et/ou indiquent une *place* dans une série (numéro de rue, numéro atomique, etc.).
From: https://www.futura-sciences.com/sciences/questions-reponses/mathematiques-difference-chiffre-nombre-numero-6990/
- (3875)How to download Private YouTube videos?
SOLUTION1: Use Developer Tool
1- Open the private video on YouTube. Right-click on it and choose "Inspect Element"
2- In the Developer Tools, click on "Network" and then choose "Media" under "Network Tool". You should see the HTTP requests made to the media files only. If you don't, reload the page.
3- Click on each link to see the type of media file it represents. Since you want to download a video, you might look for the "video/mp4" type of content.
4- Copy and paste the URL into the address bar. Then, *remove the range parameter* and press "Enter"
SOLUTION2: Use Firefox Add-on
Another way to download the complete video with its accompanying audio is to use a Firefox add-on designed for this purpose. A good option is "Video Downloader Professional" (https://addons.mozilla.org/en-US/firefox/addon/video-downloader-profession/)
From: https://www.fucosoft.com/download-video/download-private-youtube-videos.html
- (1985)How to make a perfect "fondant au chocolat"?
200gr de beurre (<1/2 beurre salé)
150gr de sucre (roux de préférence)
4 œufs
80 gr de farine
250gr de chocolat (corsé ou caramel ou praliné)
- Préchauffer le four à 180°
- Mélanger les œufs et le sucre puis ajouter la farine.
- Faire fondre le chocolat avec le beurre.
- Mélanger le tout.
- Verser la pâte dans un moule beurré.
- Faire cuire entre 20mn et 40min(!), selon le fondant désiré.
Thanks Sylvain's mum
- (1990)Les applis anti gaspi pour des restos pas chers !
http://www.toogoodtogo.fr/
http://www.optimiam.com/
Thks Ju(liette) et Yacine
- (2023)Proverbe pour pochetrons
"Blanc sur rouge, rien ne bouge,
Rouge sur blanc, tout fout le camp!"
- (2012)How to translate "de XXX à YYY, en passant par ZZZ"?
use: "from XXX to YYY by way of/via ZZZ"
"Mon frère est incollable en musique et peut te parler de tout ; de la
musique classique au hard rock en passant par le tango."
->
"My brother is very knowledgeable in music and can talk about everything: from classical music to hard rock by way of/via tango."
From: http://www.wordreference.com/fren/en%20passant%20par
- (2024)A list of documentaries about sustainable development
- L'assiette sale
- Notre pain quotidien
- Solutions locales pour un désordre global
- Les blés d'or
- Le monde selon Monsanto
- Nos enfants nous accuseront
- Supersize me
- BBC "Future of food"
https://www.youtube.com/watch?v=AgksXI3uDHA
https://www.youtube.com/watch?v=7YDQU7Ts10Q
https://www.youtube.com/watch?v=GaSd7BkJa1M
- BBC "A farm for the future"
https://www.youtube.com/watch?v=XoLJnBe-bh8
- Green
https://www.youtube.com/watch?v=-WNgoqBGw4Y
- Farmageddon
http://www.prime%REMOVE%wire.ag/watch-2663591-Farmageddon-online-free
- Food Choices
http://www.imdb.com/title/tt6039284/
From: http://www.amap-idf.org/filmograp_bibliogra_theme_agricultu_108.php
- (2088)How to get past data for the wheather?
mylist=""
for year in $(seq 2009 2016)
do
mylist+=" -new-tab -url http://www.historique-meteo.net/france/ile-de-france/paris/$year/10 "
done && firefox $(echo $mylist)
Also see Tip#1858
Thanks MatthieuCEA
- (2092)How to hide one's phone number in France?
For landline, *prefix* the called number with:
– Free, Orange, SFR, Prixtel, Alice, Darty : 3651
– Bouygues : *1651
– Darty THD : #31#
– Numericable : *31#
For cellphone, *prefix* the called number with: #31#
From: https://www.prixtel.com/decouvrir-PRIXTEL/actualite/news/comment-masquer-votre-numero-de-telephone-fixe-ou-mobile/
- (2116)Youtube Channels to follow
* Arts
http://artips.fr/
* Brazil
https://www.youtube.com/channel/UCzQDKNP-lJdHpNbTQcZm6sA
* Sustainable Development
** Permaculture
https://www.youtube.com/channel/UCm-SeCr6-0dPzfUT8gZvYLg
https://www.youtube.com/channel/UCL_r1ELEvAuN0peKUxI0Umw
https://www.youtube.com/channel/UCzgsQwiy6sKt6Ne9aDXGc5Q
https://www.youtube.com/user/permacultureetc
https://www.youtube.com/playlist?list=PLb2TbJgQNg0YC-E8BSNCUIoHdj7S0uE3Z
https://www.youtube.com/channel/UCGl2QLR344ry4Y20RV9dM3g
https://www.youtube.com/channel/UCm-SeCr6-0dPzfUT8gZvYLg
* DataScience
https://www.youtube.com/channel/UCioEIe1o73G-oGR4b34E7Dg
https://www.youtube.com/channel/UCbfYPyITQ-7l4upoX8nvctg
* DIY
https://www.youtube.com/channel/UCg7HRuQ93hl9v8dTSt_XDHA
https://www.youtube.com/user/evwestdotcom
https://www.youtube.com/user/jehugarcia
https://www.youtube.com/channel/UC-chBbBYOebDi81JdFQYeKw
* Gaming
https://www.youtube.com/channel/UCCMxHHciWRBBouzk-PGzmtQ
https://www.youtube.com/channel/UC6KmKy35GR_PO3h485ZPP7Q
https://www.youtube.com/user/docgeraud
* History
https://www.youtube.com/channel/UCDyyFxXcMKrRLc6QM2OlRwA
https://www.youtube.com/channel/UCKjDY4joMPcoRMmd-G1yz1Q
* Humour
https://www.youtube.com/user/LesKassosCanal
https://www.youtube.com/results?search_query=one%20punch%20man
http://m.mangatown.com/manga/onepunch_man/
http://www.voirfilms.info/serie/kaamelott.htm
* LifeHacks-Experiments
https://www.youtube.com/channel/UCo6DJdltbIub80bLiyJRv3w
https://www.youtube.com/user/HawkGuruHacker
https://www.youtube.com/channel/UCP4ACC1BpVsPszl3cmQzuww
https://www.youtube.com/channel/UCCohOo_tNjrR5JxgLjOb25A
https://www.youtube.com/channel/UC295-Dw_tDNtZXFeAPAW6Aw
https://www.youtube.com/channel/UCiDJtJKMICpb9B1qf7qjEOA
https://www.youtube.com/channel/UCt9sn50QjW1ch3smU0cP78A
* LockPicking
https://www.youtube.com/channel/UCp1orOGJwZvjLAvckyxC4Nw
https://www.youtube.com/channel/UCm9K6rby98W8JigLoZOh6FQ
https://www.youtube.com/channel/UCxZRF3OG7gapQ8kacWUwj2A
https://www.youtube.com/user/trekmaster30
* Music
https://www.youtube.com/user/LinksTheSun
** Metal
https://www.youtube.com/user/2guys1tv/videos
https://www.youtube.com/user/Metalliquoi
* Politics
https://www.youtube.com/user/MrUsul2000
https://www.youtube.com/user/datagueule
https://www.youtube.com/channel/UCVeMw72tepFl1Zt5fvf9QKQ
https://www.youtube.com/results?search_query=frederic%20lordon
https://www.youtube.com/results?search_query=pincon%20charlot
* Sciences
** Maths
https://www.youtube.com/user/numberphile
https://www.youtube.com/user/Micmaths
https://www.youtube.com/channel/UC0NCbj8CxzeCGIF6sODJ-7A
https://www.youtube.com/channel/UCWnfDPdZw6A23UtuBpYBbAg
https://www.youtube.com/user/epenser1/featured
https://www.youtube.com/channel/UCtqICqGbPSbTN09K1_7VZ3Q
https://www.youtube.com/user/scilabus
https://www.youtube.com/playlist?list=PL_PIQFriATiMLAHeur99xh3T0BwhXc69T
https://www.youtube.com/user/elfuegoo
https://www.youtube.com/channel/UCaNlbnghtwlsGF-KzAFThqA
https://www.youtube.com/channel/UC6nSFpj9HTCZ5t-N3Rm3-HA
https://www.youtube.com/user/destinws2
https://www.youtube.com/user/1veritasium
https://www.youtube.com/user/TroncheEnBiais
https://www.youtube.com/channel/UCS_7tplUgzJG4DhA16re5Yg
* Startups
https://www.youtube.com/user/Startupfood
* Survival
https://www.youtube.com/channel/UCAL3JXZSzSm8AlZyD3nQdBA
* Zététique
https://www.youtube.com/user/fauxsceptique
https://www.youtube.com/channel/UCU0FhLr6fr7U9GOn6OiQHpQ
https://www.youtube.com/channel/UC-4WUubuVGowG_R7gdgesPA
- (2117)What do KISS, YAGNI & DRY mean?
* KISS = "Keep It Simple, Stupid!"
The simpler your code is, the simpler it will be to maintain it in the
future.
The KISS principle was coined by Kelly Johnson, and it states that
most systems work best if they are kept simple rather than making them
complex; therefore simplicity should be a key goal in design and
unnecessary complexity should be avoided.
My advice is to avoid using fancy features from the programming
language you’re working with only because the language lets you use
them. This is not to say that you should not use those features, but
use them only when there are perceptible benefits to the problem
you're solving.
* YAGNI = "You Aren't Gonna Need It"
Sometimes, as developers, we try to think a lot in the future of the
project coding some extra features "just in case we need them" or "we
will eventually need them". Just one word... Wrong! I’ll repeat it
this way: You didn't need it, you don't need it and in most of the
cases... “You Aren't Gonna Need It”.
YAGNI is a principle behind the extreme programming (XP) practice of
"Do the Simplest Thing That Could Possibly Work". Even when this
principle is part of XP, it is applicable in all kind of methodologies
and own processes of development.
When you feel an unexplained anxiety to code some extra features that
in the moment are not necessary but you think they will be useful in
the future, just calm down and see all the pending work you have at
this moment. You can't waste time coding those features that maybe
you will need to correct or change because they do not fit to what is
needed, or in the worst scenario, they will not be used.
* DRY = "Don't Repeat Yourself"
How many times do you see that there are similar codes, in different
parts of a system. Well, this principle is formulated by Andrew Hunt
and David Thomas in their book "The Pragmatic Programmer" that every
piece of knowledge must have a single, unambiguous, authoritative
representation within a system. In other words, you must try to
maintain the behavior of a functionality of the system in a single
piece of code.
In the other hand, when the DRY principle is violated it is called as
WET solutions, which is stand for either "Write Everything Twice or We
Enjoy Typing".
I know this principle is very useful, especially in big applications
where they are constantly maintained, changed and extended by a lot of
programmers. But you also should not abuse of DRYing all things you
do, remember the first two principles KISS and YAGNI, in first place.
From: http://www.itexico.com/blog/bid/99765/Software-Development-KISS-YAGNI-DRY-3-Principles-to-simplify-your-life
- (2257)What is the difference between Manager & Leader?
While management works on ensuring that the processes run smoothly,
leadership must develop a concept of the future they desire and align
the organization's central resources accordingly.
LEADER: sees into the future, sets goals to reach
MANAGER: ensures day-to-day that the company as a whole move towards these goals
From: https://dzone.com/articles/organizational-structures-and-leadership-in-times
- (2138)How to access directly the "directions" page instead of the "place" page in GMaps?
https://www.google.fr/maps/dir/<origin>/<desitnation>/
- (2145)How to get your LinkedIn contacts' emails (2017)?
http://linkedin.com/psettings/member-data section "Obtenir les archives de vos données"
=> get a csv file of all your contacts, including their (registration!) email.
Thanks FB
- (2150)Where to find a place to sleep/have a showers when having a cyclotourism trip?
https://www.warmshowers.org/
Thanks Tacha
- (2154)How to stretch correctly?
http://www.travailsecuritairenb.ca/docs/OFFICEfrdist.pdf
https://darebee.com/images/workouts/top-to-bottom-workout.jpg
http://a141.idata.over-blog.com/1200x744/5/15/36/77/pieds/3/4/forweb-tarayoga.jpg
Active Isolated Stretching (chap 5 "Courir pour les nuls") http://www.stretchingusa.com/active-isolated-stretching
- (2155)Comment régler un dérailleur arrière d'un vélo?
I] Étape initiale:
1. Se mettre en plus petit pignon
2. Déconnecter le câble du dérailleur
II] Aligner les butées
NOTE:
L=LowSpeed = PlusGrandPignon
H=HighSpeed = PlusPetitPignon
IIa] Réglage butée basse
1. Se mettre sur le plus petit pignon
2. Serrer/Déserrer la vis H afin d'aligner le galet supérieur/guide
soit aligné avec le plus petit pignon
IIa] Réglage butée haute
1. Actionner manuellement le dérailleur (pousser dessus) pour l'amener
sur le grand pignon
2. Serrer/Déserrer la vis L afin d'aligner le galet supérieur/guide
soit aligné avec le plus grand pignon
NOTE: le bon réglage est atteint quand la chaîne ne se coince ni en
bas entre le petit pignon et le cadre, ni en haut entre le le grand
pignon et les rayons de la roue
III] Étape Intermédiaire: avant de re-tendre le câble, revisser
intégralement la vis du câble, au niveau des manettes, puis desserrer
de qq tours pour laisser une marge de manœuvre dans l'étape suivante.
IV] Réglage de la tension du câble
1. Après avoir correctement positionné la vis du câble au niveau de la
manette, on peut ré-engager le câble dans le dérailleur, en tendant
légèrement le câble.
2. (Éventuellement, régler la "vis d'englobé", sur le dérailleur, qui
règle la distance entre le dérailleur et le plus haut des galets. Il
faut mettre 5mm entre le galet et le plus grand pignon)
3. Maintenant que le câble est repositionner, faire un balayage des
différentes vitesses et affiner la tension du câble au niveau de la
manette pour que toutes les vitesses passent correctement.
From: https://www.youtube.com/watch?v=vEV9P4Q3x_Q
https://www.youtube.com/watch?v=Ooje0AY6Rhw
- (2184)How to signal a Spam/Hoax/Phishing email/SMS?
- For emails:
https://www.signal-spam.fr/
- For SMS:
forward the message to 33700
- For calls
send "spam vocal" as SMS to 33700, then send another SMS with the calling number
- (2242)Recettes de salades d'été
* Pastèque
** Vinaigre balsamique
** féta + chèvre frais (pas fort)
* Melon
** Parmesan + Gorgonzala
** Vinaigre balsamique + 1 cuillère d'huile
Thanks Seb
- (2202)Solutions Eczéma ?
Eczéma
Je suis allé à la piscine Catherine Lagatu 75010 et j'ai remarqué une
diminution de la crise.
J'ai posé la question sur le site de la mairie de Paris. La réponse du
Cabinet de la Maire de Paris :
De manière générale pour les piscines parisiennes :
1/ Filtration au sable / billes de verre / charbon actif
2/ Désinfection au chlore : 0,4 à 1,4 ppm de chlore actif
- eau de javel
- chlore solide (pour certains pédiluves: chlorite)
[- sel (transformation par électrolyse en hypochlorite de sodium)]
Pour le cas de la piscine Catherine Lagatu, les produits chimiques
utilisés sont le chlore et la javel.
Par ailleurs, suite à une gastro (du moins 2j de vomissements, peut-être dûs à l'ingestion de "Ginger Ale" fait maison : https://wellnessmama.com/8942/ginger-bug/ https://nicrunicuit.com/faire/fermenter/comment-faire-un-ginger-bug-levain-de-gingembre-pour-fermenter-jus-de-fruits-ou-de-legumes/), tous les symptômes ont disparu !
- (2228)How to orientate yourself in Paris' streets?
If you have the odd street numbers on your left, then your are going towards the increasing street numbers
=
Si vous avez les numéros impairs d'immeubles sur votre gauche, alors vous allez dans la direction croissantes des numéros de rue.
Thanks AM
- (2235)How to get the RSS feed from a Youtube Channel?
SOLUTION1:
1. Open youtube channel in FF/Qupzilla
2. If URL does not contains .../channel/<channel ID>, open page sources and look for "canonical" or "/channel/" (or "channelId" in scripts)
<link rel="canonical" href="https://www.youtube.com/channel/<channel ID>">
3. The RSS feed URL is:
https://www.youtube.com/feeds/videos.xml?channel_id=<channel ID>
Found by myself
SOLUTION2: use https://commentpicker.com/youtube-channel-id.php
- (2240)How to walk on a Slackline?
- Look far away in the distance, at eye-level (at the begining: attach point of the slack on the tree, then on the tree trunc, at eye-level)
- Make the foot you put on front of the other slip a little bit on the slackline to advance even more quickly&smoothly
- Act like a panda / be a little cloud (arms & shoulder softs ; your rotation axis is your solar plexus)
- To break lateral oscillations, create up/down oscillations - sink your whole weight on the slackline, make yourself bounce
- (2241)Climbing Training
* "vomito" version (Christophe)
répéter 3->5 fois
- 5/15 tractions sur boules
- 5 squat jambe droite
- 5 squat jambe gauche
- 10 accroupi/sauté
- 1min abdos statiques en V + medecine ball
- trainage de tapis
- 1min jumping jack
- 10 pompes
- 10 abdos
- 1 montée+descente Güllich
* Sylvain+GM's training
répéter 3 fois
- 30s pompes normales
- 30s tractions normales
- 30s abdos normaux
- 30s planche statique
- 30s traction 90° statique
- 30s abdos statiques en V
- 30s pompes tappe en face
- 30s dips
- 30s abdos cycliste
- 30s planche montées/descende dr/gauche
- 30s tractions semi-statiques 15/45/90/160/180°
- 30s abdos à 2 : poussée de jambes
- 10 burpees
- (2254)How to prepare (introduce yourself in) a Job Interview?
Develop a brief summary of your twelve sales messages, that you can
use at the end of the interview, when the interviewer says something
like "Is there anything else you'd like to tell me?"
*Never let an interview end without summarizing your twelve key messages.*
1. Passion for the Business
Why am I interested in working in this field in this industry?
2. Motivation and Purpose
Why you want to work for this particular company?
Why do I want this interview?
3. Skills and Experience
What are my key skills?
How will I use them in this job?
What are my weaknesses? How can I minimize them?
4. Diligence and Professionalism
What is your professional character?
Are you accountable (fiable)?
Do you persevere? Do you achieve desired results?
How do you work? What is your typical routine?
How do you predict obstacles?
How you manage stress?
5. Creativity and Leadership
What examples can you provide of your effectiveness, creativity, initiative, resourcefulness, and leadership?
How do you overcome problems?
How you take advantage of opportunities?
How you rally the support of others to accomplish goals?
6. Compatibility with the Job
What are your qualifications?
How well do they fit the requirements of the position?
7. Personality and Cultural Compatibility
What is your personality?
How do you fit in with other types of personalities?
What types of people would enjoy working with you for hours at a time?
How would the company's customers or clients react to you?
8. Management Style and Interpersonal Skills
What are your management and the interpersonal skills?
How do you work?
What kind of boss, colleague, and employee will you be?
9. Problem-Solving Ability
How do you solve problem?
How have you resolved difficult issues in the past?
Are you practical in how you apply technical skills?
Are you realistic?
How do you measures the outcomes?
10. Accomplishments
Have you ever delivered more than what was expected?
What actions did you took and what positive results hage you obtained?
If you were hired, what situations would you handle especially well?
What can you contribute to the organization?
11. Career Aspirations
What are the skills and strengths you want to develop further?
Why would you be more effective with that additional experience?
12. Persons! Interests and Hobbies
Do you have a balanced lifestyle?
Is your personality reflected in the type of job you choose as well as in the outside activities you pursue?
Are your personal and career interests compatible?
What are your community involvements?
How commendably would you reflect the company's image?
- (2272)Tutoriels et Vente bricolage en ligne
http://www.cedeo.fr/ [Pro uniquement?]
https://www.manomano.fr/ [Plein tutoriels]
https://www.myshop-habitat.com
Thanks Élyès
- (2274)Comment entretenir/changer son chauffe-eau avec cumulus?
- Éléments à savoir (influent sur le prix)
- Position : Vertical (le classique) >> Horizontal (bcp plus cher)
- Capacité : ~50L / personnes. Ajouter 50L pour un Horizontal.
- Résistance (chauffe l'eau) : Blindée/Plongeante (peut s'entartrer) << Stéatite (se démonte sans vidanger, s'entartre moins)
- Anode (protège de la corrosion en bouchant les µfissures) : magnésium/sacrificielle (le plus classique, doit être changé régulièrement) << ACI (Courant électrique Imposé, plutôt pour les eaux dures, ne fonctionne que si des ions redirigeables vers les µfissures sont présents dans l'eau) << ACI-hybride (mélange des 2 précédents, quasi inusable)
https://conseil.manomano.fr/guide-anti-panne-du-chauffe-eau-electrique-563#tipsheet-1
https://conseil.manomano.fr/comment-choisir-son-chauffe-eau-electrique-26
=> Capacité Vertical=100L / Horizontal=150L [ il faudra alors choisir
une capacité supérieure de 50 litres à celle du chauffe-eau vertical
équivalent]
https://conseil.manomano.fr/comment-choisir-un-groupe-de-securite-pour-chauffe-eau-513
=> Groupe Laiton (plutôt qu'Inox)?
https://conseil.manomano.fr/comment-changer-le-groupe-de-securite-dun-chauffe-eau-electrique-561
[pensez à ouvrir un robinet d'eau chaude pour évacuer la pression
restante dans le ballon avant de vidanger l'eau qui reste]
https://conseil.manomano.fr/comment-choisir-la-resistance-electrique-dun-chauffe-eau-515
=> Stéatite (plutôt que Thermoplongée/Blindée) ?
https://conseil.manomano.fr/comment-choisir-une-anode-de-chauffe-eau-a-accumulation-516
=> Anode à Courant Imposé ACI ou hybride (plutôt que sacrificielle) ?
[dureté de l'eau / efficace que dans les eaux riches en calcium et
magnésium ]
https://conseil.manomano.fr/comment-changer-le-thermostat-dun-chauffe-eau-electrique-566
https://conseil.manomano.fr/comment-detartrer-un-chauffe-eau-electrique-565
https://conseil.manomano.fr/comment-entretenir-son-chauffe-eau-a-accumulation-562
[coupez l'alimentation d'eau du ballon d'eau chaude et son
alimentation électrique, ouvrez les robinets de la maison en position
eau chaude (pour casser la pression)]
https://conseil.manomano.fr/guide-anti-panne-du-chauffe-eau-electrique-563
https://conseil.manomano.fr/comment-purger-un-chauffe-eau-electrique-570
https://conseil.manomano.fr/comment-deposer-un-chauffe-eau-electrique-a-accumulation-567
https://conseil.manomano.fr/comment-accrocher-un-chauffe-eau-electrique-au-mur-569
https://conseil.manomano.fr/comment-changer-ou-installer-un-chauffe-eau-electrique-572
[ Il est impératif que tous les raccords d'eau soient réalisés avec de
la filasse et de la pâte d'étanchéité – excepté le raccord à
compression du siphon du groupe de sécurité. Les raccords à vis
femelle reçoivent un joint fibre indispensable pour une bonne
étanchéité]
https://www.mesdepanneurs.fr/blog/qu-est-ce-qui-met-en-panne-le-contacteur-jour-nuit
- Achats pour installer un nouveau chauffe-eau
* Chauffe-eau/Ballon
* Vis/Chevilles/Goujons [préférer à scellement chimique]
* Groupe de sécurité + joints (joints fibre en 20x27 mm = 3/4'')
* (Réducteur de pression ? + joints ?)
* Perceuse/Forêt béton
* Filasse/Pâte d'étanchéité
* Niveau à bulle
- (2279)How to get the RSS feed of a soundcloud channel?
http://getrssfeed.com/
e.g. TWiML - This Week in ML/AI
https://soundcloud.com/twiml -> http://feeds.soundcloud.com/users/soundcloud:users:228427508/sounds.rss
From: https://www.reddit.com/r/pocketcasts/comments/4280zy/subscribe_to_soundcloud_channels/
- (2294)Office Ergonomics: how to sit and what exercices to do at office
http://travailsecuritairenb.ca/docs/OFFICEFRdist.pdf
- (2309)How to compute your ideal weight (Lorentz's formula / BMI)?
- Pour les hommes (les tailles sont en cm) :
POIDS IDÉAL (en kilogrammes) = (TAILLE-100) - ((TAILLE-150)/4)
- Pour les femmes (les tailles sont en cm) :
POIDS IDÉAL (en kilogrammes) = (TAILLE-100) - ((TAILLE-150)/2,5)
BMI (BodyMassIndex) = Mass/Height² # should be [18.5,25]
From: http://www.regimesmaigrir.com/calcul/poids-ideal.php
https://en.wikipedia.org/wiki/Body_mass_index
- (2327)What are the available free non-GAFAM (and open source) cloud/mailinglist/website services?
- FOSS (NextCloud)
https://nextcloud.com/providers/
https://chatons.org/find
- Encrypted
http://mega.co.nz
- WebHosting / ML
http://www.apinc.org/
http://www.no-log.org/
http://www.marsnet.org/
http://www.lautre.net/
https://lists.riseup.net/
https://www.colibris-lemouvement.org/
http://www.infini.fr/
https://indiehosters.net
http://infini.fr
https://lautre.net
https://ouvaton.coop
http://rhien.org
https://tuxfamily.org
https://zaclys.com
- (2339)Restaurants in Saint-Étienne
- Java Bleue
http://www.restaurant-lajavableue.fr/
- Genêts d'Or
https://www.facebook.com/Les-Genets-dOr-Auberge-Salvaris-450355334985408/
- Trois B
https://www.tripadvisor.fr/Restaurant_Review-g187269-d7854002-Reviews-Les_Trois_B-Saint_Etienne_Loire_Auvergne_Rhone_Alpes.html
- La bouche pleine
https://www.labouchepleine-42.fr/
- Kasseria
https://www.facebook.com/pages/Le-Kasseria/168345983176042
- K6 Tandoori
https://www.facebook.com/pages/K6-Tandoori/200823183287155
- EXO Pizza
https://www.facebook.com/EXO-Pizza-560356611029621
- (2391)How use LinkedIn in your job search (mainly: let people know you're looking new job)?
I] Tag Line/Bio
Use common keywords / phrases:
- Seeking Opportunities
- Looking for a new role
- Open to new challenges
- ...
PRO TIP: Include your industry as well as the fact you are searching for a new job. This will make you more visible to recruiters that are more targeted with their search. e.g. “Currently seeking opportunities in x, y, z.”
Let your followers know you’re looking for a new role. One of the best ways to do this is pinning a visual tweet to your profile (an image that everyone will see as soon as they hit your profile).
II] Ask your connections for referrals
PRO TIP: Write a post on LinkedIn’s pulse asking for referrals and / or introductions. When you publish a post, every one of your connections gets a notification, so you can guarantee that they will all see it. Remember to include who you are, what your skills are and what you are looking for.
III] Personal business cards
PRO TIP: moo.com is a great site for creating professional looking business cards that don’t cost an arm and a leg.
IV] Email signature
DO:
- Include your phone number
- Include a tagline
- Include the fact that you’re “Seeking new opportunities”
- Include a link to your blog or examples of work
- Inject some personality
DON'T
- Include too many social profiles
- Include your physical address
- Have your email signature as one image
PRO TIP: Use WiseStamp to create your email signature. WiseStamp enables you to create a professional looking email signature that gets inserted into any email you send.
V] Sign up to Job Boards
https://www.linkedin.com
http://indeed.fr
http://talent.io
http://glassdoor.fr
http://choosemycompany.com/fr
http://fr.hired.com
https://www.rhonealpesjob.com
From: https://www.linkedin.com/pulse/how-let-people-know-youre-looking-new-job-liam-nolan/
https://medium.com/the-zealify-blog/21-steps-to-a-killer-linkedin-profile-for-your-job-search-91a5b8e26fad
https://medium.com/the-zealify-blog/dos-and-don-ts-creating-an-email-signature-for-a-job-search-ae87a033c08d
- (2404)What to do in Saint-Étienne?
I] Sport
- Course à Pieds / Trail dans le Pilat
- Balade au Barrage de Planfoy
- Vélo à Rochetaillée / Bessat / Croix Chaubouret / Crêt Perdrix / Saint-Victor-sur-Loire
- Vélo jusquà Saint-Chamond par la Route Touristique
- Escalade / Via Ferrata / Via Corda @ Gouffre d'Enfer
- Base Nautique de Saint-Victor-sur-Loire
- Acrobranche @ Saint-Jean-Bonnefonds
II] Bouffe
- Pic Nic à la Madonne de Rochetaillée
- Tarte Myrtilles @ Jasserie
- Rapée+Sarasson @ Salvaris
- Brioche aux Pralines @ rue des Martyrs de Vingré
- Chocolats Weiss
- Bières locales (Brasserie Stéphanoise : Glütte, Manu, ...)
- Fromage aux artisons bleu & charcuterie du marché Fauriel
- Bouchon Lyonnais
- Lentilles au Puy-en-Velay
- Manneken Pis @ Saint-Galmier (CLOSED!)
III] Culture
- Cinémas Indépendants : Le France, Méliès, Camion Rouge
- Musée de la Mine / Arts-et-Industrie / Art Moderne
- Château de Rochetaillée
- ALOLISE / La Bricoleuse / Ocivelo
- ancien appart rue Joséphin SOULARY
- (2410)Quels droits en cas de rupture de période d'essai par l'employeur?
- On dispose de 2h par jour restant à travailler pour chercher un autre travail !
https://droit-finances.commentcamarche.com/forum/affich-4196944-rupture-periode-d-essai-et-recherche-d-emploi#newanswer
- Le délai de prévenance (=les jours restants après l'annonce de rupture) ne peut pas allonger la durée de la période d’essai (<=> jours déjà travaillés + délai prévenance <= 4 mois)
https://www.juritravail.com/Actualite/salarie-protege-contester-l-autorisation-de-licenciement/Id/172661
- Les titres-restaurant ne sont pas obligatoires pour l'employeur, mais s'il les propose, il doit les donner par jour complet effectivement travaillé (<=>la période travaillée doit comprendre le déjeuner, ce qui n'est pas le cas des vacances/RTT ou 1/2 journées de travail)
http://www.dicotravail.com/droit-du-travail/titre-restaurant/
- La rupture de la période d'essai, si elle est à l'initiative de l'employeur, donne droit aux indemnités chômage, même si l'on a démissionné de son ancien poste
https://www.legalplace.fr/guides/rupture-periode-essai-droit-chomage/
- (2411)Les congés peuvent être pris dès l'embauche, au fil de l'eau
Depuis la loi El Komeri, les congés peuvent être pris dès l'embauche, au fur et à mesure de leur attribution
From: https://www.juritravail.com/Actualite/conges-payes/Id/14532
Thanks Carmen
- (2415)What administrative papers do you need to rent a flat in France?
- pièce justificative d'identité
=> CNI
- pièce justificative de domicile
=> 3 dernières quittances / preuve de propriété (taxe foncière)
- documents attestant des activités professionnelles
=> 3 derniers bulletins salaire
=> Nouveau contrat / promesse d'embauche
- documents attestant des ressources
=> avis d'imposition
=> 3 derniers bulletins salaire
=> Nouveau contrat / promesse d'embauche
- caution
+ texte manuscript
+ CNI
+ attestation activité pro/revenus (impôts)
+ attestation logement (assurance)
- prévoir suffisemment de chèques pour la caution + 1er loyer.
- prévoir d'augmenter les plafonds de la CB pour les dépenses du déménagement (camion+essences+...)
- Attestation assurance du nouveau logement à faire faire pour la remise des clefs
From: https://www.pap.fr/bailleur/choisir-locataire/location-les-documents-que-le-proprietaire-peut-exiger/a18248
- (2416)Équivalents longs mais gratuits des numéros de téléphone courts des opérateurs téléphoniques
http://www.numerosgratuits.info/
- (2423)[photography / copyright] What are the prices for each type of use / marketing scheme?
From: http://www.adagp.fr/sites/default/files/bareme_adagp.pdf
- (2425)Where to download color books based on actual library/museums images?
See "Color Our Collections" project
From: http://library.nyam.org/colorourcollections/
- (2435)Tips&Tricks Démission
* La démission
http://droit-finances.commentcamarche.net/contents/593-la-demission-du-salarie-comment-donner-sa-demission
http://droit-finances.commentcamarche.net/contents/594-droit-au-chomage-apres-une-demission
** Inconvénients
*** Pas de chômage (sauf cas spécifiques)
*** Pas d'indémnités
** La lettre de démission doit contenir
*** les coordonnées du salarié et de l'employeur ;
*** l'emploi occupé et la date d'embauche ;
*** la décision de rompre le contrat de travail (qui n'a pas à être motivée) ;
*** la durée du préavis, et la demande de dispense, le cas échéant ;
*** la date et la signature du salarié.
* Remise en main propre vs LRAR
** La remise en main propre
*** Avantages
**** Gratuit
**** Déclenche immédiatemant les délais légaux (préavis,...)
*** Inconvénients
**** Le courrier doit préciser "Lettre remise en main propre en X exemplaires contre décharge" (X>=2: employeur+employé+tout autre responsable)
**** Il faut demander un récépicé à l'employeur (=copie de la lettre signée par l'employeur) avec mention *manuscrite* "remis en main propre" + date + signature
** LRAR
*** LRAR peut être obligatoire par la Convention Collective (ex: Syntec)!
*** LRAR : c'est la date de *première présentation* qui fait foi => attention en cas de problème de livraison avec La Poste
* Le préavis
http://forum-juridique.net-iris.fr/vie-professionnelle/80709-preavis-cdi-cne.html
** Les congés posés AVANT la démission ne peuvent être refusés
** L'employeur NE peut PAS imposer de prendre les autres congés
** Les jours de congés payés repoussent le préavis
** Les accidents du travail repoussent le préavis
** Les congés maladie NE repoussent PAS le préavis
** Les RTT NE repoussent PAS le préavis
** Les jours fériés NE repoussent PAS le préavis
** Si c'est l'employeur qui dispense du préavis, il doit le payer
** Les heures d'absence pour recherche d'emploi par des salariés démissionnaires
ne donnent pas lieu à rémunération. pour les salarié licenciés, elles sont rémunérées
* La clause de non-concurrence
** Si l'employeur décide de la faire jouer, alors il doit la payer en intégralité ; il NE peut PAS arrêter de la payer quand il estime que ça suffit.
** Le montant des indemnités et la durée doivent être une compensation raisonnable au regard des possibilités d'emplois dont elle prive le salarié (ex: 25% du salaire sur 1 an)
* Rupture conventionnelle vs démission
http://droit-finances.commentcamarche.com/contents/1449-rupture-conventionnelle-de-cdi-conditions-et-procedure
** Avantages rupture conventionnelle
*** Indemnités au moins égales à celle d'un licenciement (1/4 de mois de salaire par année d'ancienneté)
http://www.coindusalarie.fr/rupture/calcul-indemnite
*** Indemnités de congés payés
**** le meilleur entre (a) 1/10 de la rémunération brute totale perçue par le salarié au cours de la période de référence (b) maintien salaire)
*** Droit au chômage
*** TODO
** Inconvénients
*** Il n'y a très peu de cadre légal, à part un entretien préalable
*** Il faut que les 2 parties soient OK
*** C'est une négociation, il faut avoir des arguments, elle peut durer longtemps
*** Elle prend au minimum 1 mois : il y a deux délais de 15j (rétractation+DIRECCTE)
*** L'employeur va sûrement demander: d'épuiser les congés payés, de repousser la date de départ, faire jouer la clause de non-concurrence, etc. L'employé peut demander : à faire des formations/DIF, être assisté pour être recasé (cabinet d'outplacement), l'ancienneté et la difficulté à retrouver du travail peuvent permettre d'obtenir une indemnité supérieure, etc.
*** Le fait de percevoir des indemnités supérieures décale le versement du chômage, d’un nombre de jours égal au supplément reçu divisé par le salaire journalier. Ce report s’ajoute au délai de carence de 7 jours, mais est plafonné à 75 jours.
* Abandon poste vs Démission
http://abandondeposte.fr/risques-abandon-de-poste-salarie-cdi/
http://droit-finances.commentcamarche.com/faq/514-abandon-de-poste-ou-demission-vos-droits
** Avantages abandon
*** Si l'employeur fait le premier pas, alors il s'agira d'un licenciement et pas d'une démission
** Inconvenients abandon
*** Se retrouver longtemps sans revenu (ni salaire/indemnités/chômage)
*** Perdre ses indemnités de départ
*** Date du licenciement indéterminée (au bon vouloir de l'employeur), si jamais il arrive !
*** L’employeur peut réclamer des dommages et intérêts pour conséquence du travail non fait (échec d'un contrat, perte de contrat, etc.)
*** Pôle Emploi peut poser des difficultés
*** L'avenir professionnel de l'employé peut être compromis
* Faute Grave vs Démission
** Il n'y a JAMAIS d'avantage à chercher à se faire licencier pour faute grave
http://licenciementpourfautegrave.fr/
* Période d'essai
** See Tip#2410
- (2430)How to compute ideal human body mass?
- Pour les hommes (les tailles sont en cm) :
POIDS IDÉAL (en kilogrammes) = (TAILLE-100)-((TAILLE-150)/4)
- Pour les femmes (les tailles sont en cm) :
POIDS IDÉAL (en kilogrammes) = (TAILLE-100)-((TAILLE-150)/2.5)
From: http://www.regimesmaigrir.com/calcul/poids-ideal.php
https://en.wikipedia.org/wiki/Body_mass_index
- (2434)How to remove all articles but favorites/archived in Pocket?
##### O] Create in app
##https://getpocket.com/developer/apps/
##E.g. my app: NonFavoritesArchiveRemover
##### I] OAuth
##### 1) request authorization
# From https://getpocket.com/developer/docs/authentication
\rm request get authorize all_favorites.json
##xterm -e "nc -l 55555" &
wget --cookies=on --keep-session-cookies --save-cookies cookies.txt \
--post-data 'consumer_key=<app_id>&redirect_uri=localhost:55555' \
"https://getpocket.com/v3/oauth/request"
code=$(cat request | sed "s/code=//g")
firefox --new-tab "https://getpocket.com/auth/authorize?request_token=$code&redirect_uri=NonFavoritesArchiveRemover:authorizationFinished"
##### 2) Get access_token
wget --cookies=on --keep-session-cookies --load-cookies cookies.txt \
--header='Content-Type: application/json' \
--post-data '{ "consumer_key":"<app_id>", "code":"'$code'" }' \
"https://getpocket.com/v3/oauth/authorize"
token=$(cat authorize | sed -nr "s/access_token=([^&]+).*/\1/p")
##### II]) Download content
# From https://getpocket.com/developer/docs/v3/retrieve
## Get favorites (both unread & archived)
wget --cookies=on --keep-session-cookies --load-cookies cookies.txt \
--header='Content-Type: application/json' \
--post-data '{ "consumer_key":"<app_id>", "access_token":"'$token'", "state":"all", "favorite":"1" }' \
"https://getpocket.com/v3/get" -O all_favorites.json
### Get archived
#wget `#--load-cookies cookies.txt` \
# --header='Content-Type: application/json' \
# --post-data '{ "consumer_key":"<app_id>", "access_token":"'$token'","state":"archive" }' \
# "https://getpocket.com/v3/get" > archived.html
##### III] Get urls in "bookmarks" format
# Get only urls in HTML bookmark format
(
echo -e '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<!-- This is an automatically generated file.\n It will be read and overwritten.\n DO NOT EDIT! -->\n<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n<TITLE>Bookmarks</TITLE>\n<H1>Bookmarks Menu</H1>\n'
echo '<DL>'
jq '.list[] | { given_url }' all_favorites.json | grep given | sed -rn "s/[^:]*: \"(.*)\"/<DT><A HREF=\"\1\">\1<\/A>/p"
echo '</DL>'
) > all_favorites.html
##### IV] Remove all articles from Pocket
# Clean
# Web Pocket Account > User Logo > Options > Privacy > Clear Account Data
##### V] Import articles in bookmarks format into Pocket
#https://getpocket.com/developer/docs/v3/modify
#https://help.getpocket.com/article/1133-importing-into-pocket
#https://getpocket.com/import/browser
- (2498)How to remove one's activities/private data from Google?
Delete all activity
On your computer, go to your Google Account.
On the top left navigation panel, click Data & personalization.
On the Activity and timeline panel, click My Activity.
At the top right of the page, click the More icon More.
Click Delete activity by.
Below "Delete by date," click the Down arrow Down arrow and select All time.
Click Delete.
Delete individual activity items
On your computer, go to your Google Account.
On the top left navigation panel, click Data & personalization.
On the Activity and timeline panel, click My Activity.
Find the item you want to delete. You can find an item a few different ways, including:
Browse by topic or product. At the top center of the page, on the line under Delete by topic or product, choose Try it
Search by key word or date.
On the item you want to delete, click the More More icon.
Click Delete
From: https://support.google.com/accounts/answer/465?co=GENIE.Platform%3DDesktop&hl=fr
- (2509)How to convert Google/Twitter/Facebook to RSS?
https://fetchrss.com/account/settings (limited but still works for Facebook in 2009!)
http://queryfeed.net/
http://feed.exileed.com/?lang=en
- (2518)SumUp of the book "Born to Run" from Christopher McDougall
=== Born To Run SumUp ===
* Dico
** Tarahumaras = Rarámuris
** Tsampa = farine d'orge grillée
** Iskiate = boisson à base de Graines de Chia
** p.303 Pinole = style de polenta = farine de maïs grillée avec de l'eau et des haricots
** Huaraches = sandales de course
** p.305 Tesgüino = bière de maïs (peu fermenté/peu de sucres)
* Coureurs
** Steve Prefontaine
** Caballo Blanco = Micah True = Gipsy Cowboy = Mike Hickman [p.404 pour Vinz]
** p.130-162
*** Lincoln / Mandela
*** Frank Shorter
*** Bill Rodgers
*** Karl Meltzer
*** Catra Corbett
*** Eric Karl Skaggs
*** *Emil Zatopek*
*** Ron Clarke
*** *Scott Jurek* (reste sur la ligne d'arrivée pour voir jusuq'au dernier)
*** Tony Krupicka
*** *Matt Carpenter*
*** Deena Kastor
** p.179
*** Lisa Smith-Batchen ("aimer la bête de la fatigue")
*** Marshall&Heather Ulrich (se retire les ongles de pieds)
*** Sunny Blende
*** Dean Karmazes / Pam Reed
*** Jenn "Moochie" Sheton & Billy "Bone Head" Barnett
*** Barefoot Ted
*** Coyotte Fourplay
*** Jenny Shimizu
*** Barefoot Ken Bob Saxton ("naked toe manifesto")
*** Abebe Bikila
** p.247
*** Arthur Newton (change de chaussures tous les 6000km)
*** David Smyntek ("crazy feet experiment" = inversion chaussures droite&gauche)
*** Alan Webb (voute plantaire creusée)
*** Paula Radcliffe
*** Heile Gebrselassie
*** Khalid Khamouchi
** p. 277
*** Cliff Young (mineur extra-terrestere)
** p.292
*** Mensen Ernst (5400km, puis retour)
*** Mackensie Riford (13 ans, 50 miles)
*** Jack Kirk (96ans)
** p.296
*** Ken Mierke (correction d'un corps diforme)
** p?
*** Ken Pat Cole Chlouder
*** Merilee O'Neil
*** David Harton
* Docteurs / Entraîneurs
** Dr Charlie Robbins (p.179)
** Joe Vigil (p.243)
** Vin Lananna (p.243)
** Dr Stephen Pribut
** Dr Irene Davis
** Dr Craig Richards (lancé un défi aux fabricants de chaussures de prouver l'efficacité => 0 réponses)
** Dr Marti (p.247) chaussures + chères => plus blessures)
** Dr Barry Bates (p.247) vieilles chaussures => moins de blessures que en changer souvent
** E.C. Frederick (p.247) Nike
** Steven Robbins + Edward Waked (p.247) plus la surface est molle, plus le corps chute violemment (lien force d'impact vs. équilibre)
** Dr Gerard Hartmann (pronation=++, chaussures=plâtres, pas chaussures avant 17ans)
** Dr Paul W. Brand (chaussures <-> oignons, corps, orteils en marteau, pieds plats...)
** Dr Robert Weinberg (diététique : changer style de vie : + sport / meilleure bouffe => moins cancer)
** Dr Nicholas Romanov (méthode "POSE")
* Diététique (~p.277)
** Moines du mont Hiei
*** Soupe Miso, Tofu, Légumes
** Percy Cerutti (entraîneur)
*** Raw food 3 fois/an
*** Avoine, Fruits, Légumes, Noix, Fromages
** Cliff Young
*** Haricots, bière, avoine
** Scott Jurek
*** -viande, -sucres, -œuf, -fromage, -farine blanche, -crème glacée
*** +burritos riz, +pitas houmous, +pitas olives, pain maison (farine non blanche), +purée haricots+quinoa, +fruits, +légumes, +céréales complètes
*** soins entorses: aconit + bcp ail + bcp ginger
** Dr Weinberg
*** -viande, -sucres rafinés, +légumes, +fruits
*** soins: géranium niveum contre les radicaux libres
** Dr Ruth Heindrich
*** salade (+fruits +fromage) au petit déjeuner
*** fruits, haricots, patate douce, céréales complètes, légumes, mélasse/pavot
** p.348 Louis
*** grignotter toute la journée
*** boire régulièrement
** Tony Krupicka/Raramuris
*** haricots pinto
*** piments
*** courgettes
*** pinole
*** chia
* Magazines
** Ultrarunning
** Runner's World
* p.18/19 "The running Athlete" Torg
* p.24/25 Intérêt pour la course à pieds lié à la société qui va mal: 3 grandes périodes de la Course à Pieds aux USA
** Grande dépression
** Guerre du Vietnam
** Attentats 9/11
* p.30/31 Raramuris ne mangent pas de protéines à part des souris grillées. Ils ne font pas d'échauffements ni d'étirements
* p.46/47 Génétique/Environnement Lumholtz
* p.124 Particularité de l'ultra-trail
** Pas de doctrine
** Pas de mode d'emploi
** Pas de manuel d'entraînement
** Pas de précautions
** Pas de récompense disproportionnée
** Même récompense pour tous les finishers
** Fraternité
* p.136 Ce qui march pour l'entraînement
** Amour
** Plaisir
** Courir avec les potes
** Courir comme fin en soi
* p.145 Signe qu'on approche de la disparition de l'espèce humaine : premières générations qui vivent moins longtemps que leurs parents
* p.169 "UnaBomber's Manifesto"
* p.243 Nike (sait depuis ~1986 et) avoue depuis 2001 que ses chaussures sont néfastes (études des coureurs de Stanford)
*** On va plus vite et se blesse moins avec des chaussures moins chères
* ~60%/80% de coureurs se blessent chaque année
* 1993 "The American Journal of Sprots Medicine"
** Pas d'échauffements/étirements => même taux de blessure qu'avec
* Hawaï : étirements néfastes: 33% blessures en plus
* 2008 Dr Craig Richards "British Journal of Sports Medicine", étude des coureurs de New Castle
* p.247 3 Grands Apprentissages des études scientifiques [pour SylvainL]
** 1) Lien statistique entre chaussures plus chères (+amorti +correction pronation) et plus de blessures
*** Dr. Marti 1988
*** Medicine&Science in Sports&Exercices 1991
** 2) Les pieds se renforcent en étant mal traités
*** 1988 Dr. Barry Bates Oregon "Journal of Orthopaedic and Sports Physical Therapy": vieilles chaussures => moins de blessures que en changer souvent
**** Arthur Newton change de chaussures tous les 6000km
**** David Smyntek "crazy feet experiment" = inversion chaussures droite&gauche
*** 1986 E.C. Frederick, Nike Sport Research Lab: la force de rebond est plus forte dans les chaussures avec amorti !
*** 1997 Steven Robbins + Edward Waked : plus la chute se fait sur une surface molle, plus le corps compense en tombant bviolemment pour garder l'équilibre
** 3) La pronation et la voute plantaire très creusé c'est bien!
*** Alan Webb en travaillant à renforçer son pieds, à creusé sa voute plantaire (-2 pointures!) => + élasticité
*** Dr Gerard Hartmann
**** voute plantaire creusée = ++ s'oppose à Dr George Sheehan (cardiologue) prétendait que l'humain n'est pas fait pour la course
**** chaussures=plâtres => atrophie 40%/60% en 6 semaines
**** => pas mettre de chaussures avant 17ans
**** GM: => il faut porter les mini-shoes même juste pour marcher et marcher pieds-nus @home/herbe
*** p.255 Dr. Paul W. Brand 1976 lien entre chaussures et oignons, corps, orteils en marteau, pieds plats... [pour Nathalie]
* p.274 Crédo de l'ultra-runner "si tu ne peux pas voir le sommet, marche !"
* Les pieds sont faits pour les surfaces non-planes et abrasives. Ils se renforcent dessus => les prendre comme un massage
* Meilleure récup : pierres plates dans un ruisseau froid
* p.277 Dans bcp de populations d'ultra-runners on retrouve un régime végétarien
*** Moines du mont Hiei (Japon)
*** Navajos
*** Raramuris
*** Bochimans
* Glucides digérés + vite que les protéines
*** permet de s'entraîner plus en passant moins de temps dans des grosses phases de digestion
*** p.299 il faut les conserver en courant => rester sous seuil anaérobie (= qd capable courir bouche fermée)
* p.292 position optimale minimaliste = position en côte = position d'un enfant qui court (p.297 comme les Kenyans) = similaire à si on devait tirer quelqu'un avec une corde
** sur l'avant pied, très peu de contact talon
** dos droit
** tête stable
** bras hauts (GM: contradictoire avec Kiné Français???)
** coudes actifs
** appuis/foulée rapides
** hanches vers l'avant
* p.299 Autres nom barefoot = "minimalisme" = "foulée avant-pieds" = "Evolution Running" = "Chi Running" = "POSE method"
* Courir nus pieds oblige contrôler la vitesse et casser le rythme (suivant le terrain: cailloux,etc.)
* p.~300 2007 Journal of American Medicine Association
** manger de la viande après ablation d'un cancer => reprise assurée
* Eric : routine -> blessures vs. surprises/contraintes -> adaptation du corps
* http://www.nativeseeds.org
- (2519)Restaurants/Food in Saint-Malo
- Salons de thé
- Stéphane Denis, rue georges clémenceau (meilleures pâtisseries)
- Bergamotte, intra, près de la cathédrale (accueil top, gâteaux moins bons)
- Crêperies
- intra : crêperie des lutins, grand-rue ;
- crêperie du port, à solidor, plus du tout intra, quai sébastopol
- le grain noir, intra. (prétentieuse et parisianiste mais à la mode)
- Grands classiques pour cadeaux
- épices rolinger, très bon, abordable, rue saint-vincent
- beurre bordier, rue de l’orme
- Cancalaise rue saint vincent
Thanks Soso!
- (2525)10/20/30 Presentation Rule
- 10 slides,
- 20 minutes max duration
- 30 points minimal font size
From: https://guykawasaki.com/the_102030_rule/
- (2531)What does the arrow mean next to the gas station icon on your car's dashboard?
It indicates the side of the tank opening
https://youtu.be/1CHKkwxiuAg?t=561
- (2557)Where to check if an information/mail is a Hoax?
https://www.snopes.com/
https://www.politifact.com/
https://www.factcheck.org/
https://www.truthorfiction.com/
https://hoax-slayer.com/
https://www.thoughtco.com/urban-legends-4132595
- (2567)Six techniques pour vérifier une information sur un réseau social
1. Partir du principe que, par défaut, c’est faux
2. Remonter à la source, croiser avec d’autres informations
3. Faire attention à la date de publication
4. Utiliser une recherche d’image inversée
5. Installer une extension de navigateur (TinEye ou RevEye)
6. Réfléchir avant de partager, faire appel à son bon sens
From: https://www.lemonde.fr/les-decodeurs/article/2019/04/12/six-techniques-pour-verifier-une-information-sur-un-reseau-social_5449052_4355770.html
- (2706)What are the keywords you can use in a GMail query?
from:xxx / to:xxx / cc:xxx / bcc:xxx
subject:xxx / label:xxx [=tags]
has:attachment
filename:<complete filename or single extension>
after: / before:
...
From: https://support.google.com/mail/answer/7190?hl=en
- (2734)How to make a new cake?
Cake aux olives, jambon et fromage
Ingrédients / pour 6 personnes
200 g de farine
1 sachet de levure
3 oeufs
1 pincée de sel
poivre moulu
10 cl d'huile (olive)
10 cl de lait chaud
100 g de gruyère ou de comté râpé
200 g de lardons ou de jambon coupé en dés
150 g d'olives vertes dénoyautées
Réalisation
Difficulté Facile
Préparation 15 mn
Cuisson 45 mn
Temps Total 1 h
Préparation
1 Faire bouillir de l'eau, et y plonger les lardons 2 minutes. Les égoutter, puis les faire revenir dans une poêle, sans matières grasses, jusqu'à ce qu'ils soient bien dorés ; réserver.
2 Dans un saladier (ou dans le bol du robot), mettre la farine, la levure, les oeufs, le sel, le poivre et l'huile. Bien mélanger, puis ajouter le lait chaud, le fromage râpé, les olives égouttées et les lardons.
3 Graisser un moule à cake, le tapisser de papier sulfurisé beurré et y verser la préparation. Mettre au four 45 minutes environ à thermostat 6/7 (200°C), en couvrant avec un papier aluminium à mi-cuisson si le cake dore trop vite. Laisser tiédir dans le moule, et servir tiède ou froid.
From: https://cuisine.journaldesfemmes.fr/recette/343218-cake-aux-olives
- (2736)Movies with rock climbing scenes?
- Star Trek V (1989)
- Cliff Hanger (1993)
- Mission Impossible 2 (2000)
- Vertical Limit (2000)
- Failure to Launch (2006)
- Dark Knight Raises (2012)
- Point Break (2015)
From : https://www.youtube.com/watch?v=R7qSiEKntQA
- (2742)How to study/work efficiently?
0. First compute your own "efficient working time":
* Mark the time(1)
* Work on a single task until you get bored/until your mind starts to wander on other things/until your read the same line/paragraph several time
* Mark the time(2)
* Compute your "effective working time"=time(2)-time(1)
* NOTE: it should be ~ 25/30min for avg person
1. Normal Working session should be:
a) [IN WORKING CONTEXT] Study for "effective working time"
b) [IN PAUSE CONTEXT] Pause 5 minutes
* Repeat 6 to 12 times a)+b)
* Get a big reward (beer, candy, movie...)
2. What is WORKING CONTEXT
* Specific room = office or library (not sleeping room, not living room, not a bar)
* Specific place at calm (turned backwards to bed, in front of a wall)
* Specific light
* No music/TV (or music at very low volume and with no lyrics)
3. It is easier to remember new things if they are understood (more connexions with previous things in the brain)
* Understand
- Take notes during lecture
- Re-read them right after the lecture & ask teacher for unclear points
- Teach another person your lesson (parent, brother, friend...)
+ Things are better remembered if reformulated
READ [10%] < HEAR [20%] < SEE [30%] < SEE+HEAR [50%] < SAY+WRITE [75%] < DO [100%]
https://3e7e6c34hre53ebyea38hmr6-wpengine.netdna-ssl.com/wp-content/uploads/2016/02/La-me%CC%81morisation-1.png
4. How to read a book
* SQ3R https://en.wikipedia.org/wiki/SQ3R
1- Overview chapter
1a- S(urvey)
1b- Q(uestion)
3- R(ead) chapter
4- R(evise)
5- R(eview)
* Same principle as in 3: create first general ideas, then link more detailed ideas
* Phase 1a/1b serves at creating "directories" in your brain
* Phase 2/3/4/5 serves at creating "files" in the directories and linking them together
5. Sleep well
* Brain re-visits things learned during the day during dreams/deep sleep phases
From: https://www.youtube.com/watch?v=IlU-zDU6aQ0
- (2750)What websites to use to look for a job in Computer Science/Data Science in France circa 2020?
- Biggest Websites for Computer Science jobs:
https://www.monster.fr (generally you'll receive many calls from SSII/ESN that haven't looked correctly at your CV)
https://www.indeed.fr
https://www.glassdoor.fr (it's cool, there are rating from ex-employees about employers)
https://www.keljob.com (lots of advice on how to look for a job)
https://www.pole-emploi.fr
https://mypepit.tech/
https://www.hellowork.com/fr-fr/ (DON'T subscribe to the mailinglist, it sends totally unrelated jobs, and their admin thinks it's a feature not a bug!!!!)
- For Computer Science outside of big cities
https://www.laou.fr
- For high-end employees ("cadres", postdoc, etc.):
https://www.apec.fr/
https://www.abg.asso.fr/
- For Data Science:
https://www.kdnuggets.com/jobs/index.html
https://datajobs.com/
http://www.analytictalent.com/
https://www.aijobs.tech/fr/
https://www.datarecrutement.fr/
+ LinkedIn
- For DataSCience in Academic domain
https://www.madics.fr/
- For startup/freelance, see Tip#2017
- (3149)Comment re-régler une tringle extensible de douche quand elle a été réglée trop grande?
Il faut en fait l'étendre encore plus, jusqu'à ce que le tube intérieur sorte complètement et le ré-insérer à l'autre bout du tube extérieur.
From: https://www.youtube.com/watch?v=ozOX7Kff41g
- (3152)How to print access/print Medium articles?
- To access restricted articles, using your browser "Incognito/Private" mode is sufficient in general
- To print articles without the overlay boxes/ads/etc and with all the dynamic images/code snippets loaded, you can submit them to "Print Friendly & PDF" web site or install the FF extension
From: https://www.printfriendly.com/
https://addons.mozilla.org/en-US/firefox/addon/print-friendly-pdf/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search
- (3211)How to search emails from multiple people in GMail search engine?
You need to separate the e-mails with the vertical line "|"
It is really ridiculous that google makes it so hard to figure out a basic usage - they should explain it or allow common separators like commas.
Example:
from:{...@company.com | sen...@company.com}
From: https://groups.google.com/g/gmail-power-users/c/eSxF3VYB1Fk/m/UT-sXlzv_TYJ
- (3217)How to delete a google apps script service?
SOLUTION1:
Open a spreadsheet then go to Tools -> Script Editor, then on the editor window go to Edit -> All your triggers... and see if the gmail meter method is still listed there. If so, delete it.
SOLUTION2:
- Find the URL to the script url in the script editor i.e:
https://script.google.com/macros/d/MS3-PFwnUdYw7_bQF3y8BJte_1Q7n6BNa/edit
- Remove edit from url and replace with manage/uninstall
https://script.google.com/macros/d/MS3-PFwnUdYw7_bQF3y8BJte_1Q7n6BNa/manage/uninstall
- Click uninstall and that should be it!
From: https://stackoverflow.com/questions/10459410/how-to-delete-a-google-apps-script-service
- (3242)How to memorize things easily?
Use visualization: invent a (visual) story which *embodies* the things to learn into your own body: for instance, attach something to be memorized to your mouth, another thing to your shin, antoher to your shoulder or arm, etc.
From: https://www.youtube.com/watch?v=JsC9ZHi79jo
- (3252)How to motivate yourself to change your behavior?
- Make social commitments: get help from others, create social pressure for yourself
- Turn things upside down: instead of blaming yourself for not doing good things (negative reward), give yourself *immediate* reward when doing good things (positif reward)
- Monitor your progress: draw charts to show progress (positive reward) and display steps to reach goal (incentive to go further)
From: https://www.youtube.com/watch?v=xp0O2vi8DX4
- (3253)How not to take things personally?
- It's not about me
=> Imagine the other's intentions
- It's about me
=> give yourself a bit of empathy (childhood trouble)
=> Speak Up : tell the other what's wrong/that you don't like what's
been said/done
NOTE: Whatever the others say, you always keep your value (image: 20$ bill can be
trashed, it's still worth 20$)
From: https://www.youtube.com/watch?v=LnJwH_PZXnM
- (3256)How to prepare / What to bring to a 100km race?
- Préparation
- Idée : si on peut faire l'objectif sur plusieurs séances étalées sur 1 semaine, alors on pourra faire l'objectif en 1 fois.
- DEBUT: Partir de ce qu'on sait faire / 1 semaine
ex: plus grosse course faite = 40km => 40km étalé sur 1 semaine
- FIN: Aller vers ce qu'on doit faire / 1 semaine
ex: objectif = 100 km => 100km étalés en plusieurs séances sur 1 semaine
- ENTRE les 2:
- Augmenter toutes les semaines la quantité (augmentation = (fin-depart)/(-1+#semaines entre début et course)) . Le -1 est là pour la semaine de repos avant la course (cf. ci-dessous)
- Diviser par 2 la quantité toutes les 4 semaines pour laisser le corps se reposer
- Laisser au moins 1 semaine sans rien entre le dernier entraîenement et la course elle-même
- Alimentation *Salée*
- Soupe / Fromage (mini-sandwiches)
- Fruits secs
- Alimentation Sucrée
- Ovomaltine/Balisto
- Boisson
- Coca dilué à l'eau gazeuse
From: 100km du Trail des Fauvettes + Tips CEA
- (3257)What is the name of the miraculous drug that helps alcoholic patients not desire alcohol anymore?
Baclophène (décontractant)
- (3286)Where to find a list of nice Hikes/Treks/Trails?
https://thruhikes.net/
- (3353)How to create fire with a broken lighter?
... If the sparkling part still works.
1. Reduce some wood/mushrooms/bark to powder
2. Fill the top part of the lighter (sparkling part) with the powder
3. Just use the lighter as usual, it should spark a big sparkles or even a little (short duration) flame that should be sufficient to light the wood/mushrooms/bark at the bottom of your fire
From: https://www.youtube.com/watch?v=wUpQRIEuaG4
- (3413)A list of the classical things that French real estate agencies illegally do (a.k.a. Liste des frais que les agences immobili&egrave;res font ill&eacute;galement payer)
Est r&eacute;put&eacute;e non &eacute;crite toute clause :
a) Qui oblige le locataire, en vue de la vente ou de la location du local lou&eacute;, &agrave; laisser visiter celui-ci les jours f&eacute;ri&eacute;s ou plus de deux heures les jours ouvrables ;
b) Par laquelle le locataire est oblig&eacute; de souscrire une assurance aupr&egrave;s d\'une compagnie choisie par le bailleur ;
c) Qui impose comme mode de paiement du loyer l\'ordre de pr&eacute;l&egrave;vement automatique sur le compte courant du locataire ou la signature par avance de traites ou de billets &agrave; ordre ;
d) Par laquelle le locataire autorise le bailleur &agrave; pr&eacute;lever ou &agrave; faire pr&eacute;lever les loyers directement sur son salaire dans la limite cessible ;
e) Qui pr&eacute;voit la responsabilit&eacute; collective des locataires en cas de d&eacute;gradation d\'un &eacute;l&eacute;ment commun de la chose lou&eacute;e ;
f) Par laquelle le locataire s\'engage par avance &agrave; des remboursements sur la base d\'une estimation faite unilat&eacute;ralement par le bailleur au titre des r&eacute;parations locatives ;
g) Qui pr&eacute;voit la r&eacute;siliation de plein droit du contrat en cas d\'inex&eacute;cution des obligations du locataire pour un motif autre que le non-paiement du loyer, des charges, du d&eacute;p&ocirc;t de garantie, la non-souscription d\'une assurance des risques locatifs ou le non-respect de l\'obligation d\'user paisiblement des locaux lou&eacute;s, r&eacute;sultant de troubles de voisinage constat&eacute;s par une d&eacute;cision de justice pass&eacute;e en force de chose jug&eacute;e ;
h) Qui autorise le bailleur &agrave; diminuer ou &agrave; supprimer, sans contrepartie &eacute;quivalente, des prestations stipul&eacute;es au contrat ;
i) Qui autorise le bailleur &agrave; percevoir des amendes ou des p&eacute;nalit&eacute;s en cas d\'infraction aux clauses d\'un contrat de location ou d\'un r&egrave;glement int&eacute;rieur &agrave; l\'immeuble ;
j) Qui interdit au locataire l\'exercice d\'une activit&eacute; politique, syndicale, associative ou confessionnelle ;
k) Qui impose au locataire la facturation de l\'&eacute;tat des lieux de sortie d&egrave;s lors que celui-ci n\'est pas &eacute;tabli par un huissier de justice dans le cas pr&eacute;vu par l\'article 3-2 ;
l) Qui pr&eacute;voit le renouvellement du bail par tacite reconduction pour une dur&eacute;e inf&eacute;rieure &agrave; celle pr&eacute;vue &agrave; l\'article 10 ;
m) Qui interdit au locataire de rechercher la responsabilit&eacute; du bailleur ou qui exon&egrave;re le bailleur de toute responsabilit&eacute; ;
n) Qui interdit au locataire d\'h&eacute;berger des personnes ne vivant pas habituellement avec lui ;
o) Qui impose au locataire le versement, lors de l\'entr&eacute;e dans les lieux, de sommes d\'argent en plus de celles pr&eacute;vues aux articles 5 et 22 ;
p) Qui fait supporter au locataire des frais de relance ou d\'exp&eacute;dition de la quittance ainsi que les frais de proc&eacute;dure en plus des sommes vers&eacute;es au titre des d&eacute;pens et de l\'article 700 du code de proc&eacute;dure civile ;
q) Qui pr&eacute;voit que le locataire est automatiquement responsable des d&eacute;gradations constat&eacute;es dans le logement ;
r) Qui interdit au locataire de demander une indemnit&eacute; au bailleur lorsque ce dernier r&eacute;alise des travaux d\'une dur&eacute;e sup&eacute;rieure &agrave; vingt et un jours ;
s) Qui permet au bailleur d\'obtenir la r&eacute;siliation de plein droit du bail au moyen d\'une simple ordonnance de r&eacute;f&eacute;r&eacute; insusceptible d\'appel ;
t) Qui impose au locataire, en surplus du paiement du loyer pour occupation du logement, de souscrire un contrat pour la location d\'&eacute;quipements.
From: https://www.legifrance.gouv.fr/loda/article_lc/LEGIARTI000028806566/2020-10-29
- (3449)The problem of personality tests / IA in Human Resources
- If you tell the truth (e.g. "I'm shy") in a Job Interview you do not get the job
- Thus, Job Interviews have become a (difficult) exercise where you demonstrate that you understand what the employer needs/wants to hear and you tell him everything she wants to hear (of course without lying!)
- With Personality tests/AI HR testing, employers now alledgely want to know when you're "lying" ; in fact, what they detect is when it take "too much" time for you to answer, or you do not seems "comfortable" with your (building) answer. Of course, you are almost always in such a situation when being interviewed! Respectively because
- you have to put yourself in the shoes of someone else, then think like her, and both processes take more time than just thinking for yourself &
- because you are not the other person, thus thinking as-if you are this other someone as a (higher) probability of "failing", whereas when you think for yourself, there's no such think as an "error". Thus you are less confident when making/giving such answers.
Thus these systems will almost always detect a problem in any candidate (apart for VERY GOOD liars or schizophrenic, for which it has become almost natural to "lie"/think in the shoes of someone else)!
Personal thoughts that came while watching: https://www.primewire.ag/movie/1377827-watch-persona-the-dark-truth-behind-personality-tests
- (3456)What are the "ten essentials of Mountaineering"? (a.k.a. Things to take when going in the mountains)
1- Navigation (map, compass…)
2- Headlamp + extra batteries
3- Sun protection (sunglasses, sunscreen…)
4- First aid (foot care, insect repellent…)
5- Knife
6- Fire (matches/lighter, tinder, stove…)
7- Shelter (tent or tarp or bivy)
8- Food + extra
9- Water + extra (or purificator)
10- Clothes + extra (sufficient to survive an emergency overnight)
From: https://www.mountaineers.org/blog/what-are-the-ten-essentials
- (3463)Useful Methods in Mounteneering
TECAP method (objectivate decision making situations)
- Timing
- État
- Conditions
- Adaptation
- Plaisir
OSRER method (provide a clear order)
- Objectif
- Séquence
- Risque
- Équipement
- Règles
- (3571)How to parse street addresses?
https://openports.se/geo/libpostal
- (3587)How to put yourself in condition to find a solution to a hard problem?
- Researchers have proven that sleeping helps, and dreams often carry the solution. But how to remember ones dream once one wakes up?
https://www.science.org/content/article/edison-was-right-waking-right-after-drifting-sleep-can-boost-creativity
The trick is to wake up in the transition between sleep and wakefulness, just before deep sleep.
- Thomas Edison used this technique: he would nap in an armchair while holding a steel ball. As he started to fall asleep and his muscles relaxed, the ball would strike the floor, waking him with insights into his problems.
- Some people sleep with one of their arms or a pen as a support for the head, so that head falls/loose its support when one falls asleep.
From: https://science.slashdot.org/story/21/12/08/2124243/waking-up-right-after-drifting-off-to-sleep-can-boost-creativity
- (3594)Watching A Lecture Twice At Double Speed Can Benefit Learning Better Than Watching It Once At Normal Speed
Researchers have proved that watching a Lecture twice at double speed can benefit learning better than watching it once at normal speed.
From: https://science.slashdot.org/story/21/12/23/1252235/watching-a-lecture-twice-at-double-speed-can-benefit-learning-better-than-watching-it-once-at-normal-speed
https://digest.bps.org.uk/2021/12/21/watching-a-lecture-twice-at-double-speed-can-benefit-learning-better-than-watching-it-once-at-normal-speed/
https://onlinelibrary.wiley.com/doi/10.1002/acp.3899?af=R
- (3622)How to listen to music on YouTube without wasting a lot of bandwidth with the useless video stream?
http://jango.com
https://chrome.google.com/webstore/detail/music-mode-for-youtube/abbpaepbpakcpipajigmlpnhlnbennna
- (3640)What are the worst food in the world?
https://en.wikipedia.org/wiki/Surstr%C3%B6mming
https://en.wikipedia.org/wiki/Kiviak
https://fr.wikipedia.org/wiki/Igunaq
https://lebarbareerudit.wordpress.com/2009/10/24/gastronomie-inuit/
https://www.thecanadianencyclopedia.ca/fr/article/nourriture-traditionnelle-au-canada
http://www.quebecuisine.ca/?q=la-cuisine-des-innus
https://en.wikipedia.org/wiki/H%C3%A1karl
https://en.wikipedia.org/wiki/Shiokara
https://en.wikipedia.org/wiki/Century_egg
https://en.wikipedia.org/wiki/Durian
https://en.wikipedia.org/wiki/Tyrolean_grey_cheese
- (3673)What is the "mandela effect"?
It's the collective rememberance of something that never happened.
E.g. the fact that the guy in the Monopoly logo wears a monocle is false!
From: https://en.wikipedia.org/wiki/False_memory#Mandela_effect
- (3754)How to draw iso-distant / iso-chrone "circles" on a map?
https://commutetimemap.com/map
https://playground.traveltime.com/isochrones
https://www.freemaptools.com/line-of-equidistance-between-points.htm
From: https://wiki.openstreetmap.org/wiki/Isochrone
- (3756)How to receive an email alert when new material appears on the web that talks about a subject of interest to you?
You can create a Google Alert:
- Go to https://www.google.com/alerts
- In the box at the top, enter a topic you want to follow.
- To change your settings, click Show options.
You can change:
- How often you get notifications
- The types of sites you’ll see
- Your language
- The part of the world you want info from
- How many results you want to see
- What accounts get the alert
- Click Create Alert. You'll get emails whenever we find matching search results.
From: https://support.google.com/websearch/answer/4815696
- (3757)What are the best sites to get accurate weather predictions?
https://www.lameteoagricole.net/
https://meteo-parapente.com/
Thanks Agnès@Slackliners
- (3761)Where to buy good new/2nd hand computers with warranty?
https://www.laptopservice.fr/
Thanks MatthieuD
- (3790)What are the 5 "R" of Zero Waste?
1- Refuse: THE MOST IMPORTANT thing to reduce our wastes is not to produce useless products, thus not to (over)consume
2- Reduce: Then, of course we
3- Reuse
4- Recycle
5- Return to earth (compost)
To help, there is the BISOU (KISS in French) method to apply before buying stuff:
B- Do I REALLY need it? [En ai-je vraiment Besoin?]
I- Do I need it IMMEDIATLY? [En ai-je besoin Immédiatement?]
S- Do I already have a SIMILAR object? [Ai-je déjà un objet Semblable?]
O- Where does this object come frOm? [Quelle est l'Origine de cet objet?]
U- Will this object be USEFUL? [Cet objet me sera-t-il Utile?]
From: https://savoir.ensam.eu/moodle/pluginfile.php/308020/mod_page/content/14/a%20pyramide%20z%C3%A9ro%20d%C3%A9chet.png
https://i0.wp.com/effetph.com/wp-content/uploads/2019/11/THE-BECHTOWN-YARD-SALE-2.png?resize=768%2C1024&ssl=1
- (3826)What to do if you do not have any toothpaste, but really need to wash your teeth?
You can use some "savon de Marseille" (Marseilles soap) or bicarbonate de soude (baking soda) or coco oil or nothing (it's always good to brush your teeth, even without any chemical)...
From: https://www.marius-fabre.com/fr/blog/astuce-savon-de-marseille-dentifrice-n125
https://missionsignal.fr/conseils/sante-bucco-dentaire-brossage-des-dents/se-laver-les-dents-sans-dentifrice-ni-brosse-a-dents.html
- (3895)Tips for "Too Kind" people that get exploited by "Dominator" people [TOFINISH]
#+STARTUP: showall indent latexpreview inlineimage
# --- Use C-c C-c to reload this ---
#+TODO: TODO(t) LATER(l) INPROGRESS(i) | CANCELLED(c) DELEGATED(e) DONE(d)
#+TODO: REPORT(r) BUG(b) KNOWNCAUSE(k) | FIXED(f)
#+TODO: OB(o) FlB(f) VC(v) AZ(a) MLF(l) LGN(g) PhJ(p) XS(x) MJ(m) Yous(y) TM(t) | GM(g)
#+TITLE: Résumé de différentes vidéos de coaching personnel d'Yves GAUTIER
#+AUTHOR: Yves GAUTIER
#+DATE: 2023/01
#+DESCRIPTION: Résumé de différentes vidéos de coaching personnel d'Yves GAUTIER
#+KEYWORDS: Coaching Personnel, Yves GAUTiER, YouTube, Gentillesse, Domination, Dire NON,
#+LANGUAGE: fr
#+OPTIONS: toc:nil ## remove Table Of Content
#+OPTIONS: H:1 ## With H:1, *=slides || with H:2, *=sections
# #+OPTIONS: num:nil ## use itemize vs. enumerate
#+OPTIONS: comments yes
* Source: Channel YouTube du coach Yves GAUTIER
+ https://www.youtube.com/watch?v=OuVHQC30M-g&list=PLfSFLujgfxj5663T5X6lY-GolQGIn1r21
* 5 Phrases pour quand on te coupe la parole
+ https://www.youtube.com/watch?v=OuVHQC30M-g
** Phrase 1 : la solution classique. Avec 2 options : public connu et public inconnu.
- "Alors je termine et ensuite je réponds sur ce point."
- "Oui XXX, je sais tu es toujours très vigilante sur YYY [écouter/brosser dans sens du poil] alors j'aborde cet aspect un petit peu plus loin, on y revient tout à l'heure [Gagner du temps]."
- [écouter] <elle dit son truc> "Oui quel est votre prénom ? XXX ? Ecoutez XXX, je termine ma présentation [rappel à l'ordre] et ensuite je vous le promets lors de la phase question-réponse, vous serez la première personne à qui je vais donner la parole.
** Phrase 2 : jouer la réciprocité
- "Je vous ai écouté sans vous interrompre, je souhaite que ce soit la même chose de votre côté"
** Phrase 3 : utiliser la notion de respect
- "Alors... que vous ne soyez pas d'accord avec mon point de vue je l'entends et je le respecte. Maintenant, ce que j'aimerais c'est qu'en retour vous respectiez mon point de vue, en me laissant aller au bout de mes idées."
** Phrase 4 : confronter la personne qui vous coupe la parole
- "Je parle et vous m'interrompez sans cesse. Où voulez-vous en venir exactement ?" [ton non agressif]
** Phrase 5 : La stratégie Patrick Sébastien + Option réseaux sociaux. Approche contre-intuitive
- "Je vois que vous avez beaucoup de choses à dire donc je vous invite à me rejoindre ici, sur l'estrade, et à prendre le micro pour présenter votre point de vue..."
- [si filmé] "...pour information cette conférence est filmée donc certains éléments pourront se retrouver diffusés sur les médias sociaux"
* [si pas filmé] "...je pense que cette intervention va être intéressante donc j'invite des personnes dans le public à sortir leur téléphone portable et à filmer cette intervention"
* 7 Phrases pour arrêter d'être trop gentil
+ https://www.youtube.com/watch?v=yiMlfdBACr4
** Phrase n°1, le réflexe de base
- "laisse-moi quelques jours pour y réfléchir il faut que je cogite là-dessus" + synonymes
- "faut que j'y réfléchisse" / "faut que j'y pense" / "faut que je vois" / "faut que je creuse le sujet" / "faut que je me renseigne"
- ⚠ si l'autre dit "URGENT" => y'a un loup (urgent pour lui… pas pour vous! ⚠)
** Phrase n°2, jouer le noeud-noeud !
- "bah non ça me dit rien" + généralités
- "je ne me vois pas faire ça" / "je ne me projette pas" / "ça ne me parle pas"
** Phrase n°3, la pause
- "je crois que j'ai déjà beaucoup donné sur le sujet donc là j'ai envie de faire une pause" + lister dans le détail l'ensemble des choses que l'on a faites
** Phrase n°4, forcer l'autre à écouter mon point de vue
- "bon admettons que je te dise oui et toi de ton côté tu fais quoi pour moi ?"
** Phrase n°5, approche plus musclée
- "bon imaginons je te dis oui là-dessus et après c'est quoi la prochaine étape ? Qu'est-ce que tu vas me demander ? C'est quoi le projet ? Où est-ce que tu veux en venir exactement ?"
** Phrase n°6, une approche puissante
- "Non ça ne correspond pas avec mes valeurs" [parler de vous/dire qui vous êtes/comment vous fonctionnez]
- Citer une seule valeurs : égalité / morale / justice / équité / éthique
** Phrase n°7 L'arroseur arrosé
- "Bah non là en ce moment je suis sur un autre truc" + une tonne de détails
* 10 Phrases pour déstabiliser une personne dominante
+ https://www.youtube.com/watch?v=wxKnj-Uzu_U
** [Tips: phrases courtes sous forme de questions]
- "Ouais celle-là tu me l'as déjà faite t'as pas autre chose s'il te plaît ?"
- "C'est beau ce que tu dis tu peux me redire la phrase s'il te plaît ?"
- "Ah ce que tu dis ça me fait mal... je souffre... je souffre comme jamais je n'ai souffert" [exagérer un max]
- "Oui moi aussi j'ai une question importante : qu'est-ce qu'on bouffe à midi ?"
- "Ah non là aujourd'hui je suis pas d'humeur. Une autre fois peut-être"
- "Vas-y, vas-y, continue, tu es mignon quand tu fais le méchant. Je pourrais presque y croire !" [ton d'un parent qui gronde son enfant]
- "Tu te sens bien ? Tu veux que j'appelle quelqu'un ?" [ton sérieux pour faire peur à l'agresseur]
- "Là c'est de toi ou bien tu l'appliqué dans une série ? Game of Thrones, c'est ça ? Quelle saison déjà ?" [détourner l'attention]
- "Tu es sûr de ce que tu dis ? Tu veux vraiment aller sur ce terrain là ?"
- "Et tu vas faire quoi ?" [Tu parles... Tu parles... Mais c'est McCain "ce qui parlent le plus qui en mangent le moins"]
* 7 PHRASES QUI ANNONCENT UNE TENTATIVE DE PRISE DE POUVOIR
+ https://youtu.be/ImiCvLarhSo?t=851
** Phrases
- "C'est urgent"
- "Tu es la seule personne qui peut m'aider"
- "Tu n'as pas d'humour"
- "S'il te plaît, on est des amis"
- "Donc tu es d'accord pour faire ça ou ça"
- "Tout le monde pense que tu es ceci et cela"
- "Mais je comprends pas, avant ça posait pas de problème"
- ("on compte sur toi")
* Comment déstabiliser une personne dominante ?
+ https://www.youtube.com/watch?v=ImiCvLarhSo
** Techniques
- faire un silence
- répéter la phrase qui vous met en cause
- utiliser la phrase "C'est quoi l'idée ?"
- différer votre réponse
- la phrase "Tu te bases sur quoi ?"
- la phrase "Tu es sûr de ce que tu dis ?"
- rigoler, prendre les choses avec humour
* Comment arrêter de trop penser ?
+ https://www.youtube.com/watch?v=FNlrHMbR_T0
** Pourquoi on pense trop?
- Trop penser, cela veut dire penser à des choses qui ont une charge émotionnelle négative
- Trop penser, souvent la thématique de base, c'est « qu'est ce qui va se passer ? »
- Parfois, trop penser, c'est repenser au passé, ruminer des échecs
- Trop penser, c'est parfois se justifier dans sa tête, pour soi même
- Trop réfléchir, c'est souvent anticiper des dialogues avec les autres
- Trop penser, c'est parfois penser à des choses futiles, juste pour faire du bruit dans sa tête
- Trop penser, c'est accorder trop d'importance à la pensée.
** Comment arrêter de trop penser ?
- Désencombrer votre environnement : si vous vivez dans un logement très encombré, vous serez plus facilement dans la confusion mentale
- Limitez les flux : en particulier internet ou la télé
- Organisez-vous pour avoir moins de choses à penser
- Faites des transitions
- Ayez des activités de loisir qui vous permettent de vous régénérer
- Notez vos pensées. Cela peut se faire sous la forme d'un cahier, ou sous la forme d'un tableau
- Passez à l'action. Quand vous avez un problème, demandez vous : qu'est ce que je peux faire ? Quand on pense trop, on se disperse. Avoir un projet permet de canaliser les énergies
* INPROGRESS Comment réagir face au manque de respect
https://www.youtube.com/watch?v=mUuk8TJEWgA
** Manque de respect au travail, de la part d'un supérieur hiérarchique
- "Oui peut-être que j'ai fait une erreur [accepter] mais je ne pense pas que ce soit la peine de remettre mon diplôme en questions [recadrer]"
** Manque de respect dans le couple
- 1. Donner du contexte
- 2. Faire un pas vers l'autres (reconnaître qu'il a partiellement raison)
- 3. Demander à l'autre de faire un effort
** Manque de respect dans une relation amoureuse (rupture avec un ex)
- .
** Manque de respect de la part d'un collègue
- .
** Manque de respect envers un supérieur hiérarchique
- .
* INPROGRESS 10 Phrases pour répondre à une insulte
https://www.youtube.com/watch?v=z723sU8d_8o
** La phrase judoka
-
** La négation
** La déviation
** Le sauveur
** La tendresse
** L'incantation (retour au moyen-âge)
** La répartie Choucroute
** Scientifique
** Relax Max !
** Le mendiant du Drama
* TODO Comment arrêter de procrastiner ?
+ https://www.youtube.com/watch?v=-DyRvZIQhNY
** .
* TODO
https://www.youtube.com/watch?v=yMIS5zIKlss
https://www.youtube.com/watch?v=Sj1b5dqJAeE
https://www.youtube.com/watch?v=nLRW-Mgu5Y0
- (3911)Turcs et astuces Bricolage Electricité [TO FINISH]
- Pour tester si un élément est électrifié, approcher le dos de la main : on sait qu'un gros courant électrique fait contracter les muscles. En présentant le dos de la main, la contraction va faire naturellement s'éloigner le corps du danger :)
- ...
- (3925)Good French researchers on Sustainable Development?
- Jose Halloy
- Olivier Hamant
- Natacha Gondran
From: https://www.youtube.com/watch?v=fW4hCmldvEQ
- (3926)"Nature optimizes for Robustness, not Performance"
- "Nature optimizes for Robustness, not Performance"
+ This is related to the requirement of adaptability in Nature
+ Photosynthesis is inefficient (1% in nature vs. 15% in solar panels)
+ Human Body Temperature is sub-optimal: most of our enzymes would work way better at 40°C
- "Robustness & Performance are incompatible/opposite"
+ Performance optimizes the *functioning efficiency* but on very *restricted conditions* vs.
+ Robustness is the idea of being able to work on *many conditions*/even if conditions change/degrade at the cost of a potential *lost in efficiency*
+ Think of racing boats: the faster we design them to go, the easier they break
+ Performance creates fluctuation but Performance does not work in fluctuent world :{
- Performance = effective(efficacité) + efficiency(efficience) = Optimization
- Robustness = Random + Slow + Redundant + Incoherent + Incomplete
Olivier Hamant
From: https://www.youtube.com/watch?v=fW4hCmldvEQ
- (3927)La loi de Goodhart / Goodhart's law
« lorsqu'une mesure devient un objectif, elle cesse d'être une bonne mesure »
"When a measure becomes a target, it ceases to be a good measure".
car elle devient sujette à des manipulations, directes (trucage des chiffres) ou indirectes (travailler uniquement à améliorer cette mesure).
From: https://en.wikipedia.org/wiki/Goodhart%27s_law
- (3933)/ Conway's law
"organizations design systems that mirror their own communication structure"
"les organisations créent des systèmes à l’image de leurs propres structures de communication"
From: https://en.wikipedia.org/wiki/Conway's_law
- (3944)How to rip Scholarvox's books?
NOTE !! they do stats on your readings ⇒ don't rip too much a day (a.k.a. don't "read" too much pages a minute/day) otherwise they will block your account!
- Login to institution
- Go to scholarvox page
- Find your book
- Open it in the reader
- Right click on the background of the page to reopen "This frame in a new tab"
- Force load of all pages : Zoom out(?) so that pages are very small then scroll slowly till the end of the page (eventually do it back from end to start to ensure all pages are loaded)
- Zoom back to a readable level
- Ctrl+P/Print to PDF (HTML page zoom)
- You can play with both scaling of the print and/or the scaling of the HTML page itself + print preview to fit pages on selected paper size
- (3956)Where to get a "plain English" version of any Licence/EULA/...?
https://tosdr.org/
NOTE: ChatGPT can rephrase/summarize license texts for you :)
- (3970)How to see all my posts across all Google Groups?
Just type:
author:me
in the search field.
From: https://webapps.stackexchange.com/questions/16407/see-all-my-posts-across-all-google-groups/59368#59368
- (3985)How to download the PDF of a ReadTheDocs online book?
Typically, it should not be necessary to construct this URL yourself. There is a link in the navigation bar of RtD. You just have to know where to find it.
Notice the 'Read the Docs' label at the bottom left of the page (together with the version indicator). Click it and a panel will open.
In the panel, you can select the desired version. The 'PDF' link navigates to the PDF file. The build system of RtD should automatically keep this file up to date with the documentation source.
From: https://stackoverflow.com/questions/50425740/how-to-find-the-pdf-version-of-a-read-the-docs-project/52131151#52131151
- (3991)How to get "premium" download links for sites like 4share, RapidGator, 1file, uploadgig...)?
https://leechall.com/
https://anydebrid.com/
https://www.newscon.org/download/
- (3994)Quelques mots de djeuns'
- https://fr.wiktionary.org/wiki/quoicoubeh
quoicoubeh = réponse débile d'étudiant à un 'quoi?' d'enseignant
- https://fr.wiktionary.org/wiki/zbeul
zbeul = brodel
- https://fr.wiktionary.org/wiki/cheh
cheh = bien fait pour toi
- (4009)What is "nudge"?
This technique aims to influence behavior through incitement.
In French "nudge" = "coup de coude/pouce". A technique developed since 2008 by the 2017 Nobel Prize in Economics Richard Thaler and derived from behavioral economics, which aims to influence us in our own interest. Adopted before the crisis by the public authorities according to France culture, it would have imposed itself as a method of communication since the start of the Covid-19 epidemic.
*In economics, the "nudge" theory aims to guide a consumer who is disturbed in his choices towards "the right decision", through incentives more than through legislation or instruction*. In non-pandemic times, this can mean a fly drawn on the bottom of Amsterdam airport urinals to prevent splashing. In politics, it is a question of improving public action by taking into account the real and not supposed feelings of users. David Cameron in the UK and Barack Obama in the US became interested in it in the early 2010s.
From: https://www.sudouest.fr/sante/coronavirus/qu-est-ce-que-le-nudge-cette-technique-de-communication-du-gouvernement-en-temps-de-covid-19-1556466.php
- (4023)7 things you should never clean with white vinegar
1. Marble and granite countertops/tiles
2. Waxed furniture
3. Hardwood floors
4. Kitchen knives
5. Egg stains
6. Computer and phone screens
7. Rubber items
From: https://www.tomsguide.com/news/7-things-the-experts-warn-you-to-never-clean-with-white-vinegar
- (4041)Que faire en cas de VSS (Violence Sexuelle et Sexiste)?
Les principaux points à retenir :
- #nerienlaisserpasser
- Ne pas rester seul·e et se tourner vers des personnes et structures de confiance.
- En tant que témoin :
+ rester *disponible et à l'écoute* des besoins de la personne qui a été *victime* de VSS
+ assurer votre *sécurité* (celle de la victime et la vôtre)
+ *écrire votre témoignage* et le *mettre à disposition de la victime*.
+ En tant que témoin direct·e :
* Il est possible d'intervenir pour faire cesser la situation si vous vous sentez en sécurité (grâce, par exemple, à la méthode des 5D or 5D Method. See Tip#4042) et *façon proportionnée* à la menace.
* Ensuite, vous pouvez *soutenir la victime* en lui demandant ce que vous pouvez faire pour elle. Vous pouvez également la rassurer en disant que ce qui s'est produit est grave, n'est pas normal, est condamné par la loi, etc.
+ En tant que témoin indirect·e :
* Il est important de montrer à la personne qui se confie à vous que *vous la croyez* et qu'elle peut vous faire confiance. Il *ne faut pas remettre en cause son récit*, minimiser les faits ou avoir des propos qui pourraient la faire culpabiliser. Une victime de VSS n'est jamais responsable de ce qui lui arrive.
Dans tous les cas, rappelez-vous :
- qu'il est primordial de respecter les choix et le rythme de la personne qui a subi une VSS.
- que vous n'êtes ni super-héros, ni super-héroïne. Il ne s'agit pas de vous mettre en danger ou de mettre en danger d'autres personnes. De plus, toute forme de violence, les phénomènes de rumeurs, de mise à l'écart, etc... vis-à-vis de l'auteur présumé sont à proscrire.
- qu'en situation d’urgence, il faut s’adresser aux dispositifs d’urgence comme la police, les pompiers ou le SAMU.
- En cas de viol, il est fortement conseillé de *se rendre rapidement au service des urgences* de l’hôpital pour faire procéder à des *constatations qui auront une valeur juridique* si la victime dépose plainte, mais cela doit rester la décision de la victime.
From: https://ecampus.emse.fr/course/view.php?id=1418§ion=5
https://www.youtube.com/watch?v=A8djnqK-_Fw&list=PLvcD7vIpCTBWLrkXUfQQdaQjOFRqGPEuV&index=12
- (4042)Qu'est-ce que la méthode des 5D pour réagir à un harcellement/agression dans la rue?
- *Distraire* : il s’agit d’agir de manière indirecte pour éviter que la situation ne dégénère en engageant une conversation avec la cible ou en trouvant un autre moyen de détourner l’attention du harceleur. Faire semblant de connaître la victime, lui demander l’heure ou son chemin, faire tomber quelque chose de façon faussement accidentelle... Il est possible de faire preuve de créativité selon le contexte.
- *Déléguer* : il s’agit de repérer une personne représentant l’autorité (conducteur ou conductrice de bus, agent.e de sécurité, professeur.e, gérant.e du bar…) et de demander de l’aide. Expliquer à cette personne ce qu’il s’est passé et lui demander si elle peut faire quelque chose. Il est aussi possible de déléguer à une personne lambda, ou de demander de l’aide en parlant très fort pour attirer l’attention sur la situation (“Regardez, vous ne trouvez pas que c’est étrange ?”). Appeler la police avec l’accord de la victime.
- *Documenter* : il s’agit de filmer l’incident ou de prendre des photos, ce qui peut s’avérer très utile si la victime décide de porter plainte et souhaite apporter des preuves. Ne pas oublier de se tenir à une certaine distance de sécurité, d’énoncer la date et l’heure à voix haute et de filmer les panneaux de signalisation ou tout autre indice qui permette de repérer le lieu et le moment du délit. Attention cependant aux questions de droit à l’image. Il est interdit de publier des vidéos ou des photos sur les réseaux sociaux sans l’accord de la personne sur l’image.
- Diriger* : il s’agit tout simplement de diriger la situation, après avoir au préalable évalué sa propre sécurité, car c’est le “D” le plus impactant. En dernier recours, demander au harceleur d’arrêter, intervenir, défendre la cible, demander de l’aide tout en évitant de se confronter directement au harceleur ou de s’exposer au danger.
- *Dialoguer* : dès que l’incident est terminé (et même si le harceleur est toujours présent), faire le point calmement avec la personne harcelée pour la rassurer (“Puis-je m’asseoir à côté de vous ? Voulez-vous que je demande de l’aide ? Voulez-vous sortir d’ici ?”) Indiquer que l’attitude du harceleur n’était pas normale, agir comme un.e ami.e. Eviter de parler avec l’agresseur car la création d’un débat peut entraîner une possible escalade de la violence.
From: https://www.femmeactuelle.fr/actu/news-actu/harcelement-de-rue-la-regle-des-5d-une-methode-a-connaitre-pour-aider-une-victime-et-intervenir-en-toute-securite-2091301
- (4047)Problems of Marseilles
- rues privées
- luxe côtoye pauvreté
- immeubles s'écroulent
- quéqués au volant
- cagoles/baleines sur plage
- relations faciles mais superficielles
- (4053)How to (easily) remove a (lips) piercing?
PROBLEM: turning the ball makes the whole piercing turn ⇒ impossible to unscrew
SOLUTION
- Use latex gloves
- Use handkerchief
From: https://forum.doctissimo.fr/forme-beaute/tatouages-piercings/piercing-deviser-labret-sujet_7690_1.htm