Skip to content

Instantly share code, notes, and snippets.

View devhawk's full-sized avatar

Harry Pierson devhawk

View GitHub Profile
@devhawk
devhawk / gist:2920919
Created June 13, 2012 00:03
Cecil Metadata Resolver for WinRT
class WinRTMetadataResolver : MetadataResolver
{
public WinRTMetadataResolver(IAssemblyResolver resolver)
: base(resolver)
{
}
IDictionary<string, ModuleDefinition> _loadedModules = new Dictionary<string, ModuleDefinition>();
public override TypeDefinition Resolve(TypeReference type)
@devhawk
devhawk / win8-js-restapi-boilerplate.js
Created June 18, 2012 17:43 — forked from crtr0/win8-js-restapi-boilerplate.js
Win8 JS library boilerplate for REST services
(function () {
var
// The username and password for BASIC auth
username,
password,
// CHANGE THIS
apiRoot = "https://api.foo.com/version",
@devhawk
devhawk / gist:2979933
Created June 23, 2012 20:53
get-bitrate powershell function
function get-bitrate( $file) {
$shell = New-Object -ComObject Shell.Application
$dir = $shell.NameSpace($file.Directory.FullName)
$fileObj = $dir.parseName($file.Name)
$bitrateAttribute = 0
for( $index = 5; -not $bitrateAttribute; ++$index ) {
$name = $directoryObject.GetDetailsOf( $dir.Items, $index )
if( $name -eq 'Bit rate' ) { $bitrateAttribute = $index }
}
@devhawk
devhawk / gist:4151122
Created November 26, 2012 22:37
SSO Code for Win8 apps
var authClient = new LiveAuthClient();
LiveLoginResult authResult = await authClient.LoginAsync(
new List<string>() { "wl.signin", "wl.basic" });
if (authResult.Status == LiveConnectSessionStatus.Connected)
{
LiveConnectClient client = new LiveConnectClient(authResult.Session);
LiveOperationResult liveOpResult = await client.GetAsync("me");
string name = (string)liveOpResult.Result["name"];
}
static class ObservableExtensions
{
public static IObservable<TSource> CompleteAfter<TSource>(this IObservable<TSource> source, Func<TSource, bool> predicate)
{
return new AnonymousObservable<TSource>(observer =>
{
var complete = false;
return source.Subscribe(
x =>
{
@devhawk
devhawk / gist:5570128
Created May 13, 2013 17:55
VBA macro to delete sub folders from Deleted Items in OUtlook
Sub RemoveAllDeletedItemsSubFolders()
Dim oDeletedItems As Outlook.Folder
Dim oFolders As Outlook.Folders
Dim oItems As Outlook.Items
Dim i As Long
'Obtain a reference to deleted items folder
Set oDeletedItems = Application.Session.GetDefaultFolder(olFolderDeletedItems)
Set oFolders = oDeletedItems.Folders
For i = oFolders.Count To 1 Step -1
# Enable-RemoteDesktop
# Install-WindowsUpdate -Full
Update-ExecutionPolicy RemoteSigned
#cinst boxstarter
#cinst git
#cinst git-credential-winstore
cinst notepad2-mod
cinst 7zip
#cinst nodejs
@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
@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 / 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
-->