Skip to content

Instantly share code, notes, and snippets.

@SebSept
SebSept / cron.php
Last active March 15, 2020 10:40 — forked from Shagshag/cron.php
<?php
class BackupDatabaseCronModuleFrontController extends ModuleFrontController
{
public function init()
{
try {
$this->checkAccess();
$this->module->cron();
header( "backup ok", true ,200 );
@SebSept
SebSept / custom.php
Last active March 15, 2020 10:39
php functionnal playground
<?php
/**
* playground
*
* functionnal use is at the bottom.
*
* Don't damn me, that's a playground.
*/
class Pipe {
@SebSept
SebSept / html_javascript_playground.html
Last active July 6, 2017 07:17
javascript playground
<html>
<head>
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", (event) => {
console.log('hello')
})
</script>
</head>
<body>
<button>Action !</button>
@SebSept
SebSept / stdLog.php
Last active March 15, 2020 10:38
non verbose way to send output to stderr or stdout
<?php declare(strict_types=1);
/**
* Writes messages to stderr or stdout.
*
* @author Sébastien Monterisi <https://gist.github.com/SebSept/>
* @throws FailureToWriteToFile
*/
function stdErr(string $message): void { stdLog('php://stderr', $message); }
function stdOut(string $message): void { stdLog('php://stdout', $message); }
<?php declare(strict_types=1);
// this may be defined in the enviroment, not in the code.
// or can we find a system path for auto setup persistent cache ?
define('CACHE_FILE_TEMPLATE','/home/seb/.cache/test_php_{file}.txt');
// usage : get some data : get('the key') // return some string content
print 'get("the stuff to fetch") -> "'.get('some stuffx.').'"'.PHP_EOL;
// you can also use the 'tool' functions
@SebSept
SebSept / some.js
Created December 12, 2018 09:26
I never remember this .js
// document.ready without js
document.addEventListener("DOMContentLoaded", function(event) {
//do work
});
@SebSept
SebSept / clear_cache_cron.php
Last active September 21, 2020 19:31
Script pour vider le cache de prestashop 1.7
<?php declare(strict_types=1);
/**
* Script pour vider le cache de prestashop.
*
* Résoud le problème de lenteur lié a l'exces de ressource consommé par le vidage du cache.
* Script a placer à la racine de l'installation de prestashop.
*
* Fonctionnement
* 1 - création d'un dossier vide destiné a être le nouveau dossier de cache.
* 2 - renomage du dossier de cache actuel
@SebSept
SebSept / imu.php
Created May 7, 2020 16:10
immutable, not hackable by the __construct()
<?php
class imu
{
/**
* @var float
*/
private $one;
/**
* @var float
@SebSept
SebSept / install_php_versions.sh
Last active December 1, 2023 22:58
Install various php versions from remi's repo
#!/bin/env bash
# installation des versions de php
PHPS=('php56' 'php72' 'php73' 'php80')
EXTENSIONS=('fpm' 'gd' 'xml' 'zip' 'mysqlnd' 'mysqli' 'yaml' 'soap' 'mbstring' 'intl' 'pecl-zip')
dnf install "https://rpms.remirepo.net/fedora/remi-release-33.rpm" -y
for PHP in "${PHPS[@]}"
do
@SebSept
SebSept / Update.php
Created December 8, 2020 10:39
first implementation (wip) of an ajax admin controller. (for review).
<?php
namespace SebSept\Adminproductquantities\Controller;
use PrestaShopBundle\Api\Stock\Movement;
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
use PrestaShopBundle\Entity\ProductIdentity;
use PrestaShopBundle\Entity\Repository\StockRepository;
use PrestaShopBundle\Service\ProductService;