Skip to content

Instantly share code, notes, and snippets.

View lyrixx's full-sized avatar
😀

Grégoire Pineau lyrixx

😀
View GitHub Profile
@lyrixx
lyrixx / MessageExporter.php
Created June 19, 2014 07:40
Export all messages from an AMQP queue
<?php
class MessageExporter
{
private $broker;
public function __construct(Broker $broker = null)
{
$this->broker = $broker;
}
@lyrixx
lyrixx / segfault-finder.php
Last active August 15, 2023 21:17
How to find a segfault in PHP
<?php
register_tick_function(function() {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
$last = reset($bt);
$info = sprintf("%s +%d\n", $last['file'], $last['line']);
file_put_contents('/tmp/segfault.txt', $info, FILE_APPEND);
// or
// file_put_contents('php://output', $info, FILE_APPEND);
});
@lyrixx
lyrixx / refresh-assetic.sh
Last active August 29, 2015 13:56
Refresh assetic on any modification
#!/bin/bash
BASE_PATH=`dirname $0`/..
ASSETS_PATH=$BASE_PATH/app/Resources/assets
ASSETS_PATH2=$BASE_PATH/src/SensioLabs/Bundle/InsightAnalysisBundle/Resources/public
if [[ `which inotifywait` ]]; then
while true; do
inotifywait -r -e modify -e move -e create -e delete $ASSETS_PATH/ $ASSETS_PATH2/ | while read line; do
php $BASE_PATH/app/console assetic:dump --force
@lyrixx
lyrixx / unset.php
Created February 19, 2014 20:55
Ensure visibility of a property does not change when unseted
<?php
class Foobar
{
private $foo = 'start';
public function getFoo()
{
return $this->foo;
}
@lyrixx
lyrixx / .gitignore
Last active January 4, 2016 03:09
Play with Patchwork / Parser
/vendor/
@lyrixx
lyrixx / post-checkout
Created June 26, 2013 13:37
Git post checkout
#!/bin/bash
# Put this file at: .git/hooks/post-checkout
# and make it executable
# You can install it system wide too, see http://stackoverflow.com/a/2293578/685587
PREV_COMMIT=$1
POST_COMMIT=$2
NOCOLOR='\e[0m'
<?php
function waitContinue($message, $timeout, closure $timeoutCallback) {
$read = array(STDIN);
$write = null;
$except = null;
$answer = '';
fwrite(STDOUT, trim($message) . ': ');
@lyrixx
lyrixx / goto-sample.php
Created June 19, 2013 21:41
goto-sample.php
public function foo()
{
$bool = true;
a:
try {
$bool = $this->do()
} catch($e)
goto a;
}
@lyrixx
lyrixx / css.php
Last active December 17, 2015 14:59
Assets async
<?php
sleep(10);
header('Content-Type: text/css');
echo 'h1 { color: red; }';
@lyrixx
lyrixx / .gitignore
Last active December 17, 2015 07:09
Symfony debug exception listenner
/vendor/