Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael Handschuh mchandschuh

View GitHub Profile
@mchandschuh
mchandschuh / int-to-string-fast.cs
Created Sep 5, 2021
Converts an integer to string in any base
View int-to-string-fast.cs
public static string IntToStringFast(int value, char[] baseChars)
{
// 32 is the worst cast buffer size for base 2 and int.MaxValue
var i = 32;
var buffer = new char[i];
var targetBase = baseChars.Length;
do
{
@mchandschuh
mchandschuh / README.md
Last active Mar 15, 2021
Visual Studio Project Type to Replace the Solution Items Folder
View README.md

Visual Studio Project Type to Replace the Solution Items Folder

When adding miscellaneous items to a visual studio solution, the files end up getting added under this Solution Items folder. What's particularly terrible about this is it's total disconnect from the underlying file system. These files define a shared project that will automatically add all items in its project directory to itself while maintaining the underlying file structure. Currently I'm using this for the convenience of being able to access related files, such as configuration and scripts, easily from within visual studio. I think that this type of project also allows every other project to reference these files, but I'll need to look into this bit more. I'll update this readme if any unexpected use cases are found.

Caveats

When adding files via the file system visual studio doesn't immediately display them, which is lame. Reloading the project makes them visible, but obviously that defeats the entire purpose. We're trying to be l

@mchandschuh
mchandschuh / SingleValueListConverter.cs
Last active Jun 7, 2016
C# JsonConverter Single Value to List Deserializer
View SingleValueListConverter.cs
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace QuantConnect.Util
{
/// <summary>
/// Reads json and always produces a List, even if the input has just an object
/// </summary>
public class SingleValueListConverter<T> : JsonConverter
@mchandschuh
mchandschuh / FindAllPalindromes.cs
Last active Aug 29, 2015
Find all unique palindromes of any length in a source string
View FindAllPalindromes.cs
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Genetic.Tests
{
[TestFixture]
public class PalindromeTests
{