Skip to content

Instantly share code, notes, and snippets.

@rseon
rseon / Database.php
Last active February 1, 2022 13:10
[PHP] Simple database abstraction class (using PDO)
<?php
/**
* Simple MySQL database abstraction class (using PDO).
*
* @method Database::connect(array $config): Database
* @method Database::getInstance(): Database
* @method $Database->setConfig($key, $value): void
* @method $Database->getConfig(): array
* @method $Database->getDBO(): PDO
@rseon
rseon / random_token.php
Last active August 27, 2018 14:52
[PHP] Random token
<?php
/**
* Génère une chaine aléatoire de $ln caractères.
*
* @param int $ln
* @return string
*/
function getToken($ln = 8) {
return bin2hex(openssl_random_pseudo_bytes((int) $ln / 2));
}
@rseon
rseon / create_host.sh
Last active September 3, 2018 13:17
[Bash] Apache hosting creation
#!/bin/bash
#
# No english version, sorry !
#
# Création automatique de nouveau projet Apache2 / MySQL.
# Testé sous Debian Stretch
#
# Remplacer my-hosting par votre hébergement ainsi que l'adresse IP_HOST de votre serveur.
# Attention : vérifiez bien les chemins !
@rseon
rseon / 0_Install.md
Last active November 18, 2020 09:15
[PHP] Apache2/PHP/MySQL hosting creation

Create Apache2/PHP/MySQL hosting

Warning : DON'T USE THIS SCRIPT AS IS

You probably must change Apache user, rights, folders, etc...

  1. Download file
$ curl -O https://gist.githubusercontent.com/rseon/9be0ba438aff20897305dc3da84210d1/raw/23688660cd4dcb4263e0d99bedfc5815f8292ca1/create_hosting
@rseon
rseon / Shadok.php
Last active November 9, 2018 10:25
Convert numbers and strings into Shadok
<?php
/**
* Shadok 1.2
*
* This class converts numbers and strings into Shadok.
* Only for fun.
*
* @changelog
* 1.2 - Support strings
* 1.1 - Add Shadok alphabet
@rseon
rseon / Doctrine.md
Last active March 22, 2019 13:13
Doctrine 2 cheatsheet

Doctrine 2 cheatsheet

Ajouter une fonction MySQL (ex : DATE())

Si vous rencontrez cette erreur : Error: Expected known function, got 'DATE', c'est une fonction MySQL non reconnue par Doctrine.

Fichier /src/AppBundle/DQL/Date.php :

<?php
@rseon
rseon / Prestashop_exports.md
Last active June 4, 2024 14:58
Quelques scripts SQL d'export pour Prestashop

Prestashop exports

URL replacement

ps_configuration.name (PS_SHOP_DOMAIN, PS_SHOP_DOMAIN_SSL, PS_SSL_ENABLED)
ps_shop_url.domain
ps_shop_url.domain_ssl
@rseon
rseon / sort_array_by_key_order.php
Last active April 8, 2019 12:28
Sort an array by keys based on specified order (without changing association)
<?php
// Our initial array
$array_in = [
'L' => 'foo',
'R' => 'bar',
'skibidi' => 'wapwapwap',
3 => 'baz',
'V' => 'qux',
];

Memo installation Laravel 5.8

composer create-project --prefer-dist laravel/laravel projectname
cd projectname
@rseon
rseon / Linux.md
Created May 12, 2019 16:27
Quelques commandes linux

MySQL

Backup d'une base

mysqldump -u USERNAME -p BASENAME --routines > backup_`date "+%Y%m%d%H%M"`.sql
mysqldump -u USERNAME -p BASENAME TABLENAME1 TABLENAME2 > TABLENAME_`date "+%Y%m%d%H%M"`.sql

Vérifier les accents, si ils ont sautés :