Skip to content

Instantly share code, notes, and snippets.

🌴
On vacation

Grégoire Pineau lyrixx

🌴
On vacation
View GitHub Profile
@lyrixx
lyrixx / index.php
Created Apr 22, 2020
Very low memory usage iterator
View index.php
<?php
function m()
{
$memory = round(memory_get_usage() / 1024 / 1024, 2);
$frame = debug_backtrace(0, 1)[0];
$file = basename($frame['file']);
$line = $frame['line'];
printf("%s:%d | %sMb\n", $file, $line, $memory);
@lyrixx
lyrixx / README.md
Last active Feb 21, 2020
Add shared tracks in to slack to a Spotify Playlist
View README.md
@lyrixx
lyrixx / README.md
Last active Mar 17, 2020
Spotify does not handle Media Keys
View README.md

Debug media keys and Spotify

TL;DR: There is a bug in gnome that have been fixed in 3.3. But you can temporary fix this issue with: pkill gsd-media-keys

Let's Debug

  1. We check logs

@lyrixx
lyrixx / .gitignore
Last active Feb 26, 2020
UUID generation in PHP
@lyrixx
lyrixx / HardCoreDebugLogger.php
Last active Jul 9, 2020
Hardcore Debug Logger
View HardCoreDebugLogger.php
<?php
const STREAM_OPEN_FOR_INCLUDE = 128;
final class HardCoreDebugLogger
{
public static function register(string $output = 'php://stdout')
{
register_tick_function(function () use ($output) {
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1);
@lyrixx
lyrixx / rootCA.pem
Created Feb 25, 2019
my rootCA.pem (mkcert)
View rootCA.pem
-----BEGIN CERTIFICATE-----
MIIEjTCCAvWgAwIBAgIQcxWNVb9OEeS51am6xUW6FzANBgkqhkiG9w0BAQsFADBf
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExGjAYBgNVBAsMEWdyZWdv
aXJlQGdyZWdvaXJlMSEwHwYDVQQDDBhta2NlcnQgZ3JlZ29pcmVAZ3JlZ29pcmUw
HhcNMTkwMTIzMTAyNjMzWhcNMjkwMTIzMTAyNjMzWjBfMR4wHAYDVQQKExVta2Nl
cnQgZGV2ZWxvcG1lbnQgQ0ExGjAYBgNVBAsMEWdyZWdvaXJlQGdyZWdvaXJlMSEw
HwYDVQQDDBhta2NlcnQgZ3JlZ29pcmVAZ3JlZ29pcmUwggGiMA0GCSqGSIb3DQEB
AQUAA4IBjwAwggGKAoIBgQDz7qMbfPDd3tn8Q1RYMZBuQiQclK/MRi9mwOT78rnw
Oy520t2VqThX6Cp47JnSgmglOQK0LuY2YuYXIVAMusnC5M+oP6vRK2H4DIFq/9Pc
HVIgPDsbx1e4hyEodqDK0G8Q0sufvmWqHu7olvHpXIVSvp+1nGtOgkJ8kTkjrHWR
@lyrixx
lyrixx / BrokerFactory.php
Last active Jul 1, 2019
PHPStan extension to extract property type hint from constructor argument
View BrokerFactory.php
<?php
use PHPStan\Broker\Broker;
use PHPStan\Broker\BrokerFactory as PhpstanBrokerFactory;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\Php\PhpPropertyReflection;
use PHPStan\Reflection\PropertiesClassReflectionExtension;
use PHPStan\Reflection\PropertyReflection;
use PHPStan\Type\ObjectType;
@lyrixx
lyrixx / run.php
Last active Dec 4, 2019
Updated your templates with the new twig include
View run.php
<?php
<<<CONFIG
packages:
- "symfony/finder: ~3.0"
- "symfony/console: ~3.0"
CONFIG;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@lyrixx
lyrixx / index.php
Created Aug 11, 2017
Box PHP calls
View index.php
<?php
class Foobar
{
public function success()
{
return $this->box('doSuccess', false, '123', '456');
}
public function fail()
@lyrixx
lyrixx / .gitignore
Last active Feb 24, 2017
Blackfire Upload
View .gitignore
/composer.json
/composer.lock
/vendor/
You can’t perform that action at this time.