Skip to content

Instantly share code, notes, and snippets.

@andhieka
andhieka / main.dart
Created August 7, 2020 06:29
PrototypePattern
//#region Plain Maze
enum Direction {
North,
West,
South,
East
}
class Maze {
List<Room> rooms = [];
@andhieka
andhieka / main.dart
Created June 4, 2020 08:15
MysteryGame - Refactored
import 'dart:io';
abstract class GameState {
String getPrompt();
void process(String input, MysteryGame game);
}
//#region Concrete states
class TheKitchenGameState extends GameState {
@andhieka
andhieka / main.dart
Last active June 4, 2020 08:09
MysteryGame - Completed with State Pattern
import 'dart:io';
abstract class GameState {
String getPrompt();
void process(String input, MysteryGame game);
}
//#region Concrete states
class TheKitchenGameState extends GameState {
@andhieka
andhieka / main.dart
Created June 4, 2020 02:54
MysteryGame - Before
import 'dart:io';
enum GameState {
start,
theKitchen,
success,
dead,
}
@andhieka
andhieka / main.dart
Last active May 14, 2020 07:58
Visitor Pattern - Dart (After)
//#region Zoo
enum VisitOrder {
age,
name,
species,
}
class Zoo {
@andhieka
andhieka / main.dart
Created May 14, 2020 04:16
Visitor Pattern
//#region Zoo
class Zoo {
final List<Dog> dogs;
final List<Cat> cats;
final List<Bear> bears;
const Zoo({
this.dogs,
this.cats,
@andhieka
andhieka / main.dart
Created January 8, 2020 06:59
Dart to JSON Copy Constructor
class Person {
String name;
int age;
Person({this.name, this.age});
Person copyWithUpdate({
String name,
int age,
@andhieka
andhieka / main.dart
Last active December 20, 2019 04:14
Proof that Dart enum extension works
enum FruitType {
orange,
apple,
guava,
}
extension FruitTypeDescriptions on FruitType {
String get name {
switch (this) {
@andhieka
andhieka / cltools.sh
Created July 19, 2017 08:42 — forked from justinbellamy/cltools.sh
Install Autoconf and Automake on OS X El Capitan
#!/bin/sh
##
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/devtools # or wherever you'd like to build

Keybase proof

I hereby claim:

  • I am andhieka on github.
  • I am andhieka (https://keybase.io/andhieka) on keybase.
  • I have a public key whose fingerprint is CFD6 F7D5 2F62 2348 916B B228 CA8F E88B E8E2 DE8F

To claim this, I am signing this object: