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
| function fib(n, callback) { | |
| if (n < 2) return process.nextTick(function() { | |
| callback(1); | |
| }); | |
| var results = []; | |
| function done(ret) { | |
| results.push(ret); | |
| if (results.length === 2) |
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
| var bounds = [0] | |
| var hashs = [inital_number_of_box] | |
| function map(user_id) { | |
| for (var i = bounds.length-1; i >= 0; --i) { | |
| if (user_id > bounds[i]) { | |
| var shard_id = user_id % hashs[i] | |
| return shard_id | |
| } | |
| } |