Skip to content

Instantly share code, notes, and snippets.

View seaneagan's full-sized avatar

Sean Eagan seaneagan

View GitHub Profile
class ProgressBar {
ProgressBar();
Future<Duration> show(Stream<num> onProgress);
stop();
}
class ProgressController {
StreamController _controller;
@seaneagan
seaneagan / gist:19f12a6b8b9bf18f3b69
Created October 28, 2014 16:02
version_part.dart
class VersionPart {
final int index;
final String _name;
const VersionPart._(this.index, this._name);
static const VersionPart major = const VersionPart(0, 'major');
static const VersionPart minor = const VersionPart(1, 'minor');
static const VersionPart patch = const VersionPart(2, 'patch');
#! /usr/bin/env dart
import 'package:unscripted/unscripted.dart';
main(arguments) => declare(NavalFate).execute(arguments);
class NavalFate {
@Command(help: 'Naval Fate', plugins: const [const Completion()])
NavalFate({bool version}) {
if(version) print('Naval Fate 2.0');
abstract class Generable<E> extends Iterable<E> {
Generator<E> get iterator;
}
abstract class Generator<E> extends Iterator<E> {
/// [yieldValue] is the value returned from the previous `yield` expression.
bool moveNext([yieldValue]);
/// Causes the previous `yield` expression to throw.
void fail(e, StackTrace s);
@seaneagan
seaneagan / Clock.md
Last active August 29, 2015 13:58
Add Clock interface to dart:core

This would serve two purposes:

  • Provide the low-level system-time ala java's System.currentTimeMillis() or JavaScript's Date.now.

  • allow mocking of time in DateTime.now and Stopwatch:

Star the bug.

class Clock {
@seaneagan
seaneagan / how_to_test_not_called.dart
Created February 20, 2014 21:09
How to test that something was not called
import 'dart:async';
import 'package:unittest/unittest.dart';
import 'package:unittest/mock.dart';
cb() {}
main() {
@seaneagan
seaneagan / gist:8408456
Created January 13, 2014 21:25
test DeclarationMirror.declarations ordering
import 'dart:mirrors';
main() {
print(reflectClass(Foo).declarations.keys.map(MirrorSystem.getName).join(' '));
}
class Foo {
static var sv1 = 1;
static var sv2 = 2;
library intl.tool.cldr.ldml2json;
import 'dart:io';
import 'dart:async';
import 'package:path/path.dart';
import 'util.dart';
/// Converts CLDR data to JSON
main() {
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
part of intl;
/**
* Bidi stands for Bi-directional text.
* According to http://en.wikipedia.org/wiki/Bi-directional_text:
* Bi-directional text is text containing text in both text directionalities,
The current dart:async getAttachedStackTrace could potentially be used for sync errors as well, in which case the API could move directly to the StackTrace class:
class StackTrace {
/// the [StackTrace] attached to the given [error]
StackTrace.attachedTo(var error);
/// attach the current [StackTrace] to the given [error].
static void attach(var error);
//...
}