Skip to content

Instantly share code, notes, and snippets.

View tkouba's full-sized avatar

Tomas Kouba tkouba

  • Prague, Czech Republic
View GitHub Profile
@ErikNoren
ErikNoren / Program.cs
Last active February 27, 2024 18:15
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 February 27, 2024 20:26
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:grog@grogscave.net
#>
/*
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 April 1, 2024 06:22
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
@plumbum
plumbum / sector.scad
Created July 12, 2017 08:59
How to make cylinder sector in OpenSCAD
translate([0,0,0]) sector(30, 20, 10, 90);
translate([22,0,0]) sector(30, 20, 300, 30);
translate([0,22,0]) sector(30, 20, 30, 300);
translate([22,22,0]) sector(30, 20, 10, 190);
module sector(h, d, a1, a2) {
if (a2 - a1 > 180) {
difference() {
cylinder(h=h, d=d);
translate([0,0,-0.5]) sector(h+1, d+1, a2-360, a1);
@vermorel
vermorel / Half.cs
Last active November 26, 2023 22:43
C# Half-precision data type
/// ================ Half.cs ====================
/// The code is free to use for any reason without any restrictions.
/// Ladislav Lang (2009), Joannes Vermorel (2017)
using System;
using System.Diagnostics;
using System.Globalization;
namespace SystemHalf
{
@GER-NaN
GER-NaN / SourceCombiner.cs
Last active June 25, 2023 06:59
This will combine multiple .cs files from a solution into a single source file.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Construction;
namespace SourceCombiner