Skip to content

Instantly share code, notes, and snippets.

View RedirectingHandler.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Knapcode.Http.Handlers
{
View keybase.md

Keybase proof

I hereby claim:

  • I am mlaily on github.
  • I am mlaily (https://keybase.io/mlaily) on keybase.
  • I have a public key whose fingerprint is FA26 96FF E5BB A99A FB01 0AF5 3A2E D6B3 9BAF 5555

To claim this, I am signing this object:

View OutlookDataObject.cs
/*
* OutlookDataObject - Drag and drop of outlook messages and attachments - http://www.iwantedue.com
* Copyright (C) 2008 David Ewen
*
* Patched to take into account most of the remarks from the original project comments...
*
* == BEGIN LICENSE ==
*
* Licensed under the terms of following license:
*
View Combinations.cs
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp
{
    public static class Combinations
    {
        public static IEnumerable<IReadOnlyList<T>> GetAllCombinations<T>(IEnumerable<T> setint combinationLength)
View prune-branches.sh
#!/bin/bash
echo "Comparing current with remote:"
echo
git fetch --dry-run --prune
echo
read -p "Press enter to fetch the changes and prune the deleted branches..."
echo
git fetch --prune
echo
@mlaily
mlaily / NativeMembers.cs
Last active Jul 20, 2021
Find which process have a file opened using the Restart Manager API
View NativeMembers.cs
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable InconsistentNaming
namespace RestartManager
@mlaily
mlaily / ToHumanReadableString.cs
Last active Jan 12, 2018
Convert a length in bytes to a human readable string with the appropriate unit.
View ToHumanReadableString.cs
//we can't shift more than 63 bits with a long, so we would need a big int to support ZB and YB...
static readonly string[] units = new string[] { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB" };
/// <summary>
/// Supports any non negative value up to long.MaxValue (~8EB)
/// </summary>
public static string ToHumanReadableString(long length)
{
if (length < 0) throw new ArgumentOutOfRangeException("length", "length cannot be negative!");
long shiftResult = 0;
long previousShiftResult = 0;