Skip to content

Instantly share code, notes, and snippets.

@samiy-xx
samiy-xx / asynctest.dart
Created January 25, 2013 10:16
Async unittesting with Dart on the server side
test("Channel, joining/leaving, fires event", () {
User u = TestFactory.getTestUser(userId, ws);
MockChannelConnectionEventListener l = new MockChannelConnectionEventListener();
c.subscribe(l);
bool wasJoined = false;
bool wasLeft = false;
l.joinCallback = (Channel chan, User user) {
expect(chan, equals(c));
expect(user, equals(u));
@samiy-xx
samiy-xx / test8361.dart
Created February 13, 2013 15:33
Test 8361
import 'dart:html';
void main() {
RtcPeerConnection pc1 = new RtcPeerConnection(null);
RtcPeerConnection pc2 = new RtcPeerConnection(null);
pc1.onAddStream.listen((MediaStreamEvent e) {
print("pc1 got stream");
});
@samiy-xx
samiy-xx / gist:5212544
Created March 21, 2013 12:05
WebRTC Fail
import 'dart:html';
void main() {
RtcPeerConnection pc1 = new RtcPeerConnection(null);
RtcPeerConnection pc2 = new RtcPeerConnection(null);
pc1.onAddStream.listen((MediaStreamEvent e) {
print("pc1 got stream");
});
import 'dart:json' as json;
class CartItem {
int id;
String name;
String category;
CartItem(this.id, this.name, this.category);
Map toJson() {
@samiy-xx
samiy-xx / readfiles.dart
Created December 19, 2013 12:08
read files in dir
var d = new Directory("PATH");
d.exists().then((bool exists) {
if (!exists)
return;
d.list().toList().then((List<FileSystemEntity> entities) {
entities.forEach((FileSystemEntity entity) {
if (entity is File) {
// Do something with the file
}
@samiy-xx
samiy-xx / blaa.dart
Last active December 31, 2015 20:09
blaa
import 'dart:io';
void main() {
getFiles().then((List<String> paths) {
print(paths[0]);
});
}
Future<List<String>> getFiles() {
Completer<List<String>> c = new Completer<List<String>>();
@samiy-xx
samiy-xx / ugh.dart
Created December 19, 2013 13:50
ugh
void start() {
window.animationFrame.then(pump);
}
void pump(num delta) {
_time.pump();
_engine.update(_time);
_engine.draw(_time);
if (_keepPumping)