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'; | |
var gameOfLife; | |
var NAMESPACE = { | |
// helper data structure - might not be most efficient but works | |
Infinite2dBooleanArray: function() { | |
var cells = new Array(); | |
this.getValue = function(x, y) { | |
if (cells[x]) { | |
return cells[x][y] || false; |
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
internal static System.Web.HttpContext FakeHttpContext() | |
{ | |
var httpRequest = new System.Web.HttpRequest("", "http://localhost/", ""); | |
var stringWriter = new System.IO.StringWriter(); | |
var httpResponse = new System.Web.HttpResponse(stringWriter); | |
var httpContext = new System.Web.HttpContext(httpRequest, httpResponse); | |
var sessionContainer = new System.Web.SessionState.HttpSessionStateContainer( | |
"id", new System.Web.SessionState.SessionStateItemCollection(), | |
new System.Web.HttpStaticObjectsCollection(), 10, true, |
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 class ObjectFromNameValueCollectionConverter | |
{ | |
public static T CreateFromNameValueCollection<T>(NameValueCollection nameValueCollection, string keyPrefix = "") | |
where T : new() | |
{ | |
var target = new T(); | |
Type type = target.GetType(); | |
foreach (var key in nameValueCollection.AllKeys.Where(x => x.StartsWith(keyPrefix))) | |
{ | |
var propertyName = key.Substring(keyPrefix.Length); |
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
using System; | |
using System.Collections.Generic; | |
using System.Collections.Specialized; | |
using System.ComponentModel; | |
using System.Configuration; | |
using System.Linq; | |
internal static class AppSettingsReader | |
{ | |
/// <summary> |
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
// credit: http://stackoverflow.com/a/2759898/487544 | |
public static string RenderRazorViewToString(this Controller controller, string viewName, object model) | |
{ | |
controller.ViewData.Model = model; | |
using (var sw = new StringWriter()) | |
{ | |
var viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName); | |
var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw); | |
viewResult.View.Render(viewContext, sw); | |
viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View); |
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
/*-- js/nojs with Modernizr --*/ | |
html.js .js-hide, .no-js-hide | |
{ | |
display: none; | |
} | |
html.js .no-js-hide | |
{ | |
display: inherit; | |
} |
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
/*-- to detect mobile size in js --*/ | |
/* credit: http://bricss.net/post/22198838298/easily-checking-in-javascript-if-a-css-media-query-has */ | |
function isMobileSize() { | |
var size = window.getComputedStyle(document.body, ':after').getPropertyValue('content'); | |
return size.indexOf('mobile') != -1; | |
} | |
/* | |
@media (max-width: 767px) | |
{ | |
body:after |
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
// credit: @mcintyre321 | |
public static class ModelStateDictionaryExtensions | |
{ | |
public static bool Try(this ModelStateDictionary ms, string key, Action action) | |
{ | |
try | |
{ | |
action(); | |
return true; | |
} |
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 static string AbsoluteAction(this UrlHelper url, | |
string actionName, string controllerName, object routeValues = null, bool isHttps = false) | |
{ | |
return url.Action(actionName, controllerName, routeValues, "http" + (isHttps ? "s" : "")); | |
} |
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> | |
/// adds the active class if the link's action & controller matches current request | |
/// </summary> | |
public static MvcHtmlString MenuActionLink(this HtmlHelper htmlHelper, | |
string linkText, string actionName, string controllerName, | |
object routeValues = null, object htmlAttributes = null, | |
string activeClassName = "active") | |
{ | |
IDictionary<string, object> htmlAttributesDictionary = | |
HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); |
OlderNewer