Skip to content

Instantly share code, notes, and snippets.

@schmittjoh
schmittjoh / gist:45f0a8174b6f8550e2fb
Created January 21, 2016 17:56 — forked from antonkulaga/gist:5497894
Experiments with scala-graph JSON
package semantic.graph
import scala.Predef._
import scalax.collection.mutable.{Graph => MGraph}
import scalax.collection.GraphEdge._
import scalax.collection.edge._
import scalax.collection.mutable._
import scalax.collection.edge.Implicits._
checks:
php: true
tools:
external_code_coverage: # ...
/**
* Take screenshot when step fails.
* Works only with Selenium2Driver.
*
* @AfterStep
*/
public function takeScreenshotAfterFailedStep($event)
{
if (4 === $event->getResult()) {
$driver = $this->getSession()->getDriver();
@schmittjoh
schmittjoh / ArrayOf.php
Last active August 29, 2015 13:56
Example for how the same array is re-validated multiple times instead of validating it once/keeping track of its types.
<?php
class MyClass
{
public function doSomething(Foo[] $array) { // First check here.
if ($this->hasSomeElement($array)) {
$this->doSomethingBranch1($array);
} else {
$this->doSomethingBranch2($array);
}
@schmittjoh
schmittjoh / type-hinting-just-fine.php
Last active July 22, 2018 13:37
Different Ways of Consuming Options
<?php
Option::fromValue($this->scope->getTypeOfThis())
->flatMap(function(PhpType $type) { return $type->getObjectTypeMaybe(); })
->map(function(PhpType $type) {
if ($type instanceof Clazz && $type->getSuperClassType() instanceof PhpType) {
return $type->getSuperClassType();
}
return $this->typeRegistry->getNativeType('unknown');
@schmittjoh
schmittjoh / gist:3025399
Created June 30, 2012 20:31
PHP Memory Limit Test
<?php
// Memory Limit: -1
// Max Execution Time: 0
printf("Memory Limit: %s\n", ini_get('memory_limit'));
printf("Max Execution Time: %s\n", ini_get('max_execution_time'));
// Fatal error: Out of memory (allocated 1913651200) (tried to allocate 536870912 bytes)
// 1825,00 MB
@schmittjoh
schmittjoh / transcript.txt
Created January 5, 2012 18:25 — forked from jmikola/transcript.txt
Log of #symfony-dev meeting 20120105 (all times GMT-5)
Jan 05 11:01:39 <Seldaek> it's time (but I don't have time to be around too much, so I hope someone can manage this)
Jan 05 11:02:01 <fabpot> Hi all
Jan 05 11:02:23 <cordoval> this is the link just in case http://www.doodle.com/kxpxkrvhgnd2bx5i
Jan 05 11:02:57 <cordoval> and http://goo.gl/BWjAN - [WIP] Integrates metadata into Symfony validator goes first as it has 3 checks
Jan 05 11:03:08 * stodan has quit (Quit: Over & Out)
Jan 05 11:04:18 <fabpot> I have not read the PR, nor do I know anything about the metadata library but we already have loader in the Config components
Jan 05 11:04:25 <fabpot> that are already used in quite a few places
Jan 05 11:04:35 <fabpot> so the first question is why not reuse them for the validator component
Jan 05 11:04:58 <beberlei> henrik is not here, he suggestet that
Jan 05 11:05:12 <Stof> the goal of the Metadata libraries is mainly to manage the metadata after they are loaded
@schmittjoh
schmittjoh / AjaxFailureHandler.php
Created June 12, 2011 09:48
Twitter Anywhere Authentication
<?php
namespace Security\Authentication;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
class AjaxFailureHandler implements AuthenticationFailureHandlerInterface