Skip to content

Instantly share code, notes, and snippets.

View enyachoke's full-sized avatar

Emmanuel Nyachoke enyachoke

View GitHub Profile
@enyachoke
enyachoke / _form.php
Created September 14, 2012 11:15
A yii datepicker code
<div class="row">
<?php echo $form->labelEx($model,'End_date'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model'=>$model, 'attribute'=>'End_date',
'options'=>array(
'dateFormat'=>'yy-mm-dd',
'yearRange'=>'-70:+0',
'changeYear'=>'true',
'changeMonth'=>'true',
),
@enyachoke
enyachoke / WebUser.php
Created September 14, 2012 12:39
A three level user access control without rbac.Yii framework
<?php
/**
* Created by JetBrains PhpStorm.
* User: ubeergeek
* Date: 9/12/12
* Time: 12:34 PM
* To change this template use File | Settings | File Templates.
*/
class WebUser extends CWebUser{
private $_user;
@enyachoke
enyachoke / _form.php
Created September 19, 2012 10:50
Yii dropdown.
<div class="row">
<?php echo $form->labelEx($model,'CountryID'); ?>
<?php
echo $form->dropDownList($model,'CountryID',
CHtml::listData(Country::model()->findAll(), 'ID', 'Name'));
?>
<?php echo $form->error($model,'CountryID'); ?>
</div>
@enyachoke
enyachoke / _form.php
Created September 20, 2012 08:57
Timepicker yii
<div class="row">
<?php echo $form->labelEx($model,'Send_Time'); ?>
<?php $form->widget( 'ext.EJuiTimePicker.EJuiTimePicker', array(
'model' => $model,
'attribute' => 'Send_Time',
)); ?>
$criteria = new CDbCriteria;
//Select tip filterin by ID and TipcategoryID
$criteria->condition='ID=:ID AND TipcategoryID=:TipcategoryID';
$criteria->params=array('ID'=>$NextTip,':TipcategoryID'=>$Tip_Alert->TipcategoryID);
@enyachoke
enyachoke / admin.php
Created October 16, 2012 06:31
Replace Id with Name from relationship
array( // display 'status.Name' using an expression
'name'=>'accessLevelID',
'value'=>'$data->level->Name',
),
@enyachoke
enyachoke / gist:4144198
Created November 25, 2012 16:13
Readbean one to many
$invoice = R::dispense('invoice');
$invoice->Customer = 'Greg';
$lineItems = R::dispense('lineitem', 2);
$lineItems[0]->LineNumber = 1;
$lineItems[0]->Amount = 2.50;
$lineItems[1]->LineNumber = 2;
$lineItems[1]->Amount = 10.00;
$invoice->ownLineItem = $lineItems;
<ifModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.html
</ifModule>
<?php
namespace Baofeng\Ucenter;
class OAuth
{
const REQUEST_TOKEN_TTL = 1800;
const TOKEN_TTL = -1; // unlimited
/*
Original code by Nick Brenn
Modified by Marc de Vinck
Make Projects Arduino-based 4WD robot
http://makeprojects.com/Project/Build-your-own-Arduino-Controlled-Robot-/577/1
*/
#include <AFMotor.h>
AF_DCMotor motor1(1, MOTOR12_8KHZ);
AF_DCMotor motor2(2, MOTOR12_8KHZ);
AF_DCMotor motor3(3, MOTOR12_1KHZ);