Skip to content

Instantly share code, notes, and snippets.

@Brar
Brar / postgres-configure-sspi.ps1
Last active January 27, 2025 06:57
PowerShell script to automate configuring PostgreSQL for SSPI authentication on Windows
# Requires PowerShell 6+
# Some commands will fail if the PostgreSQL bin directory is not in your PATH
# The pg_ctl reload command may require running it with Administrator rights
$data_directory, $pg_hba_conf_path, $pg_ident_conf_path = psql -c "SELECT setting FROM pg_settings WHERE name IN ('data_directory', 'hba_file', 'ident_file') ORDER BY name" -tU postgres |
%{ $_.Trim() } |
where { $_.Length -gt 0 } |
Convert-Path
# Add a user mapping for domain users (or local users if your computer is not in a domain) to your pg_ident.conf
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active March 31, 2025 09:49
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@mombrea
mombrea / DbInitializer.cs
Last active April 5, 2023 21:55
EF Core 1.0 and ASP.NET Core Identity Seed Data
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using System.Linq;
namespace My.App.Data
{
public class DbInitializer : IDbInitializer
{
private readonly ApplicationDbContext _context;
private readonly UserManager<ApplicationUser> _userManager;
@DalSoft
DalSoft / DalSoftDbContext.cs
Last active March 12, 2018 07:41
Entity Framework Core Migrations and Seeding
using System;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Configuration;
namespace DalSoft.Data
@maartenba
maartenba / DomainTemplateRoute - GetVirtualPath
Last active May 15, 2023 07:30
ASP.NET MVC 6 / ASP.NET 5 Domain Routing + Tenant Middleware
public string GetVirtualPath(VirtualPathContext context)
{
foreach (var matcherParameter in _matcher.Template.Parameters)
{
context.Values.Remove(matcherParameter.Name); // make sure none of the domain-placeholders are appended as query string parameters
}
return _innerRoute.GetVirtualPath(context);
}
@bt5e
bt5e / gist:7507535
Last active November 2, 2024 07:43
Markdown subscript and superscript

Testing subscript and superscript

Testing subscript subscript level 2

Testing superscript superscript level 2