Skip to content

Instantly share code, notes, and snippets.

View mbunge's full-sized avatar
💭
tinker, tinker, ponder, ponder

Marco Bunge mbunge

💭
tinker, tinker, ponder, ponder
View GitHub Profile
@mbunge
mbunge / gist:2925070
Created June 13, 2012 16:23
Anonymus Function Test
<?php
$stdClass = new stdClass();
$stdClass->value = 'HELLO WOLRD';
//return message defined by $stdClass::value with a context
//use $stdClass as scope
$lambda = function($context) use ($stdClass)
{
$msg = $context . ': ' . $stdClass->value;
return $msg;
@mbunge
mbunge / headermessageConvert.php
Created June 26, 2012 21:31
Display a converted raw http message
<?php
/**
* @author Marco Bunge
* @copyright 2012 Marco Bunge <efika@rubymatrix.de>
*/
$string = 'HTTP/1.1 200 OK
Server: Apache/1.3.29 (Unix) PHP/4.3.4
Content-Length: (Größe von infotext.html in Byte)
Content-Language: de (nach RFC 3282 sowie RFC 1766)
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@mbunge
mbunge / Collection.php
Created July 24, 2012 15:25
A simple Collectionclass in PHP
<?php
/**
* @author Marco Bunge
* @copyright 2012 Marco Bunge <efika@rubymatrix.de>
*/
interface CollectionInterface
{
/**
* @abstract
@mbunge
mbunge / TraitFlavoredSqlBuilder.php
Created July 26, 2012 13:57
Trait flavored sqlbuilder (experiment)
<?php
/**
* @author Marco Bunge
* @copyright 2012 Marco Bunge <efika@rubymatrix.de>
*/
abstract class AbstractSqlCommand {
public function build(){
return implode(' ', $this->getCommandElements());
@mbunge
mbunge / preg_match_array.php
Created August 2, 2012 13:02
preg_match over given array with a defined pattern
<?php
/**
* preg_match over given array with a defined pattern
*
* Example:
*
* $names = array(
* 'hans',
* 'dieter',
* 'peter',
@mbunge
mbunge / mysteriousNaN.php
Created August 10, 2012 11:23
Hum. Can'T get any sense about this.
Since NaN is not even equal to itself, here is a way to test it:
From: http://de.php.net/manual/en/function.is-nan.php#50295
<?php
function my_is_nan($_) {
return ($_ !== $_);
}
@mbunge
mbunge / kol.md
Last active October 8, 2015 09:38
Key of life

The key of life is an infinite circle of

inspiration > idea > action > reflection >

@mbunge
mbunge / profiler.php
Created March 26, 2013 14:52
A small profiler.
<?php
class Profiler {
public $time = 0;
public $memory = 0;
public function startRecordTime(){
$this->time = microtime(true);
}
@mbunge
mbunge / bootatrap_ideas.php
Last active December 18, 2015 21:49
Some ideas how bootstrapper could work.
<?php
interface Bootstrap {
public function setBootstrapper(Bootstrapper $object);
public function registerTask($name, $callable);
public function getTasks();
}
interface Bootstrapper {
public function setParam($name,$value);