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 / 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 / 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.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 / 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 / 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 / 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>
}
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 / 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]
@JerryNixon
JerryNixon / milliseconds.sql
Last active September 14, 2020 17:28
Convert milliseconds to Hours/Minutes/Seconds printable format in TSQL.
declare @ms bigint = 123456789;
declare @start datetime = '1/1/2000';
declare @date datetime = dateadd(millisecond, @ms, @start);
declare @day_diff int = datediff(day, @start, @date);
declare @time time = cast(@date as time);
declare @value varchar(max) = concat(
@day_diff, ' Day(s) ',
format(@time, 'hh'), ' Hour(s) ',
@JerryNixon
JerryNixon / .editorconfig
Created June 13, 2020 00:47
Simple dotnet Editor Config
[*.cs]
# Indentation and spacing
indent_size = 4
indent_style = space
# New line preferences
end_of_line = crlf
insert_final_newline = false