Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / DecoratorAttribute.cs
Created March 9, 2021 19:49
Scrutor użycie dekoratora
public class DecoratorAttribute : Attribute
{
}
@danielplawgo
danielplawgo / IRepository.cs
Created March 2, 2021 07:26
Scrutor auto rejestracja typów
public interface IRepository
{
}
@danielplawgo
danielplawgo / azurepipelines1.yml
Last active February 16, 2021 05:05
Azure DevOps path filters
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
branches:
include:
- master
paths:
@danielplawgo
danielplawgo / ProcessResponse.cs
Created February 10, 2021 07:28
SendGrid - Webhook
private async Task<IActionResult> ProcessResponse(Response response)
{
var responseContent = await response.Body.ReadAsStringAsync();
if (string.IsNullOrEmpty(responseContent) == false)
{
return BadRequest(responseContent);
}
var header = response.Headers.FirstOrDefault(h => h.Key == "X-Message-Id");
@danielplawgo
danielplawgo / SendGridConfig.cs
Created February 2, 2021 04:58
SendGrid - wysyłka wiadomości email
public class SendGridConfig
{
public string ApiKey { get; set; }
public string SenderEmail { get; set; }
public string SenderName { get; set; }
}
@danielplawgo
danielplawgo / AddData.cs
Last active February 22, 2021 04:31
EF Core 5 relacja wiele do wielu
private static async Task AddData()
{
using (var db = new DataContext())
{
var project1 = new Project()
{
Name = "project 1"
};
await db.Projects.AddAsync(project1);
@danielplawgo
danielplawgo / ConsoleExample.cs
Created January 18, 2021 07:25
RateLimiter limitowanie ilości żądań
static async Task ConsoleExample()
{
var timeConstraint = TimeLimiter.GetFromMaxCountByInterval(5, TimeSpan.FromSeconds(1));
for (int i = 0; i < 100; i++)
{
await timeConstraint;
Console.WriteLine($"{DateTime.Now:MM/dd/yyy HH:mm:ss.fff}");
}
}
@danielplawgo
danielplawgo / Auth.feature
Last active January 11, 2021 05:49
Karate - automatyczne testy API
Feature: Auth - fetching jwt token
Background:
* url baseUrl+"/api/Auth/Login"
Scenario: Featch jwt token
Given request {"Username":"#(userName)","Password":"#(password)"}
When method POST
Then status 200
And match response contains { "message": "Success" }
@danielplawgo
danielplawgo / App.razor
Last active December 16, 2020 09:34
Blazor Lazy Loading
@using System.Reflection
<Router AppAssembly="@typeof(Program).Assembly"
AdditionalAssemblies="@assemblies">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
@danielplawgo
danielplawgo / FetchData.razor
Created December 3, 2020 05:18
Blazor - prerendering
@page "/fetchdata"
@using BlazorPreRendering.Shared
@using BlazorPreRendering.Shared.Services
@inject IWeatherForecastService Service
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from the server.</p>
@if (forecasts == null)