Skip to content

Instantly share code, notes, and snippets.

View devhawk's full-sized avatar

Harry Pierson devhawk

View GitHub Profile
class Konsole : IDisposable
{
ConsoleColor _orig_fg;
public static IDisposable Color(ConsoleColor fg)
{
var k = new Konsole()
{
_orig_fg = Console.ForegroundColor
};
param
(
[Parameter(Mandatory=$True)][string]$srcPath,
[string]$dstPath = "."
)
$local_path = join-path $env:LOCALAPPDATA "cppwinrt.android"
if (-not (test-path $local_path)) {
mkdir $local_path | out-null
}
@devhawk
devhawk / colorconsole.fs
Created August 4, 2016 17:19
F# Color Console Functions
open System
// helper function to set the console collor and automatically set it back when disposed
let consoleColor (fc : ConsoleColor) =
let current = Console.ForegroundColor
Console.ForegroundColor <- fc
{ new IDisposable with
member x.Dispose() = Console.ForegroundColor <- current }
// printf statements that allow user to specify output color
@devhawk
devhawk / indent.fs
Created August 4, 2016 17:18
F# Indent
open System
// helper function to indent an indexedTextWriter and automatically un-indent
// when disposed
let indent (itw : System.CodeDom.Compiler.IndentedTextWriter) =
let current = itw.Indent
itw.Indent <- current + 1
{ new IDisposable with
member x.Dispose() = itw.Indent <- current }
@devhawk
devhawk / WinRtAwaiter.cs
Last active December 12, 2025 20:53
Simple C# class to add async/await support for WinRT async operations w/o System.Runtime.WindowsRuntime.
using System.Runtime.CompilerServices;
using Windows.Foundation;
static class WinRtHelper
{
struct VoidValueTypeParameter { }
public static TaskAwaiter GetAwaiter(this IAsyncAction op)
{
var tcs = new TaskCompletionSource<VoidValueTypeParameter>();
param([Parameter(Mandatory=$true)][string]$filename, [string]$displayname)
$local:windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$local:windowsPrincipal = new-object 'System.Security.Principal.WindowsPrincipal' $local:windowsIdentity
if ($local:windowsPrincipal.IsInRole("Administrators") -ne 1)
{
throw "add-bcd-vhd must be run from an administrator account"
}
$f = resolve-path $filename
@devhawk
devhawk / buildcpp.xml
Last active February 17, 2016 15:50
Fix VC++ broken build folder structure
<!-- Add to .vcxproj file after line importing $(VCTargetsPath)\Microsoft.Cpp.props to have sensible build output folders -->
<!-- have VC++ emit build artifacts into \bin and \obj folders like managed proejcts do -->
<PropertyGroup>
<!--
The VC++ build scripts automatically appends atrailing slash on OutDir, which annoys some tools,
so I added OutputDirectory w/o the slash. Also, I'm using "PlatformShortName" so x86 binaries don't
end up in the "win32" directory
-->
@devhawk
devhawk / CustomCommands.cs
Created September 3, 2015 02:46
ASP.NET 5 CustomCommands runner
using System;
using System.Linq;
using System.Reflection;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.Runtime;
namespace CustomCommands
{
public class Program
{
@devhawk
devhawk / Invoker.ps1
Last active August 28, 2016 02:01
Boxstarter Configuration
function Run-Boxstarter-From-Gist($gistId, $fileName) {
Invoke-WebRequest "https://api.github.com/gists/$gistId" -UseBasicParsing | ConvertFrom-Json | %{
$local:boxstarterUrl = "http://boxstarter.org/package/url?$($_.files.$fileName.raw_url)"
& 'C:\Program Files\Internet Explorer\iexplore.exe' -new $local:boxstarterUrl
}
}
Run-Boxstarter-From-Gist d5e9d66238717bab0e23 basicconfig.ps1
Run-Boxstarter-From-Gist d5e9d66238717bab0e23 devcconfig.ps1
# Enable-RemoteDesktop
# Install-WindowsUpdate -Full
Update-ExecutionPolicy RemoteSigned
#cinst boxstarter
#cinst git
#cinst git-credential-winstore
cinst notepad2-mod
cinst 7zip
#cinst nodejs