Skip to content

Instantly share code, notes, and snippets.

View arakis's full-sized avatar
⌨️
Coding

Sebastian Loncar arakis

⌨️
Coding
View GitHub Profile
@arakis
arakis / log2.cs
Created September 28, 2019 13:51
log2 algorithm
private static uint[] MultiplyDeBruijnBitPosition = new uint[]
{
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31,
};
/// <summary>
/// Find the log base 2 of an N-bit integer in O(lg(N)) operations.
/// </summary>
/// <remarks>
@arakis
arakis / ActivitySourceExtensions.cs
Last active July 23, 2021 16:25
Start new Root Activity/Span, when Activity.Current is already present
using System;
using System.Diagnostics;
using System.Collections.Generic;
// Author: https://github.com/arakis
// Inspired by https://github.com/open-telemetry/opentelemetry-dotnet/issues/984
// This is an usable implementation for the workaround in the above issue
namespace StartRootActivitySample
{
@arakis
arakis / LeanReaderFactory.cs
Created May 2, 2021 15:13
Market Data Reader for QuantConnect.Lean
// It seems there's no easy way to extract the Stock Data form the Data Directory. Here's a small helper (only tested with SPY).
// The Zip-Files have already to be existent!
public class LeanReaderFactory
{
private string DataDir;
public LeanReaderFactory(string dataDir)
{