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.Text.RegularExpressions; | |
using System; | |
const string smallRectangles = "1\n\n2\n\n~~\n\n"; | |
Regex normal = new Regex(Rect.RectanglesPatternShorter, RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); | |
Regex compiled = new Regex(Rect.RectanglesPatternShorter, RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace); | |
Console.WriteLine("normal: " + normal.IsMatch(smallRectangles)); | |
Console.WriteLine("compiled: " + compiled.IsMatch(smallRectangles)); |
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 readonly string RectanglesPattern = @" | |
\A | |
(?=(?<NextPos>[^~]*)) # \k<NextPos> always matches the position *before* the next free tilde. | |
(?: | |
(?: | |
(?<IndexLength>.)+? # Match n characters. We will use rectangle number n in position <Index>. | |
# 0 is not an option - we need some shape to be first, second, third, etc. | |
(?<=\A(?=(?<Index>(?<-IndexLength>.)+)).*) # Capture into <Index> the first n characters. | |
(?<=\A(?<CurrentIndex>\k<Index>).*) # Copy Index into CurrentIndex | |
(?=.*\Z # Ensure <Index> is unique. We cannot use the same rectangle twice |
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; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Data.Common; | |
using System.Data.Entity; | |
using System.Data.SqlClient; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using EntityFramework.Utilities; |
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
body {background-color: dodgerblue;} |
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
// based on https://github.com/oauthjs/express-oauth-server/blob/master/examples/memory/model.js | |
/** | |
* Constructor. | |
*/ | |
function InMemoryCache() { | |
this.clients = [ | |
{ | |
clientId : 'dummy-client-id', | |
clientSecret : 'dummy-client-secret', |
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
// !!! | |
// !!! Do not modify this file, it is automatically generated. Change the .tt file instead. !!! | |
// !!! | |
namespace Your.Mapper | |
{ | |
partial class Mapper | |
{ | |
/// <summary> | |
/// Set <paramref name="target"/> properties by copying them from <paramref name="source"/>. |
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
<#@ template debug="false" hostspecific="false" language="C#" #> | |
<#@ assembly name="System.Core" #> | |
<#@ assembly name="$(TargetPath)" #> | |
<#@ import namespace="System.Collections.Generic" #> | |
<#@ import namespace="System.Linq.Expressions" #> | |
<#@ import namespace="ConsoleApplicationT4So29913514" #> | |
<#@ output extension=".generated.cs" #> | |
<# | |
// Consider including the namespace in the class names. | |
// You only need to change the mappings. |
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
// !!! | |
// !!! Do not modify this file, it is automatically generated. Change the .tt file instead. !!! | |
// !!! | |
namespace Your.Mapper | |
{ | |
partial class Mapper | |
{ | |
/// <summary> | |
/// Set <paramref name="target"/> properties by copying them from <paramref name="source"/>. | |
/// </summary> |
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 | |
# Push State A, Index = 0 | |
(?<StateIdBit0>) | |
(?<StateIdBit1>) | |
(?<StateIdBit2>) | |
(?<StateIdBit3>) | |
(?: | |
(?: | |
(?: | |
# When In State A, Index = 0 |
NewerOlder