This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Startup.cs | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
app.UseIpRateLimiting(); | |
app.UseClientRateLimiting(); | |
// the rest | |
} | |
public void ConfigureServices(IServiceCollection services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IProductGet : IGet<List<Product>> | |
IProductPost : IPost<Product, Product> | |
IProductDelete : IDelete<Product, long> | |
class ProductRest : | |
IProductGet, | |
IProductPost, | |
IProductDelete | |
{ | |
public async Task<List<Product>> Get(CancellationToken cancellationToken) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
#customers { | |
font-family: Arial, Helvetica, sans-serif; | |
border-collapse: collapse; | |
width: 100%; | |
} | |
#customers td, #customers th { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You need Prism though :) | |
public class AdaptiveCommand : DelegateCommand | |
{ | |
private const double DefaultInvocationDelay = 0.7; | |
public double InvocationDelayInSeconds { get; set; } | |
private DateTime lastInvokeTime = DateTime.MinValue; | |
private readonly Func<bool>? canExecute; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GET: api/Cave | |
[HttpGet] | |
public async Task<ActionResult<IEnumerable<CaveDto>>> GetCave([FromQuery]Pager pager) | |
{ | |
var caveQuery = | |
from cave in context.Cave | |
join user in context.User on cave.AuthorId equals user.Id | |
join map in context.Map on cave.Id equals map.CaveId | |
let score = | |
( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cave in context.Cave | |
join user in context.User on cave.AuthorId equals user.Id | |
join map in context.Map on cave.Id equals map.CaveId | |
let score = | |
( | |
from score in context.Score | |
where score.CaveId == cave.Id && score.UserId == user.Id | |
select score.MaxScore | |
).Sum() | |
let paths = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isEven(n) { | |
return n % 2 == 0; | |
} | |
function getColumnSum(column, block, skipFirst) { | |
return (skipFirst ? 0 : block[column + 0]) + | |
block[column + 4] + | |
block[column + 8] + | |
block[column + 12]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseCommand : DelegateCommand | |
{ | |
public double InvocationDelayInSeconds { get; set; } | |
private DateTime lastInvokeTime = DateTime.MinValue; | |
private readonly Func<bool> canExecute; | |
public BaseCommand( | |
Action executeAction, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace TestCsharpConsole | |
{ | |
public static class ConsoleHelper | |
{ | |
public static void Write(int left, int top, string text, ConsoleColor color = ConsoleColor.White) | |
{ | |
Console.ForegroundColor = color; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Correct | |
public static async Task<string> StreamToString(Stream stream) | |
{ | |
using var reader = new StreamReader(stream); | |
return await reader.ReadToEndAsync(); | |
} | |
// Incorrect | |
public static Task<string> StreamToString(Stream stream) | |
{ |