Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CarsonF
CarsonF / TwigResponse.php
Created January 14, 2015 17:09
Subclassing Response for Twig
<?php
namespace GMO\Common\Web\Twig;
use GMO\Common\Collections\ArrayCollection;
use Symfony\Component\HttpFoundation\Response;
class TwigResponse extends Response {
public function setTemplate($template) {
$this->template = $template;
<?php
if (!isResource()) {
return false;
}
require_once __DIR__ . '/index.php';
function isResource() {
$path = $_SERVER['SCRIPT_NAME'];
@CarsonF
CarsonF / Translator.php
Created February 19, 2015 00:04
Translator
<?php
namespace Service\Translation;
use Common\Config;
use Common\Log;
use GMO\Common\Collections\ArrayCollection;
use GMO\Common\String;
use Pimple;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\Translator as BaseTranslator;
<?php
namespace GMO\Common;
class Http {
/**
* A list of HTTP headers to choose the original client IP address from. In
* addition to these the RemoteAddr (REMOTE_ADDR) is also used as a final
* fallback.
*/
<?php
namespace Log;
use Common\Config;
use GMO\Cache\CacheKeys;
use GMO\Common\String;
use Log\Handler\LogstashHandler;
use Log\Processor\EnvProcessor;
use Log\Processor\RequestProcessor;
use Monolog\Handler\ChromePHPHandler;
@CarsonF
CarsonF / dump.php
Created July 17, 2015 14:12
Dumps pimple container for silex plugin
<?php
use Sorien\Provider\PimpleDumpProvider;
use Symfony\Component\HttpFoundation\Request;
require_once __DIR__ . '/vendor/autoload.php';
$app = new \Bolt\Application();
$request = Request::create('/');
Request::setFactory(function () use ($request) {
@CarsonF
CarsonF / CarbonType.php
Last active August 29, 2015 14:27
Doctrine DBAL Carbon Integration
<?php
use Carbon\Carbon;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\DateTimeType;
/**
* Updates DateTime objects to return Carbon instance
*/
class CarbonType extends DateTimeType
@CarsonF
CarsonF / Filesystem Finding.php
Last active September 30, 2015 18:41
Using Symfony's Finder with our Filesystem abstraction...
<?php
use Bolt\Filesystem\Filesystem;
use Bolt\Filesystem\Local;
$fs = new Filesystem(new Local(__DIR__));
foreach ($fs->find()->files() as $file) {
/** @var \Bolt\Filesystem\File $file */
echo $file->getFilename() . '\n';
@CarsonF
CarsonF / composer.sh
Last active January 19, 2024 11:10
Global Composer Setup
#!/usr/bin/env bash
# As root
# Make config and data dirs
mkdir /etc/composer -p || exit 1
mkdir /var/lib/composer -p
# Set composer home dir to global location
cat << EOF > /etc/profile.d/composer.sh
#!/usr/bin/env bash
@CarsonF
CarsonF / ssh-fingerprints
Created April 20, 2016 17:37
Lists SSH public key fingerprints
#!/usr/bin/env bash
# Lists SSH public key fingerprints
file=$1
hash=""
if [[ "$OSTYPE" == "darwin"* ]]; then
hash="-E MD5"
fi