This file contains 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 path from 'path'; | |
import { pathToFileURL } from 'url'; | |
const npmPackage = await import( | |
pathToFileURL(`${process.cwd()}/package.json`).href | |
).then(({ default: json }) => json); | |
const aliases = (() => { | |
const base = process.cwd(); | |
const { aliases } = npmPackage || {}; |
This file contains 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 mergeSort(arr, low = 0, top = arr.length - 1) { | |
if (low < top) { | |
const mid = Math.floor((low + top) / 2); | |
mergeSort(arr, low, mid); | |
mergeSort(arr, mid+1, top); | |
merge(arr, low, mid, top); | |
} |
This file contains 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
/** | |
* Find a number in an ordered list of numbers. It does cheap detection for common invalid input: | |
* * Argument types | |
* * An incorrectly sorted list (descending) | |
* * An unsorted list | |
* @param {number} x - The "needle" for which to search | |
* @param {array<number>} arr - The list to search | |
* @return {number} - The (first) index where `x` occurs in `arr`, or `-1` when not found. | |
* @example | |
* binarySearch(2, [-1, 0, 0.5, 0.75, 1, 2, 5, 10]); // 5 |
This file contains 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 server … | |
// … | |
var io = require('socket.io').listen(server), | |
Twit = require('twit'); | |
var twitter = new Twit({ … }); | |
io.sockets.on('connection', function connect( socket ) | |
{ | |
function emitTweets( sn , tweets ) |
This file contains 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
//… | |
$scope.openMarkerInfo = function(marker) | |
{ | |
$scope.currentMarker = marker; | |
$scope.currentMarkerLat = marker.getPosition().lat(); | |
$scope.currentMarkerLng = marker.getPosition().lng(); | |
$scope.model.myInfoBox.open($scope.model.myMap, marker); | |
}; | |
//… |