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 / intersect.ts
Last active June 13, 2018 18:51
Intersection Proxy for Typescript
/**
* Creates an intersection object from two source objects.
*
* Typescript nicely supports defining intersection types (ie, Foo & Bar )
* But if you have two seperate *instances*, and you want to use them as the implementation
* of that intersection, the language doesn't solve that for you.
*
* This function creates a strongly typed proxy type around the two objects,
* and returns members for the intersection of them.
@fearthecowboy
fearthecowboy / sample.cs
Last active June 4, 2018 18:58
Work-in-progress - generated API for OpenAPI/Swagger file (see notes at bottom!!! https://gist.github.com/fearthecowboy/049bc3d666364eb4c7c0288866821c00#gistcomment-2609915)
namespace Sample.API
{
using static Microsoft.Rest.ClientRuntime.IEventListenerExtensions;
public class ContainerRegistryManagementClient
{
public Microsoft.Rest.ClientRuntime.ISendAsync Sender { get; set; }
/// <summary>MISSING DESCRIPTION 05</summary>
/// <param name="apiVersion"> The client API version. </param>
/// <param name="on200"> </param>
/// <param name="listener"> </param>
@fearthecowboy
fearthecowboy / Test.ts
Created May 2, 2018 21:09
Typescript conditional types oddity
export interface Dictionary<T> {
[key: string]: T;
}
export interface Pair<KEY, VALUETYPE> {
key: KEY;
value: VALUETYPE;
}
#==============================================================================
# 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 / bit-coin.user.js
Last active June 17, 2022 15:37
Tampermonkey script to turn Bitcoin into "Dutch Tulip Bulbs"
// ==UserScript==
// @name Replace 'Bitcoin' On Webpages
// @namespace https://gist.github.com/fearthecowboy
// @description Replaces bitcoin on websites.
// @include http://*
// @include https://*
// @include file://*
// @exclude http://userscripts.org/scripts/review/*
// @exclude http://userscripts.org/scripts/edit/*
// @exclude http://userscripts.org/scripts/edit_src/*
@fearthecowboy
fearthecowboy / gulp-tab.ps1
Last active August 25, 2017 10:35
Better gulp tab expansion script
# Copyright (c) 2014 Jason Jarrett
#
# Tab completion for the `gulp`
#
# Usage:
#
# To enable powershell <tab> completion for gulp you need to be running
# at least PowerShell v3 or greater and add the below to your $PROFILE
#
# Invoke-Expression ((gulp --completion=powershell) -join [System.Environment]::NewLine)
@fearthecowboy
fearthecowboy / install.ps1
Created March 3, 2017 17:32
Installing Autorest
# Install AutoRest globally (so that it is in the PATH)
npm install -g autorest
@fearthecowboy
fearthecowboy / uBlock.filters.txt
Last active January 3, 2017 13:10
My clever uBlock origin filters
[Adblock Plus 2.0]
! Title: FearTheCowboy's Filters
! Homepage: https://gist.github.com/fearthecowboy/25c3171e74e1c61dab9af7caf91517f0
# Block the "Suggested Posts" from showing in your feed
www.facebook.com##:xpath(//*[text()="Suggested Post"]/../../../..)
# Block the lame Twitter "Moments" tab.
twitter.com###global-actions > .js-moments-tab.moments
@fearthecowboy
fearthecowboy / test.cmd
Created December 9, 2016 02:00
Make a powershell script with a .cmd (or .bat) extension
@powershell -noninteractive "& ([Scriptblock]::Create( ((gc -raw '%~df0') -replace '^@powershell.*' ) )) %*" & goto :eof
###
### Example : Just use that first line in a .cmd file and it will execute this file with powershell!
###
param( $name, $lastname )
write-host -fore green "Well, hello $name $lastname"
<# Notes:
this works just fine from cmd (or powershell) - even with named parameters:
@fearthecowboy
fearthecowboy / Test.csproj
Last active April 18, 2024 23:37
The definitive way to use PowerShell from an msbuild script
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- #1 Place this line at the top of any msbuild script (ie, csproj, etc) -->
<PropertyGroup><PowerShell># 2>nul || type %~df0|find /v "setlocal"|find /v "errorlevel"|powershell.exe -noninteractive -&amp; exit %errorlevel% || #</PowerShell></PropertyGroup>
<!-- #2 in any target you want to run a script -->
<Target Name="default" >
<PropertyGroup> <!-- #3 prefix your powershell script with the $(PowerShell) variable, then code as normal! -->
<myscript>$(PowerShell)