Skip to content

Instantly share code, notes, and snippets.

@Eibwen
Eibwen / CleanConsul.js
Last active March 3, 2016 21:05
Deregister services in Consul when they get messy
"use strict";
var request = require('request');
var HOST = "http://127.0.0.1:8500";
var SERVICE_LIST = "/v1/agent/services";
var SERVICE_DEREGISTER = "/v1/agent/service/deregister/";
request(HOST + SERVICE_LIST, (error, response, body) =>
@Eibwen
Eibwen / estimationTest.html
Last active June 14, 2016 14:57
Story Point Estimation - Under development
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Canvas tutorial</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="estimationTest.js"></script>
<script>
var canvas, radius;
@echo off
:: Get into the repo
cd testrepo
:: Structure setup
mkdir build
:: Simulate src
@Eibwen
Eibwen / AnIntroduction.md
Last active August 22, 2018 21:40
Trie in C# (digital tree?)

Trie

This introduction is here in case you'd like to treat this as a programming excercise yourself.

Problem introduction

A trie (spoilers) is a fairly simple but powerful structure in computer science.

My goal here was simply to mimic a HashSet<string> with much better in-memory storage results (assuming that HashSet<string>, being generic must keep an instance of each string). NOT storing any data other than if the string exists or not.

It can allow you to store an extremely large number of strings with very small storage space and lookup operations are O(length-of-word), with no relation to how many items are being checked against.

@Eibwen
Eibwen / AnIntroduction.md
Last active August 22, 2018 22:06
Generic pieces to allow building a pipeline similar to HttpClientHandler or DelegatingHandlers in C#

Generic Handler Pipeline

This introduction is here in case you'd like to treat this as a programming excercise yourself. If doing so, feel free to implement it in any language you'd like.

Problem description

Many structures (HttpClient, Delegating handlers in MVC/WebAPI) in C# use a handler pattern. Which often have helper methods make it easy to use them but actually building one from scratch is not often done.

And those ones I've seen are always concrete types as input/outputs. So I'd like to make a generic one, so that those helper mehods do not need to be rewritten for each concrete input/output type that we need.

@Eibwen
Eibwen / ObjectDataReader.cs
Last active October 25, 2018 19:22
Use IEnumerable<T> to feed SqlBulkCopy
void Main()
{
gwalker_test_table.Dump();
// gwalker_test_table.DeleteAllOnSubmit(gwalker_test_table);
// SubmitChanges();
// return;
var rand = new Random();
var myData = new List<MyClass>
{

Policy Parameters

Here is a simple table to help determine the basic information you should consider for all Polly Policies you configure

Policy
CircuitBreaker Exception Type Exception Count Allowed Time period
Retry Exception Type Retry Count Retry Delays
Timeout Timeout Time Will it be Pessimistic? (avoid)
Bulkhead Isolation maxParallelization maxQueuingActions onRejection
@Eibwen
Eibwen / AnIntroduction.md
Last active March 9, 2021 19:42
Keep Nuget references honest, dotnet core

Keep Nuget References and similar honest between auto-merging and various nuget tools

If you ever have build/deploy issues because git merges are stupid sometimes and include the old version of a nuget along with the new, or someone doesn't use proper tooling to update or add nuget references to your projects, this will help discover those in a quick and helpful manor!

Tests include:

  • Repository_should_NOT_contain_any_csproj_files_which_are_not_referenced_by_the_sln
    • Makes sure you don't have any stray csproj files in your folders that are not referenced by the main sln file
  • All_target_frameworks_should_match
    • Make sure that all your projects are up-to-date with each other
  • This works by checking TargetFramework's full string, then comparing that count to the count without the framework version (meaning you can have netcoreapp2.2 along with netstandard2.0, but NOT netcoreapp2.2 along with netcoreapp2.1)

My (Unit) Testing Guidelines

Here are the things that are on my mind that make tests more consistent, more readable, more reliable

  • Start with a template of

      // Resharper code template
      [NUnit.Framework.Test]
      public void When_$TESTNAME$()
    

{

/*
* This is designed to (semi-)passively help with https://gzgreg.github.io/DerivativeClicker/
* The main function is to only keep a baseline of count for all Buildings
* it does this by buying any buildings which 1 second worth of time will pay for
* By doing that it still allows your base money to continue growing constantly
*
* NEW ADDED: Which doesn't fully follow that. Is auto-buying any TierUpgrades possible as soon as you can afford it
* NEW ADDED: Also not following that. If it reaches the point where your cash-on-hand can buy all the highest tier items, it will buy those for you, so that the rewards trickle down even if you're AFK
*
*