Skip to content

Instantly share code, notes, and snippets.

@bholloway
bholloway / Angular: Thick model, thin controller.js
Last active August 29, 2015 14:06
Use encapsulation to minimise the size of the angular controller.
import IdentityMap from "IdentityMap";
import Course from "studentcentre/Course";
import Topic from "studentcentre/Topic";
import Activity from "studentcentre/Activity";
import ActivityResults from "studentcentre/ActivityResults";
import courseService from "courseService";
import activityResultsService from "activityResultsService";
import myController from "myController;"
@bholloway
bholloway / SMF: Persistence Model.js
Last active August 29, 2015 14:06
Persistence Model and IdentityMap for SMF team and offices
import IdentityMap from "IdentityMap";
import OrderedList from "OrderedList";
import TeamsModel from "c4/TeamsModel";
module TeamsBehaviour from "c4/TeamsBehaviour";
import TeamModel from "c4/TeamModel";
module TeamBehaviour from "c4/TeamBehaviour";
import OfficesModel from "c4/OfficesModel";
module OfficesBehaviour from "c4/OfficesBehaviour";
@bholloway
bholloway / 01. Composition.md
Last active January 10, 2018 17:43
Angular ES6 Cheatsheet

Composition

It is important not to hide composition. It should be done centrally, at the root of the application.

In angular there are 2 different resources we must compose in order to build an application

  • Using a composition root we map directives, controllers, and services into the injector.

  • Using routing we compose views from HTML partials and controllers for each different application state.

@bholloway
bholloway / rework-css.js
Last active August 29, 2015 14:08
rework to find original sass files
var css = require('rework')(css)
.use(require('rework-plugin-url')(function(url){
if (url.slice(0, '/src/css-lib'.length) === '/src/css-lib') {
console.log(url);
return '../..' + url;
} else {
return url;
}
}))
.toString();
@bholloway
bholloway / semverRankingHeuristic.js
Created February 1, 2015 23:43
a text heuristic which allows semver magnitude comparison
/**
* Given a semver string create a heuristic string that ranks the semver in the correct order.
* To do this it applies leading zero padding such that all similar term is the same length across all given semvers.
* @param {Array.<string>} candidates A list of semver strings
* @returns {Array.<string>} A list of heuristics based on the given semvers
*/
module.exports = function semverRankingHeuristic(candidates) {
var maxLengths = [ ];
return candidates
.map(function split(candidate) { // split the semver into terms and find the longest length of similar terms
/**
* Determine the highest SemVersion between a project's bower, npm and angularity configs.
* If the versions are out of sync, update the config files with the highest version.
* Candidates are expected to have a _filename field with the full file path.
* @param {...object} config Any number of candidate configurations
*/
function synchroniseConfigs(config) {
// the list of configurations (copy)
var configurations = Array.prototype.slice.call(config);
/**
* ${NAME} Controller
*
* TODO description of this Controller
*
* @ngInject
* Created by ${USER} on ${DATE}.
*/
import bind from 'util/bind';
var objects = [],
MODULES = {
ContextModule: require('./ContextModule'),
DelegatedModule: require('./DelegatedModule'),
DllModule: require('./DllModule'),
ExternalModule: require('./ExternalModule'),
MultiModule: require('./MultiModule'),
NormalModule: require('./NormalModule'),
RawModule: require('./RawModule')
}
@bholloway
bholloway / index.html
Created December 4, 2015 06:19 — forked from anonymous/index.html
Angular 1.x RxJS test Angular 1.x RxJS test // source https://jsbin.com/cequwu
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<meta name="description" content="Angular 1.x RxJS test">
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.js"></script>
<meta charset="utf-8">
<title>Angular 1.x RxJS test</title>
@bholloway
bholloway / index.html
Created December 4, 2015 11:11 — forked from anonymous/index.html
rxjs delayed subscriber with default rxjs delayed subscriber with default // source https://jsbin.com/panela
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="rxjs delayed subscriber with default">
<meta charset="utf-8">
<title>rxjs delayed subscriber with default</title>
</script>
<script src="https://npmcdn.com/@reactivex/[email protected]/dist/global/Rx.js"></script>
</head>
<body>