Init a git repository
# Git global setup
git config --global user.name "myname"
git config --global user.email "myemail@domain.local"

#Create a new repository
git clone git@gitlab.domain.net:it/diskusagereports.git
cd diskusagereports
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

# Push an existing folder
cd existing_folder
git init
git remote add origin git@gitlab.domain.net:it/diskusagereports.git
git add .
git commit -m "Initial commit"
git push -u origin master

# Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.domain.net:it/diskusagereports.git
git push -u origin --all
git push -u origin --tags
Retrieve just one file from a remote repository
git archive --format=tar --remote=git_url HEAD -- <file> | tar xf -
Git: make hotfix
# display branch info
git branch -v

#go in branch hotfix/xx
git checkout -b hotfix/xx

# commit change
git commit -am "ton message"
git status

# push hotfix
git push origin hotfix/xxx

# MAJ branch master
git pull master

# update submodule
git submodule update --init --remote

# init submodule with branch
git submodule add -b branchname git@bitbucket.org:dir/repo.git path_to_submodule
Annuler un commit après un push
# Annuler un commit, c'est finalement appliquer l'inverse de son diff !
# On peut rediriger le diff des commits à annuler vers la commande patch --reverse :)
git diff HEAD^ | patch --reverse

# Pour faire plus simple, il y a git revert !
# Par exemple pour annuler les trois derniers commits :
git revert HEAD~3..HEAD

# Ou pour annuler un commit en particulier :
git revert 444b1cff
# Il suffit alors de pousser proprement le commit obtenu sur le serveur.
Branch manipulation
# To list all local branches
git branch
# To list all remote branches
git branch -r
# To list all branches (local and remote)
git branch -a

# If you are on the branch you want to rename:
git branch -m new-name

# Delete the old-name remote branch and push the new-name local branch.
git push origin :old-name new-name

# Reset the upstream branch for the new-name local branch.
# Switch to the branch and then:
git push origin -u new-name

# Deleting a single local branch
git branch -d <branchname>
# If you are sure you want to delete an unmerged branch:
git branch -D <branch>

# To delete all merged local branches:
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

# DANGER! Only run these if you are sure you want to delete unmerged branches.
# delete all local unmerged branches
git branch --no-merged | egrep -v "(^\*|master|dev)" | xargs git branch -D
# delete all local branches (merged and unmerged).
git branch | egrep -v "(^\*|master|dev)" | xargs git branch -D

# Deleting non-existent tracking branches
git remote prune <remote> --dry-run

# Deleting a single remote branch
git push <remote> --delete <branch>

# To delete all merged remote branches:
git branch -r --merged | egrep -v "(^\*|master|dev)" | sed 's/origin\///' | xargs -n 1 git push origin --delete
PromQL Expressions

List of operations and functions to your PromQL expressions.

Arithmetic binary operators:

\+ (addition)
\- (subtraction)
\* (multiplication)
/ (division)
% (modulo)
^ (power/exponentiation)

Comparison binary operators:

== (equal)
!= (not-equal)
\> (greater-than)
< (less-than)
\>= (greater-or-equal)
<= (less-or-equal)

Logical/set binary operators:

and (intersection)
or (union)
unless (complement)
Aggregation operators:

sum (calculate sum over dimensions)
min (select minimum over dimensions)
max (select maximum over dimensions)
avg (calculate the average over dimensions)
stddev (calculate population standard deviation over dimensions)
stdvar (calculate population standard variance over dimensions)
count (count number of elements in the vector)
count_values (count number of elements with the same value)
bottomk (smallest k elements by sample value)
topk (largest k elements by sample value)
quantile (calculate ?-quantile (0 ? ? ? 1) over dimensions)

Get the total memory in bytes:

node_memory_MemTotal_bytes

Get a sum of the total memory in bytes:

sum(node_memory_MemTotal_bytes)

Get a percentage of total memory used:

((sum(node_memory_MemTotal_bytes) - sum(node_memory_MemFree_bytes) - sum(node_memory_Buffers_bytes) - sum(node_memory_Cached_bytes)) / sum(node_memory_MemTotal_bytes)) * 100

Using a function with your query:

irate(node_cpu_seconds_total{job="node-exporter", mode="idle"}[5m])

Using an operation and a function with your query:

avg(irate(node_cpu_seconds_total{job="node-exporter", mode="idle"}[5m]))

Grouping your queries:

avg(irate(node_cpu_seconds_total{job="node-exporter", mode="idle"}[5m])) by (instance)
Sed Expressions
# Viewing a Range of Lines of a File
sed -n '5,10p' file.txt

# Viewing the Entire File Except a Given Range
sed '20,35d' file.txt

# Viewing Non-Consecutive Lines and Ranges
sed -n -e '5,7p' -e '10,13p' file.txt

# Replacing Words or Strings in a File
sed 's/version/story/g' file.txt
sed 's/version/story/gi' file.txt # ignore character case

# Replate multiple blank spaces with a single space
cat file.txt | sed 's/  */ /g'

# Replacing Words or Strings Inside a Range
sed '30,40 s/version/story/g' file.txt

# Remove Comments From a File
sed '/^#\|^$\| *#/d' file.txt

# Replace a Case-insensitive Word in a File
sed 's/[Zz]ip/rar/g' file.txt

# Finding a Specific Events in a Log File
sed -n '/^Jan  1/ p' /var/log/syslog

# Inserting Spaces or Blank Lines in a File
sed G file.txt
sed 'G;G' file.txt # 2 blank lines

# Removing ^M in a File
sed -i 's/\r//' file.txt

# Create a Backup File with Sed Command
sed -i'.orig' 's/this/there/gi' file.txt

# Switching Pairs of Words in a File
sed 's/^\(.*\),\(.*\)$/\2\, /g' names.txt
Vim Tips
# Supprimer toutes les lignes vides ou contenant tabulation et/ou espace
:%s/^[\ \t]*\n//g

# Suppression des lignes commençant par un #
:g/^#/d

# Suppression des ^M en milieu de ligne et substitution par un vrai retour à la ligne : Taper sur “Enter” pour obtenir le ^M.
:g/^M/s//^M/g

# Changer de mode DOS / UNIX
:se ff=dos
:se ff=unix

# You can show control characters (including where a line ends)
:set list
:set nolist (to toggle off)

# This replaces the beginning of each line with "//":
:%s!^!//!

# This replaces the beginning of each selected line (use visual mode to select) with "//":
:'<,'>s!^!//!

# Execute external command
:map ,t :!make<cr>