This file contains hidden or 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
interface A<T> { | |
something: T | |
} | |
function call(arg: (input: A<void>) => void): () => void; | |
function call<T>(arg: (input: A<T>) => T): (input: T) => void { | |
return {} as any; | |
} | |
interface Input { |
This file contains hidden or 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
https://www.typescriptlang.org/play/index.html#src=interface%20IContext%3CT%3E%20%7B%0D%0A%09input%3A%20any%2C%0D%0A%09state%3A%20any%2C%0D%0A%09output%3A%20T%2C%0D%0A%09services%3A%20any%0D%0A%7D%0D%0A%0D%0Atype%20IRes%20%3D%20IResult%20%7C%20void%0D%0A%0D%0Ainterface%20IResult%20%7B%0D%0A%09success%3A%20((input%3A%20any)%20%3D%3E%20IRes)%2C%0D%0A%09error%3A%20((input%3A%20any)%20%3D%3E%20IRes)%0D%0A%7D%0D%0A%0D%0Aclass%20SignalBuilder%20%7B%0D%0A%09private%20signals%20%3D%20%5B%5D%3B%0D%0A%09dor%3CT%3E(func%3A%20(input%3A%20IContext%3CT%3E)%20%3D%3E%20void)%3A%20SignalBuilderResult%3CT%3E%20%7B%0D%0A%09%09this.signals.push(func)%3B%0D%0A%09%09return%20new%20SignalBuilderResult%3CT%3E(this%2C%20this.signals)%3B%0D%0A%09%7D%0D%0A%09do%3CT%3E(...func%3A%20((input%3A%20IContext%3CT%3E)%20%3D%3E%20void)%5B%5D)%3A%20SignalBuilder%20%7B%0D%0A%09%09for%20(var%20item%20of%20func)%20this.signals.push(item)%3B%0D%0A%09%09return%20this%3B%0D%0A%09%7D%0D%0A%09build()%20%7B%0D%0A%09%09return%20this.signals%3B%0D%0A%09%7D |
This file contains hidden or 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 HStore : Dictionary<string, string> | |
{ | |
private static readonly Regex QuotedString = new Regex(@"""[^""\\]*(?:\\.[^""\\]*)*""", RegexOptions.Compiled); | |
private static readonly Regex UnquotedString = new Regex(@"(?:\\.|[^\s,])[^\s=,\\]*(?:\\.[^\s=,\\]*|=[^,>])*", RegexOptions.Compiled); | |
private static readonly Regex HstoreKeyPairMatch = new Regex(string.Format(@"({0}|{1})\s*=>\s*({0}|{1})", QuotedString, UnquotedString), RegexOptions.Compiled); | |
private static readonly Regex KeyReg = new Regex(@"^""(.*)""$", RegexOptions.Compiled); | |
private static readonly Regex KeyReg2 = new Regex(@"\\(.)", RegexOptions.Compiled); | |
private static readonly Regex EscapeRegex = new Regex(@"[=\s,>]", RegexOptions.Compiled); | |
private static readonly Regex EscapeRegex2 = new Regex(@"([""\\])", RegexOptions.Compiled); |
This file contains hidden or 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 EnumerableReader : TextReader | |
{ | |
private readonly char _separator; | |
private readonly IEnumerator<string> _enumerator; | |
private string _s; | |
private int _pos; | |
private readonly bool _useSeperator; | |
private bool _enumeratorDisposed = false; | |
public EnumerableReader(IEnumerable<string> lines) : this(lines, '\n') |
This file contains hidden or 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 conventions = FluentMappingConfiguration.Scan(scanner => | |
{ | |
scanner.Assembly(typeof(User).Assembly); | |
scanner.IncludeTypes(x=>x.Namespace.StartsWith(typeof(User).Namespace)); | |
scanner.TablesNamed(x => Inflector.MakePlural(x.Name).BreakUpCamelCaseUsing("_").ToLower()); | |
scanner.Columns.Named(x => x.Name.BreakUpCamelCaseUsing("_").ToLower()); | |
scanner.PrimaryKeysNamed(x => x.Name.BreakUpCamelCaseUsing("_").ToLower() + "_id"); | |
scanner.OverrideMappingsWith(new OverrideMappings()); | |
}); |
This file contains hidden or 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
<img src="~/test.aspx" /> | |
// This complies to | |
Response.Write("<img src=\""); | |
Response.Write(SiteResource("~/test.aspx")); | |
Response.Write("\" />"); | |
// The problem is that the SiteResource method uses Request.ApplicationPath under the covers, but we are doing some | |
// URL rewriting so the URL is not the same as the ApplicationPath. |
This file contains hidden or 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 database deadlocktest | |
go | |
SELECT snapshot_isolation_state_desc from sys.databases where name='deadlocktest' | |
go | |
--ensure this is off: If Not do the following alters | |
ALTER DATABASE deadlocktest | |
SET ALLOW_SNAPSHOT_ISOLATION OFF | |
go |
This file contains hidden or 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 BindingExtensions | |
{ | |
public static HtmlTag Data(this HtmlTag html, Dictionary<string, object> dataattrs) | |
{ | |
foreach (var item in dataattrs) | |
{ | |
html.Data(item.Key, item.Value); | |
} | |
return html; | |
} |
This file contains hidden or 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 FluentValidationKeys : StringToken | |
{ | |
public static StringToken CREDITCARD_ERROR = new FluentValidationKeys("'{PropertyName}' is not a valid credit card number."); | |
public static StringToken EMAIL_ERROR = new FluentValidationKeys("'{PropertyName}' is not a valid email address."); | |
public static StringToken EQUAL_ERROR = new FluentValidationKeys("'{PropertyName}' should be equal to '{PropertyValue}'."); | |
public static StringToken EXACT_LENGTH_ERROR = new FluentValidationKeys("'{PropertyName}' must be {MaxLength} characters in length. You entered {TotalLength} characters."); | |
public static StringToken EXCLUSIVEBETWEEN_ERROR = new FluentValidationKeys("'{PropertyName}' must be between {From} and {To} (exclusive). You entered {Value}."); | |
public static StringToken GREATERTHAN_ERROR = new FluentValidationKeys("'{PropertyName}' must be greater than '{ComparisonValue}'."); | |
public static StringToken GREATERTHANOREQUAL_ERROR = new FluentValidationK |
This file contains hidden or 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 HomeController : DelegatingControllers.DelegatingController | |
{ | |
public ActionResult Edit(UserEditQueryModel model) | |
{ | |
var vm = Invoker.Execute<UserEditQueryModel, UserEditViewModel>(model); | |
return View(vm); | |
} | |
public ActionResult Edit(UserEditInputModel model) |
NewerOlder