Skip to content

Instantly share code, notes, and snippets.

View LPeter1997's full-sized avatar

LPeter1997

View GitHub Profile
@LPeter1997
LPeter1997 / Program.cs
Created October 6, 2023 16:46
Stackification
using System.Collections.Immutable;
namespace Stackification;
// https://gist.github.com/evanw/58a8a5b8b4a1da32fcdcfbf9da87c82a
enum OpCode
{
Add,
Load,
@LPeter1997
LPeter1997 / Program.cs
Last active September 29, 2023 15:23
Scheduler
using System.Collections.Concurrent;
using System.Threading.Channels;
namespace ConcurrentConsumer;
internal sealed class MessageScheduler<TMessage>
{
private enum ConsumerState
{
None,
@LPeter1997
LPeter1997 / Program.cs
Last active September 24, 2023 16:12
Pattern matching algo
using System.Collections;
using System.Collections.Immutable;
using System.Data;
using System.Diagnostics.Tracing;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
namespace ExhaustivenessChecking;
@LPeter1997
LPeter1997 / tictactoe.draco
Created August 21, 2023 21:06
Draco Tic-Tac-Toe
import System;
import System.Math;
import System.Console;
import System.Linq.Enumerable;
val dim = 3;
val toConnect = 3;
val board = createBoard();
func createBoard(): Array2D<string> {
@LPeter1997
LPeter1997 / syntax.md
Last active March 12, 2023 16:15
Draco bench
BenchmarkDotNet=v0.13.5, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
AMD Ryzen 9 5900X, 1 CPU, 24 logical and 12 physical cores
.NET SDK=7.0.103
  [Host]     : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
  DefaultJob : .NET 7.0.3 (7.0.323.6910), X64 RyuJIT AVX2
Method ElementCount StringLength CommentLength Mean Error StdDev
@LPeter1997
LPeter1997 / 5900x.md
Last active February 6, 2023 13:57
CPU bench
Thread Count Time elapsed Perf MFLOPS Perf per thread MFLOPS
1 2505 1573.9 1573.9
2 2507 3153.8 1576.9
3 2501 4755.8 1585.2
4 2511 6276.2 1569
6 2504 9312.8 1552.1
8 2502 12142.6 1517.8
10 2509 15006.7 1500.6
12 2501 17855.2 1487.9
@LPeter1997
LPeter1997 / gist:71c54a2a114e72f1f65a93bbe10fc9be
Created January 21, 2023 11:17
New tree generation tool
* Generate from a markup
* Roslyn uses XML, it's pretty good
* I don't think JSON or YAML would fit here, too "simplistic" to express compactly
* Generate the...
* Green syntax tree
* Red syntax tree
* Syntax factory
* Bound nodes
* Bound node factory
* Data-flow operations (?) (for both internal and public API)
@LPeter1997
LPeter1997 / aoc-2022.rb
Last active December 6, 2022 14:05
AoC 2022 solutions golfed in Ruby
# Day 1
i=$<.map(&:to_i).chunk_while{_2>0}.map(&:sum).sort
p [1,3].map{i.last(_1).sum}
# Day 2
i=[*$<]
m=->a,b{a.ord+b.ord*3-329}
s=->k{i.map{'417852396'[m[_1[0],k[m[*_1.split]]]].to_i}.sum}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Compiler;
namespace Compiler.Presentation;
@LPeter1997
LPeter1997 / Program.cs
Created November 11, 2022 18:52
Basic algorithm-W in C#
using System.Collections.Immutable;
class Program
{
static void Main(string[] args)
{
try
{
// Assume we have a function (int, bool) -> ?