Skip to content

Instantly share code, notes, and snippets.

View pictos's full-sized avatar
🐒
Creating tools for you

Pedro Jesus pictos

🐒
Creating tools for you
View GitHub Profile
@pictos
pictos / usingForLazyPeople.cs
Last active March 28, 2024 04:21
A ref struct that will tweak values for you
new ViewModel().Run();
class ViewModel
{
private bool flag = true;
public bool Flag {get; set;} = false;
public void Run()
{
using(new HoldAndChangeValue(ref flag, () => Flag = !Flag))
{
@pictos
pictos / bench.cs
Created July 17, 2023 18:41
someBenchmarkCode
using BenchmarkDotNet.Attributes;
namespace GeneralBench;
public record Registro
{
public required string Nome { get; init; }
public int Total { get; init; }
}
[MemoryDiagnoser]
/*
SharpLab tools in Run mode:
• value.Inspect()
• Inspect.Heap(object)
• Inspect.Stack(value)
• Inspect.MemoryGraph(value1, value2, …)
*/
using System;
using System.Threading.Tasks;
public class GravatarImageSource : ImageSource
{
/// <summary>The backing store for the <see cref="Email" /> bindable property.</summary>
public static readonly BindableProperty? EmailProperty = BindableProperty.Create(nameof(Email), typeof(string), typeof(GravatarImageSource), defaultValue: GravatarImageSourceDefaults.DefaultEmail, propertyChanged: OnEmailPropertyChanged);
/// <summary>The backing store for the <see cref="Image" /> bindable property.</summary>
public static readonly BindableProperty ImageProperty = BindableProperty.Create(nameof(Image), typeof(DefaultImage), typeof(GravatarImageSource), defaultValue: GravatarImageSourceDefaults.Defaultimage, propertyChanged: OnDefaultImagePropertyChanged);
/// <summary>Gets or sets the email address.</summary>
public string? Email
class BlaP
{
public static async Task<T> FromJsonHttpContent<T>(HttpContent httpContent)
{
Stream stream = null;
try
{
stream = await httpContent.ReadAsStreamAsync();
var res = DeserializeJsonFromsStream<T>(stream);
static class ComicRouteFactory
{
public static RouteFactory Create<TPage, TViewModel>()
where TPage : Page, new()
where TViewModel : BaseViewModel
{
return new Factory<TPage, TViewModel>();
}
private class Factory<GPage, GViewModel> : RouteFactory
@pictos
pictos / VLCService.cs
Created August 13, 2021 00:07
VLCService
using LibVLCSharp.Shared;
using static MediaPlayerX.Helpers.GlobalResources;
using MediaPlayerX.Models;
using System;
using System.Threading.Tasks;
using Xamarin.Forms;
using MediaPlayerX.Helpers;
using System.Collections.ObjectModel;
@pictos
pictos / CornerRadiusXCT.cs
Created May 24, 2021 22:45
Spec to using an Attached property
public class CornerRadiusEffect
{
public static readonly BindableProperty CornerRadiusProperty = BindableProperty.CreateAttached(
nameof(CornerRadius),
typeof(CornerRadius),
typeof(CornerRadiusEffect),
default(CornerRadius),
propertyChanged: OnCornerRadiusPropertyChanged);
static void OnCornerRadiusPropertyChanged(BindableObject bindable, object oldValue, object newValue)
using System;
namespace WeakTest
{
class Program
{
static WeakReference<SomeClass> myClass;
static SomeClass holder;
static void Main(string[] args)
using Android.App;
using Android.Content;
using Android.Content.Res;
using Android.Graphics.Drawables;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Google.Android.Material.BottomNavigation;
using ShellBox.Droid;