Skip to content

Instantly share code, notes, and snippets.

View acorncom's full-sized avatar

David Baker acorncom

View GitHub Profile
namespace common\components;
use \yii\web\UrlManager as BaseUrlManager;
class UrlManager extends BaseUrlManager {
protected $choice;
public function init() {
Component::init();

FiniteStateMachine Trait

Add a DSL to the PHP Finite package, borrowed from the Ruby StateMachine gem.

Usage

In your Stateful Class, add the stateMachineConfig() method and call initStateMachine() method at initialization (__contruct() method).

Example

@acorncom
acorncom / fracToDeci.js
Last active August 29, 2015 14:00 — forked from drifterz28/fracToDeci.js
Updated to allow full whole numbers and then a fraction
function toDeci(fraction) {
var result,wholeNum=0, frac, deci=0;
if(fraction.search('/') >=0){
if(fraction.search('-') > 0){
var wholeNum = fraction.split('-');
frac = wholeNum[1];
wholeNum = parseInt(wholeNum,10);
}else if(fraction.search(' ') > 0){
var wholeNum = fraction.split(' ');
fraction = wholeNum[1];