Skip to content

Instantly share code, notes, and snippets.

View speedmax's full-sized avatar

Taylor luk speedmax

View GitHub Profile
array = class {
function(self, data)
for k, v in pairs(data) do
self[k] = v
end
end;
check = function(...)
print(...)
end;
array = class {
length = function() end;
['.length'] = function() end;
}
spec = {
specs = {}, passed = 0, failed = 0, current = nil
}
function spec.report(success, message)
spec.current.success = success
if success then
spec.passed = spec.passed + 1
else
spec.failed = spec.failed + 1
var Class = new Native({
name: 'Class',
initialize: function(properties){
properties = properties || {};
var klass = function(){
for (var property in this) this[property] = $unlink(this[property]);
this.parent = null;
for (var Property in Class.Mutators){
-- global
people = {}
person = class {
function(self, name, age)
self.name, self.age = name, age
table.insert(people, self)
end
-- generic by default
-- current method and property lookup
function instance_protocol:__index(member)
if type(class_object[member]) == 'function' then
return function(...)
return class_object[member](self, ...)
end
elseif type(member) == 'string' and type(class_object['.'..member]) == 'function' then
return class_object['.'..member](self)
elseif type(instance_protocol.___index) == 'function' then
return instance_protocol.___index(self, member)
class = {}
class['@instance_protocol'] = {
-- Dispatch instance methods
__index= function(instance, member) end
}
class['@protocol'] = {
class = class,
<?php
require 'lib/Lambda.php';
require 'lib/shortcuts.php';
function describe($context, $examples) {
$instance = new stdClass;
if (isset($examples['before']) && $before = $examples['before'])
unset($examples['before']);
@speedmax
speedmax / gist:13045
Created September 26, 2008 05:41
AttributeBehaivor - modified find result attribute the DRY way
// AttributeBehaivor
// ==========================
// Simple way to modified your model find results,
// Either be value filtering, building virtual attribute or filtering
// Cleanup your afterFind callbacks
//
// Example
// ----------------------
// class Article extends AppModel {
// $actsAs = array(
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/print.css" type="text/css" media="print">
<!--[if lt IE 7]><link rel="stylesheet" href="http://www.blueprintcss.org/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
<![if lt IE 7]>
<style type="text/css">
div#floating {