Skip to content

Instantly share code, notes, and snippets.

View johnpapa's full-sized avatar
💭
🐺Winter is coming

John Papa johnpapa

💭
🐺Winter is coming
View GitHub Profile
define(function () {
var mapper = {
mapDtosToEntities: mapDtosToEntities
};
return mapper;
function mapDtosToEntities(manager, dtos, entityName) {
// Map an array of DTO's for a type of entity
// to an array of Breeze entities that are managed by
@johnpapa
johnpapa / gist:4770826
Created February 12, 2013 15:51
Partial Entity Mapper. Now accepts the key name (only supports single names) and the additional object property and value pairs you want to map. The latter defaults to {isPartial:true}
define(
function () {
var defaultExtension = { isPartial: true };
var mapper = {
mapDtosToEntities: mapDtosToEntities
};
return mapper;
/**
@johnpapa
johnpapa / gist:d9c8c99d6079493ff840
Created July 19, 2014 03:51
Jasmine Angular Controller test
describe('avengers', function () {
describe('avengers', function () {
var $controller,
dataservice,
$httpBackend,
$location,
$q,
$rootScope,
$route,
scope;
(function () {
var root = $(document.getElementsByTagName('body'));
var watchers = [];
var f = function (element) {
if (element.data().hasOwnProperty('$scope')) {
angular.forEach(element.data().$scope.$$watchers, function (watcher) {
watchers.push(watcher);
});
}
@johnpapa
johnpapa / gist:ffce55d7cda11d52889e
Last active August 29, 2015 14:14
setting resolveAlways
angular
.module('app.core')
.factory('cranker', cranker);
cranker.$inject = ['$http', '$log', '$q'];
function cranker($http, $log, $q) {
var data;
return {
go: function () {
@johnpapa
johnpapa / constant injector thing.js
Last active July 27, 2016 11:01
angular.bootstrap
angular.element(document).ready(bootstrapper);
// to boostrap you need to remove ng-app="app"
function bootstrapper() {
var initInjector = angular.injector(['ng']);
var someval = 'some id'; // here is what you would write in node
// or
// $http call to go get the value
//var $http = initInjector.get('$http');
@johnpapa
johnpapa / shell.controller.spec.with.bard.js
Last active March 4, 2016 00:46
Basic Controller with and without bard.js
/* jshint -W117, -W030 */
describe('layout shell controller', function() {
var controller;
beforeEach(function() {
bard.appModule('app.layout');
bard.inject(this, '$controller', '$log', '$timeout');
controller = $controller('Shell');
});
@johnpapa
johnpapa / gulpfile.js
Last active August 29, 2015 14:22
task that wont debug
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({ lazy: true });
gulp.task('serve-dev', function () {
log(process.argv);
var nodeOptions = {
script: './src/server/app.js',
delayTime: 1,
env: {
'PORT': 8001,
'use strict';
class DashboardController {
static $inject: Array<string> = ['$q', 'dataservice', 'logger'];
constructor(private $q: ng.IQService,
private dataservice: app.core.IDataService,
private logger: blocks.logger.Logger) {
var promises = [this.getMessageCount(), this.getPeople()];
this.$q.all(promises).then(function () {
logger.info('Activated Dashboard View');
@johnpapa
johnpapa / .gitclone
Last active April 14, 2017 13:56
git clone
# A better git clone
# clones a repository, cds into it, and opens it in my editor.
#
# Based on https://github.com/stephenplusplus/dots/blob/master/.bash_profile#L68 by @stephenplusplus
#
# Note: code is already setup as a shortcut to VS Code. Replace with your own editor if different
#
# - arg 1 - url|username|repo remote endpoint, username on github, or name of
# repository.
# - arg 2 - (optional) name of repo