This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* EventManager, v1.0.1 | |
* | |
* Copyright (c) 2009, Howard Rauscher | |
* Licensed under the MIT License | |
*/ | |
(function() { | |
function EventManager() { | |
this._listeners = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// derived from http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm | |
function map() { | |
emit(1, // Or put a GROUP BY key here | |
{sum: this.value, // the field you want stats for | |
min: this.value, | |
max: this.value, | |
count:1, | |
diff: 0, // M2,n: sum((val-mean)^2) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://groups.google.com/forum/#!topic/angular/hVrkvaHGOfc | |
// jsFiddle: http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/ | |
// author: Pawel Kozlowski | |
var myApp = angular.module('myApp', []); | |
//service style, probably the simplest one | |
myApp.service('helloWorldFromService', function() { | |
this.sayHello = function() { | |
return "Hello, World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple method to detect a mobile device | |
function isMobile(){ | |
return (/iphone|ipod|android|blackberry/).test(navigator.userAgent.toLowerCase()); | |
} | |
// Example usage: | |
if(isMobile()){ | |
console.log('This is a mobile device.'); | |
} else { | |
console.log('This is not a mobile device'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var renderList = []; | |
var timer = 0; | |
var timeToLog = 100; | |
function debugRendered(templateName) { | |
// init renderList | |
renderList[templateName] = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Workaround to make defining and retrieving angular modules easier and more intuitive. | |
*/ | |
(function(angular) { | |
var origMethod = angular.module; | |
var alreadyRegistered = {}; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Building a router</title> | |
<script> | |
// Put John's template engine code here... | |
(function () { | |
// A hash to store our routes: |
Using Microsoft.Owin.Security
along with .NET Web API 2 for authentication on Single Page Applications.
My example is split up into 2 different projects, API which is WebAPI2 project and MyProj which is a basic MVC that contains primarily only JavaScript/CSS/etc and the startup classes.
namespace API
{
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myApp') | |
.run(function ($rootScope) { | |
$rootScope.mixin = function(urls) { | |
if (angular.isUndefined(urls) || urls == '') { | |
return $q.when('no mixin url'); | |
} | |
var deferred = $q.defer(); | |
OlderNewer