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
(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 / 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');
my.router = (function () {
// Client-side routes
Sammy(function () {
this.get('#:folder', function () {
amplify.request({ // This would instead call the data service, not amplify
resourceId: "getFolder",
data: { folder: this.params.folder },
success: my.webmailVM.displayFolderCallback, // I don't like that it calls the VM.
error: function () {
toastR.error('oops!');
<%@ Page
Inherits="ViewPage<GenericPresentationModel<object>>"
Language="C#"
MasterPageFile="~/Views/Shared/Site.master" %>
<asp:Content runat="server" ContentPlaceHolderID="ViewHead">
<%
Bundles.Reference("Content/New/Styles/App.less");
Bundles.Reference("Content/New/Scripts");
Bundles.AddPageData("accountData", Model.Model);
var Attendance = function () {
var self = this;
self.datacontext = datacontext;
self.sessionId = ko.observable();
self.personId = ko.observable();
// id is string compound key {personId,sessionId} like "3,10"
self.id = ko.computed({
read: function () {
return attendanceMakeId(self.personId(), self.sessionId());
@johnpapa
johnpapa / partial main.js
Created June 18, 2012 03:41
partial main.js
requirejs([
// 3rd party libraries
'json2',
'jquery',
'underscore',
'moment',
'sammy',
'amplify',
'ko',
'toastr',
@johnpapa
johnpapa / DirtyFlag
Created June 18, 2012 03:44
DirtyFlag
define(['ko'], function(ko) {
// (function (ko) {
ko.DirtyFlag = function (objectToTrack, isInitiallyDirty, hashFunction) {
hashFunction = hashFunction || ko.toJSON;
var
_objectToTrack = objectToTrack,
_lastCleanState = ko.observable(hashFunction(_objectToTrack)),
_isInitiallyDirty = ko.observable(isInitiallyDirty),
@johnpapa
johnpapa / main.js for Jim
Created June 26, 2012 17:44
main.js for Jim
requirejs.config({
// script default location
baseUrl: 'scripts/app',
// shim in the libs that don't know define.amd (excluding extensions)
shim: {
'amplify': { deps: [], exports: 'amplify' },
// jquery 1.7.x understands define; no shim needed.
'jquery.ui': ['jquery'],