Nothing Special   »   [go: up one dir, main page]

Skip to content

Instantly share code, notes, and snippets.

View mchandschuh's full-sized avatar

Michael Handschuh mchandschuh

View GitHub Profile
@mchandschuh
mchandschuh / int-to-string-fast.cs
Created September 5, 2021 03:34
Converts an integer to string in any base
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 March 15, 2021 06:34
Visual Studio Project Type to Replace the Solution Items Folder

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 June 7, 2016 19:22
C# JsonConverter Single Value to List Deserializer
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 August 29, 2015 14:15
Find all unique palindromes of any length in a source string
using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
namespace Genetic.Tests
{
[TestFixture]
public class PalindromeTests
{