Skip to content

Instantly share code, notes, and snippets.

View alifgiant's full-sized avatar
🇮🇩

Muhammad Alif Akbar alifgiant

🇮🇩
View GitHub Profile
@alifgiant
alifgiant / basic-multiply-test-correct.md
Created November 11, 2023 05:47
Unit Test Correctness vs Coverage, mana yang lebih penting?
test('2 multiply 3 is equal to 6', (int a, int b) {
    // Arrange
    const a = 2;
    const b = 3;    

    // Act
    final answer = multiply(a, b);

 // Assert
@alifgiant
alifgiant / setup-flutter.md
Last active August 13, 2023 08:50
Setup Kelas Flutter
@alifgiant
alifgiant / isolated_json_parser.dart
Created July 27, 2022 02:18
Reuse Dart isolate for json parsing
import 'dart:async';
import 'dart:convert';
import 'dart:isolate';
void _runner(SendPort toMainPort) {
final ReceivePort fromMainPort = ReceivePort();
toMainPort.send(fromMainPort.sendPort);
fromMainPort.listen((final message) {
if (message == 'kill') fromMainPort.close();
if (message is! Map<String, dynamic>) return;
@alifgiant
alifgiant / isolate_testing.dart
Last active April 30, 2023 09:11
Testing Isolate Perf
import 'dart:convert';
import 'dart:isolate';
void main() async {
const jsonStr = '{'
'"name": "alif",'
'"age": 26,'
'"gender": "male",'
'"office": "work from home"'
'}';
@alifgiant
alifgiant / MVI-example-with-scheduler.md
Last active July 20, 2021 12:57
MVI example with scheduler
data class State (
   val coffee: CoffeeCup = EmptyCoffeeCup()
)

sealed class Intent(val state: State) {
   class CheckCupContent(state: State) : Intent(state)
   class Refill(state: State) : Intent(state)
}
@alifgiant
alifgiant / MVP-example-with-scheduler.md
Last active July 20, 2021 08:21
MVP example with scheduler
interface RefillProvider {
   fun refill()
}

class PersonPresenter {
   var coffee = EmptyCoffeeCup()
   val shopper = ShopController() // si OB
   val person = PersonController() // otak si Bos
 
@alifgiant
alifgiant / MVC-example-with-scheduler.md
Last active July 20, 2021 08:02
MVC example with scheduler
/**
 * Money dan Coffee adalah Model
 * ShopController adalah Si OB "Controller"
 * ConsumerView adalah Si Bos "View"
 */
class CustomerView {   
   var coffee = EmptyCoffeeCup()

 val shopper = ShopController() // si OB
@alifgiant
alifgiant / check_deps.py
Last active September 5, 2021 06:03
Flutter Check Deps and Compatibility
### prerequisite: python 3.6+
### pip install pyyaml
### pip install beautifulsoup4
###
### use this script to check your flutter deps to find out lates deps
### and check whether it is compatible to your platform target
### it will create a table in markdown file (compability_deps.md)
import urllib.request
import yaml