Skip to content

Instantly share code, notes, and snippets.

View rolaveric's full-sized avatar

Jason Stone rolaveric

View GitHub Profile
@rolaveric
rolaveric / mixinSchema.json
Created March 28, 2015 02:29
Example of using "allOf" to make JSON Schema mixins
{
"definitions": {
"nameMixin": {
"type": "object",
"properties": {
"nameFirst": {"type": "string"},
"nameLast": {"type": "string"}
},
"required": ["nameFirst", "nameLast"]
},
@rolaveric
rolaveric / relationship.js
Created March 28, 2015 02:04
Example of a relationship definition for JSON Schema design
/*
For this schema, each object's relationships are defined as an object under
a "links" property.
Each property of that object is the name of the relationship, and the value
is a single object with the "type" and "id" of the related object.
For "to-many" relationships, the value can be an array of the same objects.
*/
var data = {
"articles": [{
"id": "article1",
@rolaveric
rolaveric / flatData.json
Created March 28, 2015 01:38
Example for JSON Schema design article
{
"articles": [{
"id": "article1",
"links": {
"author": {"type": "people", "id": "person1"}
}
}],
"people": [{
"id": "person1",
"phoneNumber": "1234"
@rolaveric
rolaveric / view1.spec.js
Last active August 29, 2015 14:13
An AngularJS unit test changed to use ES6
import 'angular';
import 'angular-route';
import 'angular-mocks';
import './view1';
describe('myApp.view1 module', function() {
beforeEach(angular.mock.module('myApp.view1'));
describe('view1 controller', function(){
@rolaveric
rolaveric / karma-systemjs.conf.js
Created January 21, 2015 10:07
Snippet of a Karma configuration using karma-systemjs
// Add 'karma-systemjs' to the list of plugins
plugins: ['karma-systemjs', ...],
// Add 'systemjs' to the list of frameworks
frameworks: ['systemjs', 'jasmine'],
// Move all the `files` to `systemjs.files`
files: [],
systemjs: {
@rolaveric
rolaveric / es6Bundle.html
Created January 21, 2015 10:06
Example HTML for loading a bundle from systemjs-builder
<script src="bower_components/traceur-runtime/traceur-runtime.min.js"></script>
<script src="bundle.js"></script>
@rolaveric
rolaveric / bundle.js
Created January 21, 2015 10:04
Example of how to bundle ES6 modules using systemjs-builder for production
var builder = require('systemjs-builder'),
path = require('path');
// load SystemJS config from file
builder.loadConfig('./app/system.config.js')
.then(function() {
// Change baseURL to match the file system
builder.config({ baseURL: path.resolve('./app') });
// Build a self-executing bundle (ie. Has SystemJS built in and auto-imports the 'app' module)
@rolaveric
rolaveric / es6Imports.js
Last active August 29, 2015 14:13
Example of declaring all module imports with ES6
'use strict';
import 'angular';
import 'angular-route';
import './components/version/version';
import './components/version/interpolate-filter';
import './components/version/version-directive';
import './view1/view1';
import './view2/view2';
// Declare app level module which depends on views, and components
@rolaveric
rolaveric / systemjsAsync.html
Last active August 29, 2015 14:13
HTML for loading modules through SystemJS asynchronously
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script src="bower_components/traceur/traceur.js"></script>
<script src="bower_components/es6-module-loader/dist/es6-module-loader.js"></script>
<script src="bower_components/system.js/dist/system.js"></script>
<script src="system.config.js"></script>
<script>
System.import('app').then(function() {
angular.bootstrap(document, ['myApp']);
});
@rolaveric
rolaveric / system.config.js
Last active August 29, 2015 14:13
Example of a SystemJS configuration file
// Configure module loader
System.config({
baseURL: '/app/',
// Set paths for third-party libraries as modules
paths: {
'angular': 'bower_components/angular/angular.js',
'angular-route': 'bower_components/angular-route/angular-route.js'
}
});