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
<!-- | |
Requires the following Nuget packages: | |
1. MVCFlash | |
2. JQueryUI (combined) | |
3. Fancybox | |
--> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>@ViewBag.Title</title> |
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
---Today | |
SELECT GETDATE() 'Today' | |
----Yesterday | |
SELECT DATEADD(d,-1,GETDATE()) 'Yesterday' | |
----First Day of Current Week | |
SELECT DATEADD(wk,DATEDIFF(wk,0,GETDATE()),0) 'First Day of Current Week' | |
----Last Day of Current Week |
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
--Reset identity to 0 | |
DBCC CHECKIDENT('TableName', RESEED, 0) |
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
//replace all but links | |
/<(?!\/?a(?=>|\s.*>))\/?.*?>/g | |
//validate url | |
/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/ | |
//Validate US phone number | |
/^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/ | |
//Test if a password is strong |
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
<a href="javascript:void(0);" onclick="tinyMCE.execCommand('mceInsertContent', false, '<a href=\'http://www.google.com\'>This is a test</a>');">Insert</a> |
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> | |
/// class for validating a phone number in our MVC Model inheriting from the ValidationAttribute. We mark it with the | |
/// AttributeUsageAttribute <see cref="http://msdn.microsoft.com/en-us/library/tw5zxet9(v=VS.100).aspx"/> To | |
/// tell the compiler that it can only be used on properties or fields | |
/// </summary> | |
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] | |
sealed public class PhoneNumberFormatAttribute : ValidationAttribute | |
{ | |
/// <summary> | |
/// our format 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
public static void LogException(string ErrorDescription) | |
{ | |
// The name of our log in the event logs | |
string Log = “AspNetError”; | |
// Check to see fi the log for AspNetError exists on the machine | |
// If not, create it | |
if ((!(EventLog.SourceExists(Log)))) | |
{ |
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
// The Logger Class | |
public static class Logger | |
{ | |
public static void Log(string message) | |
{ | |
File.AppendAllText("C:\\MyLogFile.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ":\t" + message + Environment.NewLine); | |
} | |
} | |
// Usage |
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 List<string> stringToWordArray(string s) | |
{ | |
List<string> words = new List<string>(); | |
string word; | |
s = s.ToUpper(); | |
s = s.Trim(',', '.', '"', '-', ' ', ':', ';', '\n', '!', '?'); | |
while (s.Length > 0) | |
{ | |
if (s.Contains(' ')) | |
{ |
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 PostalLookup | |
{ | |
public static Postal Find(string countryCode, string postalCode) | |
{ | |
// remove letters from postal code | |
postalCode = Regex.Replace(postalCode, "[^0-9]", ""); | |
if (string.IsNullOrEmpty(postalCode) || postalCode.Length != 4) | |
return null; |
OlderNewer