Skip to content

Instantly share code, notes, and snippets.

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

Aldan Rizki Santosa inialdan

🏠
Working from home
View GitHub Profile
import 'dart:async';
void main(List<String> args) {
print("Starting");
var timer = Timer(Duration(seconds: -3), ()=>print("Timer completed"));
print("Finished");
}
Windows Registry Editor Version 5.00
; Open files
; Default Git-Bash Location C:\Program Files\Git\git-bash.exe
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash]
@="Open Git Bash"
"Icon"="C:\\Program Files\\Git\\git-bash.exe"
[HKEY_CLASSES_ROOT\*\shell\Open Git Bash\command]
@="\"C:\\Program Files\\Git\\git-bash.exe\" \"--cd=%1\""
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\{ChangeWithYourUser}\\proje\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\{ChangeWithYourUser}\\proje\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
@inialdan
inialdan / main.dart
Created March 3, 2021 13:09
Aldan 065118112 - Use Dart for functional programming
String scream(int length) => "A${'a' * length}h!";
main() {
final values = [1, 2, 3, 5, 10, 50];
values.skip(1).take(3).map(scream).forEach(print);
}
@inialdan
inialdan / main.dart
Created March 3, 2021 13:06
Aldan 065118112 - Implement an interface
import 'dart:math';
abstract class Shape {
factory Shape(String type) {a
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@inialdan
inialdan / main.dart
Created March 3, 2021 13:05
Aldan 065118112 - Create a factory
import 'dart:math';
abstract class Shape {
factory Shape(String type) {
if (type == 'circle') return Circle(2);
if (type == 'square') return Square(2);
throw 'Can\'t create $type.';
}
num get area;
}
@inialdan
inialdan / main.dart
Created March 3, 2021 13:04
Aldan 065118112 - Use optional parameters
import 'dart:math';
class Rectangle {
int width;
int height;
Point origin;
Rectangle({this.origin = const Point(0, 0), this.width = 0, this.height = 0});
@override
@inialdan
inialdan / main.dart
Created March 3, 2021 13:02
Aldan 065118112 - Simple Dart Class
class Bicycle {
int cadence;
int _speed = 0;
int get speed => _speed;
int gear;
Bicycle(this.cadence, this.gear);
void applyBrake(int decrement) {
_speed -= decrement;