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 UsingDisplayAttributeOnEnum | |
{ | |
private void Main() | |
{ | |
IEnumerable<SelectListItem> result = typeof (Genre).GetItems(); | |
} | |
} | |
public enum Genre | |
{ |
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.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Gists | |
{ | |
public partial class Utilities | |
{ | |
public void Main() | |
{ |
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
static void Main(string[] args) | |
{ | |
const string root = @"C:\aspProjects\"; | |
const string path = @"Folder1\Page1.asp"; | |
File.WriteAllText(@"C:\combined.asp", GetLines(root, path, true)); | |
Console.WriteLine("{0} include files processed.", _counter); | |
} | |
private static int _counter; | |
private static string GetLines(string root, string path, bool includePath = 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
String.prototype.Trim = function(trimCharacter) { | |
var start = 0; | |
var end = this.length; | |
if (this.indexOf(trimCharacter) === 0) start = 1; | |
if (this.lastIndexOf(trimCharacter) == this.length - 1) end = this.length - 1; | |
var trimmedData = this.slice(start, end); | |
return trimmedData; | |
}; | |
String.prototype.TrimStart = function trimStart(trimCharacter) { |
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
CREATE FUNCTION [dbo].[Split] ( @delimiter VARCHAR(2), @string VARCHAR(max)) | |
RETURNS @table TABLE ( value VARCHAR(max) ) | |
BEGIN | |
DECLARE @nextString VARCHAR(max) | |
DECLARE @position INT, @nextPosition INT | |
SET @nextString = '' | |
SET @string = @string + @delimiter | |
SET @position = charindex(@delimiter, @string) |
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
/* | |
RESULT | |
====== | |
Adding two values: 16 | |
Subtracting two values: 6 | |
*/ | |
void Main() | |
{ | |
//creating the class which contains the methods |
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
/* | |
RESULT | |
====== | |
Received event. Shape area is now 10201.86 | |
Drawing a circle | |
Received event. Shape area is now 49 | |
Drawing a rectangle | |
Press enter to 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
using System; | |
public static class DateTimeConverters | |
{ | |
public static long ToJavaScript(this DateTime value) | |
{ | |
var epoch = new TimeSpan(new DateTime(1970, 1, 1, 0, 0, 0, 0).Ticks); | |
DateTime time = value.Subtract(epoch); | |
return (time.Ticks / 10000); | |
} |
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; | |
public static class DateTimeConverters | |
{ | |
public static DateTime CombineDateAndTime(DateTime dateValue, DateTime timeValue) | |
{ | |
return new DateTime(dateValue.Year, dateValue.Month, dateValue.Day, timeValue.Hour, timeValue.Minute, timeValue.Second); | |
} | |
} |
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
// resource https://gist.github.com/4017806 | |
using System; | |
using System.Text.RegularExpressions; | |
public static class StringConverters | |
{ | |
public static string[] SplitCrLf(this string input) | |
{ | |
return new Regex(string.Format("{0}?{1}", ControlChars.CarriageReturn, ControlChars.LineFeed)).Split(input); |