Skip to content

Instantly share code, notes, and snippets.

View scheffler's full-sized avatar

Steve Scheffler scheffler

View GitHub Profile
@scheffler
scheffler / launchSettings.json
Last active October 15, 2020 22:45
Starting launchSettings.json file
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:42480",
"sslPort": 44393
}
},
@scheffler
scheffler / README.md
Last active August 26, 2020 13:17
Preserve JSON case using NewtonSoft in aspnet core 3.x

With aspnet core 3.x, the default Text JSON serializer as well as the Newtonsoft extension (if you're still holding on to Newtonsoft like I am) apply a camel casing naming strategy.

This means that for your upper case properties in C# land, they get translated to lower case starting letters in javascript. This is great. Unless you're dealing with a legacy codebase where the javascript is expecting the starting upper cases.

The fix is easy. Just set contract resolver in your Startup to an instance of DefaultContractResolver.

@scheffler
scheffler / README.md
Created August 11, 2020 00:11
Using System.Windows.Forms in a dotnet core app

With dotnet core 3.x you can have libraries which rely on System.Windows.Forms if you setup you project file properly.

  1. In the Project tag, make sure that you specify WindowsDesktop
  2. Include the UseWindowsForms tag in PropertyGroup
@scheffler
scheffler / IsRunningInService.cs
Last active August 7, 2020 13:34
dotnet core fix configuration path when running as service
//
// When running a dotnet core console app from within a windows service, you may
// see that the service will not start. If you're using the default host builder it
// won't be able to find appsettings.json b/c your starting directory is not where it would
// be when you run interactively.
//
// Call the WindowsServiceHelpers:IsWindowsService to check to see if you're running in a service
// context and then force the current directory to the location of the exe.
//
using System.Reflection;
using log4net;
using log4net.Appender;
using log4net.Core;
using log4net.Layout;
using log4net.Repository.Hierarchy;
using Microsoft.Extensions.Configuration;
// also need Microsoft.Extensions.Configuration.Binding for the Bind to work
namespace ControlCenter.Model
@scheffler
scheffler / ola-sql-backup-to-url.md
Last active July 21, 2023 03:38
How to backup a SQL database to an Azure URL using Ola Hallengren's stored procedures

Description

How to backup a SQL database to an AZURE storage account using the Ola Hallengren scripts.

Requires the stored procedures from: https://ola.hallengren.com/sql-server-backup.html

Create an azure storage account

First, create an azure storage account with block blob support (v2 will suffice) and then create a blob container within that. For this example we'll call it sqlbackup.

@scheffler
scheffler / .gitignore
Created September 4, 2019 12:32
.gitignore for dotnet projects
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
@scheffler
scheffler / windows-terminal-profile.json
Created July 19, 2019 18:46
Windows Terminal Profile
{
"globals" :
{
"alwaysShowTabs" : true,
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"initialCols" : 120,
"initialRows" : 30,
"keybindings" :
[
{
@scheffler
scheffler / fix-ifmetric-issue.ps1
Last active October 11, 2019 18:29
Fix VPN connection issue for BankPoint
#
# Occassionally, you won't be able to connect to Azure VMs when you've properly connected to the BankPoint VPN.
# If you ping the server and you get a non 10.x.x.x address then you can pretty much be certain that's your problem.
# https://www.windowscentral.com/how-change-priority-order-network-adapters-windows-10
# Get-NetIPInterface
# To correct, you need to bump up the priority of your VPN interface
#
# First, make sure that you're connected to the BankPoint Azure VPN
#
# Then, open up a powershell console window in Administrator mode and then run the following
@scheffler
scheffler / aspnetcore-snippets.md
Last active June 26, 2019 19:14
ASP.Net Core Snippets

Nuget packages when working in aspnet core

Automapper

Package: AutoMapper.Extensions.Microsoft.DependencyInjection

In Startup\ConfgureServices:

servcies.AddAutomapper();