Skip to content

Instantly share code, notes, and snippets.

View ilmax's full-sized avatar
🚀

Massimiliano Donini ilmax

🚀
View GitHub Profile
public class AuthorizationController : Controller
{
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
[Route("~/connect/authorize")]
public async Task<ActionResult> Authorize(CancellationToken cancellationToken)
{
// Note: when a fatal error occurs during the request processing, an OpenID Connect response
// is prematurely forged and added to the OWIN context by OpenIdConnectServerHandler.
// In this case, the OpenID Connect request is null and cannot be used.
// When the user agent can be safely redirected to the client application,
[Authorize, HttpPost, Route("~/connect/authorize/accept"), ValidateAntiForgeryToken]
public async Task<ActionResult> Accept(CancellationToken cancellationToken)
{
// Extract the authorization request from the cache, the query string or the request form.
var request = OwinContext.GetOpenIdConnectRequest();
if (request == null)
{
return View("Error", new OpenIdConnectMessage
{
Error = "invalid_request",
@ilmax
ilmax / git-stop-tracking-remote-branch.md
Created June 14, 2016 13:01 — forked from magnusbae/git-stop-tracking-remote-branch.md
How to make Git stop track a remote branch without deleting the remote branch.

You don't have to delete your local branch.

Simply delete your remote tracking branch:

git branch -d -r origin/<remote branch name> (This will not delete the branch on the remote repo!)

See "Having a hard time understanding git-fetch"

there's no such concept of local tracking branches, only remote tracking branches.

@ilmax
ilmax / FiddlerRule.js
Created July 1, 2016 10:39
Fiddler exclude css & javascript rules by @hasegawayosuke
// Open Fiddler and Choose "Rules" menu, click "Customize Rules..." and add this code to CustomRule.js
class Handlers
{
// ....
public static RulesOption("Hide CSS")
BindPref("fiddlerscript.rules.HideCSS")
var m_HideCSS: boolean = false;
// ....
static function OnBeforeResponse(oSession: Session) {
@ilmax
ilmax / gist:f5dfe6835d9215109b3fb7ba3702fef8
Last active March 16, 2018 15:21
Asp.net core 2.1 prev1 perf comparison

IIS ANCM 2.1 preview1 hosting in process

Running 30s test @ http://localhost:8080/api/values/5
  12 threads and 50 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.34ms  371.95us  18.71ms   96.25%
    Req/Sec     3.00k   212.61     5.64k    83.34%
  Latency Distribution
     50%    1.30ms
     75%    1.39ms
@ilmax
ilmax / ReflectionVsTypeloader.cs
Created November 2, 2018 10:07
Reflection vs TypeLoader
void Main()
{
BenchmarkRunner.Run<TypeBenchmark>();
BenchmarkRunner.Run<FieldsBenchmark>();
BenchmarkRunner.Run<PropertiesBenchmark>();
BenchmarkRunner.Run<MethodsBenchmark>();
}
// Define other methods and classes here
[MemoryDiagnoser]
git config --global alias.unstage 'reset HEAD --'
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.mem '!git fetch origin main; git merge origin/main'
git config --global alias.rem '!git fetch origin main; git rebase origin/main'
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.purge '!git fetch -p && git branch -vv | awk '"'"'/: gone]/{print $1}'"'"' | xargs git branch -d'
git config --global alias.cleanup '!git branch --merged | grep -v '"'"'\*\|master\|develop|main'"'"' | xargs -n 1 -r git branch -d'
git config --global alias.lc 'log -1 HEAD'
az webapp config ssl list -g tg-ts-prod -o tsv --query "[?contains(issuer, 'Let') && contains(expirationDate, '2019')].[thumbprint]" | wsl awk '{print "call az webapp config ssl delete -g tg-ts-prod --certificate-thumbprint "$1}' > run.cmd && run.cmd
// Courtesy of https://github.com/IdentityServer/IdentityServer4/blob/18897890ce2cb020a71b836db030f3ed1ae57882/src/IdentityServer4/src/Endpoints/DiscoveryEndpoint.cs
// This slightly adjusts the original implementation to play nicely behind an application gateway so it checks if we have an X-original-host header and uses that as our baseUrl
internal class DiscoveryEndpointHandler : IEndpointHandler
{
private readonly ILogger _logger;
private readonly IdentityServerOptions _options;
private readonly IDiscoveryResponseGenerator _responseGenerator;
@ilmax
ilmax / Sorting.cs
Last active November 23, 2020 12:18
public class Sorting
{
public string FieldName { get; set; }
public SortDirection SortDirection { get; set; }
public override string ToString() => $"{FieldName} {SortDirection}";
}
public enum SortDirection