Skip to content

Instantly share code, notes, and snippets.

View timheuer's full-sized avatar
🚴‍♂️
https://twitter.com/timheuer

Tim Heuer timheuer

🚴‍♂️
https://twitter.com/timheuer
View GitHub Profile
const command1 = 'extension.command1';
const command1Handler = () => {
};
const command2 = 'extension.command2';
const command2Handler = () => {
};
context.subscriptions.push(
commands.registerCommand(command1, command1Handler),
docker run --rm -v $(pwd):/entrypoint.sh:/script/entrypoint.sh debian /script/entrypoint.sh
@timheuer
timheuer / Dockerfile
Created October 28, 2022 02:11
blazor-front-end-container
FROM nginx:latest AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["BlazorApp47/BlazorApp47.csproj", "BlazorApp47/"]
RUN dotnet restore "BlazorApp47/BlazorApp47.csproj"
COPY . .
@timheuer
timheuer / WANT.yaml
Created November 2, 2022 04:20
what i want
on: [push, pull_request, workflow_dispatch]
branches:
- main
paths-ignore:
- '**/*.md'
- '**/*.gitignore'
- '**/*.gitattributes'
{
"image": "mcr.microsoft.com/dotnet/sdk:7.0",
"extensions": [
"ms-dotnettools.csharp"
],
"postCreateCommand": "dotnet restore",
"forwardPorts": [
5163,
7105
],
@timheuer
timheuer / explanation.md
Created January 10, 2023 01:19
Explanation of Assembly properties

The Visual Studio 'project properties' UI provides easy modification of lots of properties for the project, assembly, and packaging capabilities (note: packaging means DLL, EXE, and NuGet packages).

In .NET Framework, VS provided a UI for Assembly Information: image

This translates in .NET Framework projects to (by default) an AssemblyInfo.cs (in Properties\AssemblyInfo.cs by default) and writes out the specific AssemblyAttribute (e.g., AssemblyTitleAttribute. It looks like this with the values in the UI from above:

[assembly: AssemblyTitle("This is the file description")]
[assembly: AssemblyDescription("This is a description but actually a Comment")]
[assembly: AssemblyConfiguration("")]
using System.Net;
using System.Net.Http.Json;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.VisualStudio.TestPlatform.TestHost;
using Xunit;
@timheuer
timheuer / aksworkflow.yaml
Created January 20, 2023 15:10
AKS Simple Workflow
name: build_deploy_aks
on:
push:
paths:
- "azure-vote/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
[Function(nameof(GetLiveChannels))]
public async Task<HttpResponseData> GetLiveChannels(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req,
ILogger log
)
{
var formData = new FormReader(req.Body);
// There is no Form property. How do we access the HTTP POST content?
var channelIds = formData.GetValue("ChannelIdCsv").ToString().Split(',');
@timheuer
timheuer / TokenHelper.cs
Created February 17, 2023 19:03
Helper function to try to estimate token size for OpenAI
static class TokenHelper
{
public static int EstimateTokenSize(this string text)
{
// Calculate the word count by splitting the text by spaces
int wordCount = text.Split(" ").Length;
// Calculate the character count by getting the length of the text
int charCount = text.Length;