This file contains hidden or 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 Describe_context_lookup extends SimpleSpec { | |
function prepare() { | |
$this->context = create_context(array( | |
'location' => (object) array( | |
'address' => '1st Jones St', | |
'city' => 'Marry hill', 'state' => 'NSW', | |
'postcode' => 2320 | |
), | |
'document' => new Document( |
This file contains hidden or 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
class Profile < ActiveRecord:Base | |
# Controller pass request object as param | |
# Stat wrapper sends out async request to web services | |
def register_pageview(request) | |
api = "asdf2134asfd2134" | |
@stat = SimpleStat.new(api, request) | |
end | |
# pageviews most likely to be cached |
This file contains hidden or 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 | |
function strip_regex($regex, $delimiter = '/') { | |
return substr($regex, 1, strrpos($regex, $delimiter)-1); | |
} | |
class H2O_RE { | |
static $whitespace, $seperator, $parentheses, $pipe, $name, $filter_end, | |
$string, $i18n_string, $number, $operator, $named_args; | |
function init() { |
This file contains hidden or 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
class ApplicationController < ActionController::Base | |
before_filter :load_site | |
private | |
def load_site | |
if request.host =~ Site.domain_pattern | |
subdomain = current_subdomain | |
else | |
subdomain = find_cname(request.host) | |
end |
This file contains hidden or 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 'spec_helper.php'; | |
class Describe_local_variable extends SimpleSpec { | |
function should_retrive_variable_using_array_interface() { | |
$c = create_context(array( | |
'name' => 'peter', | |
'hobbies' => array('football', 'basket ball', 'swimming'), | |
'location' => array( |
This file contains hidden or 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
<!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 { |
This file contains hidden or 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
// 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( |
This file contains hidden or 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 'lib/Lambda.php'; | |
require 'lib/shortcuts.php'; | |
function describe($context, $examples) { | |
$instance = new stdClass; | |
if (isset($examples['before']) && $before = $examples['before']) | |
unset($examples['before']); |
This file contains hidden or 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
class = {} | |
class['@instance_protocol'] = { | |
-- Dispatch instance methods | |
__index= function(instance, member) end | |
} | |
class['@protocol'] = { | |
class = class, |
This file contains hidden or 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
-- 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) |