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
// Usage: myCollection.Page(pageNumber, pageSize); | |
public static class IEnumerableExtension { | |
public static IEnumerable<T> Page<T>(this IList<T> source, int pageNumber, int pageSize) | |
{ | |
return source.Skip((pageNumber - 1) * pageSize).Take(pageSize); | |
} | |
} |
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 class StringExtension | |
{ | |
public static string SplitByCaps(this string value) | |
{ | |
var r = new Regex(@" | |
(?<=[A-Z])(?=[A-Z][a-z]) | | |
(?<=[^A-Z])(?=[A-Z]) | | |
(?<=[A-Za-z])(?=[^A-Za-z])", RegexOptions.IgnorePatternWhitespace); | |
return r.Replace(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
using System; | |
using System.Collections.Generic; | |
using System.Net; | |
using System.Net.Mail; | |
using SendGridMail; | |
public class SendGridEmailService | |
{ | |
public bool Send(string toAddress, string fromAddress, string fromAddressAlias, string subject, string body) |
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 class HtmlHelperExtensions | |
{ | |
public static MvcHtmlString SerializeToJson(this HtmlHelper helper, string javascriptVariableName, | |
object objectToSerialize) | |
{ | |
if (javascriptVariableName.Contains(" ")) | |
throw new Exception("Invalid JS variable name"); | |
return | |
MvcHtmlString.Create(String.Format("var {0}={1};", javascriptVariableName, |
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
<div id='result'></div> |
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
<h4>Basic Knockout Binding Demo</h4> | |
<div> | |
<span data-bind="text:firstName"></span> | |
<span> </span><span data-bind="text:lastName"></span> | |
</div> |
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 class EnumUtil { | |
public static IEnumerable<T> GetValues<T>() { | |
return Enum.GetValues(typeof(T)).Cast<T>(); | |
} | |
public static T ParseEnum<T>( string value ) | |
{ | |
return (T) Enum.Parse( typeof( T ), value, 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
IF "$(BuildingInsideVisualStudio)"=="true" goto :local | |
// this runs in automated build | |
goto :exit | |
:local | |
// this runs in Visual Studio | |
:exit |
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
if (!String.format) { | |
String.format = function(format) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
return format.replace(/{(\d+)}/g, function(match, number) { | |
return typeof args[number] != 'undefined' | |
? args[number] | |
: match | |
; | |
}); | |
}; |
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
#results { | |
font-size:16px; | |
color:red; | |
font-weight:bold; | |
} |
OlderNewer