This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
application: new-project-template | |
version: 1 | |
runtime: python27 | |
api_version: 1 | |
threadsafe: yes | |
handlers: | |
- url: (.*/) | |
static_files: static_content\1index.html | |
upload: static_content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:math'; | |
/* | |
* Findings: | |
* streams can be single or broadcast, but not sure why the diff. | |
* can check if a stream is broadcast with isBroadcast | |
* StreamController make it easy to use a stream and send it events | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HashMap(RunTime): 17443.478260869564 us. | |
SplayTreeMap(RunTime): 31250.0 us. | |
LinkedHashMap(RunTime): 817000.0 us. | |
HashMap(RunTime): 0.7287397466317649 us. | |
SplayTreeMap(RunTime): 2.640243113585899 us. | |
LinkedHashMap(RunTime): 1.4227564198326554 us. | |
HashMap(RunTime): 0.7923399740667126 us. | |
SplayTreeMap(RunTime): 2.406854722248965 us. | |
LinkedHashMap(RunTime): 1.4545084306944913 us. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HttpServer.bind('127.0.0.1', 8889) | |
.then((HttpServer server) { | |
var sc = new StreamController(); | |
sc.stream.transform(new WebSocketTransformer()).listen(handleWebSocket); | |
server.listen((HttpRequest request) { | |
if (request.uri.path == '/ws') { | |
sc.add(request); | |
} else if (request.uri.path == '/foo') { | |
request.response.addString('foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:io'; | |
import 'dart:async'; | |
import 'dart:math'; | |
// The following function is part of a third-party package that you can't touch. | |
Future doCoolStuff() { | |
var completer = new Completer(); | |
// Sometimes bad things happen. | |
if (new Random().nextBool()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:mirrors'; | |
import 'dart:async'; | |
// TODO: inject the persistance storage driver | |
abstract class Persistable { | |
int _dbId; | |
static const constructor = const Symbol('fromPersistance'); | |
static Future load(int id, Type type) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Database db; | |
window.indexedDB.deleteDatabase('justtesting') | |
.then((_) { | |
print('opening'); | |
return window.indexedDB.open('justtesting', version: 1, | |
onUpgradeNeeded: (e) { | |
print('upgrading to v1'); | |
Database d = e.target.result as Database; | |
d.createObjectStore('store1'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
DARTFILENAME=$1.dart | |
HTMLFILENAME=$1.html | |
ELEMENTNAME=$2 | |
LIBNAME=`echo $2 | sed -e "s/-/_/g"` | |
CLASSNAME=$3 | |
echo > $HTMLFILENAME | |
echo "<head>" >> $HTMLFILENAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sample app</title> | |
<script src="packages/polymer/boot.js"></script> | |
</head> | |
<body> | |
<polymer-element name="x-c"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Sample app</title> | |
<link rel="stylesheet" href="testme.css"> | |
<!-- import the click-counter --> | |
<link rel="import" href="clickcounter.html"> |