Skip to content

Instantly share code, notes, and snippets.

View MattKetmo's full-sized avatar

Matt Ketmo MattKetmo

View GitHub Profile
@MattKetmo
MattKetmo / StreamedProcessResponse.php
Created May 20, 2012 17:57
StreamedProcessResponse
<?php
use Symfony\Component\HttpFoundation\StreamedResponse;
use Symfony\Component\Process\Process;
class StreamedProcessResponse extends StreamedResponse
{
public function __construct(Process $process, $status = 200, $headers = array())
{
$callback = function() use ($process) {
@MattKetmo
MattKetmo / FacebookSessionPersistence.php
Created May 25, 2012 08:10
Quick (and dirty) fix for running tests using FosFacebookBundle
<?php
namespace Foo\BarBundle\Facebook;
use FOS\FacebookBundle\Facebook\FacebookSessionPersistence as BaseFacebookSessionPersistence;
use Symfony\Component\HttpFoundation\Session\Session;
/**
* Quick (and dirty) fix for running tests using FosFacebookBundle.
* It may have unwanted consequences (not tested)!
@MattKetmo
MattKetmo / some_mail.html.twig
Created June 1, 2012 14:56
TwigMailGenerator + embed tag
{% block subject 'Hello World' %}
{% block body_html %}
{% embed "layout_mail.html.twig" %}
{% block content %}
I'm the <b>content</b>.
{% endblock %}
{% endembed %}
{% endblock %}
@MattKetmo
MattKetmo / FooCommand.php
Created September 7, 2012 11:46
[Console] Write into stdout and stderr
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Testcase: app/console foo > std 2> err
*/
@MattKetmo
MattKetmo / NullOutputCommand.php
Created October 24, 2012 21:54
Option --quiet in Symfony2 command
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Console\Output\OutputInterface;
class NullOutputCommand extends Command
@MattKetmo
MattKetmo / logger-aware.php
Last active December 18, 2015 13:28
Inject logger in objects using dependency injection
<?php
require __DIR__.'/vendor/autoload.php';
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Monolog\Logger;
interface LoggerAwareInterface
{
@MattKetmo
MattKetmo / google-sign.php
Created October 9, 2013 08:16
Google Maps Sign URL
#!/usr/bin/env php
<?php
/**
* @see https://github.com/geocoder-php/Geocoder/blob/21e562a5ad595c6fee7a33ae90e0b42dc8866c23/src/Geocoder/Provider/GoogleMapsBusinessProvider.php#L82
*/
function signQuery($query, $privateKey)
{
$url = parse_url($query);
@MattKetmo
MattKetmo / lock.php
Created November 13, 2013 14:17
Playing with LiipProcessManager
<?php
// see https://github.com/liip/LiipProcessManager/
require __DIR__.'/vendor/autoload.php';
use Liip\ProcessManager\ProcessManager;
use Liip\ProcessManager\PidFile;
try {
$lock = new PidFile(new ProcessManager(), '/tmp/foobar');
@MattKetmo
MattKetmo / TagManager.txt
Last active August 29, 2015 14:01
TagManager
http://www.tagcommander.com/en/
http://ensighten.com/
http://www.opentag.qubitproducts.com/
https://www.google.com/tagmanager/