Navigation Menu

Skip to content

olibre/GreatTips

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Great Tips, Mindsets and Practices for Coders

Empowering tips, mindsets and practices for happy coders about Training, Coding, Git, Unit tests, Agile, GNU/Linux installation, Markdown/Pandoc... Not the best ones because continuously evolving and any one can propose improvements. 😉

Maintained with faireness in mind and shared in Public Domain.

Also available as a slide show (using Reveal.js).

See also

Design / CSS

Web site architecture

  SSR CSR Universal Static JAMStack
Requires hosting yes no yes no yes (API)
CDN 👎 👍 👎 👍 👍
SEO 👍 👎 👍 👍 depends on content from API
Initial load âšĄïžâšĄïž âšĄïž âšĄïžâšĄïž âšĄïžâšĄïžâšĄïž âšĄïžâšĄïž
Reload yes no no no depends on the tool
Fluid UX 👎 👍 👍 👍 👍
Frequent updates 👍 👍 👍 👎 👎/👍*

* To be frequently updated, JAMStack website can use APIs to retrieve content but looses SEO benefits. Approche can be hybrid: only very recent content is delivered by API, while static content is continuously re-built & delivered acroos CDN.

Security

Programming

Features Programming languages
Fast compilation V, D, Go, Delphi
Simplicity & maintainability V, Go, Nim, Python, Julia, Jupyter, Elm, Kotlin, Dart, Elixir
Great perf. and zero cost C interop V, C, C++, D, Delphi, Erlang, Rust
Safety (immutability, no null, option types, free from data races) V, Rust
Easy concurrency V, Go
Easy cross compilation V, Go
Compile time code generation V, D
Small compiler with no dependency V
No global state V
Hot code reloading V

Les résultats du sondage JavaScript https://2019.stateofjs.com/overview/

  • ReprĂ©sentation intĂ©ressante des technos sur les deux axes "connaissance" et "opinion positive/nĂ©gative"
  • TypeScript a le vent en poupe
  • Angular est de moins en moins apprĂ©ciĂ© : Ă©normĂ©ment de rĂ©ponses I've USED it before, and would NOT use it again
  • React (et Vue) sont de plus en plus utilisĂ©s
  • Svelte arrive en force aux cĂŽtĂ©s de React et Vue
  • GraphQL est de plus en plus utilisĂ© et apprĂ©ciĂ© (notamment, avec Apollo comme client)
  • Par contre, plus Redux est utilisĂ©, moins il est apprĂ©ciĂ©

Training

Artificial Intelligeance & Machine Learning

Dev tools

Dotfiles Managers

Backup your customized configuration files (~/.bashrc, ~/.gitconfig...) and share them across the computers you use (home, work...).

yadm - Easy too use

  • https://yadm.io in Python
  • YADM = Yet Another Dotfiles Manager
  • Easy install/updgrade on Ubuntu/Debian apt install yadm and macOS brew install yadm
  • Add OpenSuse RPM repository for Fedora and other RPM-based distros: https://yadm.io/docs/install
  • But missing installation with pip install --user yadm
  • Enter subshell for Git commands: yadm enter (exit to return)
  • Support three template engines depending on file extension: awk, j2cli and envtpl
  • Simple to use:
    • Keep leading dot . (in filename)
    • What is changed in Git repo is applyied (even removal)

chezmoi - Filename prefixes as deployment operations

  • https://chezmoi.io in Go
  • Ubuntu/Debian/Fedora installations can rely on Snappy:
    sudo dnf install snapd                # provide "snap" command line
    sudo ln -s /var/lib/snapd/snap /snap  # prevent error: classic confinement requires snaps under /snap
    sudo snap install chezmoi --classic   # storage: 20 MB
    snap run chezmoi
    
  • Enter subshell for Git commands: chezmoi cd (exit to return)
  • Encode operations to apply during deployment as filename prefixes
  • Replace leading dot . by dot_
  • Require -r option to (recursively) add a configuration folder (silent failure even with -v) twpayne/chezmoi#668
  • Support template based on Go text/template (append *.tmpl)

dotdrop - Easy to hack (manual Git management)

  • https://deadc0de.re/dotdrop/ in Python
  • Disclamer: I do not have installed Dotdrop in the recommanded way, I do not use dotdrop.sh because I do not want to git submodule (I do not want to upgrade all installed software using git submodule update individually, I prefer a script doing pip install --upgrade for all installed user Python packages)
  • Easy install/upgrade anywhere with python3 -m pip install --user --upgrade dotdrop (I think I do not need dotdrop.sh)
  • Use default Dotdrop config.yaml location or provide it in another way: ( cd ~/dd; dotdrop import ~/.bashrc ) or alias dotdrop='dotdrop --cfg=~/dd/config.yaml or export DOTDROP_CONFIG=~/dd/config.yaml
  • Simple tool = Do not handle Git commands (manual repo management)
  • Dotdrop and Git use different command names: import/add, compare/diff...
  • Dotdrop drops dot: Archived filename without leading dot . if keepdot:false (default) in ~/.dd/config.yaml
  • Do not recover simple config.yaml errors: missing profiles: or empty hostname profile deadc0de6/dotdrop#221
  • Easy to hack beacause Git is not managed by dotdrop and because all other operations are clearly described in the config.yaml

Installation of dotdrop to be almost yadm-compatible

YADM repo looking is often a convention: respect of original path/filenames.

Two almost yadm-compatible installations are described here:

  1. Two Git repo (dotdrop repo + dotfiles sub repo)
  2. The dotfiles repo archives itself the ~/.config/dotdrop/config.yaml

Use same filename as YADM setting keepdot:true in ~/.config/dotdrop/config.yaml:

config:
  keepdot: true      # same filename as YADM
  dotpath: dotfiles  # set your dotfiles repo path/name
  backup: true
  banner: false
  create: true
  link_dotfile_default: nolink
  link_on_import: nolink
  longkey: false
dotfiles:
[...]

In order to have a dotfiles repo without dotdrop configuration and subfolder, use two repos:

  • The dotdrop repo
  • The dotfiles repo

Use tree -a -I .git ~/.config/dotdrop/ to have a look on your dotfiles backup:

$ tree -a -I .git ~/.config/dotdrop/
~/.config/dotdrop/
├── config.yaml     # above configuration file
├── .gitmodules     # main repo: ~/.config/dotdrop/
└── dotfiles        # Git submodule similar to YADM repo
    ├── .gitconfig
    ├── .bashrc
    ├── .config
    │   └── htop
    │       └── htoprc
    └── .ssh
        └── config

In the second installation, no need of the main dotdrop repo because the ~/.config/dotdrop/config.yaml is archived within the dotfiles repo. After each dotdrop import, also perform:

dotdrop import ~/.config/dotdrop/config.yaml
cd ~/.config/dotdrop/dotfiles
git add .config/dotdrop/
git commit -m 'Update dotdrop config'

Encrypt sensitive data

Other dotfiles managers

See also: https://dotfiles.github.io/utilities/

Dotfiles manager alternative

vcsh Multiple Git repositories in $HOME https://github.com/RichiH/vcsh

Sandboxing

  • EBox uses Zero Install (0install) to securely install software (from web sites) and runs them in a restricted environment.

Z shell - zsh

Most extra shell extensions are developed for zsh, this is the reason why to use zsh for you daily-used workstation. But, I do not recommend it for production servers where dash (or bash) seems to be more suitable.

To extend Zsh capabilities, you can use either use a zsh plugin manager or manually maintains your plusgins directly within your ~/.zshrc. The plugin manager will help keeping your Zsh plugins uptodate, but can slow down your Zsh startup time.

Plugin managers Activity Motivation
Oh-My-Zsh Active (2009) Historical community-driven project collecting & maintaining hundreds plusgins & thems within one big Git repo for simplicity and having eyes rewieving/checking malware in source code.
Prezto Active (2013) Created in contrast to Oh-My-Zsh, to keep only the plugin manager source code within its Git repo.
Antigen Active (2013) Written in Go to speed up the zsh stratup.
zgen Inactive Fast plugin manager inspired by Antigen (generates a static init script) but written in Zsh to avoid installing Go dependencies when updating the plugin manager. See Nukesor's fork for most recent commits.
zplug Active Support all kind of plugin sources: Git repo, Oh-My-Zsh/Prezto plugins, binary artifacts...
zinit Active Inspired by Zplug (zinit was formely zplugin) but written in C and compiling plugins to bytecode in background (Turbo mode) to be both rich-featured (like Zplug) and having a fast startup.
Antibody Active Like Antigen (in Go), but aiming to be even faster: for example, Antibody loads earlier the zsh and does not require the apply statement.
zr Active Simple plugin manager project written in Rust that generates static init script to speed up zsh startup.

DevOps

Hardware

Health & Work efficiency

Linux

Privacy

Popular self-hostable tools to share passwords:

Quikly converge to valuable API

  1. Design - RĂ©diger une documentation pĂ©dagogique (Markdown) Ă  destination de l’utilisateur final, cela permet de se mettre dans la peau du client, d’itĂ©rer sur ce qu’il lui ferait plaisir, de se baser dessus dans nos Ă©changes, et ainsi de suite jusqu’à obtenir une documentation API mature Ă  publier sur https://docs.example.com
  2. Code - Une fois, que nous sommes synchronisĂ©s et matures dans nos idĂ©es, on code avec des annotations afin de gĂ©nĂ©rer la documentation Ă  partir du code source (OpenAPI, reDoc
). Coder c’est rencontrer des problĂ©matiques techniques auxquelles nous n’avions pas pensĂ©es, et cela nous permet d’accumuler du retour d’expĂ©rience, de gagner encore plus en maturitĂ©, et on implĂ©mente une API diffĂ©rente. La gĂ©nĂ©ration de la documentation est mise Ă  disposition sur https://openapi.exemple.com et https://redoc.exemple.com
  3. Test - On commence Ă  avoir une premiĂšre Ă©bauche de l’API, on commence Ă  mettre Ă  jour la documentation pĂ©dagogique (Markdown), on commence Ă  tester l’API, des premiers utilisateurs nous font des remarques
 encore de nouvelles idĂ©es pour simplifier, pour clarifier
 on re-code
 on re-documente
 on itĂšre

  4. Deliver - Au final, on en a marre de toujours tout chambouler, on finalise dans l’état actuel, on stabilise, on livre ! On garde nos bonnes idĂ©es pour la version suivante :-D

JSON

One JSON per line

The "JSON Lines" formats: https://jsonlines.org/on_the_web/

The mos popular is application/x-ndjson http://ndjson.org/

JSON/JWT versus CBOR/CWT

Une alternative au JWT, est le CWT dont la RFC 8392 (may 2018) explique bien l'intĂ©rĂȘt.

Le CWT utilise CBOR Ă  la place de JSON, CBOR Ă©tant une variante binaire du JSON.

Il existe une dizaine de formats binaires pour JSON (comme BSON, MessagePack...), mais seul CBOR est traitĂ© dans les RFC, donc CBOR semble ĂȘtre mieux standardisĂ©.

See also: RFC 8747 (Proof-of-Possession Key Semantics for CBOR Web Tokens).

JSON dealing with float and 64-bit numbers

Une API qui gÚre des nombres 64 bits et des prix exprimés par des flottants double précision :

  • Pour le CSV, pas de problĂšme.

  • Mais pour le JSON qui va ĂȘtre manipulĂ© par du JavaScript, c'est plus dĂ©licat, voir l'Appendice D de la RFC 8785

En attendant que tous les navigateurs web soient compatibles avec ECMAScript 2021 (BigInt), l'API devrait prendre en charge le format I-JSON :

The API uses a JSON subset format called "Internet JSON" (I-JSON) in order to guaranty a better interoperability with any client software:

However, the API uses the 64-bit signed integer type with the full range [-2⁶³, 2⁶³-1] because modern JavaScript (ECMAScript 2021) supports BigInt type and are no more limited to the [-2⁔³+1, 2⁔³-1] range. All other popular programming languages do not have this number range limitation. See also RFC 8785 Appendix D.

Other

Public Domain Dedication

CC0 1.0 Universal

Creative Commons Zero   No Rights Reserved   (CC) ZERO   (0) PUBLIC DOMAIN

To the extent possible under law, olibre has waived all copyright and related or neighboring rights to GreatPractices. This work is published from France since 2015. Refer to CC0 Legal Code or a copy in file COPYING.