Skip to content

Instantly share code, notes, and snippets.

mr5z / RaisedTabbedPageRenderer.cs
Last active May 13, 2021
Raised Middle Button TabbedPage implementation for Xamarin.Android. Just replace the `Replace_With_Your_Custom_BottomNavigationView` with your own implementation of BNV!
View RaisedTabbedPageRenderer.cs
using System;
using System.Reflection;
using Android.Content;
using Android.Support.Design.Widget;
using Android.Support.V4.View;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
using AWidget = Android.Widget;
using ATabbedRenderer = Xamarin.Forms.Platform.Android.AppCompat.TabbedPageRenderer;
using System.Collections.Specialized;
View MonitorController.cs
public class MonitorController : Controller
private readonly IActionDescriptorCollectionProvider _provider;
public MonitorController(IActionDescriptorCollectionProvider provider)
_provider = provider;
mr5z / Observable.cs
Last active May 9, 2021
Property event to observable.
View Observable.cs
class Observable
private object actionCollection = null!;
private MethodInfo? methodInfo;
public ActionCollection<TModel> From<TModel>(TModel target) where TModel : INotifyPropertyChanged
return BuildActionCollection<TModel>();
View LoggingInterceptor.cs
class LoggingInterceptor : HttpClientHandler
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
Debug.Log("Request {0}", request.RequestUri.PathAndQuery);
if (request.Content != null)
var contentRequest = await request.Content.ReadAsStringAsync();
mr5z / Configuration.cs
Last active Apr 26, 2021
Scheduled closing of config file
View Configuration.cs
public class Configuration : IConfiguration
private readonly string assemblyResourceFile;
private AutoDisposeJsonDocument? smartJsonDocument;
public Configuration(string assemblyResourceFile)
this.assemblyResourceFile = assemblyResourceFile;
mr5z / AutoDisposeJsonDocument.cs
Created Apr 26, 2021
Scheduled disposable objects to be registered in an IoC container where IDisposable is disallowed.
View AutoDisposeJsonDocument.cs
private void ScheduleDisposeResourceStreams()
_ = Task.Factory.StartNew(async () =>
await Task.Delay(TimeSpan.FromMinutes(1));
// `stream` creation happens right after the invocation of this
// They are in the same thread so no lock needed
jsonStream = null;
mr5z / PleaseHelp.cs
Created Apr 24, 2021
JSON Path to Object
View PleaseHelp.cs
public async Task<T?> GetValue<T>(string path, JsonSerializerOptions? options, CancellationToken cancellationToken)
using var stream = GetStream();
using var jsonDocument = await JsonDocument.ParseAsync(stream, cancellationToken: cancellationToken);
var root = jsonDocument.RootElement;
var jsonPath = JsonPath.Parse(path);
var pathResult = jsonPath.Evaluate(root);
if (pathResult.Error != null)
throw new InvalidOperationException(pathResult.Error);
mr5z / RateLimiter.cs
Last active Apr 21, 2021
View RateLimiter.cs
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
// the rest
public void ConfigureServices(IServiceCollection services)
View productrest.cs
IProductGet : IGet<List<Product>>
IProductPost : IPost<Product, Product>
IProductDelete : IDelete<Product, long>
class ProductRest :
public async Task<List<Product>> Get(CancellationToken cancellationToken)
mr5z / neil.php
Last active Mar 26, 2021
1k lang
View neil.php
#customers {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
#customers td, #customers th {