Compare commits
19 Commits
015b896f65
...
master
Author | SHA1 | Date | |
---|---|---|---|
6ea54b1218
|
|||
2fa462c0ee
|
|||
9dfa0e63bb
|
|||
6e78335f5d
|
|||
aa8990e1c7
|
|||
719e4b2780
|
|||
9feeed82e5
|
|||
d410b35b37
|
|||
e8c7b3d1e7
|
|||
1513d0cc9a
|
|||
df0ef69452
|
|||
324da3208b
|
|||
5d223655fc
|
|||
18ea6afb94
|
|||
16705027d6 | |||
2a29096d17 | |||
50825985b7 | |||
ab9ee4660a | |||
4e9442c835 |
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: ca50d517-3e8a-4d03-ba38-7ff411e87408
|
:ID: ca50d517-3e8a-4d03-ba38-7ff411e87408
|
||||||
:mtime: 20220602223012
|
:mtime: 20220928120750
|
||||||
:ctime: 20211230101331
|
:ctime: 20211230101331
|
||||||
:END:
|
:END:
|
||||||
#+title: Software
|
#+title: Software
|
||||||
@@ -18,6 +18,9 @@ Il est nécessaire que le language mis en oeuvre permette l'interception d'erreu
|
|||||||
* Design pattern
|
* Design pattern
|
||||||
TODO
|
TODO
|
||||||
|
|
||||||
|
* Classement/tri de données
|
||||||
|
** [[id:6af01039-a0a9-46fc-abe8-82f9662bc4b7][heap sort algorithm]]
|
||||||
|
|
||||||
* Langages
|
* Langages
|
||||||
** Compilés
|
** Compilés
|
||||||
*** [[id:ed8be72a-8a4d-4ef7-92e4-78d07095deaf][C++]]
|
*** [[id:ed8be72a-8a4d-4ef7-92e4-78d07095deaf][C++]]
|
||||||
@@ -25,17 +28,21 @@ TODO
|
|||||||
** Interprétés
|
** Interprétés
|
||||||
*** [[id:a877b82e-4925-41de-8903-8109dd98e773][Bash]]
|
*** [[id:a877b82e-4925-41de-8903-8109dd98e773][Bash]]
|
||||||
*** [[id:33ef1e68-70ad-43c8-850d-4b8ed2c5ea16][Elisp]]
|
*** [[id:33ef1e68-70ad-43c8-850d-4b8ed2c5ea16][Elisp]]
|
||||||
|
*** [[id:d4197090-4ee5-4fa3-ba2d-a70ce9953923][Javascript]]
|
||||||
*** [[id:4fabfe6a-b104-464f-8a87-dfd7d761dbcc][Python]]
|
*** [[id:4fabfe6a-b104-464f-8a87-dfd7d761dbcc][Python]]
|
||||||
|
|
||||||
* Composition de docs
|
* Composition de docs
|
||||||
** [[id:3250943b-32f0-4bdc-b0d2-5fbcf1724f36][Latex]]
|
** [[id:3250943b-32f0-4bdc-b0d2-5fbcf1724f36][Latex]]
|
||||||
|
|
||||||
* Méthodes
|
* Méthodes/Principes
|
||||||
|
** [[id:b827c6e7-fe86-4301-a72c-dfaee85e142f][SOLID]]
|
||||||
** [[id:6da0b985-e6f4-4454-bb6a-e941b722365b][Test driven development]]
|
** [[id:6da0b985-e6f4-4454-bb6a-e941b722365b][Test driven development]]
|
||||||
|
|
||||||
* Gestionnaire de versions
|
* Gestionnaire de configuration
|
||||||
** [[id:e93719b3-088d-4fe7-9ef8-fc9a4fd84827][Git]]
|
** [[id:e93719b3-088d-4fe7-9ef8-fc9a4fd84827][Git]]
|
||||||
|
|
||||||
* Outils
|
* Outils
|
||||||
|
** Diff
|
||||||
|
*** [[id:67317dba-3771-405f-ae58-0ef13062975d][diffsitter]]
|
||||||
** Performances
|
** Performances
|
||||||
*** [[https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html#gs.26xa9e][Intel® VTune™ Profiler]]
|
*** [[https://www.intel.com/content/www/us/en/developer/tools/oneapi/vtune-profiler.html#gs.26xa9e][Intel® VTune™ Profiler]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 4fabfe6a-b104-464f-8a87-dfd7d761dbcc
|
:ID: 4fabfe6a-b104-464f-8a87-dfd7d761dbcc
|
||||||
:mtime: 20220601215830
|
:mtime: 20221003215204
|
||||||
:ctime: 20211230101535
|
:ctime: 20211230101535
|
||||||
:END:
|
:END:
|
||||||
#+title: Python
|
#+title: Python
|
||||||
@@ -27,11 +27,15 @@ La méthode ~__repr__~ est utilisée pour le debug quand ~__str__~ pour l'utilis
|
|||||||
** Fonctions Built-in
|
** Fonctions Built-in
|
||||||
*** [[id:487f57f5-e9fc-4df7-ae14-b41f9c1fa186][Fonction vars]]
|
*** [[id:487f57f5-e9fc-4df7-ae14-b41f9c1fa186][Fonction vars]]
|
||||||
*** [[id:acda43fa-70be-4939-9128-47114e48e4cb][Fonction zip]]
|
*** [[id:acda43fa-70be-4939-9128-47114e48e4cb][Fonction zip]]
|
||||||
|
** Functools module
|
||||||
|
*** [[id:25d994fd-375b-429d-af38-6afba818159f][functools.singledispatch]]
|
||||||
|
|
||||||
|
|
||||||
* Frameworks
|
* Frameworks
|
||||||
** Web
|
** Web
|
||||||
*** [[id:26b04294-75e8-4043-a9a6-a20acd952963][Flask]]
|
*** [[id:26b04294-75e8-4043-a9a6-a20acd952963][Flask]]
|
||||||
|
|
||||||
|
|
||||||
* UI
|
* UI
|
||||||
** GUI
|
** GUI
|
||||||
*** [[https://kivy.org/#home][Kiwi]]
|
*** [[https://kivy.org/#home][Kiwi]]
|
||||||
@@ -46,6 +50,7 @@ Bindings python pour Qt.
|
|||||||
** Text UI
|
** Text UI
|
||||||
*** [[id:6cc56ee4-6d42-4d50-beb3-bb22a98298dd][textual]]
|
*** [[id:6cc56ee4-6d42-4d50-beb3-bb22a98298dd][textual]]
|
||||||
|
|
||||||
|
|
||||||
* Outils
|
* Outils
|
||||||
** Analyseur statique de code
|
** Analyseur statique de code
|
||||||
*** [[id:1d258869-5421-496a-b296-2d157ebdf3b6][mypy]]
|
*** [[id:1d258869-5421-496a-b296-2d157ebdf3b6][mypy]]
|
||||||
@@ -59,11 +64,14 @@ Outil en ligne de commande permettant d'automatiser les tests dans multiples env
|
|||||||
** Couverture de code
|
** Couverture de code
|
||||||
*** [[https://github.com/plasma-umass/slipcover][Slipcover]]
|
*** [[https://github.com/plasma-umass/slipcover][Slipcover]]
|
||||||
Outil de mesure de couverture de code plus rapide que [[https://github.com/nedbat/coveragepy][coverage.py]].
|
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
|
** Formatter
|
||||||
*** [[https://github.com/hhatto/autopep8][autopep8]]
|
*** [[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
|
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
|
[[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).
|
pouvoir d'~autopep8~ et le laisser modifier le code).
|
||||||
*** [[https://github.com/PyCQA/isort][isort]]
|
*** [[https://github.com/PyCQA/isort][isort]]
|
||||||
Outil classant les imports par ordre alphabétique, les séparant par section et par type.
|
Outil classant les imports par ordre alphabétique, les séparant par section et par type.
|
||||||
*** [[https://black.readthedocs.io/en/stable/][Black]]
|
*** [[https://black.readthedocs.io/en/stable/][Black]]
|
||||||
@@ -79,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.
|
* Créer des fichiers JSON ou XML d'après une structure arbitraire.
|
||||||
*** [[https://github.com/joke2k/faker][Faker]]
|
*** [[https://github.com/joke2k/faker][Faker]]
|
||||||
Génération de données.
|
Génération de données.
|
||||||
|
** Gestion dépendances
|
||||||
|
*** [[id:01f24d29-e833-4bfa-acb0-95140800d081][poetry]]
|
||||||
** Mockup
|
** Mockup
|
||||||
*** [[https://github.com/spulec/freezegun][FreezeGun]]
|
*** [[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.
|
Mockup du module [[https://docs.python.org/fr/3/library/datetime.html][datetime]] permettant de simuler des changements de temps.
|
||||||
@@ -92,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.
|
/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]]
|
*** [[https://jiffyclub.github.io/snakeviz/][SnakeViz]]
|
||||||
Visualisation des rapports de /cProfile/ (web browser).
|
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]]
|
*** [[https://github.com/nvdv/vprof][vprof]]
|
||||||
Profiling de programmes python permettant de surveiller le temps d'exécution et l'usage mémoire.
|
Profiling de programmes python permettant de surveiller le temps d'exécution et l'usage mémoire.
|
||||||
~vprof -c hpm "<cmd>"~
|
~vprof -c hpm "<cmd>"~
|
||||||
@@ -102,10 +114,6 @@ Outil permettant de tester la tenue en charge d'applications (initialement web s
|
|||||||
** Traceur d'exécution de code
|
** Traceur d'exécution de code
|
||||||
*** [[https://github.com/ionelmc/python-hunter][Python-hunter]]
|
*** [[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).
|
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
|
* Implémentations
|
||||||
** CPython
|
** CPython
|
||||||
@@ -120,6 +128,7 @@ Activation du mode développeur ~python -X dev~ ou ~PYTHONDEVMODE=1 python~ (cf.
|
|||||||
Implémentation CPython optimisée par Instagram :
|
Implémentation CPython optimisée par Instagram :
|
||||||
* [[https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/][Jit]]
|
* [[https://engineering.fb.com/2022/05/02/open-source/cinder-jits-instagram/][Jit]]
|
||||||
|
|
||||||
|
|
||||||
* Modules intéressants
|
* Modules intéressants
|
||||||
** Bases de données
|
** Bases de données
|
||||||
*** [[https://spark.apache.org/docs/latest/api/python/][PySpark]]
|
*** [[https://spark.apache.org/docs/latest/api/python/][PySpark]]
|
||||||
@@ -133,6 +142,10 @@ Ensemble d'outils en ligne de commande pour convertir en csv et pour les manipul
|
|||||||
** Graphique
|
** Graphique
|
||||||
*** [[https://github.com/tfardet/mpl_chord_diagram][mpl_chord_diagram]]
|
*** [[https://github.com/tfardet/mpl_chord_diagram][mpl_chord_diagram]]
|
||||||
Génération de [[https://en.wikipedia.org/wiki/Chord_diagram_(information_visualization)][Chord diagrams]] avec /matplotlib/.
|
Génération de [[https://en.wikipedia.org/wiki/Chord_diagram_(information_visualization)][Chord diagrams]] avec /matplotlib/.
|
||||||
|
*** [[https://networkx.org/][networkX]]
|
||||||
|
Représentation de graphs.
|
||||||
|
*** [[https://github.com/pwaller/pyfiglet][pyfiglet]]
|
||||||
|
Représentation de texte sous forme d'ASCII art font.
|
||||||
** Logs
|
** Logs
|
||||||
*** [[https://github.com/itamarst/eliot][eliot]]
|
*** [[https://github.com/itamarst/eliot][eliot]]
|
||||||
Génération de logs sous forme d'arbre.
|
Génération de logs sous forme d'arbre.
|
||||||
@@ -146,10 +159,14 @@ Création de classes en évitant l'écriture du /boilerplate code/ (possibilité
|
|||||||
** Médias
|
** Médias
|
||||||
*** [[https://github.com/ytdl-org/youtube-dl][youtube-dl]]
|
*** [[https://github.com/ytdl-org/youtube-dl][youtube-dl]]
|
||||||
Téléchargement de vidéo depuis youtube, utilisé par mpv.
|
Téléchargement de vidéo depuis youtube, utilisé par mpv.
|
||||||
|
*** [[https://github.com/goldsmith/Wikipedia][wikipedia]]
|
||||||
|
Wrapper permettant l'accès au contenu de wikipedia.
|
||||||
** Sérialization/déserialization
|
** Sérialization/déserialization
|
||||||
*** [[https://github.com/ICRAR/ijson][ijson]]
|
*** [[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
|
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]]).
|
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
|
** Surveillance de fichers
|
||||||
*** [[https://watchfiles.helpmanual.io/][watchfiles]]
|
*** [[https://watchfiles.helpmanual.io/][watchfiles]]
|
||||||
Surveillance de fichiers basé sur la librarie Rust /Notify/.
|
Surveillance de fichiers basé sur la librarie Rust /Notify/.
|
||||||
@@ -159,6 +176,12 @@ Surveillance de fichiers basé sur la librarie Rust /Notify/.
|
|||||||
*** [[https://scrapy.org/][scrapy]]
|
*** [[https://scrapy.org/][scrapy]]
|
||||||
Framework d'extraction de données depuis des site web.
|
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
|
* Performances
|
||||||
** [[id:b9f392bd-bd45-4e9e-94ec-b19caedff86f][List vs tuple]]
|
** [[id:b9f392bd-bd45-4e9e-94ec-b19caedff86f][List vs tuple]]
|
||||||
** [[id:26e1fdfb-1f8e-4c62-a08f-468a56ab03c8][Peephole optimization]]
|
** [[id:26e1fdfb-1f8e-4c62-a08f-468a56ab03c8][Peephole optimization]]
|
||||||
@@ -191,6 +214,13 @@ 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
|
* 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~).
|
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
|
* Tips
|
||||||
** [[id:24408701-21d8-4f4e-aed9-c58746df2244][Différence entre les opérateurs + et +=]]
|
** [[id:24408701-21d8-4f4e-aed9-c58746df2244][Différence entre les opérateurs + et +=]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 171ce2f7-4028-47b0-b4e0-5a4a6ccb74ac
|
:ID: 171ce2f7-4028-47b0-b4e0-5a4a6ccb74ac
|
||||||
:mtime: 20220527114623
|
:mtime: 20230729082927
|
||||||
:ctime: 20220104155310
|
:ctime: 20220104155310
|
||||||
:END:
|
:END:
|
||||||
#+title: Postgres
|
#+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.
|
* 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
|
* 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
|
* Howto
|
||||||
** Pour lister les utilisateurs
|
** Pour lister les utilisateurs
|
||||||
@@ -33,5 +37,60 @@ sudo -u postgres dropdb <database>
|
|||||||
\password <user>
|
\password <user>
|
||||||
#+END_SRC
|
#+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
|
* Références
|
||||||
* [[https://stackoverflow.com/questions/45395538/postgres-md5-password-plain-password][Postgres: MD5 Password / Plain password - Github]]
|
* [[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]]
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 0455921f-3ac0-437e-ba76-1afb3f6f85ea
|
:ID: 0455921f-3ac0-437e-ba76-1afb3f6f85ea
|
||||||
:mtime: 20220104160506
|
:mtime: 20221229101120
|
||||||
:ctime: 20220104155517
|
:ctime: 20220104155517
|
||||||
:END:
|
:END:
|
||||||
#+title: Psql
|
#+title: Psql
|
||||||
#+filetags: :postgre:database:
|
#+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.
|
stockées.
|
||||||
|
|
||||||
* Commandes
|
* Commandes
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: e7581fe3-f83f-4243-91ed-6ef7ade6a844
|
:ID: e7581fe3-f83f-4243-91ed-6ef7ade6a844
|
||||||
:mtime: 20220530204913
|
:mtime: 20220910172209
|
||||||
:ctime: 20220109134723
|
:ctime: 20220109134723
|
||||||
:END:
|
:END:
|
||||||
#+title: Linux
|
#+title: Linux
|
||||||
@@ -10,13 +10,18 @@
|
|||||||
* Distributions
|
* Distributions
|
||||||
** [[id:393342ff-bf38-4472-8713-3de5ebe43eca][Guix]]
|
** [[id:393342ff-bf38-4472-8713-3de5ebe43eca][Guix]]
|
||||||
|
|
||||||
|
* Gestionnaire de paquets
|
||||||
|
** [[id:4cb68913-62c6-43bb-835f-85237b2a8b40][apt]]
|
||||||
|
|
||||||
* Systèmes d'initialisation
|
* Systèmes d'initialisation
|
||||||
** [[id:af912c20-4752-44ba-bdc0-99451ac0cd10][systemd]]
|
** [[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
|
* Fonctionnalités
|
||||||
** [[id:fad57303-ce0c-4ae4-9529-294f70ecfaa5][Inotify]]
|
** Surveillance de fichiers
|
||||||
|
*** [[id:fad57303-ce0c-4ae4-9529-294f70ecfaa5][Inotify]]
|
||||||
|
|
||||||
* Interpreteur de commandes
|
* Interpreteur de commandes
|
||||||
** [[id:72eb2d10-5b92-4fb7-9e4e-1398bd933335][bash]]
|
** [[id:72eb2d10-5b92-4fb7-9e4e-1398bd933335][bash]]
|
||||||
@@ -25,3 +30,5 @@
|
|||||||
** Parsing de contenu json (lib+bin) : [[id:83908b49-3945-4dce-8b26-2a5e4636df13][jq]]
|
** 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]]
|
** 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]]
|
** Template utilisant les variables d'environnement : [[https://manpage.me/?q=envsubst][envsubst]]
|
||||||
|
** Lecture de fichiers
|
||||||
|
*** [[id:d5b19724-9559-44de-aef7-c4d57fb6dc95][batcat]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 5943c76c-8b25-4cbd-b0b9-c819e5a490ba
|
:ID: 5943c76c-8b25-4cbd-b0b9-c819e5a490ba
|
||||||
:mtime: 20220305154620
|
:mtime: 20220927121655
|
||||||
:ctime: 20220130140137
|
:ctime: 20220130140137
|
||||||
:END:
|
:END:
|
||||||
#+title: cyber
|
#+title: cyber
|
||||||
@@ -20,6 +20,10 @@
|
|||||||
** Linux: [[id:262f233d-9ae9-4bd7-a8e9-cba392a2c1f6][AIDE]]
|
** Linux: [[id:262f233d-9ae9-4bd7-a8e9-cba392a2c1f6][AIDE]]
|
||||||
|
|
||||||
* Serveur
|
* Serveur
|
||||||
|
** "Tarpit"
|
||||||
|
*** [[id:1ed652bc-bdcc-4410-a207-fb470df29e71][endlessh]]
|
||||||
|
** Anti-DoS
|
||||||
|
*** [[id:00b1b480-0f0c-42a3-8952-4275bc10bc00][fail2ban]]
|
||||||
** Tips
|
** Tips
|
||||||
*** [[id:9eedbc4b-a961-4057-b2d8-8f10845f0478][Vérification des cyphers suites acceptées par un serveur]]
|
*** [[id:9eedbc4b-a961-4057-b2d8-8f10845f0478][Vérification des cyphers suites acceptées par un serveur]]
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 6cc56ee4-6d42-4d50-beb3-bb22a98298dd
|
:ID: 6cc56ee4-6d42-4d50-beb3-bb22a98298dd
|
||||||
:mtime: 20220528185642
|
:mtime: 20220814131534
|
||||||
:ctime: 20220130153624
|
:ctime: 20220130153624
|
||||||
:END:
|
:END:
|
||||||
#+title: textual
|
#+title: textual
|
||||||
@@ -73,6 +73,11 @@ division(5, 0)
|
|||||||
#+END_SRC
|
#+END_SRC
|
||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
|
|
||||||
|
|
||||||
|
* Projets
|
||||||
|
** [[https://github.com/Traumatism/ToastCord][ToastCord - Github]]
|
||||||
|
** [[https://github.com/kraanzu/dooit][Dooit - Github]]
|
||||||
|
|
||||||
* Références
|
* Références
|
||||||
* [[https://github.com/Textualize/textual][Textual - Github]]
|
* [[https://github.com/Textualize/textual][Textual - Github]]
|
||||||
* [[https://github.com/Textualize/rich][Rich - Github]]
|
* [[https://github.com/Textualize/rich][Rich - Github]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: e93719b3-088d-4fe7-9ef8-fc9a4fd84827
|
:ID: e93719b3-088d-4fe7-9ef8-fc9a4fd84827
|
||||||
:mtime: 20220524205131
|
:mtime: 20221229111938
|
||||||
:ctime: 20220501191904
|
:ctime: 20220501191904
|
||||||
:END:
|
:END:
|
||||||
#+title: Git
|
#+title: Git
|
||||||
@@ -34,15 +34,15 @@ Pour positionner ~HEAD~ :
|
|||||||
* Au commit grand-père : ~git checkout HEAD^^~ ou ~git checkout HEAD~2~
|
* 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/.
|
~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 forcer le déplacement d'une branche : ~git branch -f <nom_branche> <commit>~.
|
||||||
|
|
||||||
Pour retourner en arrière :
|
Pour retourner en arrière :
|
||||||
* Branche locale : ~git reset <commit>~ (position où nous souhaitons être).
|
* Branche locale : ~git reset <commit>~ (position où nous souhaitons être).
|
||||||
* Différentes options :
|
* 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/,
|
* ~--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>~ :
|
* Branche distante (/remote/) : ~git revert <commit_ref>~ :
|
||||||
* Création d'un nouveau /commit/ qui inversera les modifications apportées par le ~<commit_ref>~,
|
* Création d'un nouveau /commit/ qui inversera les modifications apportées par le ~<commit_ref>~,
|
||||||
* Conservation de l'historique,
|
* 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),
|
* Met à jour nos branches distantes (par exemple, origin/main),
|
||||||
* Ne met par à jour nos branches locales (par exemple, 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~
|
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~,
|
pull~,
|
||||||
* La branche existe déjà : ~git branch -u <branche_distante> <branche_locale>~
|
* 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
|
* 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]]
|
*** [[https://github.com/dandavison/delta][Delta]]
|
||||||
Affichage de ~git diff~.
|
Affichage de ~git diff~.
|
||||||
*** [[https://github.com/darrenburns/dunk][Dunk]]
|
*** [[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.
|
Site permettant l'apprentissage de l'usage de Git.
|
||||||
|
|
||||||
* Références
|
* 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]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 47707ab9-7792-4592-b25b-8dd2f2e45b05
|
:ID: 47707ab9-7792-4592-b25b-8dd2f2e45b05
|
||||||
:mtime: 20220604101605
|
:mtime: 20221229104128
|
||||||
:ctime: 20220526082057
|
:ctime: 20220526082057
|
||||||
:END:
|
:END:
|
||||||
#+title: Self-hosted server
|
#+title: Self-hosted server
|
||||||
@@ -29,3 +29,9 @@ certbot certonly --nginx --force-renew -d imap.adrien.run
|
|||||||
* Vidéo
|
* Vidéo
|
||||||
** Plateforme de streaming
|
** Plateforme de streaming
|
||||||
*** [[https://github.com/Chocobozzz/PeerTube][PeerTube]]
|
*** [[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]]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 67410dad-d959-4029-b281-9bf1c9e69ede
|
:ID: 67410dad-d959-4029-b281-9bf1c9e69ede
|
||||||
:mtime: 20220529131239
|
:mtime: 20220729213822
|
||||||
:ctime: 20220529123824
|
:ctime: 20220529123824
|
||||||
:END:
|
:END:
|
||||||
#+title: Generator
|
#+title: Generator
|
||||||
@@ -94,5 +94,45 @@ print(f'{sum(square(fibonacci_numbers(30))) = }')
|
|||||||
#+RESULTS:
|
#+RESULTS:
|
||||||
: sum(square(fibonacci_numbers(30))) = 1120149658760
|
: sum(square(fibonacci_numbers(30))) = 1120149658760
|
||||||
|
|
||||||
|
* Renvoyer une valeur à un /generator/
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
def dummy_generator():
|
||||||
|
i = 0
|
||||||
|
for i in range(10):
|
||||||
|
print(f'from generator {yield i}')
|
||||||
|
|
||||||
|
generator = dummy_generator()
|
||||||
|
received = generator.send(None)
|
||||||
|
print(f'from here {received}')
|
||||||
|
try:
|
||||||
|
while True:
|
||||||
|
received = generator.send(received + 100)
|
||||||
|
print(f'from here {received}')
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: from here 0
|
||||||
|
: from generator 100
|
||||||
|
: from here 1
|
||||||
|
: from generator 101
|
||||||
|
: from here 2
|
||||||
|
: from generator 102
|
||||||
|
: from here 3
|
||||||
|
: from generator 103
|
||||||
|
: from here 4
|
||||||
|
: from generator 104
|
||||||
|
: from here 5
|
||||||
|
: from generator 105
|
||||||
|
: from here 6
|
||||||
|
: from generator 106
|
||||||
|
: from here 7
|
||||||
|
: from generator 107
|
||||||
|
: from here 8
|
||||||
|
: from generator 108
|
||||||
|
: from here 9
|
||||||
|
: from generator 109
|
||||||
|
|
||||||
* Références
|
* Références
|
||||||
* [[https://blog.devgenius.io/what-is-generator-in-python-and-how-does-it-work-e6e0588785c3][What Is Generator in Python and How Does It Work ? - Medium]]
|
* [[https://blog.devgenius.io/what-is-generator-in-python-and-how-does-it-work-e6e0588785c3][What Is Generator in Python and How Does It Work ? - Medium]]
|
||||||
|
26
20220604134309-vale.org
Normal file
26
20220604134309-vale.org
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: d2f9cefd-3e01-440a-a71b-b201edb3c619
|
||||||
|
:mtime: 20220605213208
|
||||||
|
:ctime: 20220604134309
|
||||||
|
:END:
|
||||||
|
#+title: Vale
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
/Vale/ est un outil de vérification de texte 100% offline.
|
||||||
|
|
||||||
|
* Installation (ubuntu)
|
||||||
|
#+BEGIN_SRC shell :results output
|
||||||
|
CONFIG_ROOT=${HOME}
|
||||||
|
|
||||||
|
snap install vale --edge
|
||||||
|
|
||||||
|
# Téléchargement de la configuration
|
||||||
|
cd "${CONFIG_ROOT}"
|
||||||
|
git clone http://git.adrien.run/Adrien/vale-config.git
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Intégration avec Emacs
|
||||||
|
Patch de /flycheck-vale/ afin de gérer le chemin vers le fichier de configuration de /vale/ : [[https://git.adrien.run/Adrien/flycheck-vale][flycheck-vale]]
|
||||||
|
|
||||||
|
* Références
|
||||||
|
* [[https://vale.sh/][Vale.sh]]
|
14
20220606212652-anki.org
Normal file
14
20220606212652-anki.org
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: 247b0751-90e4-4832-aa15-68a182d93476
|
||||||
|
:mtime: 20220606213432
|
||||||
|
:ctime: 20220606212652
|
||||||
|
:END:
|
||||||
|
#+title: Anki
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
|
||||||
|
* Références
|
||||||
|
** Emacs
|
||||||
|
* [[https://github.com/louietan/anki-editor][Anki-editor - Github]]
|
||||||
|
* [[https://rgoswami.me/posts/anki-decks-orgmode/][Anki Decks with Orgmode - Rohit Goswami]]
|
||||||
|
* [[https://yiufung.net/post/anki-org/][Power up Anki with Emacs, Org mode, anki-editor and more - Cheong Yiufung]]
|
72
20220607074003-functools_singledispatch.org
Normal file
72
20220607074003-functools_singledispatch.org
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: 25d994fd-375b-429d-af38-6afba818159f
|
||||||
|
:mtime: 20220607075600
|
||||||
|
:ctime: 20220607074003
|
||||||
|
:END:
|
||||||
|
#+title: functools.singledispatch
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
Le module /functools/ permet la définition de /single dispatch methods/ :
|
||||||
|
* Une sorte de méthode générique pour laquelle différentes implémentations sont écrites,
|
||||||
|
* L'implémentation à exécuter est déterminée d'après le type du premier argument non /self/ ou non /cls/,
|
||||||
|
* Peut être imbriqué (/nested/) avec d'autres décorateurs mais /singledispatchmethod/ doit être le plus englobant (cf. howto),
|
||||||
|
* Depuis Python3.8 (3.9 pour les imbrications, cf. PCR 83860 en référence).
|
||||||
|
|
||||||
|
* Howto
|
||||||
|
** Usage de base
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
from functools import singledispatchmethod
|
||||||
|
|
||||||
|
class Negator:
|
||||||
|
|
||||||
|
@singledispatchmethod
|
||||||
|
def neg(self, arg):
|
||||||
|
raise NotImplementedError("Cannot negate a")
|
||||||
|
|
||||||
|
@neg.register
|
||||||
|
def _(self, arg: int):
|
||||||
|
return -arg
|
||||||
|
|
||||||
|
@neg.register
|
||||||
|
def _(self, arg: bool):
|
||||||
|
return not arg
|
||||||
|
|
||||||
|
negator = Negator()
|
||||||
|
print(f'{negator.neg(5) = }')
|
||||||
|
print(f'{negator.neg(False) = }')
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: negator.neg(5) = -5
|
||||||
|
: negator.neg(False) = True
|
||||||
|
** Imbrication (/nested/) avec d'autres /decorator/
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
from functools import singledispatchmethod
|
||||||
|
|
||||||
|
class Negator:
|
||||||
|
|
||||||
|
@singledispatchmethod
|
||||||
|
@classmethod
|
||||||
|
def neg(cls, arg):
|
||||||
|
raise NotImplementedError("Cannot negate a")
|
||||||
|
|
||||||
|
@neg.register
|
||||||
|
@classmethod
|
||||||
|
def _(cls, arg: int):
|
||||||
|
return -arg
|
||||||
|
|
||||||
|
@neg.register
|
||||||
|
@classmethod
|
||||||
|
def _(cls, arg: bool):
|
||||||
|
return not arg
|
||||||
|
|
||||||
|
print(f'{Negator.neg(5) = }')
|
||||||
|
print(f'{Negator.neg(False) = }')
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
|
||||||
|
* Références
|
||||||
|
* [[https://medium.com/@sunilrana123/python-trick-functools-singledispatch-4cdf71843cd2][Python Trick : functools.singledispatch - Medium]]
|
||||||
|
* [[https://docs.python.org/3/library/functools.html#functools.singledispatchmethod][functools.singledispatch - Python]]
|
||||||
|
* [[https://github.com/python/cpython/issues/83860][functools: singledispatchmethod doesn't work with classmethod #83860 - CPython Github]]
|
23
20220820195639-poetry.org
Normal file
23
20220820195639-poetry.org
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: 01f24d29-e833-4bfa-acb0-95140800d081
|
||||||
|
:mtime: 20220820200208
|
||||||
|
:ctime: 20220820195639
|
||||||
|
:END:
|
||||||
|
#+title: poetry
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
* Utilitaire de gestion de projets Python (équivalent à ~yarn~).
|
||||||
|
* Encapsule différents services:
|
||||||
|
* ~venv~
|
||||||
|
|
||||||
|
* Configuration
|
||||||
|
** Création des environnements virtuels dans le répertoire du projet
|
||||||
|
#+BEGIN_SRC shell
|
||||||
|
poetry config virtualenvs.in-project true
|
||||||
|
#+END_SRC
|
||||||
|
** Supprimer un cache
|
||||||
|
#+BEGIN_SRC shell
|
||||||
|
# Pour afficher la liste des environnements existants
|
||||||
|
poetry env list
|
||||||
|
poetry env remove <env_name>
|
||||||
|
#+END_SRC
|
12
20220825074527-javascript.org
Normal file
12
20220825074527-javascript.org
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: d4197090-4ee5-4fa3-ba2d-a70ce9953923
|
||||||
|
:mtime: 20220825074959
|
||||||
|
:ctime: 20220825074527
|
||||||
|
:END:
|
||||||
|
#+title: Javascript
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
Language interprété très largement utilisé pour les clients web. Il est aussi utilisé pour des applications backend ou
|
||||||
|
standalone via /v8/ ou [[https://deno.land/][Deno]].
|
||||||
|
|
||||||
|
* Références
|
14
20220825080435-diffsitter.org
Normal file
14
20220825080435-diffsitter.org
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: 67317dba-3771-405f-ae58-0ef13062975d
|
||||||
|
:mtime: 20220825080750
|
||||||
|
:ctime: 20220825080435
|
||||||
|
:END:
|
||||||
|
#+title: diffsitter
|
||||||
|
#+filetags: :TO_TRY:
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
Outil de diff basé sur l'analyse d'arbres AST plutôt que de chaines de caractères pour identifier les différences entre
|
||||||
|
deux fichiers contenant du code.
|
||||||
|
|
||||||
|
* Références
|
||||||
|
* [[https://github.com/afnanenayet/diffsitter][GitHub - afnanenayet/diffsitter: A tree-sitter based AST difftool to get meaningful semantic diffs]]
|
13
20220825081058-batcat.org
Normal file
13
20220825081058-batcat.org
Normal 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.]]
|
31
20220830224237-fail2ban.org
Normal file
31
20220830224237-fail2ban.org
Normal 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]]
|
328
20220908193040-solid.org
Normal file
328
20220908193040-solid.org
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
:PROPERTIES:
|
||||||
|
:ID: b827c6e7-fe86-4301-a72c-dfaee85e142f
|
||||||
|
:mtime: 20220910133550
|
||||||
|
:ctime: 20220908193040
|
||||||
|
:END:
|
||||||
|
#+title: SOLID
|
||||||
|
|
||||||
|
* Introduction
|
||||||
|
* Cinq principes de design de classes (P.O.O),
|
||||||
|
* Principes décrits par Robert J. Martin (a.k.a Uncle Bob) en 2000,
|
||||||
|
* Acronyme créé par Michael Feathers.
|
||||||
|
|
||||||
|
* Principes
|
||||||
|
** Responsabilité unique (Single responsability principle)
|
||||||
|
/A class should have one and only one reason to change, meaning that a class should have only one job./
|
||||||
|
|
||||||
|
Exemple de classe réalisant différentes tâches:
|
||||||
|
* Calcul du total de la facture (méthode ~calculate_total~),
|
||||||
|
* Impression de la facture (méthode ~print_invoice~),
|
||||||
|
* Sauvegarde de la facture (méthode ~save_to_file~).
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
class Invoice:
|
||||||
|
|
||||||
|
def __init__(self, book, quantity, discount_rate, tax_rate, total):
|
||||||
|
self.book = book
|
||||||
|
self.quantity = quantity
|
||||||
|
self.discount_rate = discount_rate
|
||||||
|
self.tax_rate = tax_rate
|
||||||
|
self.total = self.calculate_total()
|
||||||
|
|
||||||
|
def calculate_total(self):
|
||||||
|
price = (self.book.price - self.book.price * self.discount_rate) * self.quantity
|
||||||
|
price_with_taxe = price * (1 + self.tax_rate)
|
||||||
|
return price_with_taxe
|
||||||
|
|
||||||
|
def print_invoice(self):
|
||||||
|
print(f'{self.quantity}x {self.name} {self.price} $')
|
||||||
|
print(f'Discount Rate: {self.discount_rate}')
|
||||||
|
print(f'Tax Rate: {self.tax_rate}')
|
||||||
|
print(f'Total: {self.total}')
|
||||||
|
|
||||||
|
def save_to_file(self):
|
||||||
|
# Creates a file with given name and writes the invoice
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Les erreurs :
|
||||||
|
* La logique d'impression d'une facture (méthode ~print_invoice~) devrait étre isolée : la seule raison pour laquelle
|
||||||
|
la classe ~Invoice~ devrait étre mise à jour est le changement de logique de calul du total (méthode
|
||||||
|
~calculate_total~).
|
||||||
|
* La logique de sauvegarde d'une facture (méthode ~save_to_file~) devrait elle aussi étre isolée : la classe ~Invoice~
|
||||||
|
ne devrait pas étre mise à jour suite au changement de méthode de sauvegarde (passage d'un fichier à une BDD par ex).
|
||||||
|
|
||||||
|
Une implémetation respectant le principe de *responsabilité unique* :
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
class Invoice:
|
||||||
|
|
||||||
|
def __init__(self, book, quantity, discount_rate, tax_rate, total):
|
||||||
|
self.book = book
|
||||||
|
self.quantity = quantity
|
||||||
|
self.discount_rate = discount_rate
|
||||||
|
self.tax_rate = tax_rate
|
||||||
|
self.total = self.calculate_total()
|
||||||
|
|
||||||
|
def calculate_total(self):
|
||||||
|
price = (self.book.price - self.book.price * self.discount_rate) * self.quantity
|
||||||
|
price_with_taxe = price * (1 + self.tax_rate)
|
||||||
|
return price_with_taxe
|
||||||
|
|
||||||
|
|
||||||
|
class InvoicePrinter:
|
||||||
|
|
||||||
|
def __init__(self, invoice):
|
||||||
|
self._invoice = invoice
|
||||||
|
|
||||||
|
def print(self):
|
||||||
|
print(f'{self._invoice.quantity}x {self._invoice.name} {self._invoice.price} $')
|
||||||
|
print(f'Discount Rate: {self._invoice.discount_rate}')
|
||||||
|
print(f'Tax Rate: {self._invoice.tax_rate}')
|
||||||
|
print(f'Total: {self._invoice.total}')
|
||||||
|
|
||||||
|
|
||||||
|
class InvoicePersistance:
|
||||||
|
|
||||||
|
def __init__(self, invoice):
|
||||||
|
self._invoice = invoice
|
||||||
|
|
||||||
|
def save_to_file(self):
|
||||||
|
# Creates a file with given name and writes the invoice
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Ouvert-fermé (Open-close principle)
|
||||||
|
/Objects or entities should be open for extension but closed for modification./
|
||||||
|
|
||||||
|
Une classe doit étre *ouverte pour l'extension* et *fermée pour les modifications* :
|
||||||
|
* Il doit étre possible d'ajouter une fonctionnalité à une classe sans modifier le code existant,
|
||||||
|
* Réalisé à l'aide d'interfaces et classes virtuelles,
|
||||||
|
|
||||||
|
Exemple de classe ne respesctant pas le principe :
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
class InvoicePersistance:
|
||||||
|
|
||||||
|
def __init__(self, invoice):
|
||||||
|
self._invoice = invoice
|
||||||
|
|
||||||
|
def save_to_file(self):
|
||||||
|
# Creates a file with given name and writes the invoice
|
||||||
|
...
|
||||||
|
|
||||||
|
def save_to_database(self):
|
||||||
|
# Save the invoice to database
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Il ne devrait pas étre nécessaire de modifier la classe ~InvoicePersistance~ lorsqu'une nouvelle manière de sauvegarder
|
||||||
|
une ~Invoice~ est requise.
|
||||||
|
|
||||||
|
Une implémetation respectant le principe *ouvert/fermé* :
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
from abc import abstractmethod
|
||||||
|
|
||||||
|
class InvoicePersistance():
|
||||||
|
|
||||||
|
def __init__(self, invoice):
|
||||||
|
self._invoice = invoice
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def save(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class FileInvoicePersistance(InvoicePersistance):
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
# Creates a file with given name and writes the invoice
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class DatabaseInvoicePersistance(InvoicePersistance):
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
# Save the invoice to database
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Principe de substitution de Liskov
|
||||||
|
/Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T./
|
||||||
|
|
||||||
|
Les classes filles doivent pouvoir être substituées par leur classe mère :
|
||||||
|
* Pour une classe B, fille de A, il doit être possible de passer une instance de B à toute méthode s'attendant à avoir une instance de A, sans disfonctionnement.
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
class Rectangle:
|
||||||
|
|
||||||
|
def __init__(self, width, height):
|
||||||
|
self._width = width
|
||||||
|
self._height = height
|
||||||
|
|
||||||
|
@property
|
||||||
|
def width(self):
|
||||||
|
return self._width
|
||||||
|
|
||||||
|
@width.setter
|
||||||
|
def width(self, width):
|
||||||
|
self._width = width
|
||||||
|
|
||||||
|
@property
|
||||||
|
def height(self):
|
||||||
|
return self._height
|
||||||
|
|
||||||
|
@height.setter
|
||||||
|
def height(self, height):
|
||||||
|
self._height = height
|
||||||
|
|
||||||
|
def get_area(self):
|
||||||
|
return self._width * self._height
|
||||||
|
|
||||||
|
|
||||||
|
class Square(Rectangle):
|
||||||
|
|
||||||
|
def __init__(self, size):
|
||||||
|
super().__init__(size, size)
|
||||||
|
|
||||||
|
@Rectangle.width.setter
|
||||||
|
def width(self, size):
|
||||||
|
self._width = size
|
||||||
|
self._height = size
|
||||||
|
|
||||||
|
@Rectangle.height.setter
|
||||||
|
def height(self, size):
|
||||||
|
self._width = size
|
||||||
|
self._height = size
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_area(rectangle):
|
||||||
|
width = rectangle.width
|
||||||
|
rectangle.height = 10
|
||||||
|
print(f'Expected area of {10 * width}, got {rectangle.get_area()}')
|
||||||
|
|
||||||
|
rectangle = Rectangle(2, 3)
|
||||||
|
test_get_area(rectangle)
|
||||||
|
|
||||||
|
square = Square(2)
|
||||||
|
square.width = 5
|
||||||
|
test_get_area(square)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
: Expected area of 20, got 20
|
||||||
|
: Expected area of 50, got 100
|
||||||
|
|
||||||
|
La classe ~Square~ ne respecte pas le principe car le comportement de la méthode ~get_area~ diffère selon l'instance de
|
||||||
|
classe passée en paramètre.
|
||||||
|
|
||||||
|
** Principe de ségrégation d'interface (Interface segregation principle)
|
||||||
|
/A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use./
|
||||||
|
|
||||||
|
Il s'agit d'un principe de séparation des interfaces : plusieurs interfaces spécifiques sont meilleures qu'une unique
|
||||||
|
générale. Ainsi, seules les méthodes nécessaires sont implémentées et non l'intégralité de celles définies par
|
||||||
|
l'interface générique.
|
||||||
|
|
||||||
|
Exemple d'implémentation ne respectant pas le principe : l'interface ~ParkingLot~ englobe le stationnement
|
||||||
|
ainsi que le paiement. Quid de son implémentation pour le cas d'un parking gratuit ?
|
||||||
|
L'ideal serait d'isoler la partie paiement dans une interface dédiée.
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
from abc import abstractmethod
|
||||||
|
|
||||||
|
class Car:
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class ParkingLot:
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def park_car(self):
|
||||||
|
# Decrease empty spot count by 1
|
||||||
|
...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def unpark_car(self):
|
||||||
|
# Increase empty spot count by 1
|
||||||
|
...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def get_capacity(self):
|
||||||
|
# Return car capacity
|
||||||
|
...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def calculate_fee(self, car):
|
||||||
|
# Return the price based on the number of hours
|
||||||
|
...
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def do_payment(self, car):
|
||||||
|
# Do the payment process for the computed fee
|
||||||
|
...
|
||||||
|
|
||||||
|
class FreeParking(ParkingLot):
|
||||||
|
|
||||||
|
def park_car(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
def unpark_car(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
def get_capacity(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
def calculate_fee(self, car):
|
||||||
|
# Unused method here... the parking is free.
|
||||||
|
...
|
||||||
|
|
||||||
|
def do_payment(self, car):
|
||||||
|
# Unused method here... the parking is free.
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Principe d'inversion de dépendence (Dependency inversion principle)
|
||||||
|
/Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the
|
||||||
|
low-level module, but they should depend on abstractions./
|
||||||
|
|
||||||
|
Les classes devraient être baséees sur des interfaces ou des classes abstraites plutôt que des classes concrètes,
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results output
|
||||||
|
class SqlConnection:
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
class PasswordReminder:
|
||||||
|
|
||||||
|
def __init__(self, connection: SqlConnection) -> None:
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
La classe ~PasswordReminder~ ne doit pas avoir de couplage fort avec la méthode employée pour obtenir le mot de
|
||||||
|
passe. L'usage d'une interface permettrait d'abstraire la méthode de collecte.
|
||||||
|
|
||||||
|
#+BEGIN_SRC python :results outputs
|
||||||
|
from abc import abstractmethod
|
||||||
|
|
||||||
|
class Connection:
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def connect(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
class SqlConnection(Connection):
|
||||||
|
|
||||||
|
def connect(self):
|
||||||
|
...
|
||||||
|
|
||||||
|
class PasswordReminder:
|
||||||
|
|
||||||
|
def __init__(self, connection: Connection) -> None:
|
||||||
|
...
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
* Références
|
||||||
|
* [[https://fi.ort.edu.uy/innovaportal/file/2032/1/design_principles.pdf][Uncle bob design principes]]
|
||||||
|
* [[https://www.freecodecamp.org/news/solid-principles-explained-in-plain-english/][SOLID principes explained in plain english - freecodecamp.org]]
|
30
20220926120504-get_things_done.org
Normal file
30
20220926120504-get_things_done.org
Normal 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]]
|
39
20220927093748-endlessh.org
Normal file
39
20220927093748-endlessh.org
Normal 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]]
|
||||||
|
|
||||||
|
|
86
20220927123818-mastodon.org
Normal file
86
20220927123818-mastodon.org
Normal 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 it’s 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]]
|
71
20220928113147-heap_sort_algorithm.org
Normal file
71
20220928113147-heap_sort_algorithm.org
Normal 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]]
|
||||||
|
|
37
20221001210655-framadate.org
Normal file
37
20221001210655-framadate.org
Normal 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
145
20230520112339-readflow.org
Normal 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]]
|
99
20230520122106-keycloak.org
Normal file
99
20230520122106-keycloak.org
Normal 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]]
|
||||||
|
|
97
20240215223404-uptime_kuma.org
Normal file
97
20240215223404-uptime_kuma.org
Normal 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 |
Reference in New Issue
Block a user