Skip to content

Instantly share code, notes, and snippets.

Jacob jshado1

  • Fueled
  • London, UK
View GitHub Profile
@jshado1
jshado1 / mergeSort.js
Created Aug 3, 2018
recursive merge sort: Average runtime O(log n)
View mergeSort.js
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);
}
View binarySearch.js
/**
* 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
@jshado1
jshado1 / twitter.js
Last active Dec 31, 2015
WebSocket (socket.io) proxy for Twitter stream (Twit).
View twitter.js
// 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 )
@jshado1
jshado1 / controllers.js
Created Apr 19, 2013
Html markup for uiMap (before refactor)
View controllers.js
//
$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);
};
//
You can’t perform that action at this time.