Skip to content

Instantly share code, notes, and snippets.

@vincentchalamon
vincentchalamon / .gitignore
Last active September 11, 2024 15:30
Gitignore global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@vincentchalamon
vincentchalamon / GeocodingFilter.php
Created April 7, 2019 10:13
GeocodingFilter for ApiPlatform 2.3
<?php
/*
* This file is part of the Zero Dechet project.
*
* (c) Vincent Chalamon <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
<?php
declare(strict_types=1);
namespace App\Mercure\EventSubscriber;
use App\Mercure\JwtProvider;
use Fig\Link\Link;
use Psr\Link\LinkProviderInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
liip_monitor:
# enabling the controller requires that `assets` are enabled in the framework bundle
enable_controller: false
checks:
php_extensions:
- amqp
- apcu
- curl
- date
- dom
@vincentchalamon
vincentchalamon / changelog.sh
Created October 18, 2019 07:38
Bash command to check a file has been modified in a branch comparing to another
git diff --name-only origin/$CI_COMMIT_REF_NAME $(git merge-base origin/$CI_COMMIT_REF_NAME origin/develop) | grep CHANGELOG.md > /dev/null 2>&1
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:26
Cypress.io: ignore Symfony debug requests like /_wdt
Cypress.Server.defaults({
whitelist: xhr => {
return (new RegExp(`^${Cypress.config().baseUrl}/_`.replace('/', '\/'))).test(xhr.url)
|| /\.(jsx?|html|css)(\?.*)?$/.test(xhr.url);
}
});
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:26
Replace `fetch` requests to `xhr` in Cypress configuration
before(() => {
Cypress.log({});
cy.request('https://unpkg.com/[email protected]/dist/unfetch.umd.js', {log: false}).as('unfetch').then(unfetch => {
Cypress.on('window:before:load', win => {
delete win.fetch;
win.eval(unfetch);
win.fetch = win.unfetch;
});
});
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:27
Cypress.io: keep session between tests
Cypress.Cookies.defaults({
whitelist: 'PHPSESSID',
});
@vincentchalamon
vincentchalamon / cypress.js
Created December 9, 2019 14:28
Cypress.io: parse iframe content
Cypress.Commands.add('iframe', {
prevSubject: 'element',
}, $iframe => {
const contentWindow = $iframe.prop('contentWindow');
return new Promise(resolve => {
if (contentWindow && contentWindow.document.readyState === 'complete') {
resolve(contentWindow);
} else {
$iframe.on('load', () => {
@vincentchalamon
vincentchalamon / reserved
Last active August 16, 2020 09:41
MySQL reserved words detector
#!/usr/bin/env php
<?php
/**
* Create the bin/reserved file in your project, and copy/paste this as content
* Add execution permissions: chmod +x bin/reserved
*/
set_time_limit(0);