Skip to content

Instantly share code, notes, and snippets.

View devdave's full-sized avatar
🌴
On vacation

devdave

🌴
On vacation
View GitHub Profile
@devdave
devdave / metaclass_servicebus.py
Created August 26, 2011 01:27
Proof of concept for tying a metaclass auto-decorator with a service bus
from collections import defaultdict
from functools import wraps
decoratedCalls = defaultdict(list)
def call(name, *args, **kwargs):
print name, args, kwargs
if name in decoratedCalls:
for cb in decoratedCalls[name]:
cb(*args, **kwargs)
@devdave
devdave / wtf.php
Created June 22, 2011 16:37
I am in hell
<?php
class Parent {
public $auto_render = true;
public function after(){
echo ($this->auto_render ? "true" : "false"), \n;
}
}
@devdave
devdave / Doctrin2Search.php
Created June 21, 2011 23:40
Semi-dynamic Doctrine2 search function
<?php
function searchCriteria($criteria){
$cleanCritera = array();
foreach($criteria as $key => $value){
if( isset( $this->_class->fieldNames[$key] ) && !empty($value) ){
$cleanCritera[$key] = $value;
}
}
if(empty($cleanCritera)){