Skip to content

Instantly share code, notes, and snippets.

View acorncom's full-sized avatar

David Baker acorncom

View GitHub Profile
@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];

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

namespace common\components;
use \yii\web\UrlManager as BaseUrlManager;
class UrlManager extends BaseUrlManager {
protected $choice;
public function init() {
Component::init();
@acorncom
acorncom / triangle-workflow.md
Created December 22, 2015 22:37 — forked from anjohnson/triangle-workflow.md
Triangle workflows

Triangle Workflows

A triangle workflow involves an upstream project and a personal fork containing a development branch of the project. This configuration makes git pull merge changes from the upstream but git push send local commits to the personal fork.

To set up a project area

  • Fork the project on https://github.com/<project>

If you already cloned the upstream repository

@acorncom
acorncom / router.js
Created October 6, 2016 15:36
New Twiddle
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.route('app', function() {
@acorncom
acorncom / controllers.application-error.js
Last active October 17, 2016 15:56 — forked from amk221/controllers.application.js
Basic loading / error templates
import Controller from 'ember-controller';
export default Controller.extend({
init() {
this._super(...arguments);
console.log('error controller initialised');
}
});
import Ember from 'ember';
import { task, timeout, asyncComputed, emit } from 'ember-concurrency';
export default Ember.Controller.extend({
value: 23,
tweened: asyncComputed('value', function * (v) {
let targetValue = parseInt(v) || 0;
if (targetValue > 100) {
@acorncom
acorncom / controllers.application.js
Last active November 30, 2016 20:45 — forked from diamondo25/controllers.application.js
2.10 'duplicate route error'
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@acorncom
acorncom / router.js
Created December 21, 2016 21:24 — forked from ef4/router.js
deeply nested routes
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('outside', { path: '/' }, function() {
@acorncom
acorncom / travis.yml
Created December 21, 2016 21:37 — forked from ef4/travis.yml
Example of ember-cli-deploy from travis
deploy:
- provider: script
skip_cleanup: true
script: node_modules/.bin/ember deploy development --activate --verbose
on:
branch: master
- provider: script
skip_cleanup: true
script: node_modules/.bin/ember deploy staging --activate --verbose
on: