Skip to content

Instantly share code, notes, and snippets.

View bradygaster's full-sized avatar

Brady Gaster bradygaster

View GitHub Profile
@bradygaster
bradygaster / AddRating.cs
Last active April 10, 2026 02:42
Contoso Crafts
public void AddRating(string productId, int rating)
{
var products = GetProducts();
var query = products.First(x => x.Id == productId);
if(query.Ratings == null)
{
query.Ratings = new int[] { rating };
}
else
@bradygaster
bradygaster / import-api-into-azure-api-management.ps1
Created April 27, 2020 07:13
Import a REST API described by a Open API Specification (the artist formerly known as Swagger) file using the PowerShell cmdlets for Azure.
# Variables
Set-Variable -Name ResourceGroupName "SomeApi"
Set-Variable -Name ApimInstance "my-app-apis"
Set-Variable -Name SwaggerFilePath "C:\Users\brady\source\repos\brady\SomeApi\bin\Debug\netcoreapp3.1\swagger.json"
Set-Variable -Name ServiceUrl "https://some-api-123.azurewebsites.net"
Set-Variable -Name ApiId "SomeApi"
Set-Variable -Name ApiVersion "v1"
Set-Variable -Name AzureSubscriptionId ""
# select the subscription
@bradygaster
bradygaster / api.cs
Last active June 25, 2021 01:24
An OpenAPI-enabled HTTP API in .NET 5, in two files, using top-level statements programming style
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Carter;
using Carter.Response;
using Carter.OpenApi;
az apim api import --specification-format Swagger
--subscription-required false
--path "recipes/v1"
--resource-group RecipeApiGroup
--service-name recipe-apis
--api-id RecipeApi
--service-url "https://recipe-api-host.azurewebsites.net"
--specification-path "/home/runner/work/Recipe-Api/Recipe-Api/RecipeApi/bin/Release/net5.0/swagger.json"
dotnet swagger tofile --output [output] [startupassembly] [swaggerdoc]
#include <RK002.h>
RK002_DECLARE_INFO("BeatStep Pro to Digitakt 1.3","notmyrealemail@hotmail.com",".1","01bbe92b-f211-46e0-b635-c591254251b6")
boolean RK002_onNoteOn(byte channel, byte key, byte velocity)
{
if(channel == 0)
{
if(key == 24)
{
@bradygaster
bradygaster / bradyg.json
Last active February 27, 2026 19:04
bradyg's posh git profile
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"style": "powerline",
"template": " \uebd8 {{ .Name }} ({{ if .EnvironmentName | contains \"AzureCloud\" }}{{ \"Global\" }}{{ else }}{{ .EnvironmentName }}{{ end }}) ",
@bradygaster
bradygaster / profile.ps1
Last active May 19, 2025 04:27
bradyg's powershell profile
set-alias k kubectl
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/bradyg.2024.json" | Invoke-Expression
Import-Module -Name Terminal-Icons
cd c:\src
cls
# Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows
@bradygaster
bradygaster / Program.cs
Last active August 29, 2022 21:47
How to authenticate ASP.NET with GitHub
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using System.Security.Claims;
var signin = "/signin";
var signout = "/signout";
var callback = "/signin-github";
var redirectUrl = "/";
var builder = WebApplication.CreateBuilder(args);
@bradygaster
bradygaster / README.md
Created June 22, 2026 07:45
GitHub Copilot extension — ski-game

⛷️ Downhill Ski

A retro-style downhill skiing game built as a GitHub Copilot canvas extension. Dodge trees, rocks, and other skiers while hitting ramps for massive air time bonuses and threading slalom gates for extra points.

Downhill Ski gameplay

How to Play