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
@timheuer
timheuer / template.xaml
Created July 28, 2023 18:40
WPF Styling problem
<HierarchicalDataTemplate x:Key="TreeViewRunNodeDataTemplate" ItemsSource="{Binding Jobs}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<TextBlock VerticalAlignment="Center" FontFamily="{StaticResource CodiconFont}"
Foreground="{Binding Path=Conclusion, Converter={StaticResource ConclusionColorConverter}}"
Text="{Binding Path=Conclusion, Converter={StaticResource ConclusionIconConverter}}"/>
<emoji:TextBlock Text="{Binding DisplayName}" VerticalAlignment="Bottom" Tag="{Binding Url}"/>
</StackPanel>
</HierarchicalDataTemplate>
@timheuer
timheuer / vsdot.ps1
Created July 19, 2023 19:37
vs dot
function vs {
$p = Get-Location
$sln = gci *.sln,*.csproj -n -recurse | select -f 1
Write-Output "Opening $p\$sln"
Start-Process -FilePath "C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\devenv.exe" -ArgumentList "$p\$sln"
}
@timheuer
timheuer / address.json
Created July 10, 2023 22:50
address.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"Street": {
"type": "string"
},
"City": {
"type": "string"
},
@timheuer
timheuer / person.json
Last active July 10, 2023 22:52
person.json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"FirstName": {
"type": "string"
},
"LastName": {
"type": "string"
},
@timheuer
timheuer / file.html
Last active June 26, 2023 22:49
code examples
<html>
<head><title>test</title></head>
<body>
<div> This is some text with <b>bolding</b></div>
<div> But when representing code in html you use 'pre' like this</div>
<div><pre>public class Foo { }</pre></div>
</body>
</html>
@timheuer
timheuer / devcontainer.json
Last active November 21, 2024 14:29
.NET 8 SDK devcontainer w/aspire
{
"name": ".NET with Aspire",
"image": "mcr.microsoft.com/dotnet/sdk:8.0",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "2"
},
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest"
  1. SOME STARTING NOTE

    (a) Some specific section header

  2. ANOTHER STARTING NOTE

a. Section subheader

i. Sub sub header

@timheuer
timheuer / background.js
Created April 23, 2023 00:18
Simple Chrome extension
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
console.log("Completed tab was loaded, injecting content.js");
chrome.scripting.executeScript(
{
target: {tabId: tabId},
files: ['content.js']
}
);
}
@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;
[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(',');