Skip to content

Instantly share code, notes, and snippets.

View 0x414c49's full-sized avatar
💪
Coding!

Ali Bahrami 0x414c49

💪
Coding!
  • ValueBlue B.V
  • Utrecht, The Netherlands
View GitHub Profile
@0x414c49
0x414c49 / Sample.cs
Created January 15, 2021 20:45
Part of CSharp Generated Code from Protbuf
public sealed partial class DecimalValue : pb::IMessage<DecimalValue>
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
, pb::IBufferMessage
#endif
{
private static readonly pb::MessageParser<DecimalValue> _parser = new pb::MessageParser<DecimalValue>(() => new DecimalValue());
private pb::UnknownFieldSet _unknownFields;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public static pb::MessageParser<DecimalValue> Parser { get { return _parser; } }
@0x414c49
0x414c49 / DbContextExtensions.cs
Created September 7, 2020 11:07
EF Core - Tag Queries with source information
public static class DbContextExtensions
{
public static IQueryable<T> TagWithSource<T>(this IQueryable<T> queryable,
string tag = "",
[CallerMemberName] string methodName = "",
[CallerFilePath] string sourceFilePath = "",
[CallerLineNumber] int line = 0)
{
return queryable.TagWith(string.IsNullOrEmpty(tag)
? $"{methodName} - {sourceFilePath}:{line}"
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using AzureFunctions.Ioc.Configurations;
using AzureFunctions.Ioc.Services;
using Microsoft.Extensions.Options;
@0x414c49
0x414c49 / Startup.cs
Created February 4, 2020 13:04
Azure Startup
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
[assembly: FunctionsStartup(typeof(azure_functions_ioc.Startup))]
namespace azure_functions_ioc
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
@0x414c49
0x414c49 / Battery.razor
Created January 20, 2020 15:06
Battery component
<StackLayout Orientation="StackOrientation.Horizontal"
HorizontalOptions="LayoutOptions.Center">
<Label Text="@("Battery level is " + BatteryLevel.ToString())"
FontAttributes="FontAttributes.Bold"
VerticalTextAlignment="TextAlignment.Center" />
</StackLayout>
@0x414c49
0x414c49 / Battery.razor
Created January 20, 2020 14:33
Sample sensor using in BlazorMobileBindings
<StackLayout Orientation="StackOrientation.Horizontal"
HorizontalOptions="LayoutOptions.Center">
<Label Text="@("Battery level is " + Battery.ToString())"
FontAttributes="FontAttributes.Bold"
VerticalTextAlignment="TextAlignment.Center" />
</StackLayout>
@0x414c49
0x414c49 / Sample1.razor
Created January 20, 2020 14:13
Blazor Web Assembly Example
@page "/counter"
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
@0x414c49
0x414c49 / Sample1.razor
Created January 20, 2020 14:11
Mobile Bindings Razor
<StackLayout Orientation="StackOrientation.Horizontal"
HorizontalOptions="LayoutOptions.Center">
<Button Text="Increment" OnClick="@IncrementCount" />
<Label Text="@("The button was clicked " + count + " times")"
FontAttributes="FontAttributes.Bold"
VerticalTextAlignment="TextAlignment.Center" />
</StackLayout>
@0x414c49
0x414c49 / Program.cs
Created January 14, 2020 09:34
Program
using Terminal.Gui;
using System.Collections.Generic;
using System.Threading;
using System;
namespace RetroChat
{
internal static class Program
{
private static string _username;
var menu = new MenuBar(new MenuBarItem[] {
new MenuBarItem("_File", new MenuItem[]{
new MenuItem("_Quit", "", () => Application.RequestStop())
}), // end of file menu
new MenuBarItem("_Help", new MenuItem[]{
new MenuItem("_About", "", ()
=> MessageBox.Query(10, 5, "About", "Written by Ali Bahraminezhad\nVersion: 0.0001", "Ok"))
}) // end of the help menu
});
top.Add(menu);