Skip to content

Instantly share code, notes, and snippets.

View MatthewKing's full-sized avatar

Matthew King MatthewKing

View GitHub Profile
Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value 0
@MatthewKing
MatthewKing / .editorconfig
Last active June 8, 2023 06:17
Baseline editorconfig, gitattributes, and gitignore
[root] = true
[*]
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
[*.{csproj,props}]
indent_size = 2

Keybase proof

I hereby claim:

  • I am matthewking on github.
  • I am mking (https://keybase.io/mking) on keybase.
  • I have a public key ASBwtMSceGTkj0I8hd1O8ABiNdXgp9v86HO7ZQEzjRIy6go

To claim this, I am signing this object:

// Adapted from Greg Beech's blog post:
// http://gregbee.ch/blog/natural-sort-order-of-strings-and-file
// Distributed under the Creative Commons Zero (CC0) license.
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
/// <summary>
/// A string comparer that uses the StrCmpLogicalW function for natural string comparisons.
@MatthewKing
MatthewKing / FormExtensions.cs
Last active August 29, 2015 14:13
Extension methods adding an awaitable ShowAsync method to System.Windows.Forms.Form.
using System;
using System.Threading.Tasks;
using System.Windows.Forms;
/// <summary>
/// Extension methods for System.Windows.Forms.Form.
/// </summary>
static class FormExtensions
{
/// <summary>
@MatthewKing
MatthewKing / Get-ApplicationReference.ps1
Last active August 29, 2015 14:03
Get a ClickOnce Application Reference from a ClickOnce Application Deployment Manifest.
function Get-ApplicationReference([string] $deploymentManifestPath) {
[xml]$content = Get-Content $deploymentManifestPath
$identity = $content.assembly.assemblyIdentity
$codebase = $content.assembly.deployment.deploymentProvider.codebase
$appref = '{0}#{1}, Culture={2}, PublicKeyToken={3}, processorArchitecture={4}' -f $codebase, $identity.name, 'neutral', $identity.publicKeyToken, $identity.processorArchitecture
return $appref
}
@MatthewKing
MatthewKing / GeoCoordinateWatcherFixed.cs
Last active August 29, 2015 13:58
Fixes the dodgy miswired events in Microsoft's base GeoCoordinateWatcher implementation.
using System;
using System.Device.Location;
/// <summary>
/// Supplies location data that is based on latitude and longitude coordinates.
/// </summary>
/// <remarks>
/// Fixes the dodgy miswired events in Microsoft's base GeoCoordinateWatcher implementation.
/// </remarks>
class GeoCoordinateWatcherFixed : GeoCoordinateWatcher, IGeoPositionWatcher<GeoCoordinate>
@MatthewKing
MatthewKing / gist:9657697
Created March 20, 2014 05:16
Double-buffering in WinForms using WS_EX_COMPOSITED
/// <summary>
/// A System.Windows.Forms.CreateParams that contains the required creation parameters
/// when the handle to the control is created.
/// </summary>
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000; // WS_EX_COMPOSITED
@MatthewKing
MatthewKing / ListViewWithoutFocus.cs
Last active August 29, 2015 13:56
ListViewWithoutFocus.cs
// Copyright Matthew King 2014.
// Licensed under the Boost Software License, Version 1.0.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
/// <summary>
/// Extends the System.Windows.Forms.ListView class, removing the focus indicators.
/// </summary>
@MatthewKing
MatthewKing / CueTextBox.cs
Last active June 14, 2017 18:16
A WinForms TextBox that has support for cue banners.
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
/// <summary>
/// A Windows text box control with a cue banner.
/// </summary>
public class CueTextBox : TextBox
{
/// <summary>