Compare commits

...

12 Commits

Author SHA1 Message Date
6ea54b1218 Add update-kuma monitoring tool 2024-02-17 18:49:44 +01:00
2fa462c0ee Update python, postgres, linux and textual notes 2023-07-29 08:29:54 +02:00
9dfa0e63bb Add batcat node 2023-05-21 18:03:38 +02:00
6e78335f5d Add readflow node 2023-05-21 18:03:08 +02:00
aa8990e1c7 Add keycloak node 2023-05-21 18:01:31 +02:00
719e4b2780 Update git note 2022-12-29 11:19:51 +01:00
9feeed82e5 Add query plan generation/visualisation to postgres note 2022-12-29 10:44:31 +01:00
d410b35b37 Add Framadate and mastodon notes 2022-12-29 10:42:12 +01:00
e8c7b3d1e7 Add note about heap sort algorithm 2022-09-28 12:12:56 +02:00
1513d0cc9a Add fail2ban anti-DoS 2022-09-27 12:18:28 +02:00
df0ef69452 Add GTD workflow 2022-09-27 12:14:11 +02:00
324da3208b Add endlessh tarpit 2022-09-27 12:12:57 +02:00
21 changed files with 806 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: ca50d517-3e8a-4d03-ba38-7ff411e87408
:mtime: 20220910133708
:mtime: 20220928120750
:ctime: 20211230101331
:END:
#+title: Software
@@ -18,6 +18,9 @@ Il est nécessaire que le language mis en oeuvre permette l'interception d'erreu
* Design pattern
TODO
* Classement/tri de données
** [[id:6af01039-a0a9-46fc-abe8-82f9662bc4b7][heap sort algorithm]]
* Langages
** Compilés
*** [[id:ed8be72a-8a4d-4ef7-92e4-78d07095deaf][C++]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 4fabfe6a-b104-464f-8a87-dfd7d761dbcc
:mtime: 20220720145510
:mtime: 20221003215204
:ctime: 20211230101535
:END:
#+title: Python
@@ -30,10 +30,12 @@ La méthode ~__repr__~ est utilisée pour le debug quand ~__str__~ pour l'utilis
** Functools module
*** [[id:25d994fd-375b-429d-af38-6afba818159f][functools.singledispatch]]
* Frameworks
** Web
*** [[id:26b04294-75e8-4043-a9a6-a20acd952963][Flask]]
* UI
** GUI
*** [[https://kivy.org/#home][Kiwi]]
@@ -48,6 +50,7 @@ Bindings python pour Qt.
** Text UI
*** [[id:6cc56ee4-6d42-4d50-beb3-bb22a98298dd][textual]]
* Outils
** Analyseur statique de code
*** [[id:1d258869-5421-496a-b296-2d157ebdf3b6][mypy]]
@@ -61,11 +64,14 @@ Outil en ligne de commande permettant d'automatiser les tests dans multiples env
** Couverture de code
*** [[https://github.com/plasma-umass/slipcover][Slipcover]]
Outil de mesure de couverture de code plus rapide que [[https://github.com/nedbat/coveragepy][coverage.py]].
** Debugger
*** [[https://github.com/ionelmc/python-manhole][Manhole]]
Service (interface via une socket Unix permettant l'accès à un REPL) permettant l'inspection d'un programme en cours d'exécution.
** Formatter
*** [[https://github.com/hhatto/autopep8][autopep8]]
Utilitaire formattant le code afin de respecter la [[https://www.python.org/dev/peps/pep-0008/][PEP8]] guideline. Il est basé sur l'analyse de code effectuée par
[[https://github.com/PyCQA/pycodestyle][pycodestyle]]. Autopep8 ne modifie que les espaces contenus dans le code (l'option ~--aggressive~ permet d'accroitre le
pouvoir d'autopep8 et le laisser modifier le code).
[[https://github.com/PyCQA/pycodestyle][pycodestyle]]. ~Autopep8~ ne modifie que les espaces contenus dans le code (l'option ~--aggressive~ permet d'accroître le
pouvoir d'~autopep8~ et le laisser modifier le code).
*** [[https://github.com/PyCQA/isort][isort]]
Outil classant les imports par ordre alphabétique, les séparant par section et par type.
*** [[https://black.readthedocs.io/en/stable/][Black]]
@@ -81,6 +87,8 @@ Génération de données pouvant être utilisées pour:
* Créer des fichiers JSON ou XML d'après une structure arbitraire.
*** [[https://github.com/joke2k/faker][Faker]]
Génération de données.
** Gestion dépendances
*** [[id:01f24d29-e833-4bfa-acb0-95140800d081][poetry]]
** Mockup
*** [[https://github.com/spulec/freezegun][FreezeGun]]
Mockup du module [[https://docs.python.org/fr/3/library/datetime.html][datetime]] permettant de simuler des changements de temps.
@@ -94,6 +102,8 @@ méthode et le temps passé).
/Memory profiler/ traçant les allocations mémoire dans le code Python, les modules extensions et l'interpréteur.
*** [[https://jiffyclub.github.io/snakeviz/][SnakeViz]]
Visualisation des rapports de /cProfile/ (web browser).
*** [[https://github.com/brandtbucher/specialist][Specialist]]
Outil permettant d'indiquer le code optimisé par la spécialisation du bécote (cf. [[https://peps.python.org/pep-0659/][PEP 659 Specializing Adaptive Interpreter]]).xo
*** [[https://github.com/nvdv/vprof][vprof]]
Profiling de programmes python permettant de surveiller le temps d'exécution et l'usage mémoire.
~vprof -c hpm "<cmd>"~
@@ -104,9 +114,6 @@ Outil permettant de tester la tenue en charge d'applications (initialement web s
** Traceur d'exécution de code
*** [[https://github.com/ionelmc/python-hunter][Python-hunter]]
Traçage des appels de fonctions, du code exécuté et des valeurs retournées (vs. smiley, pytrace, PySnooper).
** Debugger
*** [[https://github.com/ionelmc/python-manhole][Manhole]]
Service (interface via une socket Unix permettant l'accès à un REPL) permettant l'inspection d'un programme en cours d'exécution.
* Implémentations
** CPython
@@ -121,6 +128,7 @@ Activation du mode développeur ~python -X dev~ ou ~PYTHONDEVMODE=1 python~ (cf.
Implémentation CPython optimisée par Instagram :
* [[https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/][Jit]]
* Modules intéressants
** Bases de données
*** [[https://spark.apache.org/docs/latest/api/python/][PySpark]]
@@ -157,6 +165,8 @@ Wrapper permettant l'accès au contenu de wikipedia.
*** [[https://github.com/ICRAR/ijson][ijson]]
Parser JSON ne nécessitant pas que l'ensemble de la donnée soit chargée pour la parser (optimisation de la mémoire
consommée, cf. [[https://pythonspeed.com/articles/json-memory-streaming/][JSON memory streaming - Pythonspeed]]).
** Stockage des données
*** [[https://github.com/theskumar/python-dotenv][dotenv]]
** Surveillance de fichers
*** [[https://watchfiles.helpmanual.io/][watchfiles]]
Surveillance de fichiers basé sur la librarie Rust /Notify/.
@@ -166,6 +176,12 @@ Surveillance de fichiers basé sur la librarie Rust /Notify/.
*** [[https://scrapy.org/][scrapy]]
Framework d'extraction de données depuis des site web.
* Modules amustants
*** [[https://github.com/gahjelle/pythonji][pythonji]]
Utilisation d'emojis pour l'écriture de code en Python
* Performances
** [[id:b9f392bd-bd45-4e9e-94ec-b19caedff86f][List vs tuple]]
** [[id:26e1fdfb-1f8e-4c62-a08f-468a56ab03c8][Peephole optimization]]
@@ -198,6 +214,14 @@ Framework d'extraction de données depuis des site web.
* utiliser ~python -m pip~ et ~python -m venv~ (exécution du module en tant que script, au lieu de ~pip~ et ~virtualenv~) permet d'éviter les incohérences
entre les différents répertoires des packages Python (cas lorsqu'un répertoire est présent dans le ~PYTHONPATH~ et qu'un autre l'est dans le ~PATH~).
* Optimisations
** Création automatique de constantes numériques lors de la génération du bytecode
#+BEGIN_SRC python :results output
y = x * 5 / 9 # Une multiplcation par un entier, suivie par une division par un entier
y = x * (5 / 9) # Le ratio 5 / 9 est calculé lors de la génération du bytecode associé à la ligne : une seule multiplication par un flottant lors de l'exécution de l'opération
#+END_SRC
A partir de Python3.11, les opérations entre types identiques (ie: int+int) peuvent être spécialisées (cf. [[https://www.youtube.com/watch?v=tNs18GDmAfg][Python Perf: Specializing, Adaptive Interpreter - Talk Python Live Stream - YouTube]] - augmentation des perfs).
* Tips
** [[id:24408701-21d8-4f4e-aed9-c58746df2244][Différence entre les opérateurs + et +=]]
** [[id:a32ab138-f9a8-4d61-9c09-97953c5a0a92][type == object]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 171ce2f7-4028-47b0-b4e0-5a4a6ccb74ac
:mtime: 20220527114623
:mtime: 20230729082927
:ctime: 20220104155310
:END:
#+title: Postgres
@@ -12,7 +12,11 @@
* Fonctionne sur Solaris, SunOS, Mac OS X, HP-UX, AIX, Linux, IRIX, Digital Unix, BSD, NetBSD, FreeBSD, OpenBSD, SCO unix, NeXTSTEP, UnixWare et toutes sortes d'Unix. Depuis la version 8.0, PostgreSQL fonctionne également nativement sur Windows.
* Interfaces utilisateur
** [[id:0455921f-3ac0-437e-ba76-1afb3f6f85ea][Psql]]
** CLI
* [[id:0455921f-3ac0-437e-ba76-1afb3f6f85ea][Psql]]
** Graphique
* [[https://arctype.com/][ArcType]]
* [[https://github.com/dbeaver/dbeaver][DBeaver]]
* Howto
** Pour lister les utilisateurs
@@ -33,5 +37,60 @@ sudo -u postgres dropdb <database>
\password <user>
#+END_SRC
* Profiling de requêtes (query plan)
** Depuis [[id:0455921f-3ac0-437e-ba76-1afb3f6f85ea][Psql]]
#+BEGIN_SRC sql
EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS) SELECT _stops.kind, _stops.id, _stops.name, _stops.town_name, _stops.postal_region, _stops.xepsg2154, _stops.yepsg2154, _stops.version, _stops.created_ts, _stops.changed_ts, stops.id AS id_1, stops.latitude, stops.longitude, stops.transport_mode, stops.accessibility, stops.visual_signs_available, stops.audible_signs_available, stops.record_id, stops.record_ts, stop_areas.id AS id_2, stop_areas.type
FROM _stops LEFT OUTER JOIN stops ON _stops.id = stops.id LEFT OUTER JOIN stop_areas ON _stops.id = stop_areas.id
WHERE _stops.name ILIKE '%Chaville rive droite%'
#+END_SRC
#+BEGIN_SRC
Nested Loop Left Join (cost=148.62..250.06 rows=5 width=194) (actual time=1.213..1.346 rows=12 loops=1)
Output: _stops.kind, _stops.id, _stops.name, _stops.town_name, _stops.postal_region, _stops.xepsg2154, _stops.yepsg2154, _stops.version, _stops.created_ts, _stops.changed_ts, stops.id, stops.latitude, stops.longitude, stops.transport_mode, stops.accessibility, stops.visual_signs_available, stops.audible_signs_available, stops.record_id, stops.record_ts, stop_areas.id, stop_areas.type
Inner Unique: true
Buffers: shared hit=123
-> Nested Loop Left Join (cost=148.33..208.53 rows=5 width=182) (actual time=1.196..1.296 rows=12 loops=1)
Output: _stops.kind, _stops.id, _stops.name, _stops.town_name, _stops.postal_region, _stops.xepsg2154, _stops.yepsg2154, _stops.version, _stops.created_ts, _stops.changed_ts, stops.id, stops.latitude, stops.longitude, stops.transport_mode, stops.accessibility, stops.visual_signs_available, stops.audible_signs_available, stops.record_id, stops.record_ts
Inner Unique: true
Buffers: shared hit=97
-> Bitmap Heap Scan on public._stops (cost=148.04..166.99 rows=5 width=93) (actual time=1.172..1.219 rows=12 loops=1)
Output: _stops.kind, _stops.id, _stops.name, _stops.town_name, _stops.postal_region, _stops.xepsg2154, _stops.yepsg2154, _stops.version, _stops.created_ts, _stops.changed_ts
Recheck Cond: ((_stops.name)::text ~~* '%Chaville rive droite%'::text)
Heap Blocks: exact=11
Buffers: shared hit=63
-> Bitmap Index Scan on name_idx_gin (cost=0.00..148.04 rows=5 width=0) (actual time=1.155..1.155 rows=12 loops=1)
Index Cond: ((_stops.name)::text ~~* '%Chaville rive droite%'::text)
Buffers: shared hit=52
-> Index Scan using stops_pkey on public.stops (cost=0.29..8.31 rows=1 width=89) (actual time=0.005..0.005 rows=1 loops=12)
Output: stops.id, stops.latitude, stops.longitude, stops.transport_mode, stops.accessibility, stops.visual_signs_available, stops.audible_signs_available, stops.record_id, stops.record_ts
Index Cond: (stops.id = _stops.id)
Buffers: shared hit=34
-> Index Scan using stop_areas_pkey on public.stop_areas (cost=0.29..8.30 rows=1 width=12) (actual time=0.003..0.003 rows=0 loops=12)
Output: stop_areas.id, stop_areas.type
Index Cond: (stop_areas.id = _stops.id)
Buffers: shared hit=26
Planning:
Buffers: shared hit=22
Planning Time: 1.015 ms
Execution Time: 1.521 ms
(28 rows)
Time: 3.503 ms
#+END_SRC
** Visualisation de Query plan
Différents sites permettent de visualiser graphiquement les query plans:
* Gratuits:
* [[https://explain.dalibo.com/][PEV2 - Dalibo]]
* Payants:
* [[https://app.pgmustard.com/login][PgMustard]]
** Audit
Possibilité de logger ou de stocker en base les ajout/modifications ou suppressions de donnéées:
* logs: [[https://www.pgaudit.org/]]
* En base: [[https://wiki.postgresql.org/wiki/Audit_trigger_91plus]] ([[https://github.com/2ndQuadrant/audit-trigger]])
* Références
* [[https://stackoverflow.com/questions/45395538/postgres-md5-password-plain-password][Postgres: MD5 Password / Plain password - Github]]
* [[https://www.postgresql.org/docs/current/sql-explain.html][Sql-explain - PostgreSQL]]

View File

@@ -1,12 +1,12 @@
:PROPERTIES:
:ID: 0455921f-3ac0-437e-ba76-1afb3f6f85ea
:mtime: 20220104160506
:mtime: 20221229101120
:ctime: 20220104155517
:END:
#+title: Psql
#+filetags: :postgre:database:
Interface en ligne de commande permettant la saisie de requêtes SQL, directement ou par l'utilisation de procédures
Interface en ligne de commande permettant la saisie de requêtes PostgreSQL, directement ou par l'utilisation de procédures
stockées.
* Commandes

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: e7581fe3-f83f-4243-91ed-6ef7ade6a844
:mtime: 20220530204913
:mtime: 20220910172209
:ctime: 20220109134723
:END:
#+title: Linux
@@ -10,13 +10,18 @@
* Distributions
** [[id:393342ff-bf38-4472-8713-3de5ebe43eca][Guix]]
* Gestionnaire de paquets
** [[id:4cb68913-62c6-43bb-835f-85237b2a8b40][apt]]
* Systèmes d'initialisation
** [[id:af912c20-4752-44ba-bdc0-99451ac0cd10][systemd]]
* Gestionnaire de volumes logiques : [[id:f202b810-0fba-4c90-bc4c-f8cbc001fe88][LVM]]
* Gestionnaire de volumes logiques :
** [[id:f202b810-0fba-4c90-bc4c-f8cbc001fe88][LVM]]
* Fonctionnalités
** [[id:fad57303-ce0c-4ae4-9529-294f70ecfaa5][Inotify]]
** Surveillance de fichiers
*** [[id:fad57303-ce0c-4ae4-9529-294f70ecfaa5][Inotify]]
* Interpreteur de commandes
** [[id:72eb2d10-5b92-4fb7-9e4e-1398bd933335][bash]]
@@ -25,3 +30,5 @@
** Parsing de contenu json (lib+bin) : [[id:83908b49-3945-4dce-8b26-2a5e4636df13][jq]]
** Transfert de données à un serveur (lib+bin) : [[id:5ea61eaa-7f37-464c-aa69-8251de8f81af][curl]]
** Template utilisant les variables d'environnement : [[https://manpage.me/?q=envsubst][envsubst]]
** Lecture de fichiers
*** [[id:d5b19724-9559-44de-aef7-c4d57fb6dc95][batcat]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 5943c76c-8b25-4cbd-b0b9-c819e5a490ba
:mtime: 20220305154620
:mtime: 20220927121655
:ctime: 20220130140137
:END:
#+title: cyber
@@ -20,6 +20,10 @@
** Linux: [[id:262f233d-9ae9-4bd7-a8e9-cba392a2c1f6][AIDE]]
* Serveur
** "Tarpit"
*** [[id:1ed652bc-bdcc-4410-a207-fb470df29e71][endlessh]]
** Anti-DoS
*** [[id:00b1b480-0f0c-42a3-8952-4275bc10bc00][fail2ban]]
** Tips
*** [[id:9eedbc4b-a961-4057-b2d8-8f10845f0478][Vérification des cyphers suites acceptées par un serveur]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 6cc56ee4-6d42-4d50-beb3-bb22a98298dd
:mtime: 20220528185642
:mtime: 20220814131534
:ctime: 20220130153624
:END:
#+title: textual
@@ -73,6 +73,11 @@ division(5, 0)
#+END_SRC
#+RESULTS:
* Projets
** [[https://github.com/Traumatism/ToastCord][ToastCord - Github]]
** [[https://github.com/kraanzu/dooit][Dooit - Github]]
* Références
* [[https://github.com/Textualize/textual][Textual - Github]]
* [[https://github.com/Textualize/rich][Rich - Github]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: e93719b3-088d-4fe7-9ef8-fc9a4fd84827
:mtime: 20220524205131
:mtime: 20221229111938
:ctime: 20220501191904
:END:
#+title: Git
@@ -34,15 +34,15 @@ Pour positionner ~HEAD~ :
* Au commit grand-père : ~git checkout HEAD^^~ ou ~git checkout HEAD~2~
~HEAD~ est /detached/ lorsqu'un /checkout/ est effectué sur un /commit/ et non pas une /branch/.
Pour forcer le déplacement d'une branche : ~git branch -f <nom_branche> <commit>~.
Pour retourner en arrière :
* Branche locale : ~git reset <commit>~ (position où nous souhaitons être).
* Différentes options :
* ~--soft~ : le commit sera supprimé mais les changements seront conservés et /stashed/,
* ~--soft~ : le commit sera supprimé mais les changements seront conservés et /stashed/,
* ~--mixed~ (par défaut) : le commit sera supprimé mais les changements seront conservés et /unstashed/,
* ~--hard <commit_ref>~ pour les changements à ne pas conserver.
* ~--hard <commit_ref>~ pour les changements à ne pas conserver.
* Branche distante (/remote/) : ~git revert <commit_ref>~ :
* Création d'un nouveau /commit/ qui inversera les modifications apportées par le ~<commit_ref>~,
* Conservation de l'historique,
@@ -65,7 +65,7 @@ Pour mettre à jour une branche distante : ~git fetch~ :
* Met à jour nos branches distantes (par exemple, origin/main),
* Ne met par à jour nos branches locales (par exemple, main),
Pour rapatrier (/fetch/) les branches distantes et les fusionner (/merge/) : ~git pull~.
Pour rapatrier (/fetch/) les branches distantes et les fusionner (/merge/) : ~git pull~.
Pour rapatrier (/fetch/) les branches distantes et /rebase/ : ~git pull --rebase~
@@ -74,8 +74,32 @@ Pour créer une branche afin que celle-ci suive une distante :
pull~,
* La branche existe déjà : ~git branch -u <branche_distante> <branche_locale>~
** Correction
Pour supprimer un fichier du dernier commit non /pushed/ : ~git reset --soft HEAD <filename>~.
Pour commiter la correction d'un précédent /commit/ :
#+BEGIN_SRC shell
git commit --fixup <hash_commit_à_corriger>
git rebase -i --autosquash
#+END_SRC
** Comparaison
Pour comparer deux branches : ~git diff <branche_a>..<branche_b>~.
Pour comparer un fichier ou un répertoire entre deux branches : ~git diff <branche_a>..<branche_b> -- <path>~.
Ajouter l'option ~-w~ à /git diff/ pour ignorer les espaces.
** Logs
Pour afficher l'historique d'une fonction ou d'un fichier : ~git log -L:<class_name>:<filename>~
Pour afficher les dernières positions de /HEAD/ : ~git reflog~.
* Outils tiers
** Visualisation
** Visualisation de dépôts
*** [[https://github.com/rgburke/grv/][grv]]
Visualisation de dépôts git depuis un terminal.
*** [[https://github.com/o2sh/onefetch][onefetch]]
Informations du dépôt courant au lancement d'un terminal.
*** [[https://github.com/git-up/GitUp][GitUp]]
Application de visualisation de dépôts pour MacOS.
** Visualisation de différences
*** [[https://github.com/dandavison/delta][Delta]]
Affichage de ~git diff~.
*** [[https://github.com/darrenburns/dunk][Dunk]]
@@ -88,4 +112,6 @@ Jeu en ligne de commande permettant d'apprendre l'usage de Git.
Site permettant l'apprentissage de l'usage de Git.
* Références
*
* [[https://martinheinz.dev/blog/43][Advanced Git features you didn't know You needed - Martin Heinz]]
* [[https://medium.com/@porteneuve/getting-solid-at-git-rebase-vs-merge-4fa1a48c53aa][Getting solid at Git rebase vs. merge - Christophe Porteneuve]]
* [[https://medium.com/@porteneuve/mastering-git-reset-commit-alchemy-ba3a83bdfddc][Mastering Git Reset: Commit Alchemy - Christophe Porteneuve]]

View File

@@ -1,6 +1,6 @@
:PROPERTIES:
:ID: 47707ab9-7792-4592-b25b-8dd2f2e45b05
:mtime: 20220604101605
:mtime: 20221229104128
:ctime: 20220526082057
:END:
#+title: Self-hosted server
@@ -29,3 +29,9 @@ certbot certonly --nginx --force-renew -d imap.adrien.run
* Vidéo
** Plateforme de streaming
*** [[https://github.com/Chocobozzz/PeerTube][PeerTube]]
* Rendez-vous (remplacement de Doodle)
** [[id:8bb29bf5-219f-49ff-b410-e7cc2473337f][framadate]]
* Microblogging
** [[id:056e86ae-99ad-45c6-be11-fe6582028870][mastodon]]

13
20220825081058-batcat.org Normal file
View File

@@ -0,0 +1,13 @@
:PROPERTIES:
:ID: d5b19724-9559-44de-aef7-c4d57fb6dc95
:mtime: 20230521174952
:ctime: 20220825081058
:END:
#+title: batcat
* Introduction
utilitaire permettant de visualiser les fichiers depuis un terminal avec une mise en forme plus évoluée que /cat/
(coloration syntaxique).
* Références
* [[https://github.com/sharkdp/bat][GitHub - sharkdp/bat: A cat(1) clone with wings.]]

View File

@@ -0,0 +1,31 @@
:PROPERTIES:
:ID: 00b1b480-0f0c-42a3-8952-4275bc10bc00
:mtime: 20220831211359
:ctime: 20220830224237
:END:
#+title: fail2ban
* Introduction
Outil permettant de bloquer pendant une certaine durée toute IP depuis laquelle plusieurs tentatives de connexions ont
échoué.
* Installation
#+BEGIN_SRC shell
apt install fail2ban
#+END_SRC
* Configuration
#+BEGIN_SRC shell
cat >/etc/fail2ban/jail.d/sshd.local EOF<<
[sshd]
enabled = true
port = ssh
action = iptables-multiport
logpath = /var/log/secure
maxretry = 3
bantime = 600
EOF
#+END_SRC
* Références
* [[https://www.redhat.com/sysadmin/protect-systems-fail2ban][Linux security: Protect your systems with fail2ban - Redhat]]

View File

@@ -0,0 +1,30 @@
:PROPERTIES:
:ID: 8d548f9b-2a7c-40c3-8538-b14c2926b865
:mtime: 20220926123315
:ctime: 20220926120504
:END:
#+title: Get Things Done
* Introduction
* Méthode créée par David Allen,
* Gestion du workflow de tâches, composé des étapes suivantes :
* *Capturer* tout ce qui traverse son esprit (idées, taches, liens à explorer), rien n'est trop petit ou grand,
* *Clarifier* ce qui a été précédemment capturé sous forme de tâches,
* *Organiser* les réunions dans l'agenda, les táches dans les différents projets, définir quelles sont les prochaines
actions à réaliser, et si celles-ci nécessitent moins
de 2mins, les faire,
* *Revoir/mettre à jour* l'agenda, l'/inbox/ et les différentes táches. Les objectifs de cette étape sont les
suivants :
* Vider sa tête des choses à retenir (idéé, tâche, rendez-vous) afin de se concentrer sur la réalisation des
tâches : mise à jour de l'inbox,
* Avoir un planning et des listes de tâches à jour (contenu, priorités, dépendances entre celles-ci),
* *Réaliser les tâches plannifiées* d'après le contexte, les temps et energie disponibles et la priorité des tâches.
#+DOWNLOADED: https://www.ionos.com/startupguide/fileadmin/StartupGuide/Schaubilder/EN-getting-things-done-workflow.png @ 2022-09-26 12:17:54
#+ATTR_ORG: :width 1024
[[file:Introduction/EN-getting-things-done-workflow_2022-09-26_12-17-54.png]]
* Références
* [[https://www.ionos.com/startupguide/productivity/getting-things-done-gtd/][Getting things done - Ionos]]
** Usage avec org-mode
* [[https://github.com/rougier/emacs-gtd][emacs-gtd - Rougier]]

View File

@@ -0,0 +1,39 @@
:PROPERTIES:
:ID: 1ed652bc-bdcc-4410-a207-fb470df29e71
:mtime: 20220927114630
:ctime: 20220927093748
:END:
#+title: endlessh
* Introduction
Outil permettant de ralentir les tentatives de connexions SSH sur le port 22 en envoyant une bannière très lentement
(client SSH bloqué pendant des heures), l'idée étant de se connecter depuis un autre port.
* Installation
#+BEGIN_SRC shell
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
sed -i 's/#Port 22/Port 2222/g' /etc/ssh/sshd_config
systemctl restart sshd
apt install endlessh
mkdir /etc/endlessh
cat >/etc/endlessh/config <<EOF
Port 22
EOF
setcap 'cap_net_bind_service=+ep' /usr/bin/endlessh
mkdir /etc/systemd/system/endlessh.service.d/
cat /etc/systemd/system/endlessh.service.d/override.conf <<EOF
[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
PrivateUsers=false
EOF
systemctl daemon-reload
systemctl restart endlessh.service
#+END_SRC
* Références
* [[https://github.com/skeeto/endlessh][endlessh - github]]
* [[https://www.digitalocean.com/community/tutorials/how-to-set-up-an-endlessh-tarpit-on-ubuntu-22-04][How To Set Up an Endlessh Tarpit on Ubuntu 22.04 - DigitalOcean]]

View File

@@ -0,0 +1,86 @@
:PROPERTIES:
:ID: 056e86ae-99ad-45c6-be11-fe6582028870
:mtime: 20221229104009
:ctime: 20220927123818
:END:
#+title: mastodon
* Introduction
Service de microblogging open-source et décentalisée.
* Installation
#+BEGIN_SRC shell
# Mastodon requires nodejs 16
sudo snap install node --classic
apt install imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \
g++ libprotobuf-dev protobuf-compiler pkg-config nodejs gcc autoconf \
bison build-essential libssl-dev libyaml-dev libreadline6-dev \
zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev \
nginx redis-server redis-tools postgresql postgresql-contrib \
certbot python3-certbot-nginx libidn11-dev libicu-dev libjemalloc-dev
yarn set version stable
# We will be using rbenv to manage Ruby versions, because its easier to get the right versions and
# to update once a newer release comes out. rbenv must be installed for a single Linux user,
# therefore, first we must create the user Mastodon will be running as:
adduser --disabled-login mastodon
# The following command shall be run using root priviledges (sudo)
su - mastodon
# Proceed to install rbenv and rbenv-build:
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'eval "$(~/.rbenv/bin/rbenv init - bash)"' >> ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.0.3
rbenv global 3.0.3
gem install bundler --no-document
exit
# Creating mastodon user in postgres
sudo -u postgres psql
#+END_SRC
#+BEGIN_SRC sql
CREATE USER mastodon CREATEDB;
#+END_SRC
#+BEGIN_SRC shell
# The following command shall be run using root priviledges (sudo)
su - mastodon
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash -
nvm install v16.17.1
npx browserslist@latest --update-db
git clone https://github.com/tootsuite/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
sed -i 's/\([ ]*"emoji-mart": \)"[^"]*",/\1"^3.0.1",/' package.json
bundle config deployment 'true'
bundle config without 'development test'
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install --pure-lockfile
RAILS_ENV=production bundle exec rake mastodon:setup
exit
#+END_SRC
#+BEGIN_SRC shell
cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon
sed -i 's/example.com/mastodon.adrien.run/' /etc/nginx/sites-available/mastodon
sed -i 's/\([ ]*server 127.0.0.1\):3000/\1:3001/' /etc/nginx/sites-available/mastodon
sed -i 's/\# \(ssl_certificate[ ]*.*\)/\1/' /etc/nginx/sites-available/mastodon
certbot --nginx -d example.com
ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon
cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/
sed -i 's/\(Environment="PORT\)=3000/\1=3001/' /etc/systemd/system/mastodon-web.service
systemctl daemon-reload
#+END_SRC
* Références
* [[https://docs.joinmastodon.org/admin/install/][Installing from source - Mastodon documentation]]

View File

@@ -0,0 +1,71 @@
:PROPERTIES:
:ID: 6af01039-a0a9-46fc-abe8-82f9662bc4b7
:mtime: 20220928120648
:ctime: 20220928113147
:END:
#+title: heap sort algorithm
* Introduction
* Algorithme de classement /in-place/ d'un tableau en le divisant en deux sous-tableaux contenant les éléments classés et non
classés,
* Efficace : *O(nlog(n))* où n correspond au nombre d'éléments à classer,
* Le éléments non classés sont organisés dans une /heap data structure/,
* A chaque étape, l'élément max/min se trouvant à la racine du /heap/ est déplacé dans le sous-tableau des éléments
classés jusqu'à ce qu'il ne reste qu'un élément dans le sous-tableau des éléments non classés,
* Organisation des éléments dans le tableau
#+DOWNLOADED: https://miro.medium.com/max/720/1*KSt2oqlq_mbPK3t1RE-WFQ.png @ 2022-09-28 11:43:09
[[file:Organisation des éléments dans le tableau/1*KSt2oqlq_mbPK3t1RE-WFQ_2022-09-28_11-43-09.png]]
* Implémentation
#+BEGIN_SRC python :results output
from typing import Any, List
def heap_sort(array: List[Any]):
build_max_heap(array)
# start with the ending index all the way to 0
for end_index in range(len(array)-1, 0, -1):
swap(array, 0, end_index)
# reduce heap size by 1
# sift down the value we just swapped
heapify(0, end_index - 1, array)
# return array
def build_max_heap(array: List[Any]):
last_non_leaf_node_index = (len(array) - 2) // 2
for index in range(last_non_leaf_node_index, -1, -1):
heapify(index, len(array)-1, array)
# sift down
def heapify(current_index: int, end_index: int, array: List[Any]):
left_child_index = 2 * current_index + 1
while left_child_index <= end_index:
right_child_index = 2 * current_index + 2 if (2 * current_index + 2 <= end_index) else -1
largest_child_index = left_child_index
if right_child_index != -1 and array[left_child_index] < array[right_child_index]:
largest_child_index = right_child_index
if array[current_index] < array[largest_child_index]:
swap(array, current_index, largest_child_index)
current_index = largest_child_index
left_child_index = 2 * current_index + 1
else:
return
def swap(array: List[Any], i: int, j: int):
array[i], array[j] = array[j], array[i]
array = [1, -15, 22, 40, 9, 91]
print(f"Before sorting: {array}")
heap_sort(array)
print(f"After sorting: {array}")
#+END_SRC
#+RESULTS:
: Before sorting: [1, -15, 22, 40, 9, 91]
: After sorting: [-15, 1, 9, 22, 40, 91]
* Référence
* [[https://yuminlee2.medium.com/heap-sort-algorithm-6e200dc51845][Heap Sort Algorithm. A in-place sorting algorithm that sorts… - Medium]]

View File

@@ -0,0 +1,37 @@
:PROPERTIES:
:ID: 8bb29bf5-219f-49ff-b410-e7cc2473337f
:mtime: 20221002111411
:ctime: 20221001210655
:END:
#+title: framadate
* Introduction
Service pouvant être hébergé sur son propre server et proposant une alternative à /doodle/.
* Installation
#+BEGIN_SRC shell
apt install php-pgsql php php-intl php-mbstring
# The following command shall be run using root priviledges (sudo)
mysql -u root -p
#+END_SRC
#+BEGIN_SRC sql
CREATE DATABASE IF NOT EXISTS `framadate` DEFAULT CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
CREATE USER 'framadate'@'localhost' IDENTIFIED BY 'useastrongpassword';
GRANT ALL PRIVILEGES ON `framadate`.* TO 'framadate'@'localhost';
#+END_SRC
#+BEGIN_SRC shell
adduser --disabled-login framadate
# The following command shall be run using root priviledges (sudo)
su - framadate
wget https://packages.framasoft.org/projects/framadate/framadate-1.1.19.zip -P .
unzip ./framadate-1.1.19.zip
chown -R www-data: /home/framadate/framadate
sudo -u www-data htpasswd -bc /home/framadate/framadate/admin/.htpasswd admin 'admin_password'
#+END_SRC
* Références
* [[https://framagit.org/framasoft/framadate/framadate/-/wikis/home][Framadate · GitLab]]

145
20230520112339-readflow.org Normal file
View File

@@ -0,0 +1,145 @@
:PROPERTIES:
:ID: af021596-3d07-42bf-9131-0c203ac1c26f
:mtime: 20230521180253
:ctime: 20230520112339
:END:
#+title: readflow
* Introduction
Sauvegarde de page web pour lecture offline.
* Installation
** API
*** Build
#+BEGIN_SRC shell
cd /opt/
git clone https://github.com/ncarlier/readflow.git readflow
cd readflow
git submodule init
git submodule update
make
#+END_SRC
*** Configuration
**** Préparation des variables d'environnement
Contenu du fichier ~env~:
#+BEGIN_SRC shell
export READFLOW_DB="postgres://<db_user>:<db_pass>@localhost/readflow"
export READFLOW_LISTEN_ADDR="localhost:8010"
export READFLOW_LISTEN_METRICS=
export READFLOW_AUTHN="https://login.adrien.run/realms/readings"
export READFLOW_PUBLIC_URL="https://readflow.adrien.run"
export READFLOW_SECRET_SALT="<salt>"
export READFLOW_BLOCK_LIST=
export READFLOW_BROKER_URI=
export READFLOW_WEB_SCRAPER_URL=
export READFLOW_IMAGE_PROXY_URL=
export READFLOW_AVATAR_PROVIDER=
export READFLOW_SECRETS_ENGINE_PROVIDER=
export READFLOW_SENTRY_DSN=
export READFLOW_POCKET_CONSUMER_KEY=
export REACT_APP_API_ROOT="/api"
export REACT_APP_AUTHORITY="https://login.adrien.run/realms/readings"
export REACT_APP_CLIENT_ID="readflow"
export REACT_APP_REDIRECT_URL="https://readflow.adrien.run/login"
#+END_SRC
**** Substitution des variables du fichier de configuration
#+BEGIN_SRC shell
source ./env
envsubst < ./readflow.toml > ./config.toml
#+END_SRC
*** Exécution
#+BEGIN_SRC shell
./release/readflow -config ./config.toml
#+END_SRC
Ou
#+BEGIN_SRC shell
cat >/lib/systemd/system/readflow.service <<EOF
[Unit]
Description=Readflow service
[Service]
User=readflow
ExecStart=/opt/readflow/release/readflow -config /opt/readflow/config.toml
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=3
SyslogIdentifier=readflow
[Install]
WantedBy=multi-user.target
EOF
#+END_SRC
#+BEGIN_SRC shell
adduser --system --no-create-home --disabled-password --disabled-login readflow
systemctl enable readflow
systemctl start readflow
#+END_SRC
** Webclient
#+BEGIN_SRC shell
n lts # Require a up to date node version
npm install --legacy-peer-deps
npm run build
#+END_SRC
** Nginx
#+BEGIN_SRC conf
server {
server_name readflow.adrien.run;
listen 443 ssl http2;
listen [::]:443 ssl http2;
# SSL configuration
include /etc/nginx/ssl.conf;
ssl_certificate /etc/letsencrypt/live/readflow.adrien.run/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/readflow.adrien.run/privkey.pem;
# Logging configuration
access_log /var/log/nginx/readflow.access.log;
error_log /var/log/nginx/readflow.error.log;
gzip on;
gzip_static on; # allows pre-serving of .gz file if it exists
gzip_disable "msie6"; # Disable for user-agent Internet explorer 6. Not supported.
gzip_proxied any; # enable gzip for all proxied requests
gzip_buffers 16 8k; # number and size of buffers to compress a response
gzip_http_version 1.1;
gzip_min_length 256; # Only gzip files of size in bytes
gzip_types text/plain text/css text/html application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gunzip on;
add_header 'Access-Control-Allow-Origin' 'https://login.adrien.run';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
location /api {
rewrite /api/(.*) /$1 break;
proxy_redirect off;
proxy_pass http://127.0.0.1:8010;
}
location / {
try_files $uri $uri/ /index.html;
root /opt/readflow/ui/build;
}
}
server {
server_name readflow.adrien.run;
listen 80;
listen [::]:80;
if ($host = readflow.adrien.run) {
return 301 https://$host$request_uri;
}
return 404;
}
#+END_SRC
* Références
* [[https://github.com/ncarlier/readflow][Readflow - Github]]
* [[https://github.com/ncarlier/readflow/issues/48][Can a simple tutorial be provided for non-professionals #48 - Github]]

View File

@@ -0,0 +1,99 @@
:PROPERTIES:
:ID: e0695c59-6fd5-4074-81ca-8e14ec965bbd
:mtime: 20230521180042
:ctime: 20230520122106
:END:
#+title: keycloak
* Introduction
Service open-source de gestion d'authentification et d'accès.
* Installation
** Application
#+BEGIN_SRC shell
apt install openjdk-19-jre
cd /opt/
wget https://github.com/keycloak/keycloak/releases/download/21.1.1/keycloak-21.1.1.zip
unzip keycloak-21.1.1.zip
cd keycloak-21.1.1
# bin/kc.sh start-dev
cat >/opt/keycloak/conf/keycloak.conf <<EOF
db=postgres
db-username=keycloak
db-password=<db_password>
proxy=edge
hostname=login.adrien.run
http-host=127.0.0.1
http-port=9090
hostname-strict-https=false
EOF
bin/kc.sh build
cat >/lib/systemd/system/keycloak.service <<EOF
[Unit]
Description=Keycloak service
[Service]
User=keycloak
ExecStart=/opt/keycloak/bin/kc.sh start
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=3
SyslogIdentifier=keycloak
[Install]
WantedBy=multi-user.target
EOF
adduser --system --no-create-home --disabled-password --disabled-login keycloak
chown keycloak ./data/ -R
systemctl enable keycloak
systemctl start keycloak
#+END_SRC
** Nginx
#+BEGIN_SRC conf
server {
server_name login.adrien.run;
listen 443 ssl http2;
listen [::]:443 ssl http2;
# SSL configuration
include /etc/nginx/ssl.conf;
ssl_certificate /etc/letsencrypt/live/login.adrien.run/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/login.adrien.run/privkey.pem;
# Loggin coinfuguration
access_log /var/log/nginx/login.access.log;
error_log /var/log/nginx/login.error.log;
location / {
proxy_pass http://127.0.0.1:9090;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
server_name login.adrien.run;
listen 80;
listen [::]:80;
if ($host = login.adrien.run) {
return 301 https://$host$request_uri;
}
return 404;
}
#+END_SRC
* Références
* [[https://github.com/keycloak/keycloak][Keycloak - Github]]

View File

@@ -0,0 +1,97 @@
:PROPERTIES:
:ID: e5e49b61-ee56-4364-a96e-48d72217ef95
:mtime: 20240217184904
:ctime: 20240215223404
:END:
#+title: uptime-kuma
* Installation
#+BEGIN_SRC shell
cd /opt
mkdir uptime-kuma
chown ubuntu:ubuntu uptime-kuma/
git clone https://github.com/louislam/uptime-kuma.git
cd uptime-kuma
npm run setup
npm install vite
npm run build
useradd -m --system uptime
cat <<EOF > /usr/lib/systemd/system/update-kuma.service
[Unit]
Description=Uptime-Kuma - A free and open source uptime monitoring solution
Documentation=https://github.com/louislam/uptime-kuma
After=network.target
[Service]
Type=simple
User=uptime
WorkingDirectory=/opt/uptime-kuma
ExecStart=/bin/bash -c 'PATH=/home/uptime/.n/bin:$PATH npm run start-server'
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now uptime-kuma
cat <<EOF > /etc/nginx/sites-available/uptime
server {
server_name tools.adrien.run;
listen 80;
listen [::]:80;
return 404;
}
server {
server_name uptime.tools.adrien.run;
listen 443 ssl http2;
listen [::]:443 ssl http2;
# SSL configuration
include /etc/nginx/ssl.conf;
ssl_certificate /etc/letsencrypt/live/uptime.tools.adrien.run/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/uptime.tools.adrien.run/privkey.pem;
# Logging configuration
access_log /var/log/nginx/uptime.access.log;
error_log /var/log/nginx/uptime.error.log;
root /opt/uptime-kuma;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3002/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
server {
server_name uptime.tools.adrien.run;
listen 80;
listen [::]:80;
if ($host = uptime.tools.adrien.run) {
return 301 https://$host$request_uri;
}
return 404;
}
EOF
systemctl restart nginx.service
certbot -d uptime.tools.adrien.run --nginx
#+END_SRC

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB