This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'eventmachine' | |
EM.run do | |
EM.epoll | |
# Create a channel to push data to | |
EventChannel = EM::Channel.new | |
# The server simply subscribes client connections to the channel on connect, | |
# and unsubscribes them on disconnect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A little Object Relational Mapper in PHP | |
* @author dennis.hotson@gmail.com | |
*/ | |
class Post | |
{ | |
public $title; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
chdir(dirname(__FILE__)); | |
require_once '../lib/kelpie/kelpie_init.php'; | |
require_once('../includes/myframework.php'); | |
class MyApp | |
{ | |
public function __construct() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class DomainObject | |
{ | |
public function __construct($arr = array()) | |
{ | |
foreach($arr as $key => $value) | |
$this->$key = $value; | |
$this->_attributes = new Attributes(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$english = arr( | |
strr('Hello X'), | |
strr('Goodbye X') | |
); | |
$pirate = $english | |
->replace('/Hello/', 'Avast') | |
->replace('/Goodbye/', 'Was good te see ye') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.fn.noisy = function(opacity) { | |
if (typeof(opacity) === 'undefined') { | |
opacity = 0.1; | |
} | |
var wrapper = jQuery(this).wrapInner('<div />').children(); | |
var canvas = document.createElement("canvas"); | |
canvas.width = 100; | |
canvas.height = 100; | |
var ctx = canvas.getContext("2d"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define the 'class' class | |
$class = Obj() | |
->fn('new', function ($class) { | |
$newClass = Obj($class->methods) | |
->fn('new', function($class) { | |
$obj = Obj($class->imethods); | |
$args = func_get_args(); | |
array_shift($args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once 'oo.php' | |
// A subclass of 'class' that lets you define classes in XML ;-) | |
$xmlclass = $class->extend() | |
->fn('load', function($t, $xml) { | |
$class = $t->new(); | |
$doc = new DOMDocument(); | |
$doc->loadXML($xml); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$array = function() { | |
$elements = func_get_args(); | |
$result = fn(function($i) use ($elements) { | |
return $elements[$i]; | |
}); | |
$result->len = function() use ($elements) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Define the 'class' class | |
$class = (new Obj) | |
->fn('new', function() { | |
$newClass = (new Obj($this->methods)) | |
->fn('new', function() { | |
$obj = new Obj($this->imethods); | |
call_user_func_array(array($obj, 'init'), func_get_args()); | |
return $obj; |
OlderNewer