29 private links
Je me souviens jamais des paramètres (pourtant pas si compliqués):
# Server
iperf3 -s
#Client
iperf3 -c <my-ip> test
Reminders about some bash syntaxes I never remember :)
Read a file, line by line
while IFS= read -r line; do echo "$line"; done < file.txt
Curl with headers (in request and response)/
curl -i -X POST "http://example.com" -H "header: value" -H "another-header: value"
Cat some files in a folder (adding carriage return) (in a watch)
Here, every files matching folder-*/subfolder/file-*.txt
watch -n 1 'for file in folder-*/subfolder/file-*.txt; do cat $file; echo; done'
# check status of a port
nc -z -v <server> <port>
- Neuve: 3V
- Utilisable si > 2,5V
Edit ~/.vimrc
or /etc/vim/vimrc
:
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
test.erb
<% if condition %>TRUE<% else %>FALSE<% end %>
test.rb
require 'erb'
condition = true
template = ERB.new File.read("test.erb"), nil, "%"
puts template.result(binding)
Then, run ruby test.rb
Can also be very useful: Puppet Debugger
Pour trouver les différences sur une même ligne (typo sur une IP ou un port par exemple), l'outil diff
n'est pas terrible (ne dit que les lignes différentes).
La solution est d'utiliser vimdiff a b
.
Une autre solution: diff a b | colordiff | diff-highlight
(nécessite sudo apt install colordiff
et diff-highlight
vient de /usr/share/doc/git/contrib/diff-highlight/diff-highlight
(à rajouter dans son $PATH
ou bien à copier dans un dossier déjà référencé dans le $PATH
).
Bon, pour les printfs en C:
#include <inttypes.h>
#define PRIu8 "hu"
#define PRId8 "hd"
#define PRIx8 "hx"
#define PRIu16 "hu"
#define PRId16 "hd"
#define PRIx16 "hx"
#define PRIu32 "u"
#define PRId32 "d"
#define PRIx32 "x" // x -> number in hexadecimal
#define PRIu64 "llu" // or possibly "lu"
#define PRId64 "lld" // or possibly "ld"
#define PRIx64 "llx" // or possibly "lx"
Syntax | Description |
---|---|
%zu | size_t |
%d / %i | int |
%u | unsigned int |
%ld | long |
%lu | unsigned long |
%lld | long long |
%llu | unsigned long long |
%c | character |
%s | a string of characters |
%e | exponential floating-point number |
%f | floating-point number |
%0.2f | floating-point number (like 0.58) |
%o | octal number (base 8) |
%% | print a percent sign |
\% | print a percent sign |
- | - |
%hhn | unsigned char * |
Finalement, pourquoi on ne mets pas toujours PRIxxx
, ça serait plus explicite ...
Simple comme bonjour mais impossible à retenir d'une fois à l'autre ... Memo pour plus tard !