Skip to content

Instantly share code, notes, and snippets.

View JerryNixon's full-sized avatar
🤔
Trying to make a living.

Jerry Nixon JerryNixon

🤔
Trying to make a living.
View GitHub Profile
@JerryNixon
JerryNixon / XunitTestWithData.cs
Last active October 18, 2023 20:06
Using complex data types as InlineData for Xunit tests.
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace PlaygroundXunit
{
public class UnitTest1
{
[Theory]
drop table if exists parent
create table parent
(
id int primary key identity(1,1),
name varchar(50)
)
insert into parent (name) values ('sue'), ('michael'), ('sandy'), ('doug')
drop table if exists child
create table child
@JerryNixon
JerryNixon / index.razor
Created November 6, 2020 22:28
Blazor troubles with cascading InputSelect
@page "/"
<EditForm Model="@Model">
First
<InputSelect @bind-Value="Model.First" class="form-control" @oninput="FirstChanged">
@foreach (var item in FirstList)
{
<option value="@item">@item</option>
}
@JerryNixon
JerryNixon / index.razor
Last active November 7, 2020 08:03
Blazor troubles with rendering <option/>
@using Microsoft.AspNetCore.Components.Rendering
<EditForm Model="@Model">
<InputSelect class="form-control" @bind-Value="Model.Selection">
@{ MakeOption(__builder, "John"); }
@{ MakeOption(__builder, "Jack"); }
@{ MakeOption(__builder, "Mark"); }
</InputSelect>
@JerryNixon
JerryNixon / balance.cs
Last active January 5, 2021 01:00
Balance Parentheses in a string
// netcoreapp3.1
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
namespace Jerry
{
class Program
@JerryNixon
JerryNixon / FloydWarshall.sql
Last active January 20, 2021 23:56
TSQL version of Floyd-Warshall
IF (object_id('Matrix') is not null)
DROP TABLE Matrix;
GO
CREATE TABLE Matrix
(
SOURCE VARCHAR(50)
, DEST VARCHAR(50)
, COST MONEY
@JerryNixon
JerryNixon / InsertIdentity.sql
Last active January 19, 2021 16:49
Get the auto-generated key from a SQL insert operation
SET NOCOUNT ON
CREATE TABLE [Users]
(
[Id] INT PRIMARY KEY IDENTITY(1,1)
, [Name] VARCHAR(50) NOT NULL
)
GO
@JerryNixon
JerryNixon / FloydWarshall.cs
Created January 21, 2021 00:00
Simple implementation of Floyd-Warshall in C#
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace Algo
{
internal class Program
{
public static void Main()
@JerryNixon
JerryNixon / RandomList.cs
Created January 26, 2021 17:40
Generate a randomized list of integers.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
public class Program
{
public static void Main()
{
var count = 20000;
@JerryNixon
JerryNixon / Assert.sql
Last active May 18, 2022 23:36
An Assert framework for SQL Server
CREATE SCHEMA assert;
GO
/*
assert.Contain
Ensure fragment is inside string.
@fragment: String to search for
@string: String to search in
@msg: (optional) Append custom error message - default: NULL