This file contains hidden or 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
| class FileHandler { | |
| FileHandler(){ | |
| } | |
| void onRequest(HttpRequest request, HttpResponse response, [String fileName = null]){ | |
| final int BUFFER_SIZE = 4096; | |
| if (fileName == null) { | |
| fileName = request.path.substring(1); | |
| } |
This file contains hidden or 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
| class NotFoundHandler { | |
| NotFoundHandler(){ | |
| } | |
| List<int> _notFoundPage; | |
| static final String notFoundPageHtml = """ | |
| <html><head> | |
| <title>404 Not Found</title> | |
| </head><body> | |
| <h1>Not Found</h1> | |
| <p>The requested URL was not found on this server.</p> |
This file contains hidden or 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
| # So this is completely gone now | |
| # Moved to my own brew recipes collection at | |
| # https://github.com/kevmoo/homebrew-kevmoo | |
| # Run this: | |
| # brew tap kevmoo/kevmoo | |
| # and you'll be good to go! |
This file contains hidden or 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"); | |
| main(){ | |
| int sum = 0; | |
| DirectoryLister lister = new Directory("c:\\dropbox").list(true); | |
| var filesProcessed = new List<Future>(); | |
| lister.onError = (e) { throw e; }; | |
| lister.onFile = (String file) { | |
| // print("File: $file"); | |
| // Please ignore the length() vs lengthSync(), because my | |
| // actual use case is a longer IO operation, e.g. DB call. |
This file contains hidden or 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
| library MIME; | |
| // get MIME type (returns null if there is no such extension) | |
| String mimeType(String extension) => _mimeMaps[extension]; | |
| // default MIME type mappings | |
| Map _mimeMaps = const { | |
| 'abs': 'audio/x-mpeg', | |
| 'ai': 'application/postscript', | |
| 'aif': 'audio/x-aiff', |
This file contains hidden or 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
| // Sending futures across isolate boundaries. | |
| #import('dart:isolate', prefix: 'isolate'); | |
| // FutureSendPort/FutureReceivePorts are ports for sending and receiving futures | |
| // When connecting futures across isolates boundaries they do it by | |
| // building the following structure: | |
| // | |
| // ISOLATE A | |
| // [Future] --events--> [Completer SendPort] |
This file contains hidden or 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:math'); | |
| class SparseIntVector { | |
| static int collision = 0; | |
| static final int INITIAL_SIZE = 8; | |
| static final double DEFAULT_LOAD_FACTOR = 0.7; | |
| int modulo = INITIAL_SIZE - 1; | |
| List<int> keys; | |
| List<int> values; |
This file contains hidden or 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 'package:unittest/unittest.dart'; | |
| import 'dart:async'; | |
| main () { | |
| test("DCI sample in Dart", () { | |
| var checking = new Account(balance : 50); | |
| var saving = new Account(balance : 45); | |
This file contains hidden or 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 'package:web_ui/component_build.dart'; | |
| // Ref: http://www.dartlang.org/articles/dart-web-components/tools.html | |
| main() { | |
| build(new Options().arguments, ['web/index.html']); | |
| //recursiveFolderCopySync('web/assets', 'web/out/assets'); | |
| } | |
| bool isSymlink(String pathString) { |
This file contains hidden or 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 'package:unittest/unittest.dart'; | |
| void main() { | |
| print("intersect"); | |
| (new Seq([1, 2, 3]) & new Seq([2, 3, 4])).forEach(print); | |
| print("union"); | |
| (new Seq([1, 2, 3]) | new Seq([2, 3, 4])).forEach(print); | |