Download and install ResEx at http://resex.codeplex.com/.
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.Configuration; | |
using System.Diagnostics; | |
using System.Diagnostics.CodeAnalysis; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; |
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
package main | |
import "fmt" | |
func main() { | |
//nCr | |
n := 7 | |
r := 2 | |
c := BinCoeff(n, r) | |
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 ToSlug(this string target) | |
{ | |
var pattern = @"[^0-9a-zA-Z]+"; | |
return Regex.Replace(target, pattern, "-") | |
.Trim('-') | |
.ToLowerInvariant(); | |
} |
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 (user.IsGoldPartner()) | |
{ | |
// do something | |
} | |
public class User | |
{ | |
public int PostedPostCount { get; set; } | |
public DateTime LastActivityDate { get; set; } | |
public bool IsGoldPartner() |
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
[TestClass] | |
public class DateTimeExtensionTest | |
{ | |
[TestMethod] | |
public void FiveMinAgoShouldBeBeforeCurrent() | |
{ | |
var current = DateTime.Now; | |
var fiveMinAgo = current.AddMinutes(-5); | |
Assert.IsTrue(fiveMinAgo.IsBefore(current)); |
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
[TestMethod] | |
public void ToSlugShouldReturnJustSlug() | |
{ | |
var value = "^&*#$Slug testing ?? @3 with--- some-tokens!."; | |
var expected = "slug-testing-3-with-some-tokens"; | |
var actual = value.ToSlug(); | |
Assert.AreEqual(expected, actual); | |
} |
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 (user.PostedPostCount > 1000 | |
&& user.LastActivityDate >= DateTime.Today.AddMonths(-3)) | |
{ | |
// do something | |
} |
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
// Is it Gold Partner? | |
if (user.PostedPostCount > 1000 | |
&& user.LastActivityDate >= DateTime.Today.AddMonths(-3)) | |
{ | |
// do something | |
} |
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 DateTimeExtensions | |
{ | |
public static bool IsAfter(this DateTime current, DateTime value) | |
{ | |
return current > value; | |
} | |
public static bool IsBefore(this DateTime current, DateTime value) | |
{ | |
return current < value; |
OlderNewer