TIL
TIL how to create a npx command : via a script referenced in "bin": {"script-name": "./path-to-script.sh"} in the package.json
TIL that pm2 uses node.js by default, bun support is progressively coming, but clustering mode is not fully compatible. Need to use bunx install -g pm2-beta && pm2 update to make it work.
TIL that in JS a trailing exclamation mark ! can be use to assert the existence of the variable. e.g. list.find(elem => elem.id === 1)! will assert a type of (typeof list)[number] and not (typeof list)[number] | undefined. !!!!
TIL how federation works inside the fediverse: it is a one-way subscription from one service (e.g. a mobilizon instance) to another (e.g. another mobilizon instance or a mastodon instance). The subscribed client is responsible to handle the feed.
#TIL that there is a special type of http request, called beacon that can be use for e.g. send a request upon browser tabl closing
#TIL that htmx is mostly a js library to make requests to an API from html attributes.
TIL that on mac hitting Alt+Space produces non breakable spaces that are recognized as a character, part of a command. Hence the tr : commande introuvable or grep : commande introuvable that happen sometimes.
TIL that with docker-xampp, you can have an easy local development setup for php. localhost:41062/www gives you your site, localhost:41062/phpmyadmin the db web ui…
TIL react-leaflet map object offers a map.getZoom and map.getBounds methods to precisely know the current view. Also, Bounds offer a .contains method to tell if a point is within the bounds !
TIL with mysql (at least) its possible to order elements before aggregating them in a e.g. GROUP_CONCAT aggregate. For example : GROUP_CONCAT((SELECT date order by date) SEPARATOR ', ')
TIL that -n flag in echo command prevents the ending newline
TIL how to join on geography with a tolerance : select * from a join b on st_intersects(st_buffer(a.geog, <tolerance_meters>), b.geog)
TIL that typesense filter_by operators : and := are quite different. : filters using full-text search while := performs exact search.
TIL that you can run TS files with tsx it automatically transpiles ts to js and runs it with node.
TIL about jaccard similarity, a metric for deduplication, that compute the ratio of overlap of two binary vectors. It is computed as the ratio of the intersection over union of terms. It can be combined with tf-idf by using the tf-idf weight for each term.
TIL to set response headers with fastify, ridiculously simple. E.g. to set cache headers for browsers to use their internal cache for one hour, the callback of a simple endpoint would be: (req, res) => { res.header("Cache-control", "public, max-age=3600"); return doSomething(req)} // or res.send(doSomething(req))
TIL that to get the summary of a git diff you can add --stat to get the number of edits per file.
TIL how to extract data with jq, e.g. for extracting the names of the collections from a typesense cluster : curl -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" "http://localhost:8108/collections" | jq '.[] | {name}'
TIL that typesense now requires infix parameter to be explicitely set for each query_by field and cannot be broadcasted/inferred by server.
TIL that it is possible to avoid the gutter layout shift by using the CSS scrollbar-gutter: stable; attribute. Gutter (but not the scrollbar) is then always displayed. Not optimal but sometimes help with intempestive layout shifts…
TIL that @fastify/multipart sets a default limit on the file parts size (total, individual, etc.). One need to override them when registering multipart : e.g. app.register(multipart, {limits: {fileSize: 10_000_000}}) for 10MiB.
TIL about FormData and @fastify/multipart to handle file uploads on the front and back ends. Uploading a file requires to append each part (variable, files, etc.) with formData.append("name", data.name) or formData.append("gpx", data.gpx[0]) for a file (data.<name> for file input is always an array). Sending requires no special headers with fetch("/endpoint", {method: "POST", body: formData}). Consuming the fields and files on the back makes use for request.parts() where each file part has a file attribute set.
TIL that in REST Client Extension in VSCode, it is possible to get the cURL request of a request : Right-click > Copy cURL.
TIL that the CSS :last-child selector only applies if the html entity is actually the last child of its parent, whether the class is present or not. e.g. <div><div class='lastchild'/><div /></div> will not work, <div><div class='lastchild'/></div> will.
TIL that creating a download link is not entirely solved yet. The download attribute makes part of the job, but there are still issues for setting filenames, apache configuration to add headers such as the Content-Disposition: attachement header. Many unreliable tricks to avoid 1. opening the file in a new window. 2. downloading a file without extension and an “Unknown” filename. 3. look unsecure (especially when not same origin).
TIL that it is possible to style a console log in the browser by including %c in console.log argument and the next arg should contain css. Example console.log("%cmy background is red", "background-color: red")
TIL that in apache it is possible to customize cache expiration of a per file type basis with the mod_expires module. Chosing the expiration type is controlled by mime-type : ExpiresByType image/jpeg "access plus 1 year"
TIL that apache is great for static file serving, and enabling it is as simple as adding the an alias Alias /static/ /local/path/ and the directory specification and options <Directory /local/path/>[...]</Directory>
TIL about leaflet-textpath which enables to draw text along a polyline or a geojson.
TIL that react-leaflet doesn’t re-render a component when one of its attribute value is changing.
TIL that rclone enables to sync the content of a folder onto a cloud storage (such as s3 on OVH for example). One can rclone sync local/folder rcloneProfile:bucket to sync the entire folder and descending file tree.
TIL that the UNIX date takes a format such as +%Y-%m-%d and can be offset with the option --date e.g. --date yesterday.
TIL that you can specify crontab’s day of week with abbreviated day names such as mon, tue…
TIL (again) that using a pretty logger in fastify is as simple as specifying a transport object in the logger option when creating the fastify app.
TIL that it’s possible to open multiple sockets to one port, as long as the participating processes open their socket with the SO_REUSEPORT option. This allows to add load-balancing or clustering features transparently.
TIL that using journald as a logging driver makes it possible to have logs both from docker compose logs (or docker logs) and from journalctl.
TIL that in urls the anchor (#anchor or #/path/to/the/hash/route) has to be put after the search params, which seems wierd when using hash-routing.
TIL that syslog is a protocol and a system for log management, that is standard but rarely built-in in linux systems, whereas journald is a less UNIX-y log management system but commonly built-in, for example in ubuntu.
TIL that docker -slim images are not that much heavier than -alpine images (at least for nodejs). In the case of node 18 from 1.08 GB (node:18), it gets down to 192 MB with node:18-slim vs 128 MB for node:18-alpine.
TIL that one must enquote $@ to pass arguments to a subcommand to a script in bash. You can also use shift to pop arguments from $@ before forwarding the rest to other commands.
TIL again that it is possible to set a default value when dereferencing a variable in bash scripts with ${VAR:-default}. Also works with script arguments $1 (new to me).
TIL that running a single command on a remote vm through ssh is as simple as ssh <host> "myCommand"
TIL the difference between CMD and ENTRYPOINT : CMD can be overriden in the cli or in a docker-compose.yml file, and is appended to the ENTRYPOINT.
TIL que ‘Pierre qui roule n’amasse pas mousse’ est à prendre au sens littéral et dans le contexte de la montagne : les pierres moussues ne roulent pas et sont donc plus stables.
#TIL qu’il est possible d’exécuter un script pendant un git rebase avec l’option --exec.
TIL how caching is done in docker, and the two main caching policies. Inline caching means the cache is embedded in the image (which is then heavier). Registry caching means the cache is stored on a separated tag in a registry. Github action registry seems to provide even more powerfull caching, maybe that’s something I’ll learn on another day.
#TIL how GPX traces are structured and how to work with them with JavaScript and Leaflet.
#TIL that it’s possible to prune a monorepo with turbo to lighten a docker image.
#TIL to create github actions a matrix of parameters (with the strategy: matrix config). Also got the difference between ARG and ENV in Dockerfiles and how to set env vars at run time rather than build time.
TIL about multi-stage builds in Dockerfiles. They allow to execute work in temporary stages that do not overload the final image after they’re used. Learnt also about the COPY --from=<stage> command, then.