Skip to content

Instantly share code, notes, and snippets.

View vmandic's full-sized avatar
🤠
chillin'

Vedran Mandić vmandic

🤠
chillin'
View GitHub Profile
@vmandic
vmandic / Program.cs
Created December 24, 2020 15:07
How to inject custom IConfiguration in Startup.cs CTOR
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
namespace StartupIConfigurationInjectionProblem
{
public class Program
@philippdolder
philippdolder / Setup-Windows-Defender-Exclusions-Rider.ps1
Created January 6, 2020 00:48
Windows Defender configuration for JetBrains Rider
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$RiderHome
)
function Update-WindowsDefenderForRider {
[CmdletBinding()]
param (
@davidfowl
davidfowl / Program.cs
Last active June 29, 2024 18:09
A minimal fully asynchronous C# ASP.NET Core 3.0 application with routing (learn more about ASP.NET Core here https://docs.microsoft.com/en-us/aspnet/core/?view=aspnetcore-3.0)
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Hosting;
public class Program
{
public static void Main(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
@jeremyabbott
jeremyabbott / removeDotnetSdksRuntimes.sh
Last active April 28, 2019 08:19
Remove old .NET Core versions
# dotnet --list-sdks # output looks like
# 2.1.500 [/usr/local/share/dotnet/sdk]
# awk '{print $2"/"$1}' # takes each line from stdin and prints out the 2nd column then "/" then the first column
# this gives us [/usr/local/share/dotnet/sdk]/2.1.500
# sed 's/\]//' # replaces the first ']'. ']' has to be escaped with \
# sed 's/\[//' # replaces the first '['. '[' has to be escaped with \
# grep -Ev '2\.2\.102' # matches on 2.2.102 which was the latest SDK installed
# -E # enables extended regular expression syntax
# -v # inverts the match. So return anything that doesn't match
# xargs # allows us to pass standard in as an argument to rm -rf
@vbilopav
vbilopav / pubsub.js
Last active February 19, 2019 14:26
/*
*** Publish/Subscribe global events functions - implementation of pubsub pattern for loose coupled components ***
Usage:
* Publish global application event:
publish("unique event name / category / subcategory", arg1, arg2, arg3);
or
@hlaueriksson
hlaueriksson / Examples.cs
Last active November 12, 2023 21:19
PuppeteerSharp Documentation
using System;
using System.Threading.Tasks;
using NUnit.Framework;
namespace PuppeteerSharp.Contrib.Sample
{
public class Examples
{
async Task<IBrowser> Browser()
{
@vmandic
vmandic / cloudSettings
Last active June 23, 2020 12:25
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-06-23T12:25:19.840Z","extensionVersion":"v3.4.3"}
@akatakritos
akatakritos / create-aspnet-core-identity-schema.sql
Created June 5, 2018 03:19
Script to create the ASPNET core Identity tables
USE [HobbyDB]
GO
/****** Object: Table [dbo].[AspNetRoleClaims] Script Date: 6/4/2018 10:18:03 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AspNetRoleClaims]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[AspNetRoleClaims](

An EF Core / OData - Generic Repository 🛠 😵

This library offers an implementation of the Generic Repository Pattern for Microsoft's Entity Framework Core 2.0 ORM supporting the use of OData v4 querying service protocol.

The OData part of the library offers an additional Repository implementation named ODataEfRepository with its complementing interface type IODataEfRepository. The OData Repository exposes several methods that allow querying an IQueryable<T> with OData's query options where the queryable can be produced out of EF's DbSet<T> or any other valid IQueryable<T>. This way you can pre/post filter/select/expand EF queryable sources using OData syntax.

Beta dependency caution 💣

The library currently uses the latest Microsoft.AspnetCore.OData (7.0.0-beta2) to provide OData services and it might be buggy as it is not a stable offical release.

@regisdiogo
regisdiogo / Startup.cs
Last active June 13, 2022 11:17
ASP.NET Core - Json serializer settings Enum as string and ignore null values
public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
});
}