Skip to content

Instantly share code, notes, and snippets.

View markvincze's full-sized avatar

Mark Vincze markvincze

View GitHub Profile
@markvincze
markvincze / CustomMiddlewareExample.cs
Created January 12, 2019 13:49
Custom route matching in a middleware
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Template;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
@markvincze
markvincze / AsyncParallel.cs
Created September 27, 2018 10:39
Async parallel processing
var runningTasks = new ConcurrentDictionary<Task, string>();
var maxDegreeOfParallelism = 5;
var semaphore = new SemaphoreSlim(maxDegreeOfParallelism);
foreach (var job in jobs)
{
await semaphore.WaitAsync();
var task = ProcessAsync(job);
runningTasks.TryAdd(task, "");
@markvincze
markvincze / .hyper.js
Created March 18, 2017 13:42
My Hyper config
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 18,
// font family with optional fallbacks
@markvincze
markvincze / PeopleController.cs
Created February 11, 2017 10:59
Trying to reproduce NRE with ValidateActionParametersAttribute
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
namespace WebApplication.Controllers
{
public class Person
{
public string Name { get; set; }
}
@markvincze
markvincze / Bitbucket-filesearch-tweak.css
Created January 5, 2017 07:39
Make the Bitbucket file search box wider
/* Inject this to bitbucket.org with your favourite browser extension, for example Stylish. */
.omnibar-result-context, .omnibar-result-label {
max-width: 1170px;
}
.omnibar {
margin-left: -600px;
width: 1200px;
}
@markvincze
markvincze / Nuget.config
Created March 31, 2016 16:06
Nuget config with AspNetVNext source
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetcidev/api/v3/index.json" />
</packageSources>
</configuration>
ResolveEventHandler handler = null;
handler = (sender, args) =>
{
// Use latest strong name & version when trying to load SDK assemblies
var requestedAssembly = new AssemblyName(args.Name);
if (requestedAssembly.Name != shortName)
return null;
Debug.WriteLine("Redirecting assembly load of " + args.Name
@markvincze
markvincze / JsonAndGZipSerializer.cs
Created January 16, 2016 15:15
Simple GZip compression serializer for Couchbase
using System;
using System.IO;
using System.IO.Compression;
using Couchbase.Core.Serialization;
using Newtonsoft.Json;
namespace CouchbaseContrib
{
/// <summary>
/// A custom <see cref="ITypeSerializer"/> for the Couchbase .NET SDK that uses Json.NET and GZip compression for serialization.