Skip to content

Instantly share code, notes, and snippets.

View ElemarJR's full-sized avatar
🏠
Working from home

Elemar Rodrigues Severo Junior ElemarJR

🏠
Working from home
View GitHub Profile
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);
Console.WriteLine(compressed);
var decompressed = HuffmanDecompressor.Decompress(compressed, ht);
Console.WriteLine(decompressed);
public static class FrequencyTable
{
public static Dictionary<char, int> Create(string input)
{
foreach (char character in input)
{
if (frequencyTable.ContainsKey(character))
{
frequencyTable[character]++;
}
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
ElemarJR / STATEMENTS.md
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
ElemarJR / index.cs
Last active August 2, 2017 12:51
Esent: out of memory
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('/')
using System;
using System.Linq;
using Raven.Client;
using Raven.Client.Document;
using Raven.Client.Indexes;
namespace ConsoleApp1
{
class Program
{
_subscription = DocumentStoreHolder.Store
.Changes()
.ForDocument(CategoryIdTextbox.Text)
.Where(change =>
{
if (!_justSaved) return true;
_justSaved = false;
var localEtag = _session.Advanced.GetEtagFor(_category);
var numberOfServerChanges = change.Etag.Changes - localEtag.Changes;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication9
{
using static System.Console;
using static System.Math;
using static Helpers;
using System;
namespace JLang.Functional
{
using static Helpers;
public struct Option<T>
{
internal T Value { get; }
public bool IsSome { get; }
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;