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 generate(elements, len) { | |
if (len == 1) { | |
return elements.map(function(element) { | |
return [element]; | |
}); | |
} | |
var generated = []; | |
var subsequences = generate(elements, len - 1); | |
subsequences.forEach(function(subsequence) { |
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 help = [ | |
'Command line tool to unuglify a JavaScript file.', | |
'', | |
'Before using install js-beautify:', | |
'', | |
'npm install js-beautify', | |
'', | |
'To unuglify file code.js run:', | |
'', | |
'node unuglify code.js > code.unuglified.js' |
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 numberStringGenerator = ({ template, base = 10 }) => () => { | |
function randomNumber() { | |
return (Math.floor(Math.random() * base)).toString(base); | |
} | |
return template.replace(/x/g, function(match) { | |
return randomNumber(); | |
}); | |
} |
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 merge() { | |
var sources = [].slice.call(arguments); | |
return sources.reduce(function(previous, source) { | |
Object.keys(source).forEach(function(propertyName) { | |
previous[propertyName] = source[propertyName]; | |
}); | |
return previous; | |
}, {}); | |
} |
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
/* | |
* Computing the Levenstein distance between strings. | |
* http://en.wikipedia.org/wiki/Levenshtein_distance | |
*/ | |
/* | |
* Inefficient recursive algorithm. | |
*/ | |
function stringDistance(str1, length1, str2, length2) { |
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
/* | |
* Simplistic map-reduce like API in JavaScript. | |
* | |
* No support for scalability or distributed computations, just an illustration of the computational model. | |
*/ | |
(function(host) { | |
function MapReduce(inputs, mapper, reducer) { | |
this.inputs = inputs; | |
this.mapper = mapper; |
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
from selenium import webdriver | |
driver = webdriver.Firefox() | |
driver.get("http://www.google.com") | |
driver.quit() |
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
if (!Function.prototype.asMethod) { | |
Function.prototype.asMethod = function() { | |
var self = this; | |
return function(first) { | |
var rest = [].slice.call(arguments, 1); | |
return self.apply(first, rest); | |
} | |
}; |
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
/* | |
* Enhances 'require' from RequireJS with Promises API while preserving its original semantics. | |
*/ | |
(function() { | |
if (!Promise || !require) { | |
return; | |
} |
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
/* | |
* Bulk download of Coursera videos with wget. | |
* | |
* Copyright (c) 2014 Anton Ivanov [email protected] | |
* | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is |