Skip to content

Instantly share code, notes, and snippets.

View SebSept's full-sized avatar
💭
Learning...

Sébastien Monterisi SebSept

💭
Learning...
View GitHub Profile
@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
});
<?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 / 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); }
@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 / 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 / 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 );
<?php
/**
* check sendtoafriend module vulnerability
*
* run it in terminal
*
* @link https://blog.seb7.fr/a/faille-sécurité-prestashop-module-envoyer-a-un-ami
* @author seb7.fr
*/
@SebSept
SebSept / mikey179_vfsStream_example.php
Created December 11, 2015 12:01
Virtual in memory php filesystem | https://github.com/mikey179/vfsStream example.
<?php
/**
* This is just a simple example how to use mikey179/vfsStream - https://github.com/mikey179/vfsStream
*
* Don't be fooled by the documentation.
* This lib is great but the documentation can let you thinks it's complicated or not 'natural' filesystem usage.
* This lib register a php stream so you can (almost) use filesystem function in a regular fashion.
*
* @see http://php.net/manual/en/book.stream.php
* @see http://php.net/manual/en/stream.streamwrapper.example-1.php
@SebSept
SebSept / DbPDO.php
Created October 20, 2015 19:26
Prestashop DbPdo class override | /override/classes/db/DbPDO.php
<?php
/**
* Class DbPDOCore
*
* /override/classes/db/DbPDO.php
* @since 1.5.0.1
*/
class DbPDO extends DbPDOCore
{
@SebSept
SebSept / gitignore.php
Created October 19, 2015 18:54
tiny php script to add files to .gitignore file
#!/bin/env php
<?php
/**
* add files to .gitignore.
* Put this file in your bin dir (/home/<username>/bin/), make it executable (chmod +x /home/<username>/bin/gitingore.php). Done.
**/
// remove script name
array_shift($argv);
// arguments are file name
$files = $argv;