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 requests | |
import sys | |
import json | |
def waybackurls(host, with_subs): | |
if with_subs: | |
url = 'http://web.archive.org/cdx/search/cdx?url=*.%s/*&output=json&fl=original&collapse=urlkey' % host | |
else: | |
url = 'http://web.archive.org/cdx/search/cdx?url=%s/*&output=json&fl=original&collapse=urlkey' % host |
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 requests | |
import re | |
import sys | |
from multiprocessing.dummy import Pool | |
def robots(host): | |
r = requests.get( | |
'https://web.archive.org/cdx/search/cdx\ | |
?url=%s/robots.txt&output=json&fl=timestamp,original&filter=statuscode:200&collapse=digest' % host) |
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 sys | |
def to_octets(ip): | |
return [int(i) for i in ip.split('.')] | |
def dotless_decimal(ip): | |
octets = to_octets(ip) | |
result = octets[0] * 16777216 + octets[1] * \ |
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 nodes = [ | |
{ | |
links: [ 1 ], // node 0 is linked to node 1 | |
visited: false | |
}, { | |
links: [ 0, 2 ], // node 1 is linked to node 0 and 2 | |
path: [], | |
visited: false | |
}, | |
... |
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(array, value) { | |
var j = 0, length = array.length; | |
// A for loop was used to save space. More easily understood as a while loop. Exits if our pointer moves out of range. | |
while (j < length) { | |
var i = (length + j - 1) >> 1; // move the pointer to the median value using a shift in place of Math.floor() (to save characters) | |
// If the value we're searching for is greater than the median, move our lower-bound past the median | |
if (value > a[i]) | |
j = i + 1; | |
// Otherwise, if the value we're searching for is less than the median, move our upper-bound to the median value | |
else if (value < array[i]) |
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 insertionSort = function (a) { | |
// Iterate through our array | |
for (var i = 1, value; i < a.length; i++) { | |
// Our array is split into two parts: values preceeding i are sorted, while others are unsorted | |
// Store the unsorted value at i | |
value = a[i]; | |
// Interate backwards through the unsorted values until we find the correct location for our `next` value | |
for (var j = i; a[j-1] > value; j--) { | |
// Shift the value to the right | |
a[j] = a[j-1]; |
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 randomArray() { | |
for (var a=[], i=0; ++i < 19;) a.push(~~(Math.random() * 100)); | |
return a; | |
} | |
function quicksort(a) { | |
var l = [], r = [], m; | |
if(!a.length) return []; |
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 BinaryTree () {} (function () { | |
BinaryTree.prototype = { | |
// Container for the object's binary tree | |
tree: null, | |
count: 0, | |
_isBalancing: false, |
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 selectionSort = function (a) { | |
// Move forward through an array, swapping the value at i with the smallest value after i | |
for (var i = -1; ++i < a.length;) { | |
// Move forward from i and remember the position of the smallest value | |
for (var m = j = i; ++j < a.length;) { | |
// If the value at j is smaller than our current minimum, remember it's position | |
if (a[m] > a[j]) m = j; | |
} | |
// Swap the value at i with the minimum value following i |
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 BinaryTree () {} (function () { | |
BinaryTree.prototype = { | |
// Container for the object's binary tree | |
tree: null, | |
count: 0, | |
_isBalancing: false, |