Skip to content

Instantly share code, notes, and snippets.

James McFadden mcfdn

View GitHub Profile
View juicy-custom.icls
<scheme name="Juicy - Custom" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<property name="created">2018-05-24T15:35:34</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2018.</property>
<property name="modified">2018-05-24T15:35:37</property>
<property name="originalScheme">Juicy - Custom</property>
<option name="LINE_SPACING" value="1.4" />
mcfdn / EventDispatchingCommandTester.php
Created Jan 4, 2018 — forked from peterjmit/EventDispatchingCommandTester.php
Console events are not dispatched in Symfony when using the CommandTester class shown in This class fixes that
View EventDispatchingCommandTester.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;
mcfdn /
Last active Dec 22, 2016
Recursive PHP linter
if [[ -z $1 ]]
mcfdn / Multiple Deploy Keys in
Last active Feb 16, 2020
Using multiple GitHub deploy keys on a single server with a single user
View Multiple Deploy Keys in

Using multiple GitHub deploy keys on a single server with a single user

Within GitHub it is possible to set up two types of SSH key - account level SSH keys and and repository level SSH keys. These repository level SSH keys are known in GitHub as deploy keys.

Deploy keys are useful for deploying code because they do not rely on an individual user account, which is susceptible to change, to “store” the server keys.

There is, however, an ‘issue’ with using deploy keys; each key across all repositories on GitHub must be unique. No one key can be used more than once. This becomes a problem when deploying to repositories to the same server with the same user. If you create two keys, the SSH client will not know which key to use when connecting to GitHub.

One solution is to use an SSH config file to define which key to use in which situation. This isn’t as easy as it seems.. you might try something like this:

mcfdn / EntityManagerServiceProvider.php
Created Aug 15, 2016
Doctrine EntityManager Service Provider for Laravel 5.2
View EntityManagerServiceProvider.php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
class EntityManagerServiceProvider extends ServiceProvider
mcfdn / cli-config.php
Last active Aug 15, 2016
Doctrine ORM cli-config.php for Laravel 5.2
View cli-config.php
require __DIR__ . '/bootstrap/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$entityManager = $app->make(Doctrine\ORM\EntityManager::class);
View gist:3f75fe6e3c6805079791
### Keybase proof
I hereby claim:
* I am jamesmcfadden on github.
* I am jamesmcfdn ( on keybase.
* I have a public key whose fingerprint is 5FF5 AA62 EEE1 B318 F0DB EB9C FE76 D65B 78A1 9EE3
To claim this, I am signing this object:
mcfdn / intervals.php
Last active Dec 20, 2015
date intervals for PHP < 5.3
View intervals.php
function intervals($start, $end = 'now')
$unixStart = strtotime($start);
$unixNow = strtotime($end);
$diff = $unixNow - $unixStart;
$days = (int) ($diff / 86400);
$hours = (int) ($diff / 3600);
$minutes = (int) ($diff / 60);
mcfdn / PasswordsMatch.php
Created Apr 29, 2013
Simple password confirmation validation using Zend_Validate
View PasswordsMatch.php
class App_Validate_PasswordsMatch extends Zend_Validate_Abstract
const PASSWORD_MISMATCH = 'passwordMismatch';
* The field name of the password
* @var string
mcfdn / listener.php
Last active Dec 10, 2015
LiteMap example documentation 5
View listener.php
$map = new LiteMap_Container();
$map->setCenter(51.500152, -0.126236);
$locations = array(
'51.500152' => '-0.126236',
'51.512249182894756' => '-0.15815299440919262',
'51.52325165255695' => '-0.11283439089356762',
'51.47238304492127' => '-0.15883963991700512',
'51.49077068938746' => '-0.07232230593263012'
You can’t perform that action at this time.