Skip to content

Instantly share code, notes, and snippets.

@deyceg
deyceg / gist:8234b68b1c5ea910258b
Created June 17, 2014 21:20
imagediff node-canvas browserify
it("should parse cpl character printing command and render correctly in canvas", function(done) {
//fs is shimmed by browserify
var buff = fs.readFileSync(__dirname + '/../fixtures/helloworld.png');
/*
node-canvas impl exports Canvas.Image constructor function
browserify canvas shim does not support Canvas.Image
*/
var expected = new Canvas.Image();
describe('services', function() {
beforeEach(module('ibeApp'));
var $injector;
var SessionService;
var mockLocalStorage;
beforeEach(function($provide) {
mockLocalStorage = {
setItem: function(key, value){},
//Load module and configure providers
beforeEach(module("factfind", function($provide) {
$provide.value("customer", {
getPersonalDetails: sinon.stub(),
getRetirementDetails: sinon.stub(),
setPersonalDetails: sinon.spy(),
setRetirementDetails: sinon.spy()
});
$provide.value("engine", {})
@deyceg
deyceg / collection.html
Last active January 31, 2017 21:08
Angular Schema Form Accordion
<div sf-array="form" class="schema-form-array {{form.htmlClass}}"
ng-model="$$value$$" ng-model-options="form.ngModelOptions">
<h3 ng-show="form.title && form.notitle !== true">{{ form.title }}</h3>
<div ng-show="form.description" ng-bind-html="form.description"></div>
<accordion ng-model="modelArray" ww-collection="{{form}}" ng-form="{{form.key.slice(-1)[0]}}">
<accordion-group heading="{{group.title}}" ng-form="{{form.key.slice(-1)[0]}}_{{$index}}"
ng-repeat="item in modelArray track by $index" ww-collection-item >
@deyceg
deyceg / accordion.js
Last active August 29, 2015 14:27
Schema Form Partial Validation
function validateOnCollapse(){
var accordionScope = accordionCtrl.groups[scope.$index];
accordionScope.$watch('isOpen', function(newVal, oldVal) {
if(newVal === false){ //closing
$rootScope.$broadcast('schemaFormValidate', obj);
}
if(accordionForm.$invalid){
accordionScope.isOpen = true;
<QuestionGroup key="parent">
<CollapsablePanelContainer>
<Panel>
<PanelHeaderLayout>
<PanelHeader />
</PanelHeaderLayout>
<PanelContentLayout>
<Question key="child" /> // should render out as parent.child
</PanelContentLayout>
</Panel>
function LibraryCtrl($scope, LibraryService, artists) { //assumming you're favoring $scope over this
$scope.artists = artists || []; //defensive
$scope.albums = [];
$scope.selectedArtist = null;
activate(); //I like to put my activation logic in a function, and call it
function activate() {
$scope.selectedArtist = LibraryService.getSelectedArtist();
<Accordion>
<PanelHeader>Your Risk Illustration</PanelHeader>
<PanelContent>
<Illustration id="risk" /> { /* Dynamically load widget from CDN. Different "house view" loads different widget */ }
</PanelContent>
</Accordion>
var RadioGroupControl=exports.RadioGroupControl=function(props){
'use strict';
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Exemplar = function () {
function Exemplar() {
_classCallCheck(this, Exemplar);
}