Skip to content

Instantly share code, notes, and snippets.

View Stubbs's full-sized avatar

Stuart Grimshaw Stubbs

  • Sheffield, South Yorkshire, UK
View GitHub Profile
@Stubbs
Stubbs / multitail.conf
Last active February 12, 2016 08:50
Basic Multitail config for colourising Symfony2 log files.
colorscheme:symfony
cs_re:cyan:^\[....-..-.. ..:..:..\]
cs_re:blue: .*\.(INFO|NOTICE).*
cs_re:red: .*\.(ERROR|CRITICAL).*
cs_re:blue: \{[^}]+\}
$login = $client->post("/rest/login", array("Content-Type" => "application/json"), '', array('debug' => true));
$login->setBody("{'username':'stuart.grimshaw','password':'strongpassword'}");
$login->send();
@Stubbs
Stubbs / pre_commit
Created October 16, 2013 10:37
Git Hook to reject PHP syntax errors & any php that directly calls "error_log"
#!/bin/bash
PLATFORM='unknown'
UNAMESTR=`uname`
XARGS_EXIT=1
if [[ "$UNAMESTR" == 'Linux' ]]; then
PLATFORM='linux'
XARGS_EXIT=123
elif [[ "$UNAMESTR" == 'FreeBSD' ]]; then
PLATFORM='freebsd'
INFO global: Vagrant version: 1.2.2
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/box/plugin.rb
INFO manager: Registered plugin: box command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/destroy/plugin.rb
INFO manager: Registered plugin: destroy command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/halt/plugin.rb
INFO manager: Registered plugin: halt command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/init/plugin.rb
INFO manager: Registered plugin: init command
DEBUG global: Loading core plugin: /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.2/plugins/commands/package/plugin.rb
@Stubbs
Stubbs / bootstrap.php
Created May 26, 2013 00:22
Isolate unit tests in Symfony2 http://php-and-symfony.matthiasnoback.nl/2011/10/symfony2-use-a-bootstrap-file-for-your-phpunit-tests-and-run-some-console-commands/ and then use this as your bootstrap to load migrations & fixtures.
<?php
require_once __DIR__ . '/bootstrap.php.cache';
require_once __DIR__ . '/AppKernel.php';
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Input\ArrayInput;
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
<?php
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
@Stubbs
Stubbs / gist:5004858
Created February 21, 2013 13:52
Can you use wild cards in Puppet exec?
exec {"load-crm-fixtures":
command => "mysql -u db_user -ppassword db_name < *.sql",
cwd => "${rootDir}/sites/${siteDirectory}/db/crm/fixtures/",
path => ['/usr/bin'],
require => Exec['clean-crm-db'],
logoutput => true
}
@Stubbs
Stubbs / gist:3497762
Created August 28, 2012 12:52
Sublime text 2 phpunit plugin error.
# Running in folder: /Users/stuart/Projects/lpsite/modules/recurring_payments/tests
$ phpunit -c phpunit.xml /Users/stuart/Projects/lpsite/modules/recurring_payments/tests/recurring_payments/RecurringPaymentErrorTest.php
-c: phpunit: command not found
YUI.add('fc_cone', function(Y)
{
Y.ConeIcon = Y.Base.create("coneIcon", Y.Shape, [Y.Circle], {}, {
ATTRS: {
radius: {
value: 5
},
stroke: {
weight: 2,
color: '#fff'
@Stubbs
Stubbs / gist:2724564
Created May 18, 2012 10:36
Dirty hack for Macvim when it hangs trying to add new lines to files.
" DIRTY!
" For some reason, Macvim hangs when trying to insert a new line when editing
" mysql & javascript file.
"
" You can work around that by switching to another filetype that doesn't have
" the problem, then back again, hence these two hacks.
"
augroup mysqlhack
au!