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
| #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
| # 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
| 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
| 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
| #import('dart:io'); | |
| #import('dart:uri'); | |
| #import('dart:json'); | |
| // Dart Hackathon TLV 2012 | |
| // | |
| // A simple example to fetch JSON and parse it on the server side | |
| // This is a good start for a crawler and/or any other web service | |
| // we wish to create using dart on the server side. | |
| // |
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 MyClass{ | |
| static MyClass _ref; | |
| static MyClass get context() => _ref == null ? new MyClass() : _ref; | |
| factory MyClass(){ | |
| if (_ref != null) return _ref; | |
| _ref = new MyClass._internal(); | |
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'); | |
| final String PATH_TO_DARTSDK = "/Users/XYZ/dart-sdk"; | |
| final String SUBDIRECTORY = ""; | |
| final String LIBRARY_DARTFILE = "XYZ.dart"; | |
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
| /* | |
| * dart document.cookie lib | |
| * | |
| * ported from | |
| * http://www.quirksmode.org/js/cookies.html | |
| * | |
| */ | |
| void createCookie(String name, String value, int days) { | |
| String expires; |
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:dom', prefix:'dom'); | |
| #import('dart:html'); | |
| String VERSION = "1"; | |
| String TODOS_STORE = 'todos'; | |
| initDb(db) { | |
| if (VERSION != db.version) { | |
| dom.IDBVersionChangeRequest versionChange = db.setVersion(VERSION); | |
| versionChange.addEventListener('success', (e) { |