Skip to content

Instantly share code, notes, and snippets.

View cdiggins's full-sized avatar
🐉
Eliminating Lines of Code

Christopher Diggins cdiggins

🐉
Eliminating Lines of Code
View GitHub Profile
using System;
using System.Diagnostics;
using Vim.Logger;
namespace Vim.DotNetUtilities
{
/// <summary>
/// This interface is different from the IProgress&lt;T&gt; class in the system library
/// https://docs.microsoft.com/en-us/dotnet/api/system.iprogress-1?view=netframework-4.8
/// It was designed to simplify the use case of percentage reporting where the number of steps
@cdiggins
cdiggins / naive-binary-array-pack.cs
Created August 24, 2019 04:01
A simple algorithm for packing and unpacking binary byte arrays.
public static byte[] NaivePack(IList<byte[]> buffers)
{
using (var stream = new MemoryStream())
using (var bw = new BinaryWriter(stream))
{
bw.Write(buffers.Count);
foreach (var b in buffers)
{
bw.Write(b.Length);
bw.Write(b);
@cdiggins
cdiggins / myna_arithmetic_evaluator.js
Created July 23, 2018 18:40
An example Arithmetic evaluator in JavaScript written using the Myna parsing library:
"use strict";
function EvalArithmetic(exprNode)
{
switch (exprNode.rule.name)
{
case "expr":
{
return EvalArithmetic(exprNode.children[0]);
}
@cdiggins
cdiggins / myna_grammar_arithmetic.js
Created July 23, 2018 18:31
An example of an arithmetic grammar for the Myna parser
"use strict";
// Defines a grammar for basic arithmetic
function CreateArithmeticGrammar(myna)
{
// Setup a shorthand for the Myna parsing library object
let m = myna;
// Construct a grammar
let g = new function()
@cdiggins
cdiggins / react-best-practices.md
Created January 25, 2018 16:20
React Best Practices