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 input = "Example task section 1 section tomorrow section tagone tagtwo tagthree tagfour"; | |
// regex altered slightly from question | |
var r = new Regex(@"^([\w ]+) section (\d) section (\w+) section(?: (\w+))+$"); | |
var g = r.Match(input).Groups; | |
var output = $"{g[1]} !{g[2]} ^{g[3]} " + | |
string.Join(" ", g[4].Captures.Cast<Capture>().Select(x => "#" + x)); | |
// output: "Example task !1 ^tomorrow #tagone #tagtwo #tagthree #tagfour" |
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
using System; | |
namespace UnicodeRulez | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
Console.WriteLine("Cheese".StartsWith("C͏ͿԤԥԨԩԪԫԬԭԮԯՠֈ֍֎֏ׯ؝ـ߽߾߿ࡠࡡࡢࡣࡤࡥࡦࡧࡨࡩࡪࡰࡱࡲࡳࡴࡵࡶࡷࡸࡹࡺࡻࡼࡽࡾࡿࢀࢁࢂࢃࢄࢅࢆࢇ࢈ࢉࢊࢋࢌࢍࢎ࢙࢚࢛࢘࢜࢝࢞࢟ࢠࢡࢢࢣࢤࢥࢦࢧࢨࢩࢪࢫࢬࢭࢮࢯࢰࢱࢲࢳࢴࢵࢶࢷࢸࢹࢺࢻࢼࢽࢾࢿࣀࣁࣂࣃࣄࣅࣆࣇࣈࣉࣰࣱࣲ࣏࣐࣑࣒࣓ࣣࣦࣩ࣭࣮࣯ࣶࣹࣺ࣊࣋࣌࣍࣎ࣔࣕࣖࣗࣘࣙࣚࣛࣜࣝࣞࣟ࣠࣡ࣤࣥࣧࣨ࣪࣫࣬ࣳࣴࣵࣷࣸࣻࣼࣽࣾࣿऀॸঀ৻ৼ৽৾੶૰ૹૺૻૼ૽૾૿୕ఀఄఴ఼ౚౝ౷ಀಁ಄ೝೳഀഁഄ഻഼൏ൔൕൖ൘൙൚൛൜൝൞ൟ൶൷൸ඁ෦෧෨෩෪෫෬෭෮෯ຆຉຌຎຏຐຑຒຓຘຠຨຩຬ຺໌໎ໞໟჇჍჽჾჿᏵᏸᏹᏺᏻᏼᏽᛱᛲᛳᛴᛵᛶᛷᛸᜍ᜕ᜟ |
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
struct Identifier | |
: IEquatable<Identifier> | |
{ | |
private static StringComparer Comparer | |
= StringComparer.OrdinalIgnoreCase; | |
public Identifier(string value) | |
{ | |
Value = value; | |
} |
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
[<Struct>] | |
type UserId = UserId of string | |
type User = { id : UserId ; name : string ; age : int } | |
type IUserOperations = | |
abstract member AddUser : User -> unit | |
abstract member GetUser : UserId -> Option<User> | |
abstract member DeleteUser : UserId -> unit |
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
abstract class State | |
{ | |
public abstract bool IsFinalState { get; } | |
public abstract bool IsValidTransition(State next); | |
public abstract override string ToString(); | |
public static State NotStarted { get; } = new NotStartedT(); | |
public static State Running { get; } = new RunningT(); | |
public static State Errored { get; } = new ErroredT(); | |
public static State Completed { get; } = new CompletedT(); |
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
void Main() | |
{ | |
Flags<Color> colors = new Flags<Color>(); | |
Console.WriteLine(colors); | |
colors.Set(Color.Red); | |
Console.WriteLine(colors); | |
colors.Set(Color.White); | |
Console.WriteLine(colors); | |
} |
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
ref class Foo | |
{ | |
public: | |
!Foo() | |
{ | |
Console::WriteLine("I'm being finalized!"); | |
} | |
~Foo() | |
{ |
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
using System; | |
using System.Collections.Generic; | |
namespace StaticDependencyRegistration | |
{ | |
public static class Program | |
{ | |
public static void Main() | |
{ | |
var rand = Register.PerCaller(() => new Random(Guid.NewGuid().GetHashCode())); |
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
module SafeIL | |
open System | |
open System.Reflection.Emit | |
open System.Runtime.CompilerServices | |
open System.Runtime.InteropServices | |
open System.Reflection | |
open Microsoft.FSharp.Quotations | |
open Microsoft.FSharp.Quotations.Patterns | |
open Microsoft.FSharp.Quotations.DerivedPatterns |
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
#include <Windows.h> | |
#include <array> | |
#include <iostream> | |
#include <exception> | |
[[noreturn]] void throw_last_error() { | |
throw std::system_error{static_cast<int>(GetLastError()), std::system_category()}; | |
} |