This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const IGNORED_SELECTOR = 'input, label, select, textarea, button, fieldset, legend, datalist, output, option, optgroup'; | |
const SCROLLABLE_SELECTOR = '.drag-to-scroll'; | |
/** | |
* Transform mouse drag gesture to scroll. | |
* | |
* @param {{ | |
* [ignoredSelector]: string, // The ignored elements selector | |
* [selector]: string, // The scrollable elements selector | |
* }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace Utils; | |
/** | |
* @param callable $function Function to call | |
* @param int $times Maximum number of times the function is called | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function multiply(...$sets): array | |
{ | |
if (!$sets) { | |
return [[]]; | |
} | |
$set = array_shift($sets); | |
$products = multiply(...$sets); | |
$result = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Splits a terminal vertically | |
# | |
# panes start synchronized, to desynchronize them, type: | |
# ctrl + b then :setw synchronize-panes | |
# | |
# usage: tsplit[ n] | |
# where n is an optional number | |
## | |
function tsplit() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Command; | |
use Doctrine\DBAL\Schema\Visitor\Graphviz; | |
use Doctrine\ORM\EntityManagerInterface; | |
use Symfony\Component\Console\Command\Command; | |
use Symfony\Component\Console\Input\InputInterface; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
function println($text, $foregroundColor = NULL, $backgroundColor = NULL) { | |
$colors = [ | |
'background' => [ | |
'black' => '40', | |
'blue' => '44', | |
'cyan' => '46', | |
'green' => '42', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$root = './src'; | |
$find = 'foo'; | |
$replace = 'bar'; | |
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)); | |
$count = 0; | |
foreach ($iterator as $file) { | |
if ($file->isDir() || 'php' !== $file->getExtension() || '.' === $file->getFilename()[0]) { | |
continue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global window, Image */ | |
/** | |
* Class AppleTouchStartupImage. | |
* | |
* Insert a script in the html head at the 1st position containing: | |
* const startupImage = new AppleTouchStartupImage(); | |
* startupImage.install(); | |
* | |
* @prop {string} image - source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
############################################################################## | |
# This script is meant to be run once a day. | |
# | |
# Backup files name format must be: database-%Y-%m-%dT%H:%M.bz2 | |
# | |
# It deletes backup files that does not match one of these conditions: | |
# - backup every 15 minutes during one week | |
# - backup every day during 3 months |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Converts FormData to object. | |
* | |
* @param {FormData} data | |
* To convert. | |
* @return {string} | |
* FormData converted to object. | |
*/ | |
function formDataToObject(data) { | |
let value; |
NewerOlder