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
-- typical adjacent list table (parent/child) | |
CREATE TABLE `attribute` ( | |
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, | |
`parent_id` bigint(20) unsigned DEFAULT NULL, | |
PRIMARY KEY (`id`), | |
KEY `parent_id_idx` (`parent_id`) | |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; | |
-- typical closure structure |
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
require 'open3' | |
$CR = "\033[0m" # color reset | |
$red = "\033[1m\033[31m" | |
$green = "\033[1m\033[32m" | |
$yellow = "\033[1m\033[33m" | |
$blue = "\033[1m\033[34m" | |
ssh_options[:forward_agent] = true | |
ssh_options[:paranoid] = false |
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 | |
// components/WidgetFactory.php | |
/** | |
* Custom WidgetFactory class | |
* Provides two new events: | |
* - onBeforeCreateWidget | |
* - onAfterCreateWidget | |
* |
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
package main | |
import "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
x := make([]uint8, dx) | |
y := make([][]uint8, dy) | |
for n := range y { | |
y[n] = x |
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 Available extends CQueue { | |
} | |
class Booked extends CQueue { | |
} | |
class Unavailable extends CQueue { | |
} |
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 | |
$criteria = new \ext\activedocument\Criteria; | |
$criteria->addMapPhase(' | |
function(value, keyData, arg) { | |
if(!value["not_found"]) { | |
var object = Riak.mapValuesJson(value)[0]; | |
if(object.hasOwnProperty(arg.col) && object[arg.col] instanceof Array) { | |
if(object[arg.col].indexOf(arg.val) != -1) | |
return [[value.bucket,value.key]]; | |
} |
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 TestController extends Controller { | |
public function actionIndex() { | |
$person = TestPerson::model()->findByAttributes(array('name' => 'Parent')); | |
if ($person) { | |
CVarDumper::dump(array('person FROM ACTIVEDOCUMENT' => $person->object->data), 10, true); | |
CVarDumper::dump(array('person stepchildren LASTNAME ASC (relation criteria)' => array_map(function($c) { | |
/** |
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 | |
use \ext\activedocument\Criteria; | |
$criteria = new Criteria; | |
$criteria->addColumnCondition(array('slug'=>$slug)); | |
$category = Category::model()->find($criteria); | |
$criteria = new Criteria; | |
$criteria->order='updated ASC'; |
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 | |
use \ext\activedocument\Criteria; | |
$criteria = new Criteria; | |
$criteria->addColumnCondition(array('slug'=>$slug)); | |
$category = Category::model()->find($criteria); | |
$criteria = new Criteria; | |
$criteria->order='updated ASC'; |
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 | |
# In response to: https://www.facebook.com/groups/61355672149/10150626399467150/ | |
$hiddenFields = array('field1'=>'value1', 'field2'=>'value2'); | |
array_map('echo', array_map(array('CHtml', 'hiddenField'), array_keys($hiddenFields), $hiddenFields)); | |
# OR same solution as previous, but with the addition of common html options | |
$hiddenFields = array('field1'=>'value1', 'field2'=>'value2'); |