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 static async Task AsyncParallelForEach<T>(this IAsyncEnumerable<T> source, Func<T, Task> body, int maxDegreeOfParallelism = DataflowBlockOptions.Unbounded, TaskScheduler scheduler = null) | |
{ | |
var options = new ExecutionDataflowBlockOptions | |
{ | |
MaxDegreeOfParallelism = maxDegreeOfParallelism | |
}; | |
if (scheduler != null) | |
options.TaskScheduler = scheduler; | |
var block = new ActionBlock<T>(body, options); |
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 Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using Microsoft.CodeAnalysis.CSharp.Syntax; | |
using Microsoft.CodeAnalysis.Diagnostics; | |
using System.Collections.Immutable; | |
using System.Linq; | |
namespace BeyondAuth.Analyzers | |
{ | |
[DiagnosticAnalyzer(LanguageNames.CSharp)] |
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
addEventListener("fetch", (event) => { | |
event.respondWith( | |
handleRequest(event.request).catch( | |
(err) => new Response(err.stack, { status: 500 }) | |
) | |
); | |
}); | |
async function handleRequest(request) { | |
const { pathname, searchParams, host } = new URL(request.url); |
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
try | |
{ | |
using (var client = _clientFactory.CreateClient("captcha")) | |
{ | |
var response = await client.PostAsync("recaptcha/api/siteverify", new FormUrlEncodedContent(new Dictionary<string, string> { { "secret", _captchaSettings.Value.Secret }, { "response", model.Token }, { "remoteip", Request.HttpContext.Connection.RemoteIpAddress?.ToString() } }), ct); | |
response.EnsureSuccessStatusCode(); | |
var captchaResponse = await response.Content.ReadAsAsync<CaptchaResponse>(ct); | |
if (!captchaResponse.Success) | |
{ | |
ModelState.AddModelError(nameof(model.Email), "Invalid captcha"); |
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
finally { RunningRequests.Remove(HttpContext.Connection.RemoteIpAddress.ToString(), out var _); } |
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
await Task.Delay(3000, ct); |
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
while (!RunningRequests.TryAdd(HttpContext.Connection.RemoteIpAddress.ToString(), true)) await Task.Delay(3000, ct); |
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
private static ConcurrentDictionary<string, bool> RunningRequests = new ConcurrentDictionary<string, bool>(); |
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.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace Extensions | |
{ | |
public static class Extensions | |
{ | |
public static Task ForEachAsync<T>(this IEnumerable<T> source, int dop, Func<T, Task> body) |
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
! 2020-12-02 https://twitter.com | |
twitter.com##.r-1ny4l3l.r-1wbh5a2.r-16y2uox.css-1dbjc4n > .css-1dbjc4n > div.css-1dbjc4n > div.css-1dbjc4n > .css-1dbjc4n > .r-1g94qm0.css-1dbjc4n > .r-qvutc0.r-1w50u8q.r-m611by.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-qklmqi.r-rull8r.r-j7yic.css-901oao.css-18t94o4.css-4rbku5 | |
twitter.com##.r-1mi0q7o.r-1777fci.r-16y2uox.r-1iusvr4.css-1dbjc4n > div.css-1dbjc4n > div.css-1dbjc4n > .css-1dbjc4n > .r-1g94qm0.css-1dbjc4n > .r-qvutc0.r-1w50u8q.r-m611by.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-qklmqi.r-rull8r.r-j7yic.css-901oao.css-18t94o4.css-4rbku5 | |
twitter.com##.r-qvutc0.r-1w50u8q.r-m611by.r-1j3t67a.r-1inuy60.r-bcqeeo.r-ad9z0x.r-16dba41.r-a023e6.r-1qd0xha.r-1loqt21.r-1n1174f.r-5kkj8d.r-1efd50x.r-mxfbl1.css-901oao.css-18t94o4.css-4rbku5 | |
NewerOlder