Skip to content

Instantly share code, notes, and snippets.

View thibaut-decherit's full-sized avatar

Thibaut Decherit thibaut-decherit

View GitHub Profile
@thibaut-decherit
thibaut-decherit / Symfony - Password rehash on authentication if auto encoder settings changed & legacy password hashes migration.md
Last active August 24, 2023 09:13
Symfony - Password rehash on authentication if auto encoder settings changed & legacy password hashes migration

Disclaimer

Password rehash on login if needed is natively handled by Symfony since 4.4. See https://symfony.com/blog/new-in-symfony-4-4-password-migrations.

The legacy password hashes migration part might still be of use though, but beware of password shucking: If the legacy hash is not salted and is present in data breaches from other platforms, overhashing might have little to no effect.

Password rehash on authentication if auto encoder settings changed

config/packages/security.yaml

security:
@thibaut-decherit
thibaut-decherit / jQuery - Selector supporting future DOM elements (nonexistent on document load).md
Last active August 23, 2023 16:31
jQuery - Selector supporting future DOM elements (nonexistent on document load)

jQuery - Selector supporting future DOM elements (nonexistent on document load)

Also supports DOM elements existent on document load. Potentially heavier on performance than "classic" selector.

Selector

/*
Used instead of $('.my-element').click(function (e) {} to be able to listen to click on elements with my-element class
created by JS insertion into DOM after document load.
@thibaut-decherit
thibaut-decherit / Symfony - LocaleRedirectToClientPreference.md
Last active August 23, 2023 16:32
Symfony - Locale Redirect To Client Preference

Symfony - LocaleRedirectToClientPreference

Redirects to browser preferred locale if this locale is supported by the application.

config/services.yml

App\EventListener\LocaleRedirectToClientPreference:
  arguments:
    $router: '@router'
    $defaultLocale: '%kernel.default_locale%' # framework.default_locale in config/packages/translation.yaml
@thibaut-decherit
thibaut-decherit / index.php
Created March 15, 2019 11:20 — forked from thomasmerlin/index.php
[PHP] - Getting array max depth | Disclaimer & Warning : This function may not handle every case, but works for almost basic ones.
<?php
// Function
/**
* Get the array max depth.
*
* @param array $array
*
* @return int
*/
private function getArrayMaxDepth(array $array): int
@thibaut-decherit
thibaut-decherit / React Native - AsyncStorage custom service.md
Last active August 23, 2023 16:21
React Native - AsyncStorage custom service

React Native - AsyncStorage custom service

app/components/services/storageService/StorageService.js:

import {AsyncStorage} from 'react-native';

export default class StorageService {

    static getAsyncStorageItem(key) {
        return new Promise((resolve, reject) => {