Skip to content

Instantly share code, notes, and snippets.

View Ocramius's full-sized avatar
🔬
In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

🔬
In your repositories, watching your code. Always watching.
View GitHub Profile
<?php
namespace EntityMapperFramework {
class EntityMapper {
public function __construct() {
stream_wrapper_register('dynamicproxygenerator', __NAMESPACE__ . '\DynamicProxyGeneratorStream');
}
public function createProxy($entity) {
$class = get_class($entity);
@Ocramius
Ocramius / pr.md
Created April 4, 2014 06:23 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

Contract Killer

The popular open-source contract for web designers and developers by Stuff & Nonsense

  • Originally published: 23/12/2008
  • Revised date: 15/12/2013
  • Original post

There are a lot of complaints going around about Laravel these days, but a lot
of the important ones seem to be missing from the spotlight.
Bugfixes, issues and pull requests being left open for months with no
clarification of intent:
- https://github.com/laravel/framework/pull/1799
- https://github.com/laravel/framework/issues/1963
- https://github.com/laravel/framework/issues/2089
- https://github.com/laravel/framework/issues/2234
@Ocramius
Ocramius / Bootstrap.php
Last active December 20, 2015 05:29 — forked from vaurat/gist:6070898
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\ODM\MongoDB\DocumentManager;
/* @var $loader \Composer\Autoload\ClassLoader */
$loader = require __DIR__.'/vendor/autoload.php';
<?php
/**
* composer.json:
* {
* "require": {
* "zendframework/zend-http": "2.*"
* }
* }
*/
require __DIR__ . '/vendor/autoload.php';

Profiler

This is a simple PHP profiler based on syslog and ticks.

Killer feature is that it doesn't need to be included inside statements but only prepend your scripts.

<?php
/**
* So for example I have two tables "ab" and "cd". "ab" references "cd" table
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="\App\Entity\Repository\Ab")
@Ocramius
Ocramius / options.php
Last active December 13, 2015 21:28 — forked from bakura10/options.php
<?php
return array(
'zfr_cron' => array(
'tasks' => array(
'factories' => array(
'remove_fake_accounts' => 'Application\Cron\RemoveFakeAccountsFactory'
)
)
)
<?php
//
// Measure the time to execute two thousand jobs ten times.
//
require_once __DIR__.'/../vendor/autoload.php';
function benchmark($resque, $count) {
$start = microtime(true);
for($i=$count;$i > 0;--$i) {