When do you use map vs flatMap in RxJava?

When do you use map vs flatMap in RxJava? Say, for example, we want to map Files containing JSON into Strings that contain the JSON– Using map, we have to deal with the Exception somehow. But how?: Observable.from(jsonFile).map(new Func1<File, String>() { @Override public String call(File file) { try { return new Gson().toJson(new FileReader(file), Object.class); } … Read more

What is the best way to implement nested dictionaries?

I have a data structure which essentially amounts to a nested dictionary. Let’s say it looks like this: {‘new jersey’: {‘mercer county’: {‘plumbers’: 3, ‘programmers’: 81}, ‘middlesex county’: {‘programmers’: 81, ‘salesmen’: 62}}, ‘new york’: {‘queens county’: {‘plumbers’: 9, ‘salesmen’: 36}}} Now, maintaining and creating this is pretty painful; every time I have a new state/county/profession … Read more

What is the ideal data type to use when storing latitude / longitude in a MySQL database?

Bearing in mind that I’ll be performing calculations on lat / long pairs, what datatype is best suited for use with a MySQL database? 21 Answers 21 Basically it depends on the precision you need for your locations. Using DOUBLE you’ll have a 3.5nm precision. DECIMAL(8,6)/(9,6) goes down to 16cm. FLOAT is 1.7m… This very … Read more

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?

What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim? 4 remap is an option that makes mappings work recursively. By default it is on and I’d recommend you leave it that way. The rest are mapping commands, described below: :map and :noremap are recursive and non-recursive versions of the … Read more