Skip to content

Instantly share code, notes, and snippets.

View tkouba's full-sized avatar

Tomas Kouba tkouba

  • Prague, Czech Republic
View GitHub Profile
@maxreb
maxreb / JsonSerializerExtensions.cs
Created November 29, 2022 15:29
Benchmark PopulateObject
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
public static class JsonSerializerExt
{
// Dynamically attach a JsonSerializerOptions copy that is configured using PopulateTypeInfoResolver
private readonly static ConditionalWeakTable<JsonSerializerOptions, JsonSerializerOptions> s_populateMap = new();
@stellasphere
stellasphere / descriptions.json
Last active March 17, 2025 01:41
WMO weather interpretation code descriptions (& images)
{
"0":{
"day":{
"description":"Sunny",
"image":"http://openweathermap.org/img/wn/[email protected]"
},
"night":{
"description":"Clear",
"image":"http://openweathermap.org/img/wn/[email protected]"
}
@ErikNoren
ErikNoren / Program.cs
Last active February 3, 2025 16:05
ASP.NET Core 6 configuration settings stored in a SQL database and acts just like appsettings.json
//Snippet from Program.cs which adds the provider and sets up a Settings class to map the settings
using ErikNoren.Configuration;
using TestMvcWebApplication;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddSqlDatabase(config =>
{
//We can get the connection string from previously added ConfigurationProviders to use in setting this up
config.ConnectionString = builder.Configuration.GetConnectionString("DemoDatabase");
@philip-gai
philip-gai / github-drawio-demo.md
Last active March 15, 2025 03:05
How to integrate diagrams.net (draw.io) with your GitHub repo

Embedding Diagrams in GitHub Markdown

This explains and demos how to use diagrams.net (draw.io) diagrams in your GitHub repo.

  • See repo for more details

Benefits of using diagrams.net in GitHub repositories

  1. Diagrams are stored in your repository with your code and docs
  2. Diagram access is controlled by GitHub repository access
@cdelashmutt-pivotal
cdelashmutt-pivotal / Create-OpenSSHPubAndPrivateKeys.ps1
Created June 26, 2020 15:21
Generate OpenSSH compatible public and private key files in Powershell
<#
.SYNOPSIS
Create an OpenSSH compatible Public and Private Key in pure Powershell
.DESCRIPTION
Many scripts rely on the openssh or openssl tools to be available to generate public and private keys compatible with OpenSSH, but this script relies purely on Powershell (and some .NET classes already included) to generate public and private keys.
.EXAMPLE
PS /git/scripts> ./Create-OpenSSHPubAndPrivateKeys.ps1 -PublicKeyPath my-key.pub -PrivateKeyPath my-key
.LINK
mailto:[email protected]
#>
/*
Simple OpenSCAD DIN rail clip.
*/
module clip(z = 6) {
a = 7;
b = 1.2; // metal sheet thickness, should be ~ 1
c = 2.5;
@shanselman
shanselman / profile.json
Created May 7, 2019 04:22
Windows Terminal Profile
{
"defaultProfile": "{7d04ce37-c00f-43ac-ba47-992cb1393215}",
"initialRows": 30,
"initialCols": 120,
"alwaysShowTabs": true,
"showTerminalTitleInTitlebar": true,
"experimental_showTabsInTitlebar": true,
"requestedTheme": "dark",
"profiles": [
{
@DamienBraillard
DamienBraillard / ISimpleRoleProvider.cs
Last active March 11, 2025 14:21
Asp.Net Core simple role authorization with Windows Authentication
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace DamienBraillard.AspNetCoreSimpleRoleAuthorization
{
/// <summary>
/// Defines the base functionality of the class used to provide applicative roles for a user when using the simple role
/// authorization.
/// </summary>
using System;
using System.Collections.Generic;
using System.Linq;
public class Program {
public static void Main() {
// Test data
byte[] prefix = { 0xDE, 0xAD, 0xBE, 0xEF }; // 4 bytes
byte[] block1 = { 0xAA, 0xAA, 0xAA, 0xAA }; // 4 bytes
byte[] block2 = { 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, }; // 8 bytes