Skip to content

Instantly share code, notes, and snippets.

View peterjmit's full-sized avatar

Peter Mitchell peterjmit

View GitHub Profile
@peterjmit
peterjmit / job.md
Last active January 6, 2021 18:04
Developer @ Apple

Apple Inc | Cupertino, CA

Apple is looking for a web and/or ops focused developer to build and maintain cutting edge web based applications that are used throughout the corporation. You should have a passion for technology and continuous learning/improvement.

We run Symfony2/PHP 5.6/Ember.js apps, write tests (BDD) and deploy to production daily. Our infrastructure is managed with Chef.

If you are interested or have any questions please get in touch! pete_mitchell [at] apple [dot] com

@peterjmit
peterjmit / EventDispatchingCommandTester.php
Last active January 4, 2018 09:22
Console events are not dispatched in Symfony when using the CommandTester class shown in http://symfony.com/doc/current/components/console/introduction.html#testing-commands. This class fixes that
<?php
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
@peterjmit
peterjmit / flush-spool.php
Created April 2, 2014 18:13
Flushing the email memory spool in a symfony command
<?php
$mailer = $this->getContainer()->get('mailer');
$message = new \Swift_Message();
$message->setBody('');
$message->setSubject('');
$message->setTo('');
$message->setFrom('');
<?php
$collection = new Collection();
$collection->add('item');
$collection->add('another item');
$collection->add('item');
/*
What would you expect here? Probably a count of 3...
@peterjmit
peterjmit / TranslatableEntity.orm.yml
Last active December 25, 2015 19:39
ArrayType and AbstractPersonalTranslation.
Entity\TranslatableEntity:
type: entity
gedmo:
translation:
entity: Entity\Translation
id:
id:
type: integer
fields:
@peterjmit
peterjmit / app_dev.php
Last active March 18, 2017 18:29
Code snippets for installing Symfony 2 on a Debian VirtualBox
<?php
// ...
if (isset($_SERVER['HTTP_CLIENT_IP']) ||
isset($_SERVER['HTTP_X_FORWARDED_FOR']) ||
!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', 'fe80::1', '::1', /* Host machine IP */'10.10.4.1'))
) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file. Check '.basename(__FILE__).' for more information.');
}

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@peterjmit
peterjmit / deploy.rb
Created March 15, 2013 00:05
Preferred capifony composer settings
set :use_composer, true
set :vendors_mode, "install"
set :copy_vendors, true
@peterjmit
peterjmit / ArticleType.php
Created January 25, 2013 17:49
Symfony 2 Multi lingual
<?php
// namespaces etc...
class ArticleType
{
// ...
public function buildForm(FormBuilderInterface $builder, array $options)
{
@peterjmit
peterjmit / benchmark.sh
Created October 10, 2012 10:49
Bash Benchmark Script (using time)
#!/bin/bash
# REQUIRES SUDO
# Benchmark runner
repeats=20
output_file='benchmark_results.csv'
command_to_run='echo 1'
run_tests() {
# --------------------------------------------------------------------------