Skip to content

Instantly share code, notes, and snippets.

View pounard's full-sized avatar
💭
What's happening?

Pierre pounard

💭
What's happening?
View GitHub Profile
@pounard
pounard / dump_opcodes.sh
Last active March 13, 2018 08:33
Dumps a PHP file's generated OPCodes
phpdbg -np* file.php
@pounard
pounard / panic.php
Last active January 6, 2022 09:32
Drupal panic script (complete)
#!/usr/bin/php
<?php
function panic_bootstrap_database($site_host = null, $incomming_host = null) {
$_SERVER['REMOTE_ADDR'] = $incomming_host ? $incomming_host : '127.0.0.1';
$_SERVER['HTTP_HOST'] = $site_host ? $site_host : '127.0.0.1';
$_SERVER['SCRIPT_NAME'] = '/index.php';
define('DRUPAL_ROOT', __DIR__ . '/../html');
@pounard
pounard / xdebug.ini
Created September 21, 2017 16:10
My XDebug configuration
xdebug.remote_enable=on
xdebug.remote_host=192.168.57.1
xdebug.remote_port=9000
xdebug.profiler_enable_trigger=1
xdebug.show_mem_delta=1
xdebug.trace_enable_trigger=1
xdebug.trace_format=1
xdebug.collect_return=0
xdebug.collect_params=0
xdebug.collect_assignments=0
@pounard
pounard / MonParamConverter.php
Last active April 14, 2017 14:20
Param converter sans annotations
<?php
namespace MonVendor\MonBundle\Controller;
use MonVendor\MonBundle\Gestion\DemandeHelper;
use MonVendor\MonBundle\Gestion\Entity\Aide;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@pounard
pounard / Parse those fucking query strings.js
Created December 29, 2016 14:46
Parse those fucking query strings
function parseLink(uri) {
if (uri === "") {
return {};
}
var pos = uri.indexOf('?');
if (-1 !== pos) {
uri = uri.substr(pos + 1);
}
@pounard
pounard / common.inc
Created July 19, 2016 13:12
drupal_http_request() ignore invalid certificates
case 'https':
// Note: Only works when PHP is compiled with OpenSSL support.
$port = isset($uri['port']) ? $uri['port'] : 443;
$socket = 'ssl://' . $uri['host'] . ':' . $port;
$options['headers']['Host'] = $uri['host'] . ($port != 443 ? ':' . $port : '');
if (empty($options['context'])) {
$options['context'] = stream_context_create();
}
stream_context_set_option($options['context'], 'ssl', 'verify_host', false);
@pounard
pounard / prompt_to_finalize.sh
Last active June 17, 2016 10:33
My PS1 (for bash) needs to be fixed a bit
#!/bin/bash
# Inspired from (very far away)
# http://code-worrier.com/blog/git-branch-in-bash-prompt/
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
#
# I needed something simpler, and I work on slow FS so let it be minimal.
__git_br() {
local ingit=""
@pounard
pounard / drupal-panic.php
Last active April 26, 2016 09:35
This script will save your life
#!/usr/bin/php
<?php
if (!isset($argv[1])) {
$host = '127.0.0.1';
} else {
$host = $argv[1];
}
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['HTTP_HOST'] = $host;
@pounard
pounard / drupal-speed-install.php
Last active July 31, 2018 04:43
Installs a Drupal site really fast (really, really fast) - 3.8 seconds in a standard VM for standard profile
<?php
/**
* @file
* Drupal install speed.
*/
/**
* Yes, this is important.
*/
set_time_limit(0);
# mon_module/
# ma_library/src/Toto.php <- namespace de ma library, par exmple Ma\Library\Toto
# mon_module.module
# Dans mon_module.module, genre en haut:
spl_autoload_register(function ($class) {
$parts = explode('\\', $class);
if ('Ma' === $parts[0] && 'Library' === $parts[1]) {