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 immutabilly(props) { | |
Object.keys(props).forEach(key => { | |
const prop = props[key]; | |
if (prop === Object(prop)) { | |
immutabilly(prop); | |
} | |
Object.defineProperty(props, key, { | |
enumerable: true, | |
get: () => prop, | |
set: () => {throw new Error(`Illegal assignment to immutable property '${key}'`);}, |
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
/* | |
* childManagement | |
* =============== | |
*/ | |
void function() { | |
var childrenKey = '_children'; | |
/* | |
* Creates a private collection for child views on the receiver if one |
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
/** | |
* Test code speed. | |
* | |
* timeTest('#forEach() test', 10000, function(count) { | |
* someArray.forEach(function(){}); | |
* }); | |
*/ | |
function timedTest(name, count, test) { | |
if (count !== +count) throw new TypeError('count must be a number'); | |
// Make sure we have a uint to avoid infinite loop. |
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
"------------------------" | |
"PATHOGEN PLUGIN SETTINGS | |
"------------------------" | |
call pathogen#runtime_append_all_bundles() | |
"execute pathogen#infect() | |
"------------------------" | |
" My Settings | |
"------------------------" |
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
/* | |
* Creates a namespace based upon a string representation of a namespace. | |
* Adapted from a similar function in JavaScript Patterns by Stoyan Stefanov. | |
* | |
* @param {String} ns String representation of namespace. Eg, 'foo.bar.baz.goo' | |
* @returns {Object} Last object created in the namespace. | |
*/ | |
void function() { | |
var root = 'myapp'; |
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
/// <summary> | |
/// Returns the rendered HTML for a partial view. | |
/// </summary> | |
/// <param name="partial">Path to partial template.</param> | |
/// <param name="model"></param> | |
/// <returns></returns> | |
protected string RenderPartialToString(string partial, object model) | |
{ | |
this.ViewData.Model = model; | |
using (var sw = new StringWriter()) |
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 adder = function(precision) { | |
precision |= 0; | |
return function() { | |
var sum = 0; | |
var len = arguments.length; | |
while (len--) sum += (arguments[len] * precision) | 0; | |
return sum / precision; | |
}; | |
}; |
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
/** | |
* range(2, 6) // [2,3,4,5,6] | |
* range(5).to(8) // [5,6,7,8] | |
* range(4).until(10) // [4,5,6,7,8,9] | |
*/ | |
var range = function(s, e) { | |
if (e == null) { | |
return { | |
to: function(e) { |
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
/** | |
* Prints an element and its contents. | |
* jQuery free version of Ben Nadel's jQuery plugin. | |
* http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm | |
* | |
* @param {HTMLElement} el | |
* @returns {undefined} | |
*/ | |
function printElement(el) { | |
var csslinks = document.getElementsByTagName('link'); |
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
[HttpPost] | |
public ActionResult Create(FormCollection collection) | |
{ | |
var username = collection.Fetch("username", "anonymous"); | |
// username will equal "anonymous" if it was not submitted | |
} | |
// VERSUS: | |
[HttpPost] |
NewerOlder