Skip to content

Instantly share code, notes, and snippets.

Patrik Lermon kler

Block or report user

Report or block kler

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kler
kler / nested_restyresolver.py
Created Apr 17, 2017
Proposal for restyResolver to handle nested paths
View nested_restyresolver.py
import logging
import re
from connexion.resolver import RestyResolver
logger = logging.getLogger('connexion.resolver')
class NestedRestyResolver(RestyResolver):
"""Overrider RestyResolver to support complex paths (/a/b/c/ => a.b.c)"""
@kler
kler / semi-static-context.php
Created Oct 2, 2012
It is possible to call functions from a static context
View semi-static-context.php
<?php
class SemiStaticClass {
public function echoWhoIAm() {
echo 'I\'m ' . __FUNCTION__ . ' in class ' . __CLASS__;
// If this doesn't exists, then this function is statically called
if (! isset($this)) {
echo '... and I\'m statically called! Nice!';
}
echo "\n";
}
@kler
kler / null-and-unset-are-unpredictable.php
Created Oct 2, 2012
NULL and unset has unpredictable behavior
View null-and-unset-are-unpredictable.php
<?php
// Conclusion: NULL and unset have unpredictable behavior
// === NULL are in some cases same as unset ===
// This code will assign a value, then assign NULL, and the result will show that
// PHP think this is same as unset()
$a = "test";
$a = NULL;  // will be same as unset()
echo (isset($a) ? "true" : "false") . "\n";
@kler
kler / circular-references-segfault.php
Created Oct 2, 2012
Circular references may cause segmentation fault
View circular-references-segfault.php
<?php
// Conclusion: This code will cause Segmentation fault, because
// of recursive calls to __clone(), but PHP should handle this.
// Bug filed here: http://bugs.php.net/bug.php?id=49664
date_default_timezone_set('America/Los_Angeles');
class Test {
public $previous, $next = NULL;
@kler
kler / null-is-overwritable.php
Created Oct 2, 2012
NULL is overwritable (scalars are not)
View null-is-overwritable.php
<?php
// Conclusion: NULL is in this case considered to be of no value, and PHP
// thinks that it is OK to overwrite, but integers are not treated the same
// This code will assign NULL and the ignore that NULL was assigned and create a stdClass:
$a = NULL;
$a->test = "apa"; // should warn in my oppinion
print_r($a);
You can’t perform that action at this time.