Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jeremykendall on github.
  • I am jeremykendall (https://keybase.io/jeremykendall) on keybase.
  • I have a public key whose fingerprint is F208 596D C3AF 4E0F 5799 3253 AE91 19ED 6A12 CA18

To claim this, I am signing this object:

@jeremykendall
jeremykendall / force-ntp-update
Created October 6, 2014 15:00
Forcing a clock update using NTP: bash script edition
#!/bin/bash
# Forces an ntp update
#
# Based on SO user Martin Schröder's answer to "How to force a clock update
# using ntp?": http://askubuntu.com/a/256004/41943
# Fail fast (set -e will bail at first error)
set -e
if [ "$EUID" -ne 0 ]; then
@jeremykendall
jeremykendall / auth.php
Last active August 29, 2015 14:11
DoctrineModule stand-alone auth configuration (see https://github.com/doctrine/DoctrineModule)
<?php
// ... snip ...
use DoctrineModule\Authentication\Adapter\ObjectRepository as AuthenticationAdapter;
use DoctrineModule\Authentication\Storage\ObjectRepository as AuthenticationStorage;
use DoctrineModule\Options\Authentication as AuthenticationOptions;
use JeremyKendall\Slim\Auth\Bootstrap;
use Zend\Authentication\Storage\Session as SessionStorage;
@jeremykendall
jeremykendall / user.php
Last active August 29, 2015 14:14
Westin Shafer Brain Teaser
<?php
// Original post: https://www.facebook.com/groups/2204685680/permalink/10153079722090681/
// Run from the CLI using `php -f user.php`
// Always turn error reporting all the way up in dev
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
@jeremykendall
jeremykendall / example.js
Created February 27, 2015 16:38
Graph Story Neo4j nodejs example - seraph
// Run from the command line with `node example.js`
// Replace the example URL with your own from https://console.graphstory.com/graphs/list
var db_url = "https://user:pass@example-url.do-stories.graphstory.com:7473";
var db = require("seraph")(db_url);
db.save({ name: "Test-Man", age: 40 }, function(err, node) {
if (err) throw err;
console.log("Test-Man inserted.");
db.delete(node, function(err) {
@jeremykendall
jeremykendall / JavaProperties.php
Created July 31, 2015 00:03
Java Config Writer
<?php
namespace Whatevs\Config\Writer;
use Zend\Config\Writer\WriterInterface;
class JavaProperties implements WriterInterface
{
/**
* Who cares. Funkatron is going to have to fix it regardless.
@jeremykendall
jeremykendall / DoctrineConfig.php
Last active August 29, 2015 14:27
Doctrine2 EntityManager via Aura.Di using wrapper and factory
<?php
namespace Namespace\Di;
use Aura\Di\Config;
use Aura\Di\Container;
use Doctrine\Common\Cache\ApcCache;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
use Doctrine\ORM\Configuration;
<?php
echo "Hello world";
@jeremykendall
jeremykendall / KingDiamondTest.php
Created March 18, 2012 06:10
Tests the major plot point of Mercyful Fate's tune Melissa
<?php
namespace MercyfulFate;
use MercyfulFate\KingDiamond;
class KingDiamondTest extends \PHPUnit_Framework_TestCase
{
/**
* @var MercyfulFate\Priest
*/
@jeremykendall
jeremykendall / zf-validate-issue.php
Created August 27, 2012 16:46
First Zend_Validate_Db_NoRecordExists validator is ignored
$this->addElement('text', 'email', array(
'label' => 'Your email address',
'required' => true,
'validators' => array(
array('EmailAddress'),
array(
new \Zend_Validate_Db_NoRecordExists(array('table' => 'accounts', 'field' => 'email')),
'breakChainOnFailure' => true
),
array(new \Zend_Validate_Db_NoRecordExists(array('table' => 'beta_invites', 'field' => 'email')))