Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am mcfdn on github.
  • I am jamesmcfdn (https://keybase.io/jamesmcfdn) on keybase.
  • I have a public key ASDuqXYR4tjJ4cSKk-CknrYDmG_273tiNuxWGZihMBj5Pwo

To claim this, I am signing this object:

<scheme name="Juicy - Custom" version="142" parent_scheme="Default">
<option name="FONT_SCALE" value="1.0" />
<metaInfo>
<property name="created">2018-05-24T15:35:34</property>
<property name="ide">PhpStorm</property>
<property name="ideVersion">2018.1.2.0.0</property>
<property name="modified">2018-05-24T15:35:37</property>
<property name="originalScheme">Juicy - Custom</property>
</metaInfo>
<option name="LINE_SPACING" value="1.4" />
@mcfdn
mcfdn / EventDispatchingCommandTester.php
Created January 4, 2018 09:22 — forked from peterjmit/EventDispatchingCommandTester.php
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;
@mcfdn
mcfdn / lint.sh
Last active December 22, 2016 10:59
Recursive PHP linter
#!/bin/bash
EXITCODE=0
if [[ -z $1 ]]
then
FILES=app
else
FILES=$1
fi
@mcfdn
mcfdn / Multiple Deploy Keys in GitHub.md
Last active November 21, 2022 14:02
Using multiple GitHub deploy keys on a single server with a single user

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
mcfdn / EntityManagerServiceProvider.php
Created August 15, 2016 16:37
Doctrine EntityManager Service Provider for Laravel 5.2
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
class EntityManagerServiceProvider extends ServiceProvider
{
@mcfdn
mcfdn / cli-config.php
Last active August 15, 2016 16:38
Doctrine ORM cli-config.php for Laravel 5.2
<?php
require __DIR__ . '/bootstrap/autoload.php';
$app = require_once __DIR__ . '/bootstrap/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$kernel->handle(Illuminate\Http\Request::capture());
$entityManager = $app->make(Doctrine\ORM\EntityManager::class);
### Keybase proof
I hereby claim:
* I am jamesmcfadden on github.
* I am jamesmcfdn (https://keybase.io/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
mcfdn / intervals.php
Last active December 20, 2015 10:18
date intervals for PHP < 5.3
<?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
mcfdn / PasswordsMatch.php
Created April 29, 2013 14:39
Simple password confirmation validation using Zend_Validate
<?php
class App_Validate_PasswordsMatch extends Zend_Validate_Abstract
{
const PASSWORD_MISMATCH = 'passwordMismatch';
/**
* The field name of the password
*
* @var string
*/