Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
danielplawgo / GetWeather.cs
Created September 29, 2020 04:23
Azure Logic App - koszty
using System;
using System.Threading.Tasks;
using System.Net.Http;
private static HttpClient httpClient = new HttpClient();
public static void Run(TimerInfo myTimer, ILogger log, out string outputBlob)
{
var response = httpClient.GetAsync("http://api.openweathermap.org/data/2.5/weather?q=olsztyn,pl&APPID=4e61d7e7f40f9c3205722f24ebd3c2ac").Result;
outputBlob = response.Content.ReadAsStringAsync().Result;
@danielplawgo
danielplawgo / azure-pipelines.yml
Created October 26, 2020 05:35
Azure Logic App - wdrażanie
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- master
pool:
vmImage: 'ubuntu-latest'
@danielplawgo
danielplawgo / DataContext.cs
Created November 6, 2020 08:11
Optymistyczna współbieżność w EF Core
public class DataContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=.\SQLEXPRESS;Database=EFCoreOptimisticConcurrency;Trusted_Connection=True;");
}
public DbSet<Product> Products { get; set; }
}
@danielplawgo
danielplawgo / FetchData.razor
Created November 26, 2020 08:01
Blazor oraz .NET 5
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@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)
@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 / 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 / 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 / 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 / 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; }
}