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
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); | |
public static double GetEpochTicks(this DateTime dateTime) | |
{ | |
return dateTime.Subtract(Epoch).TotalMilliseconds; | |
} |
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 ExpandoObject ToExpandoObject(this object obj) | |
{ | |
if (obj == null) | |
throw new ArgumentNullException(nameof(obj)); | |
IDictionary<string, object> expando = new ExpandoObject(); | |
foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(obj.GetType())) | |
expando.Add(property.Name, property.GetValue(obj)); |
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 IEnumerable<TSource> Distinct<TSource>( | |
this IEnumerable<TSource> source, Func<TSource, object> predicate) | |
{ | |
return from item in source.GroupBy(predicate) select item.First(); | |
} |
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 ActionStartsWithGetConstraint : IRouteConstraint | |
{ | |
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) | |
{ | |
var action = values["action"]; | |
if (action == null) | |
{ | |
return 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
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. | |
Parser Error Message: Invalid or missing attributes found in the tagPrefix entry. For user control, you must also specify 'tagName' and 'src'. For custom control, you must also specify 'namespace', and optionally 'assembly'. |
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 DateTime? TryGetAssemblyCreationDate(Assembly assembly) | |
{ | |
try | |
{ | |
return System.IO.File.GetCreationTime(assembly.Location); | |
} | |
catch | |
{ | |
return null; | |
} |
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 FileSizeHelper | |
{ | |
private static readonly string[] Units = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; | |
private static string GetReadableFileSize(long size) // Size in bytes | |
{ | |
int unitIndex = 0; | |
while (size >= 1024) | |
{ | |
size /= 1024; |
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
console.log($().jquery); // Show original jQuery-version | |
// Closure | |
var $gs = $.getScript; | |
// http://api.jquery.com/jQuery.noConflict/ | |
// jQuery.noConflict( [removeAll] ) | |
// removeAll: A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). | |
$.noConflict(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
var isNumber = function(number) { | |
return !isNaN(parseFloat(number)) && isFinite(number); | |
}; | |
var isNumberOrEmpty = function(number) { | |
number = (number || 0).toString().replace(' ', '').replace(',', '.'); | |
return !isNaN(parseFloat(number)) && isFinite(number); | |
}; |