Code snippets

You will find here 265 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 replace UTF8mb4 characters like emojis to HTML entities in a string with PHP. It can be useful, for exam...

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


This snippet shows how to prevent duplicates in bash history. Note that it is automatically done when using Fishshell. ...

bash

Published on 2024-04-27 • Modified on 2024-04-27

 View the code


This snippet shows how to transform an array into a traversable object with PHP. A reminder: iterable is a type hint introduced in...

PHP

Published on 2024-04-21 • Modified on 2024-04-21

 View the code


This snippet shows how to update Castor when is it already installed on a Mac with a "M" processor (arm64). ...

castor

Published on 2024-04-20 • Modified on 2024-04-20

 View the code


This snippet shows how to inject the APP_ENV and APP_DEBUG parameters in your Symfony services (or your controllers) with a bind. ...

Symfony

Published on 2024-04-13 • Modified on 2024-04-13

 View the code