Skip to content

Instantly share code, notes, and snippets.

View intel352's full-sized avatar

Jonathan Langevin intel352

  • Elon, NC
  • 00:25 (UTC -04:00)
View GitHub Profile
@intel352
intel352 / gist:1186453
Created September 1, 2011 15:44 — forked from gfrison/gist:1186421
app.config
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
[
%% Riak Core config
{riak_core, [
%% Default location of ringstate
{ring_state_dir, "data/ring"},
%% http is a list of IP addresses and TCP ports that the Riak
%% HTTP interface will bind.
<?php
$ordersForShipping=new CActiveDataProvider( Orders::model()->with(array(
'cart'=>array(
/*
* Ensure occurs in same query
*/
'together'=>true,
'joinType'=>'INNER JOIN',
'with'=>array(
@intel352
intel352 / gist:1696924
Created January 29, 2012 03:00
CHtml::hiddenFields
<?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');
@intel352
intel352 / gist:1995082
Created March 7, 2012 18:49
Suggest solution to search an object's array in Riak, using ActiveDocument + js map function
<?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';
@intel352
intel352 / gist:2029327
Created March 13, 2012 15:07
Suggest solution to search an object's array in Riak, using ActiveDocument + js map function
<?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';
@intel352
intel352 / TestController.php
Created March 14, 2012 01:06
Example usage of ActiveDocument
<?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) {
/**
@intel352
intel352 / find.php
Created April 2, 2012 14:56
Remove from relation range and search
<?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]];
}
@intel352
intel352 / gist:3223862
Created August 1, 2012 05:04
Some Yii-based code to group contiguous array entries
<?php
class Available extends CQueue {
}
class Booked extends CQueue {
}
class Unavailable extends CQueue {
}
@intel352
intel352 / answer_pic.go
Created September 17, 2012 14:45 — forked from tetsuok/answer_pic.go
An answer of the exercise: Slices on a tour of Go
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
@intel352
intel352 / WidgetFactory.php
Last active September 20, 2019 02:18
Yii => custom WidgetFactory, adds onBeforeCreateWidget, onAfterCreateWidget events. An example of how the custom class can be used has been provided as well, in the process solving a typical Yii issue, regarding how to set the default pagesize for widgets that use dataproviders (due to dataproviders initializing pagination, by which widget pager…
<?php
// components/WidgetFactory.php
/**
* Custom WidgetFactory class
* Provides two new events:
* - onBeforeCreateWidget
* - onAfterCreateWidget
*