Skip to content

Instantly share code, notes, and snippets.

View fearthecowboy's full-sized avatar
🏠
Happily Working from home

Garrett Serack fearthecowboy

🏠
Happily Working from home
View GitHub Profile
@fearthecowboy
fearthecowboy / context.json
Created May 27, 2015 20:58
Context Document for Swidtag
{"@context":{"xs":"http://www.w3.org/2001/XMLSchema#","swid":"http://standards.iso.org/iso/19770/-2/2015/schema.xsd#","discovery":"http://packagemanagement.org/discovery#","installation":"http://packagemanagement.org/installation#","Link":{"@id":"swid:Link","@container":"@index"},
"link":{"@id":"swid:Link","@container":"@index"},
"href":{"@id":"swid:href","@type":"swid:@id"},
"Directory":{"@id":"swid:Directory","@container":"@index"},
"directory":{"@id":"swid:Directory","@container":"@index"},
"name":{"@id":"swid:name","@type":"xs:string"},
"File":{"@id":"swid:File","@container":"@index"},
"file":{"@id":"swid:File","@container":"@index"},
"Entity":{"@id":"swid:Entity","@container":"@index"},
"entity":{"@id":"swid:Entity","@container":"@index"},
@fearthecowboy
fearthecowboy / inconsolata.ps1
Created May 4, 2015 21:40
Add Inconsolata font as an option in console windows
# Get the incosolata font from https://github.com/google/fonts/tree/master/ofl/inconsolata
Set-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont' -Name 000 -value Inconsolata
@fearthecowboy
fearthecowboy / Test.cs
Created April 13, 2015 16:56
Show how ToArray() with Distinct isn't good
void Main()
{
Console.WriteLine("\r\n==== Distinct() without ToArray()====");
var stopwatch = Stopwatch.StartNew();
var results = Results().Distinct();
ProcessResults(results,stopwatch);
Console.WriteLine("\r\n==== Distinct() with ToArray()====");
stopwatch = Stopwatch.StartNew();
@fearthecowboy
fearthecowboy / remap-capslock.reg
Created March 3, 2015 15:24
Remap Capslock key to act as a Windows Key (import into registry and reboot)
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,5b,e0,3a,00,00,00,00,00
@fearthecowboy
fearthecowboy / comcast-find-bad-accounts.ps1
Created February 5, 2015 18:01
Comcast should totally run this on their account database
function lookup-account {
param( [string]$word )
# fill in this function
# you should probably do a search on your account database, checking if the $word is found
# in any of the fields
# if( $account -like "*$word*" ) {
# return $account
# }
@fearthecowboy
fearthecowboy / associate-powershell.ps1
Last active July 11, 2025 12:48
Make PowerShell scripts runnable from anywhere ( ie, CMD.EXE, Explorer, Run Dialog, etc)
#==============================================================================
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@fearthecowboy
fearthecowboy / elevate.ps1
Last active September 3, 2019 11:34
Better elevation script for powershell
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@fearthecowboy
fearthecowboy / example.msbuild.xml
Created January 6, 2015 15:32
Super Simple PowerShell task for MSBuild.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- @FearTheCowboy's Simple PowerShell Task for MSBuild -->
<UsingTask TaskName="PowerShell" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup><ScriptBlock ParameterType="System.String" Required="true" /></ParameterGroup>
<Task><Reference Include="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"/><Code Type="Class" Language="cs"><![CDATA[
public class PowerShell : Microsoft.Build.Tasks.Exec {
public string ScriptBlock {set { EchoOff=true; Command = string.Format( "@powershell \"Invoke-Command -ScriptBlock {{ $errorActionPreference='Stop'; {0} ; exit $LASTEXITCODE }} \"", value.Replace("\"","\"\"").Replace("\r\n",";").Replace("\n",";").Replace("\r",";")); } }
}]]></Code></Task>
</UsingTask>
@fearthecowboy
fearthecowboy / project.xml
Created January 6, 2015 01:38
Fixing wixproj file to work inside VS
<!-- When you use variable-based <BindInputPaths>
you have to make sure that you add <InProject>false</InProject> in the element
otherwise, VS tries to expand out the values and fails.
-->
<ItemGroup>
<BindInputPaths Include="$(OutputPath)">
<InProject>false</InProject>
</BindInputPaths>
<BindInputPaths Include="$(SolutionDir)">
@fearthecowboy
fearthecowboy / ResourcesWithNativeFns.cs
Last active August 29, 2015 14:12
Very Type-safe APIs for getting at resources in a PE file
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.