Skip to content

Instantly share code, notes, and snippets.

View MelbourneDeveloper's full-sized avatar
🏠
Working from home

Christian Findlay MelbourneDeveloper

🏠
Working from home
View GitHub Profile
@MelbourneDeveloper
MelbourneDeveloper / TypelessGaphQL.cs
Last active February 5, 2022 04:50
Typeless GraphQL Select
using GraphQLParser;
using GraphQLParser.AST;
using Jayse;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System.Collections;
using System.Collections.Immutable;
namespace TypelessGraphQL;
@MelbourneDeveloper
MelbourneDeveloper / bloc.dart
Last active March 6, 2022 08:30
My Version of Bloc
import 'dart:async';
import 'package:flutter/foundation.dart';
class Bloc<T> {
late T _state;
final T initialState;
late final Future<T> Function(T state, BlocEvent event)? _eventHandler;
late final T Function(T state, BlocEvent event)? _eventHandlerSync;
final StreamController<T> streamController = StreamController<T>.broadcast();
using System.Globalization;
namespace CodeRulesExample;
public static class Program
{
public static void Main() =>
Console.WriteLine(string.Format(new CultureInfo("en-US"), "Hello {0}{1}!", "World"));
}
class IocContainer {
final Map<Type, Object Function(IocContainer container)> _factories = {};
IocContainer add<T>(T Function(IocContainer container) get) {
_factories.putIfAbsent(
typeOf<T>(), () => get as Object Function(IocContainer container));
return this;
}
T get<T>() => _factories[typeOf<T>()]!(this) as T;
@MelbourneDeveloper
MelbourneDeveloper / countrydata.cshtml
Last active June 28, 2022 06:03
Country Data Razor Page
page "/countrydata"
@using BlazorApp1.Data
@using RestClient.Net;
<h1>Countries</h1>
<p>This page shows data about countries.</p>
@if (countries == null)
{
<p><em>Loading...</em></p>
}
else
@MelbourneDeveloper
MelbourneDeveloper / Protobuf.cs
Created June 28, 2022 06:19
Protobuf Web API
[HttpGet]
public IActionResult Get()
{
var person = new Person
{
FirstName = "Sam",
BillingAddress = new Address
{
StreeNumber = "100",
Street = "Somewhere",
@MelbourneDeveloper
MelbourneDeveloper / ConsoleApp.cs
Created June 29, 2022 00:32
Null Logger Console App 1
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
@MelbourneDeveloper
MelbourneDeveloper / ConsoleApp.cs
Created June 29, 2022 00:33
Null Logger Example 2
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
new Example().Print("Hello World!");
}
}
@MelbourneDeveloper
MelbourneDeveloper / ConsoleApp.cs
Created June 29, 2022 00:35
Null Logger Example 3
public Example(ILoggerFactory? loggerFactory = null)
{
_loggerFactory = loggerFactory ?? NullLoggerFactory.Instance;
_logger = _loggerFactory.CreateLogger<Example>();
}
@MelbourneDeveloper
MelbourneDeveloper / BaseClass.cs
Created June 29, 2022 00:36
Null Logger Example 4
public abstract class BaseClass
{
protected ILogger Logger { get; }
protected BaseClass(ILogger logger)
{
Logger = logger;
}
}