Skip to content

Instantly share code, notes, and snippets.

View kentkost's full-sized avatar
🎯
Focusing

Kent Kostelac kentkost

🎯
Focusing
View GitHub Profile
@kentkost
kentkost / ModelBuilderExtensions.cs
Created May 5, 2022 11:58
This is an extension to DbContext. Where it only adds Configurations that are DbSets in the DbContext
public static class ModelBuilderExtensions
{
//Only add the IEntityTypeConfigurations that are in the DataContext
public static void ApplyConfigurationsForEntitiesInContext(this ModelBuilder modelBuilder)
{
var types = modelBuilder.Model.GetEntityTypes().Select(t => t.ClrType).ToHashSet();
modelBuilder.ApplyConfigurationsFromAssembly(
Assembly.GetExecutingAssembly(),
t => t.GetInterfaces()
@kentkost
kentkost / Program.cs
Created May 4, 2022 08:07 — forked from BryanWilhite/Program.cs
.NET Core: using ServiceCollection() and AddConsole() in a console app
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
namespace Songhay.HelloWorlds.Shell
{
class Program
{
static void Main(string[] args)
{
@kentkost
kentkost / postman-bigint.js
Created December 3, 2020 12:43 — forked from mahasak/postman-bigint.js
Postman Test Runner BigInt fix
var BigNumber,
isNumeric = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
mathceil = Math.ceil,
mathfloor = Math.floor,
notBool = ' not a boolean or binary digit',
roundingMode = 'rounding mode',
tooManyDigits = 'number type has more than 15 significant digits',
ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_',
BASE = 1e14,
LOG_BASE = 14,
@kentkost
kentkost / ThreadsWithSemaphoresWithMutex.cs
Created April 11, 2020 09:36
Threads with semaphore and mutex and a variable #semaphore #threads #mutex
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Threading
{
class Program
@kentkost
kentkost / Semaphore.cs
Created April 11, 2020 09:07
Threads with semaphore #semaphore #thread
using System;
using System.Threading;
namespace MutexDemo
{
class Program
{
public static Semaphore semaphore = new Semaphore(2, 3);
static void Main(string[] args)
{
@kentkost
kentkost / ThreadedDelegate.cs
Created April 11, 2020 08:48
Threading using a delegate ThreadStart to control flow #thread #threadstart #semaphore
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Threading
{
class Program
@kentkost
kentkost / ParameterizedThreadStart.cs
Last active April 11, 2020 08:37
Threads with ParameterizedThreadStart #threads
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Threading
{
class Program
@kentkost
kentkost / ThreadsParameters.cs
Last active April 11, 2020 08:37
Threading with parameters automatic delegate casting #threads
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
namespace Threading
{
class Program
@kentkost
kentkost / UniquePermutations.cs
Created March 10, 2020 15:10
Unique permutations of a list of strings
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PermutationsUnqiue
{
class Program
{
@kentkost
kentkost / combinations.cs
Created March 10, 2020 02:12
Swap strings to get all the combinations of a string
static void SwapWords(List<string> sentence, int i, List<List<string>> results)
{
List<List<string>> combo = new List<List<string>>();
if (i < sentence.Count && map.ContainsKey(sentence[i])) {
foreach (string s in map[sentence[i]]) {
List<string> temp = new List<string>(sentence);
temp[i] = s;
combo.Add(temp);
}
foreach (List<string> ls in combo) {