Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jeremyharris
jeremyharris / TimerPrinter.php
Created September 25, 2018 14:34
A printer for PHPUnit that includes top 10 slowest tests in results. With `--verbose` it will show the top 10 slowest test methods.
<?php
namespace App\TestSuite;
use Cake\Collection\Collection;
use PHPUnit\Framework\Test;
use PHPUnit\Util\Test as TestUtil;
use PHPUnit\TextUI\ResultPrinter;
class TimerPrinter extends ResultPrinter
{
<?php
namespace App\Queue;
use Cake\Event\Event;
use Cake\Event\EventManager;
use josegonzalez\Queuesadilla\Job;
use Josegonzalez\CakeQueuesadilla\Queue\Queue;
/**
* QueueManager
<?php
class CallbackCaller
{
public function on($callback)
{
// whoops doesn't fire, perhaps due to code error
}
}

Keybase proof

I hereby claim:

  • I am jeremyharris on github.
  • I am jeremyharris (https://keybase.io/jeremyharris) on keybase.
  • I have a public key whose fingerprint is A7EC 4BE9 E2BA 76B7 BA7E 1CD0 DD51 37B6 19AA 86B4

To claim this, I am signing this object:

@jeremyharris
jeremyharris / FixtureTestCase.php
Last active December 19, 2021 19:04
Full code for: http://someguyjeremy.com/blog/database-testing-with-phpunit Place fixtures in a `fixture` folder.
<?php
// we're loading the Database TestCase here
require 'PHPUnit' . DIRECTORY_SEPARATOR . 'Extensions' .
DIRECTORY_SEPARATOR . 'Database' . DIRECTORY_SEPARATOR .
'TestCase.php';
class FixtureTestCase extends PHPUnit_Extensions_Database_TestCase {
public $fixtures = array(
'posts',
@jeremyharris
jeremyharris / backup.sh
Created July 10, 2012 19:41
Quick bash script to backup mysql databases as separate files similar to how MySQL Workbench does
#!/bin/bash
#
# Script to backup all mysql tables as separate files
#
# $BACKUP_PATH/<date>/<db_name>/<host>_<table_name>.gz
# MySQL settings
MYSQL_USER="root"
MYSQL_PASS=""
MYSQL_HOST="localhost"
@jeremyharris
jeremyharris / gist:2654088
Created May 10, 2012 15:55
A small collection of useful git commands for beginners.
# This is a handful of git commands I use on a daily basis, some of
# which are pretty basic, some of which took a little research to
# figure out how to do (so hopefully this is a time saver). It's
# by no means an exhaustive list as git is really freaking robust.
########################
# logs
########################
# unmerged differences between dev and master (not including extra master commits)
@jeremyharris
jeremyharris / gist:2032026
Created March 13, 2012 21:56
CSS 3d translation discrepancies
<!DOCTYPE html>
<html>
<head>
<title>translate/perspective test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
.wrapper {
position: absolute;
left: 50%;
top: 50%;