Skip to content

Instantly share code, notes, and snippets.

View bradygaster's full-sized avatar

Brady Gaster bradygaster

View GitHub Profile
@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 / profile.ps1
Last active May 8, 2023 03:14
bradyg's powershell profile
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/bradyg.json" | Invoke-Expression
Import-Module -Name Terminal-Icons
cls
@bradygaster
bradygaster / bradyg.json
Last active September 29, 2023 02:58
bradyg's posh git profile
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#ffffff",
"style": "plain",
"template": "\u256d\u2500",
#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)
{
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]
@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;
@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 / AddRating.cs
Last active April 8, 2024 23:35
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