Code snippets

You will find here 269 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 converting a CSV file into Symfony entities. Instead of setting manually each property, we can use the S...

Symfony

Published on 2024-07-21 • Modified on 2024-07-21

 View the code


This snippet shows how to activate and inspect MySQL or MariaDB logs. For example, This is useful for checking the queries run by ...

MySQL

Published on 2024-07-20 • Modified on 2024-07-20

 View the code


This snippet shows how to import a CSV file with the SplFileObject PHP class. What is excellent about this class is that it will a...

PHP

Published on 2024-07-06 • Modified on 2024-07-06

 View the code


This snippet shows how to execute simple math operations in the terminal using shells like bash or fish. In this example, we calcu...

terminal

Published on 2024-07-02 • Modified on 2024-07-02

 View the code


This snippet shows how to replace UTF8mb4 characters like emojis with HTML entities in a string with PHP. It can be helpful, for e...

PHP

Published on 2024-06-22 • Modified on 2024-06-22

 View the code


This snippet shows how to get the current interactive shell name. We can use this $SHELL variable, which should be available in e...

shell

Published on 2024-06-09 • Modified on 2024-06-09

 View the code


This snippet shows how to get the absolute physical path of the current Makefile. The documentation is available by clicking the "...

Makefile

Published on 2024-06-08 • Modified on 2024-06-08

 View the code


This snippet shows how to memoize a pure function result on an object. The code comes from this snippet, thanks to the author, ca...

PHP

Published on 2024-06-01 • Modified on 2024-06-01

 View the code


This snippet shows how to detect four bytes encoded characters/emojis with PHP. This can be useful to avoid errors while inserting...

PHP

Published on 2024-05-17 • Modified on 2024-05-17

 View the code


This snippet shows how to remove the copy/paste JavaScript events associated with a form's password input field. It is so dull tha...

JavaScript

Published on 2024-05-07 • Modified on 2024-05-07

 View the code