Skip to content

Instantly share code, notes, and snippets.

View adamlofts's full-sized avatar

Adam Lofts adamlofts

View GitHub Profile
void main() {
print(Set<int>() is Set<double>);
}
@adamlofts
adamlofts / main.dart
Created August 29, 2018 12:32
Casting sublists
import "dart:convert";
void main() {
dynamic a = json.decode("[[1]]");
List<List<int>> b = (a as List).cast<List<int>>();
List<int> c = b[0].cast<int>();
}
String formatFileSize(int b) {
const List<String> suffix = const [
'B',
'KB',
'MB',
'GB',
'TB',
'PB',
];
num v = b.toDouble();
@adamlofts
adamlofts / gist:2701794
Created May 15, 2012 13:30
"Table scan" CouchDB map-reduce.
/**
* Run a chained map reduce on a couchdb view
*
* @param db The db to use
* @param view The view name
* @param map_func The map function to use on the view results function({ key: , value: }) -> { key: , value: }
* @param config Standard jquery.couch.js config options
*/
var chainCouch = (function() {