Skip to content

Instantly share code, notes, and snippets.

View drub0y's full-sized avatar

Drew Marsh drub0y

View GitHub Profile
@drub0y
drub0y / BigIntegerBase64JsonConverter.cs
Created May 16, 2020 17:13
A System.Text.Json converter implementation that efficiently encodes the BigInteger to Base64
internal sealed class BigIntegerBase64JsonConverter : JsonConverter<BigInteger>
{
public override BigInteger Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
var bigIntegerBytes = reader.GetBytesFromBase64();
return new BigInteger(bigIntegerBytes);
}
public override void Write(Utf8JsonWriter writer, BigInteger value, JsonSerializerOptions options)
@drub0y
drub0y / Ignorer.cs
Last active October 17, 2017 23:19
Continuation without unecessary allocation via static method and cached delegate
public static class TaskExtensions
{
private static Action<Task> IgnorerContinuationAction = IgnorerContinuation;
public static void Ignore(this Task task)
{
if (task.IsCompleted)
{
var exception = task.Exception;
}
@drub0y
drub0y / app.html
Last active January 23, 2017 18:17 — forked from Thanood/app.html
Aurelia-Materialize bridge badge with custom caption
<template>
<div>
<ul class="collection">
<li class="collection-item">Sent</li>
<li class="collection-item">Inbox<span md-badge="is-new: true;">3</span></li>
<li class="collection-item">Spam<span show.bind="spamCount > 0" class="yellow black-text" md-badge="is-new: true; caption.bind: spamCaption">${spamCount}</span></li>
</ul>
</div>
<div class="actions">
<hr />
@drub0y
drub0y / app.html
Last active January 17, 2017 17:14 — forked from Thanood/app.html
Aurelia-Materialize bridge collapsible onOpen/Close events
<template>
<div class="collapsible-open-close-events">
<ul md-collapsible="on-open.call: collapsibleOpen($event); on-close.call: collapsibleClose($event)">
<li ref="firstSection">
<div class="collapsible-header"><i class="mdi-image-filter-drama"></i>First<span md-badge data-badge-caption="opens">${firstSection.openCount || 0}</span><span md-badge data-badge-caption="closes">${firstSection.closeCount || 0}</span></div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
</li>
<li ref="secondSection">
<div class="collapsible-header"><i class="mdi-maps-place"></i>Second<span md-badge data-badge-caption="opens">${secondSection.openCount || 0}</span><span md-badge data-badge-caption="closes">${secondSection.closeCount || 0}</span></div>
<div class="collapsible-body"><p>Lorem ipsum dolor sit amet.</p></div>
@drub0y
drub0y / ActivityLog.xml
Created June 28, 2016 02:39
Visual Studio ActivityLog.xml showing package load failures after installing Update 3 RTM
<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl" href="ActivityLog.xsl"?>
<activity>
<entry>
<record>1</record>
<time>2016/06/28 02:06:41.136</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Microsoft Visual Studio 2015 version: 14.0.25420.1</description>
</entry>
@drub0y
drub0y / install.log
Created April 22, 2016 22:54
Azure SDK 2.9 Install Failure on AzureTools.Notifications.msi
[141C:12A4][2016-04-22T15:48:46]i001: Burn v3.7.1224.0, Windows v6.2 (Build 9200: Service Pack 0), path: C:\Users\drub0\AppData\Local\Microsoft\Web Platform Installer\installers\WindowsAzureToolsOnlyVS2015BaseLocale.2.9\9D09A95A44450C409BC4F20B170635BAB9890151\MicrosoftAzureTools.VS140.exe, cmdline: '/quiet /norestart /log C:\Users\drub0\AppData\Local\Temp\WindowsAzureToolsVS2015_2_9_BaseLocale_Install.txt RUNDEVENVSETUP=0 -burn.unelevated BurnPipe.{9738F788-BE87-47BB-92CC-1939CA39524C} {DEE3715F-AECD-4961-B099-7B7AC3ABF13C} 9792'
[141C:12A4][2016-04-22T15:48:46]i000: Initializing string variable 'ProductShortName' to value 'Microsoft Azure Tools - v2.9'
[141C:12A4][2016-04-22T15:48:46]i000: Initializing string variable 'RUNDEVENVSETUP' to value '1'
[141C:12A4][2016-04-22T15:48:46]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\drub0\AppData\Local\Temp\WindowsAzureToolsVS2015_2_9_BaseLocale_Install.txt'
[141C:12A4][2016-04-22T15:48:46]i000: Setting string variable 'WixBundleOriginalSource' to
@drub0y
drub0y / .gitconfig
Created April 21, 2016 19:51
VSDiffMerge as Git DiffTool/MergeTool
[diff]
tool = vsdiffmerge
[difftool]
prompt = true
[difftool "vsdiffmerge"]
cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\vsdiffmerge.exe\" \"$LOCAL\" \"$REMOTE\" //t
[difftool "vsdiffmerge"]
keepbackup = false
[merge]
tool = vsdiffmerge
@drub0y
drub0y / TypeManager.CommitChanges.cs
Last active December 27, 2015 00:39
This is a decompiled view of how the PowerShell provider (specifically it's TypeManager class) for IIS attempts to provide consistency btwn the execution of a command and the commits actually being written to disk in applicationHost.config. All kinds of fun ensues when committing the changes to disk doesn't actually happen within that one second…
public void CommitChanges(bool doCommit)
{
if (!this.InCommitDelay() && this.WritableServerManager != null)
{
try
{
if (doCommit)
{
this.commitSynchronization = new AutoResetEvent(false);
this.WritableServerManager.CommitChanges();
@drub0y
drub0y / VS2012And2013WorkflowPCLReferenceIntellisenseBug.md
Last active December 21, 2015 18:29
Details of an Intellisense bug that affects Windows Workflow Foundation projects that reference Portable Class Library assemblies.

Description

Referencing a Portable Class Library (PCL) assembly from a Windows Workflow project results in loss of Intellisense on what appears to be all other assembly type data except from mscorlib.dll, including project referenced assemblies.

Repro

  1. Create a new Windows Workflow Foundation Console Application project.
  2. Add a PCL library such as TPL Dataflow (Install-Package Microsoft.Tpl.Dataflow) or Reactive Extensions (Install-Package Rx-Main).

Expected Result

@drub0y
drub0y / NewRelicIgnoreTransactionOwinModule.cs
Created June 25, 2013 16:46
This is a proof of concept (read: not tested yet) Owin module that one could configure in an Owin pipeline to ensure that NewRelic will ignore the transaction.
public class NewRelicIgnoreTransactionOwinModule
{
private AppFunc _nextAppFunc;
public NewRelicIgnoreTransactionOwinModule(AppFunc nextAppFunc)
{
_nextAppFunc = nextAppFunc;
}
public Task Invoke(IDictionary<string, object> environment)