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
// Get a password from the console | |
function getPassword(done) { | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.setRawMode(true); | |
var password = ''; | |
process.stdout.write('Password: '); | |
process.stdin.on('data', function(ch) { | |
ch = ch + ''; |
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 _ = require('underscore'); | |
var PassingStudentPolicy = require('./passingStudentPolicy'); | |
var EligibleForSportsEnrollmentPolicy = function( student ) { | |
this.student = student; | |
}; | |
EligibleForSportsEnrollmentPolicy.prototype = _.extend( EligibleForSportsEnrollmentPolicy.prototype, { | |
run: function() { |
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
# Example colordiffrc file for light backgrounds | |
# | |
# Set banner=no to suppress authorship info at top of | |
# colordiff output | |
banner=no | |
# By default, when colordiff output is being redirected | |
# to a file, it detects this and does not colour-highlight | |
# To make the patch file *include* colours, change the option | |
# below to 'yes' | |
color_patches=no |
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 getFactorians() { | |
var _cache = [1], | |
factorial = 1, | |
i = 1, | |
list = [], | |
greatestFactorial; | |
// cache list of digits factorials | |
while (i < 10) { | |
factorial *= i; |
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
// remove folder with all files and folders recursively | |
function removeFolderRecursive(path) { | |
if ( fs.existsSync(path) ) { | |
fs.readdirSync(path) | |
.forEach(function(file) { | |
var current = path + '/' + file; | |
if ( fs.statSync(current).isDirectory() ) { | |
removeFolderRecursive(current); | |
} 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
/** | |
* Generate sequential minified classnames: | |
* a => b => .. => z => aa => ba => .. => zz => .. => aaa ... | |
*/ | |
var ClassNameEngine = (function () { | |
var alphabet = 'abcdefghijklmnopqrstuvwxyz', | |
alphabetLength = alphabet.length, | |
// current number combination which could be mapped to classname using alphabet | |
combination = null; | |
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
/** | |
* @param {Number} count Call chain length | |
*/ | |
function createAdd(count) { | |
return function add() { | |
var length = arguments.length, | |
args, | |
result, | |
i; | |
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 color, i; | |
// Notice: octal literals are not allowed in strict mode. | |
function colorize(color, output) { | |
return ['\033[', color, 'm', output, '\033[0m'].join(''); | |
} | |
for (i = 0; i < 100; i += 1) { | |
color = Math.random() > 0.9 ? 91 : 92; // 91 - red, 92 - green | |
process.stdout.write( colorize(color, '●') ); |
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 invertLinkedList(list) { | |
var next = list.next, | |
temp; | |
list.next = null; | |
while ( next ) { | |
temp = next; | |
next = temp.next; | |
temp.next = list; |
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
{ | |
// http://www.jshint.com/docs/ | |
"jshint_options": { | |
// prohibits the use of explicitly undeclared variables | |
"undef": true, | |
// prohibits the use of a variable before it was defined | |
"latedef": true, |