Code snippets

You will find here 295 code snippets I find useful so I don't have to Google β„’ or Stackoverflow β„’ them when I need. There are also code snippets I always forget! 😁 Sometimes, related links to the code will be available. The main difference with other random snippets you will find on the web is that in most cases (for the Symfony related ones) you will be able to run them directly from this website to check the output so you can verify it works as expected β„’.

This snippet shows how to pause all Docker running containers in a single command. We can use the docker pause command combined wi...

Docker

Published on 2025-01-19 • Modified on 2025-01-19

 View the code


This snippet shows how to purge a legacy PHP version from an Ubuntu server. Now that I have installed PHP 8.4 on my server and all...

server

Published on 2024-12-30 • Modified on 2024-12-30

 View the code


This snippet shows how to get the first commit date of a Git repository. The trick is to use the --reverse flag of the log Git com...

GIT

Published on 2024-12-27 • Modified on 2024-12-27

 View the code


This snippet shows how to get the Symfony minor version of a project. Be careful; this will not work any more as of Symfony 10! ...

Symfony

Published on 2024-12-21 • Modified on 2024-12-21

 View the code


This snippet shows how to generate a random color code with PHP. In the previous snippet, we saw how to generate a random color c...

PHP

Published on 2024-12-15 • Modified on 2024-12-15

 View the code


This snippet shows how to generate a random color code with Symfony. We can use the ByteString::fromRandom() function of the Stri...

Symfony

Published on 2024-12-11 • Modified on 2024-12-11

 View the code


This snippet shows how to fix the Β«pcre2.h file not foundΒ» error when compiling a PHP PECL extension with brew. Replace both 10.44...

PHP

Published on 2024-11-29 • Modified on 2024-11-29

 View the code


This snippet shows how to install a beta version of a PHP PECL extension. For example, when PHP 8.4.1 was released; we had the fol...

PHP

Published on 2024-11-24 • Modified on 2024-11-24

 View the code


This snippet shows how to get the text content of a React node Fragment. It is sometimes helpful to extract the text of the follow...

react

Published on 2024-11-13 • Modified on 2024-11-13

 View the code


This snippet shows how to get an HTML element using a CSS selector with JavaScript. In the previous snippet, we saw how to select ...

JavaScript

Published on 2024-11-10 • Modified on 2024-11-10

 View the code