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
//Lightweight example (with support for onSuccess and onTimeout). You need to pass callback name within URL if you need it. | |
//At GitHub: https://github.com/sobstel/jsonp.js/blob/master/jsonp.js | |
var $jsonp = (function(){ | |
var that = {}; | |
that.send = function(src, options) { | |
var callback_name = options.callbackName || 'callback', | |
on_success = options.onSuccess || function(){}, | |
on_timeout = options.onTimeout || function(){}, |
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
public ActionResult Test304(string input) | |
{ | |
var requestedETag = Request.Headers["If-None-Match"]; | |
var responseETag = LookupEtagFromInput(input); // lookup or generate etag however you want | |
if (requestedETag == responseETag) | |
return new HttpStatusCodeResult(HttpStatusCode.NotModified); | |
Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate); | |
Response.Cache.SetETag(responseETag); | |
return GetResponse(input); // do whatever work you need to obtain the result |
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
objectToQueryString: function(obj) { | |
var result = []; | |
for (var prefix in obj) { | |
add(prefix, obj[prefix]); | |
} | |
return result.join("&").replace(/%20/g, "+"); | |
function add(key, value) { |
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 extendObject = function (destination, source) { | |
var objectSignature = Object.prototype.toString.call({}); | |
var isPropertyAnObject = function (property) { | |
return Object.prototype.toString.call(property) === objectSignature; | |
}; | |
for (var property in source) { | |
// http://brianflove.com/2013/09/05/javascripts-hasownproperty-method/ | |
if(source.hasOwnProperty(property)) { |
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
// merge an array into another | |
function mergeArray(source, destination) { | |
[].push.apply(destination, source); | |
return destination; | |
} | |
// Is value a function? | |
function isFunction(x) { | |
return "function" == typeof x; | |
} |
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 target = { | |
prop1: "123", | |
prop2: "456", | |
prop3: { | |
A: "1", | |
B: "2" | |
} | |
}; | |
var schema = [ |
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
function node(head, tail) { | |
return [head, tail]; | |
}; | |
function head(stream) { | |
return stream[0]; | |
}; | |
function tail(stream) { | |
var tail = stream[stream.length - 1]; |
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
'use strict'; | |
// # Globbing | |
// for performance reasons we're only matching one level down: | |
// 'test/spec/{,*/}*.js' | |
// use this if you want to recursively match all subfolders: | |
// 'test/spec/**/*.js' | |
module.exports = function (grunt) { |
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
function once(fn) { | |
var returnValue, called = false; | |
return function () { | |
if (!called) { | |
called = true; | |
returnValue = fn.apply(this, arguments); | |
} | |
return returnValue; | |
}; | |
} |
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 data = [{ | |
isActive: "1", | |
logins: 2000, | |
clicks: 1000 | |
}, { | |
isActive: "1", | |
logins: 3000, | |
clicks: 1000 | |
}, { | |
isActive: "1", |
OlderNewer