Skip to content

Instantly share code, notes, and snippets.

@benhysell
benhysell / DisplayResults.razor.cs
Created March 18, 2022 14:53
asp.net core health check controller
using Microsoft.AspNetCore.Components;
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.SignalR.Client;
namespace UI
{
public partial class DisplayResults : IDisposable
@benhysell
benhysell / SqlExamineResultHealthCheck.cs
Created March 16, 2022 17:43
c# asp.net core health check that looks at the result of the query to determine healthy or not
using System;
using System.Data.Common;
using System.Data.SqlClient;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Diagnostics.HealthChecks;
namespace YOUR_NAMESPACE_HERE
{
public class SqlExamineResultHealthCheck : IHealthCheck
@benhysell
benhysell / HistoryTableUtilities.cs
Created July 1, 2019 14:55
MS SQL History Table Utilities
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
namespace Utilities.Sql
{
public class HistoryTableUtilities
{
@benhysell
benhysell / GenerateSqlScripts.ps1
Created June 13, 2019 14:59
Extract Data From MS SQL via mssql-scripter
#https://github.com/Microsoft/mssql-scripter
#step 1 run this script to pull out all data to a local directory
#step 2 run result files through GenerateScripts application to strip out date time for system controlled fields
#step 3 save / reinsert using standard script
mssql-scripter -S localhost -d databaseName -P PASSWORD --data-only --include-objects dbo.TableName > './001 - TableName.sql'
@benhysell
benhysell / DropZone.tsx
Created July 23, 2018 19:55
React-DropZone file upload with redux-form and remove file after added
import * as React from 'react';
import { Alert, Checkbox, FormGroup } from 'react-bootstrap';
import Dropzone from 'react-dropzone';
import * as _ from 'lodash';
// tslint:disable-next-line:typedef
public static dropZoneFileInput(field) {
const files = field.input.value;
return (
<div>
@benhysell
benhysell / HttpResponseChecking.cs
Created July 23, 2018 13:08
asp.net core http response checking from a controller
using System.Collections.Generic;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
namespace Web.Utilities
{
/// <summary>
/// Check the response of a http requests
/// </summary>
public class HttpResponseChecking
@benhysell
benhysell / AzureSigningKey.cs
Created July 23, 2018 13:06
Client to call Azure for signing keys for SPA with oidc-client
using Newtonsoft.Json;
namespace Web.DataTransferObjects.Utilities
{
/// <summary>
/// Azure signing key structure
/// </summary>
public class AzureSigningKey
{
/// <summary>
@benhysell
benhysell / AzureStorageSimulator.cs
Created July 23, 2018 12:55
Azure Storage Simulator using Azurite and Docker
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Docker.DotNet;
using Docker.DotNet.Models;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
@benhysell
benhysell / directions.md
Created July 2, 2018 13:47
Create Templates from Existing .NET core applications
  • ensure current project runs/compiles
  • Add template.json to project in same directory as sln in folder .template.config
  • for example, Web\web.sln will have a new directory Web.template.config\template.json
  • From PS - dotnet new --install "C:\jobs\PATH TO FOLDER CONTAINING .template.config"
  • i.e. dotnet new -- install "c:\jobs\web" -- since .template.config exists in c:\jobs\web
  • run -- dotnet new starterWeb4 -n NAMESPACE_NEWPROJECT
  • make sure to run in directory where you'd like it created
@benhysell
benhysell / .editorconfig
Created December 3, 2017 03:59
vs2017 editor config
# EditorConfig is awesome:http://EditorConfig.org
# top-most EditorConfig file
root = true
# don't use tabs for indentation.
[*]
indent_style = space
# (Please don't specify an indent_size here; that has too many unintended consequences.)