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
| - (NSUInteger)countTilesInRegionSouthWest:(CLLocationCoordinate2D)southWest | |
| northEast:(CLLocationCoordinate2D)northEast | |
| minZoom:(int)minZoom | |
| maxZoom:(int)maxZoom | |
| { | |
| double minLat = southWest.latitude; | |
| double maxLat = northEast.latitude; | |
| double minLon = southWest.longitude; | |
| double maxLon = northEast.longitude; | |
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 digits = '0123456789' + | |
| 'abcdefghijklmnopqrstuvwxyz' + | |
| 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' + | |
| '-_'; | |
| var radix = digits.length; | |
| function shorten_number(n) { | |
| var s = ''; | |
| while (n > 0) { | |
| s = digits.charAt(n % radix) + s; |
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 flatten2D(array) { | |
| return array.reduce(function (result, item) { | |
| return result.concat(item); | |
| }, []); | |
| } |
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 getBoundsAtLatLngWithZoom(map, center, zoom) { | |
| var p = map.getProjection(); | |
| if (!p) { | |
| return null; | |
| } | |
| var el = $(map.getDiv()); | |
| var zf = Math.pow(2, zoom) * 2; | |
| var dw = (el.width() | 0) / zf; | |
| var dh = (el.height() | 0) / zf; | |
| var cpx = p.fromLatLngToPoint(center); |
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 randomString(length) { | |
| var s = ((performance.now() % 1) + Math.random()).toString(35); | |
| return s.substr(-Math.max(0, Math.min(length, s.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
| function jenkins_hash(s) { | |
| var hash = 0, i = 0, l = s.length; | |
| for (; i < l; ++i) { | |
| hash += s.charCodeAt(i); | |
| hash += (hash << 10); | |
| hash ^= (hash >> 6); | |
| } | |
| hash += (hash << 3); | |
| hash ^= (hash >> 11); | |
| hash += (hash << 15); |
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 cachedAsyncFn(fn) { | |
| var cached, queue; | |
| return function (callback) { | |
| if (cached) { | |
| process.nextTick(function () { | |
| callback.apply(null, cached); | |
| }); | |
| } else if (queue) { | |
| queue.push(callback); | |
| } else { |
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
| @interface NSIndexSet (Operations) | |
| // http://en.wikipedia.org/wiki/Union_(set_theory) | |
| - (NSIndexSet *)unionWith:(NSIndexSet *)other; | |
| // http://en.wikipedia.org/wiki/Intersection_(set_theory) | |
| - (NSIndexSet *)intersectionWith:(NSIndexSet *)other; | |
| // http://en.wikipedia.org/wiki/Complement_(set_theory)#Relative_complement | |
| - (NSIndexSet *)relativeComplementIn:(NSIndexSet *)universe; |
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 fibonacci(n) { | |
| return n < 2 ? n : fibonacci(n - 2) + fibonacci(n - 1); | |
| } | |
| function fibonacci(n) { | |
| var prev, curr = 0, next = 1; | |
| while (n-- > 0) { | |
| prev = curr; | |
| curr = next; | |
| next = prev + curr; |
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 insertAt(arr, val, i) { | |
| arr.splice(i, 0, val); | |
| } | |
| function removeAt(arr, i) { | |
| return arr.splice(i, 1).length === 1; | |
| } | |
| function genericInsertAt(arr, val, i) { | |
| Array.prototype.splice.call(arr, i, 0, val); | |
| } |