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 / unit_test.dart
Created September 30, 2023 20:43
Keyed Services with ioc_container
import 'package:ioc_container/ioc_container.dart';
import 'package:test/test.dart';
///Example service
class BigService {
final String name;
BigService(this.name);
Future<void> callApi() => Future<void>.delayed(Duration(seconds: 1));
@MelbourneDeveloper
MelbourneDeveloper / Tests.fs
Created September 26, 2023 10:30
F# Factory With Type Inference
module Tests
open Xunit
type Factory<'T> = unit -> 'T
let factoryFunction<'T> () : 'T =
if typeof<'T> = typeof<string> then "String" :> obj
elif typeof<'T> = typeof<int> then 1 :> obj
else failwith "Unsupported type"
@MelbourneDeveloper
MelbourneDeveloper / Thing.fs
Created September 25, 2023 21:00
F# Type Inference By Interpolation Not Working
module Thing
type Factory<'T> = unit -> 'T
type Printer () =
static member FactoryInstance : Factory<'T> = Printer.FactoryFunction
static member DoPrinting () =
let factory = Printer.FactoryInstance
@MelbourneDeveloper
MelbourneDeveloper / gist:e1d02c9764e25ebed49f047774be5e6a
Created September 16, 2023 10:23
flutter_integration_test.yaml
name: Flutter Integration Test iOS
on:
push:
branches: [main]
pull_request:
branches: [main]
@MelbourneDeveloper
MelbourneDeveloper / DistributedCacheWithMemoryCaching.cs
Created August 20, 2023 10:55
DistributedCachWithMemoryCaching
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
namespace Cache;
public interface ISerializationAdapter
{
T? Deserialize<T>(string key, byte[]? value);
byte[] Serialize(object value);
}
@MelbourneDeveloper
MelbourneDeveloper / aResults.md
Last active August 9, 2023 16:29
Flutter/Dart Benchmarks: ChangeNotifier/Cubit/StateNotifier/StreamController
Test Time (Microseconds)
ValueNotifier 0.14619362615225495
StateNotifier 0.6242255
Cubit 1.2855485
StreamController 1.3412715

macOS Mac Mini - 3.2 GHz 6-Core Intel Core i7, running under Flutter Release Mode

@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created July 19, 2023 10:05
Number and String Records
final records = <({String name, int value})>[
(name: 'test1', value: 1),
(name: 'test2', value: 12),
];
void main(List<String> arguments) {
print(records.first.name);
}
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Last active July 17, 2023 20:53
Delayed Save On Text Edit
import 'dart:async';
import 'package:flutter/material.dart';
void main() {
runApp(const MainApp());
}
class DelayedTextEditingController {
DelayedTextEditingController(
this.onValidated,
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
body: Center(
child: Row(children: [
Container(
color: Colors.red,
@MelbourneDeveloper
MelbourneDeveloper / main.dart
Created June 25, 2023 07:13
Navigation Extension
import 'package:flutter/material.dart';
extension NavigationExtension on BuildContext {
Future<void> navigateTo(String routeName, {Object? arguments}) {
return Navigator.pushNamed(this, routeName, arguments: arguments);
}
}
void main() {
runApp(MaterialApp(