Skip to content

Instantly share code, notes, and snippets.

View kmcginnes's full-sized avatar

Kris McGinnes kmcginnes

View GitHub Profile
@kmcginnes
kmcginnes / gist:9775481
Last active August 29, 2015 13:57
BoxStarter: Windows 7 WPF DevBox
Disable-UAC
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart
Set-TaskbarOptions -Dock Left
Write-BoxstarterMessage "Setting Windows power plan to $preferredPlan"
$guid = (Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "ElementName='High performance'").InstanceID.tostring()
$regex = [regex]"{(.*?)}$"
@kmcginnes
kmcginnes / gist:9964495
Last active August 29, 2015 13:58
BoxStarter: Windows 7 Test Box
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Write-BoxstarterMessage "Setting Windows power plan to $preferredPlan"
$guid = (Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "ElementName='High performance'").InstanceID.tostring()
$regex = [regex]"{(.*?)}$"
$newpowerVal = $regex.Match($guid).groups[1].value
powercfg -S "High performance"
Write-BoxstarterMessage "Setting Standby Timeout to Never"
powercfg -change -standby-timeout-ac 0
@kmcginnes
kmcginnes / gist:9985830
Last active August 29, 2015 13:58
Win 8.1 Visual Studio 2013
Disable-UAC
Update-ExecutionPolicy Unrestricted
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowFileExtensions -EnableShowFullPathInTitleBar
Set-StartScreenOptions -EnableBootToDesktop -EnableDesktopBackgroundOnStart -EnableShowStartOnActiveScreen -EnableShowAppsViewOnStartScreen -EnableSearchEverywhereInAppsView -EnableListDesktopAppsFirst
Set-TaskbarOptions -Lock -Dock Left
Write-BoxstarterMessage "Setting Windows power plan to $preferredPlan"
$guid = (Get-WmiObject -Class win32_powerplan -Namespace root\cimv2\power -Filter "ElementName='High performance'").InstanceID.tostring()
$regex = [regex]"{(.*?)}$"
@kmcginnes
kmcginnes / gist:77ce87741f0bd8667689
Created May 21, 2014 01:26
WPF: Hide Close Button Behavior
public class WindowBehavior
{
static readonly Type OwnerType = typeof (WindowBehavior);
public static readonly DependencyProperty HideCloseButtonProperty =
DependencyProperty.RegisterAttached("HideCloseButton", typeof (bool),
OwnerType, new FrameworkPropertyMetadata(false,
new PropertyChangedCallback(HideCloseButtonChangedCallback)));
[AttachedPropertyBrowsableForType(typeof (Window))]

Screens & Conductors

  • Dynamic Composition
  • Static Composition

Form Editing

  • Validation
  • Dirty Tracking
  • Guard Close
@kmcginnes
kmcginnes / gist:bdd307fa7e05da232eb6
Last active August 29, 2015 14:14
Typical Test Packages C#
Install-Package AutoFixture.Xunit
Install-Package AutoFixture.AutoNSubstitute
Install-Package FluentAssertions
Install-Package xunit.runner.visualstudio -Prerelease -Version 0.99.9-build1021
@kmcginnes
kmcginnes / gist:9f9c473b5170dd32f1d0
Last active August 29, 2015 14:14
RecordedEvent List
context = context.AsNonChangeTrackingContext();
return context
.AsQueryable<RecordedEvent>()
.Include(x => x.EventStreams)
.AsExpandable()
.Where(where)
.OrderBy(orderByField, ascending)
.Skip((pageNumber - 1)*recordsPerPage)
.Take(recordsPerPage)
.Select(x => new RecordedEventProjection
@kmcginnes
kmcginnes / gist:76d935abdd2a499fef1f
Created January 30, 2015 21:05
Test the Castle Windsor Container
public class describe_ioc_container
{
It should_be_able_to_resolve_all_registered_components = () =>
{
var bootstrapper = new AppBootstrapper(false);
var host = (IDiagnosticsHost) bootstrapper.Container.Kernel.GetSubSystem(SubSystemConstants.DiagnosticsKey);
var diagnostics = host.GetDiagnostic<IPotentiallyMisconfiguredComponentsDiagnostic>();
var handlers = diagnostics.Inspect();
@kmcginnes
kmcginnes / gist:49c99c465c54e7519151
Last active August 29, 2015 14:18
OS X Reinstall Checklist

Before

  • Backup virtual machines
  • Backup data not in Dropbox or iCloud
  • Backup Projects folder
  • Deauthorize iTunes (why do I still have to do this???)
  • Save open Safari tabs in Dropbox

After

var results = await new ProcessBuilder("some_command.exe")
.WithTimeout(TimeSpan.FromMinutes(5))
.WithArguments("/blah foo")
.WithPath(@"C:\bin")
.ExecuteAsync();
if(results.ExitCode == 0)
{
Console.WriteLine("Output:");
results.StandardOutput.ForEach(line => Console.WriteLine(line));