Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Linq;
using Newtonsoft.Json;
namespace XXX
{
[JsonConverter(typeof(StructWrapperConverter))]
public sealed class StructWrapper<T> where T : struct
{
public T Value { get; }
pragma solidity ^0.5.2;
contract Owned {
address public owner;
constructor() public {
owner = tx.origin;
}
modifier onlyOwner {
using System;
namespace ConsoleApp28
{
public readonly struct Unit
{
public static Unit Instance { get; } = new Unit();
}
public class State<S, A>
public static class XEnumerable
{
public static (T1[], T2[]) Unzip<T1, T2>(this IEnumerable<(T1 x, T2 y)> source)
{
if (source is IReadOnlyCollection<(T1, T2)> roc)
{
T1[] xs = new T1[roc.Count];
T2[] ys = new T2[roc.Count];
int i = 0;
foreach (var (x, y) in source)
void Main()
{
var files = Directory.EnumerateFiles(@"C:\Users\me\Documents\Repos\myrepo\", "*.csproj", SearchOption.AllDirectories);
foreach (var csprojPath in files)
{
PatchCsProj(csprojPath);
}
}
void PatchCsProj(string path)
@Pzixel
Pzixel / Main.cs
Last active September 29, 2019 17:41
Haskell vs GO: Tree mapping
using System;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
class Program
{
class Comment
@Pzixel
Pzixel / flow.cs
Created September 16, 2019 11:57
var graph = GraphDsl.Create(b =>
{
b.From(new RabbitSource<StartProcessTriggerMessage>(workerSettings.RoutingKey, mqFactory))
.Via(Flow.Create<RabbitMessage<StartProcessTriggerMessage>>()
.SelectAsync(Environment.ProcessorCount, async message =>
{
var stateInfoResult = await Result.TryAsync(() =>
RetryApiFuncAsync(() => GetOmsStateInfoApiClient(
message.Data.Trigger.PrincipalToken,
message.Data.Trigger.RequestId)
@Pzixel
Pzixel / Main.cs
Last active October 17, 2019 23:07
void Main()
{
var v = from x in 10.AsResult()
from y in 0.AsResult()
select Result.Try (() => x/y);
v.Dump();
}
@Pzixel
Pzixel / shit.cs
Created September 12, 2019 09:33
using System;
using System.Linq;
using System.Threading.Tasks;
using Akka.Actor;
using Akka.Streams;
using Akka.Streams.Dsl;
using Directive = Akka.Streams.Supervision.Directive;
namespace ConsoleApp9
{
void Main()
{
var foo = new C { B = new B { A = new A() }};
var helper = ExpressionHelper<C>.GetDelegate<A>("B.A");
helper(foo).Dump();
}
class A {
public int X => 10;
}