Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar
Working from home

Elemar Rodrigues Severo Junior ElemarJR

Working from home
View GitHub Profile
View huffman.cs
using System.Text;
string input = "AABCBAD";
var ft = FrequencyTable.Create(input); // O(n)
var ht = HuffmanTree.Build(ft); // O(m)
var et = EncodedTable.Build(ht); // O(m) => O(n + m)
var compressed = HuffmanCompressor.Compress(input, et);
var decompressed = HuffmanDecompressor.Decompress(compressed, ht);
View FrequencyTable.cs
public static class FrequencyTable
public static Dictionary<char, int> Create(string input)
foreach (char character in input)
if (frequencyTable.ContainsKey(character))
View gist:8651257c8af49eb6db181b34081945b3
using System;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using static System.Console;
ElemarJR /
Last active December 10, 2017 12:57
My Celebrity Statements

I help senior software engineers and architects to create software that meets business needs so they can have space to innovate and to get recognized for that.

I help C-Level executives to design and implement innovation strategies effectively so they can improve their skills getting innovation done.

ElemarJR / index.cs
Last active August 2, 2017 12:51
Esent: out of memory
View index.cs
public sealed class Debts_ByPayer : AbstractMultiMapIndexCreationTask<PayerInfoForBilling>
public Debts_ByPayer()
AddMap<Debt>(debts =>
from debt in debts
let person = LoadDocument<Person>("people/" + debt.Charging.PersonId.ToString())
let agreement = LoadDocument<Agreement>(debt.Source.ToString())
let personIds = person.Id.ToString().Split('/')
let agreementIds = agreement.Id.ToString().Split('/')
View QueryTimings.cs
using System;
using System.Linq;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Indexes;
namespace ConsoleApp1
class Program
View changedByOthers.cs
_subscription = DocumentStoreHolder.Store
.Where(change =>
if (!_justSaved) return true;
_justSaved = false;
var localEtag = _session.Advanced.GetEtagFor(_category);
var numberOfServerChanges = change.Etag.Changes - localEtag.Changes;
View Func.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication9
using static System.Console;
using static System.Math;
using static Helpers;
View Option.cs
using System;
namespace JLang.Functional
using static Helpers;
public struct Option<T>
internal T Value { get; }
public bool IsSome { get; }
View ToPropertyPath.cs
public static string ToPropertyPath<TB, T>(this Expression<Func<TB, T>> func)
var result = new StringBuilder();
var node = func.Body;
while (node.NodeType == ExpressionType.MemberAccess)
var me = node as MemberExpression;
if (result.Length != 0) result.Insert(0, ".");
result.Insert(0, me.Member.Name);
node = me.Expression;