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 Object { | |
private $__instanceMixins = array(); | |
private static $__classMixins = array(); | |
public function mixinInstanceMethod($class, $method = null) { | |
$reflection = self::reflect($class, $method); | |
$method = $reflection->getName(); | |
$toAppend = self::methodToAppend($reflection); |
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 People extends Iammike_Db_Table_Abstract { | |
protected $_name = 'people'; | |
// $select is an instance of Iammike_Db_Table_Select | |
// The rest of the params are what was passed to the finder | |
public function oldFinder($select) { | |
return $select->where('people.age > 60'); |
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 | |
$people = new People; | |
$young = $people->select()->young(); | |
$youngMale = $young->male(); | |
$youngFemale = $young->female(); | |
$maleWithDocuments = $people->select()->male()->withDocuments(); | |
$publishedBetween2001And2005 = $maleWithDocuments->publishedBetween('2001-01-01 00:00:00', '2005-12-31 23:59:59'); |
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 | |
set_include_path("/home/mike/Downloads/ZendFramework-1.10.7/library/:" . get_include_path()); | |
require_once 'Zend/Loader/Autoloader.php'; | |
$loader = Zend_Loader_Autoloader::getInstance(); | |
$options = array( | |
'host' => 'localhost', | |
'username' => 'root', | |
'password' => '', |
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
-- MySQL dump 10.13 Distrib 5.1.41, for debian-linux-gnu (x86_64) | |
-- | |
-- Host: localhost Database: testing | |
-- ------------------------------------------------------ | |
-- Server version 5.1.41-3ubuntu12.6 | |
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; | |
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; | |
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; | |
/*!40101 SET NAMES utf8 */; |
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
QUERY: SELECT `people`.* FROM `people` WHERE (people.age < 20) AND (people.sex = "m") | |
RESULTS: | |
Name: baby joe bloggs | |
Age: 1 | |
Sex: m | |
------- | |
QUERY: SELECT `people`.* FROM `people` WHERE (people.age < 20) AND (people.sex = "f") | |
RESULTS: | |
Name: baby joanna bloggs |
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
class Range | |
def min | |
first > last ? last : first | |
end | |
def max | |
last > first ? last : first | |
end | |
def clamp(v) |
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
% irb | |
>> require "clamp.rb" | |
=> true | |
>> (0..360).clamp(370) | |
=> 360 | |
>> (360..0).clamp(370) | |
=> 360 | |
>> (360..0).clamp(-10) | |
=> 0 |
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
h = 0 if h < 0 | |
h = 360 if h > 360 | |
s = 0 if s < 0 | |
s = 1.0 if s > 1.0 | |
v = 0 if v < 0 | |
v = 1.0 if v > 1.0 |
OlderNewer