Skip to content

Instantly share code, notes, and snippets.

View JCook21's full-sized avatar

Jeremy Cook JCook21

  • Oracle
  • Guelph, Ontario
View GitHub Profile
@JCook21
JCook21 / composer.bat
Created February 6, 2012 14:02
Quick Batch file to add a 'composer' command to windows.
@echo off
if "%PHPBIN%" == "" set PHPBIN=C:\path\to\PHP\executable\dir\.\php.exe
"%PHPBIN%" "C:\path\to\composer.phar" %*
@JCook21
JCook21 / MySQLOrmTestCase.php
Created February 27, 2012 18:02
Abstract base class for writing Doctrine test cases using MySQL. Extends OrmTestCase to allow for truncating tables.
use DoctrineExtensions\PHPUnit\OrmTestCase,
Doctrine\ORM\Configuration,
Doctrine\Common\Cache\ArrayCache,
Doctrine\ORM\EntityManager;
/**
* Base class for test cases that need an entity manager to work with.
* Defines an entity manager for the tests to work with and truncates tables in a way that is compatible with MySQL
* @author Jeremy Cook
* @version 1.0
*/
@JCook21
JCook21 / Base.php
Created February 27, 2012 18:52
Work on trying to get a Doctrine/PHPUnit connection working that allows truncates.
<?php
namespace Tests\Models\Db;
use DoctrineExtensions\PHPUnit\OrmTestCase,
Doctrine\ORM\Configuration,
Doctrine\Common\Cache\ArrayCache,
Doctrine\ORM\EntityManager,
Doctrine\DBAL\Types\Type,
Doctrine\Spatial\ORM\SchemaEventSubscriber,
Doctrine\Common\EventManager,
PHPUnit_Extensions_Database_Operation_Composite,
@JCook21
JCook21 / gist:2225895
Created March 28, 2012 12:54
Recursive closure in PHP 5.4
<?php
class foo {
public $bar;
public function __construct(Closure $closure)
{
$this->bar = Closure::bind($closure, $this);
}
@JCook21
JCook21 / gittyup.sh
Created June 21, 2012 13:28 — forked from EvanDotPro/gittyup.sh
Easily keep master in sync with upstream.
####################################################################################
## ##
## gittyup() - Easily keep master in sync with upstream. ##
## ##
## Author: Evan Coury, http://blog.evan.pro/ ##
## URL: https://gist.github.com/1506822 ##
## ##
## This bash function is a simple shortcut for keeping your local (and public ##
## fork / origin remote) master branch up to date and in sync with the upstream ##
## master. To use gittyup(), simply drop this in your ~/.bashrc. ##
@JCook21
JCook21 / gist:3824538
Created October 3, 2012 02:13
Graylog2 test
<?php
require "vendor/autoload.php";
use Monolog\Logger;
use Monolog\Handler\GelfHandler;
use Gelf\MessagePublisher;
$log = new Logger('Test');
$log->pushHandler(new GelfHandler(new MessagePublisher('IP OR DOMAIN NAME OF YOUR GRAYLOG2 SERVER')));
@JCook21
JCook21 / gist:3824561
Created October 3, 2012 02:22
Singleton class for logging to Graylog
<?php
use Monolog\Logger;
use Monolog\Handler\GelfHandler;
use Gelf\MessagePublisher;
/**
* Class to configure and return a Monolog instance
*
* @author Jeremy Cook
*/
@JCook21
JCook21 / gist:3824584
Created October 3, 2012 02:26
Error handling file to log all PHP errors to Graylog2
<?php
/**
* This file sets up exception and error handlers to log errors to our Graylog2
* server.
*
* @author Jeremy Cook
*/
//Add the autoloader generated by composer for dependencies.
require_once 'path/to/composer/autoload.php';
@JCook21
JCook21 / deploy.rb
Created November 11, 2012 18:29
Sample Capifony Deployment script
# Deployment server info
set :application, "APP NAME"
set :domain, "APP DOMAIN NAME"
set :deploy_to, "/path/on/live/server"
set :app_path, "app"
set :web_path, "web"
set :maintenance_basename, "maintenance"
# SCM info
set :repository, "GIT REMOTE REPO URL"
@JCook21
JCook21 / gist:4527261
Created January 14, 2013 01:56
Quick demo of vim path settings for a local project.
set path+=/path/to/project/src/**
set path+=/path/to/project/vendor/**