Skip to content

Instantly share code, notes, and snippets.

View divyang4481's full-sized avatar

Divyang Panchasara divyang4481

View GitHub Profile
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ConsoleApp8
{
class Program
{
class MyCustomException : Exception
{
}
private static readonly object sync = new object();
using System;
using ConsoleApp8;
namespace ConsoleApp8
{
class Program
{
class MyCustomException : Exception
{
}
using System;
using System.Linq;
using System.Reflection;
class Program
{
class MyClass
{
}
@divyang4481
divyang4481 / FalseSharing.cs
Created February 21, 2020 10:11 — forked from ForNeVeR/FalseSharing.cs
False sharing test in C#.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleApplication2
{
class Program
{
struct Fuck
@divyang4481
divyang4481 / 1.cs
Created February 21, 2020 08:17 — forked from askguanyu/1.cs
int i = 21;
TypedReference tr = __makeref(i);
Type t = __reftype(tr);
Console.WriteLine(t.ToString());
int rv = __refvalue( tr,int);
Console.WriteLine(rv);
ArglistTest.DisplayNumbersOnConsole(__arglist(1, 2, 3, 5, 6));
@divyang4481
divyang4481 / void.cs
Created February 21, 2020 08:16 — forked from Kir-Antipov/void.cs
How to create an object of type void
public class MyVoid
{
public static readonly MyVoid Instance = new MyVoid();
private MyVoid()
{
unsafe
{
MyVoid it = this;
TypedReference typedReference = __makeref(it);
public static class ArglistTest
{
public static void DisplayNumbersOnConsole(__arglist)
{
ArgIterator ai = new ArgIterator(__arglist);
while (ai.GetRemainingCount() > 0)
{
TypedReference tr = ai.GetNextArg();
Console.WriteLine(TypedReference.ToObject(tr));
}
@divyang4481
divyang4481 / FreeIOMonad.cs
Created February 18, 2020 13:51 — forked from dadhi/FreeIOMonad.cs
Example of Free IO monad in pure C# with separated re-usable monad implementation
/*
Modified from the original https://gist.github.com/louthy/524fbe8965d3a2aae1b576cdd8e971e4
- removed dependency on [language-ext](https://github.com/louthy/language-ext)
- separated monadic boilerplate, so you may concentrate on describing the operations and interpretation of the program
- removed `IO<A>.Faulted` to simplify the examples. It can be added back in straightforward manner.
Useful links:
- [John DeGoes: Beyond Free Monads - λC Winter Retreat 2017](https://www.youtube.com/watch?v=A-lmrvsUi2Y)
- [Free and tagless compared - how not to commit to a monad too early](https://softwaremill.com/free-tagless-compared-how-not-to-commit-to-monad-too-early)
@divyang4481
divyang4481 / fiber.cs
Created January 11, 2020 22:02
fiber in C#
public class Fiber
{
private readonly Stack<IEnumerator> stackFrame =
new Stack<IEnumerator>();
private IEnumerator currentRoutine;
public Fiber(IEnumerator entryPoint)
{
this.currentRoutine = entryPoint;
}