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 vm = require('vm'); | |
| var fs = require('fs'); | |
| var path = require('path'); | |
| /** | |
| * Helper for unit testing: | |
| * - load module with mocked dependencies | |
| * - allow accessing private state of the module | |
| * | |
| * @param {string} filePath Absolute path to module (file to load) |
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 random(m_w, m_z) { | |
| m_z = 36969 * (m_z & 65535) + (m_z >> 16); | |
| m_w = 18000 * (m_w & 65535) + (m_w >> 16); | |
| return (m_z << 16) + m_w; | |
| } |
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 curry(fn) { | |
| //create sunt double function to check artiy of the calling function i.e fn | |
| return function() { | |
| //check the length of args and if its greater copy them and return a new function | |
| if (fn.length > arguments.length) { | |
| //copy logic | |
| var slice = Array.prototype.slice; | |
| var args = slice.apply(arguments) | |
| //new function with args copied | |
| return 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
| //run in the command line one at a time | |
| //openssl genrsa -out privatekey.pem 1024 | |
| //openssl req -new -key privatekey.pem -out certreq.csr | |
| //openssl x509 -req -days 3650 -in certreq.csr -signkey -private.pem -out newcert.pem | |
| var express = require('express'), | |
| https = require('https'), | |
| fs = require('fs'); | |
| privateKey = fs.readFileSync('path/to/privateKey.pem'), | |
| cert = fs.readFileSync('path/to/newCert.pem'), |
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 calculateMD5String, filepath, md5; | |
| md5 = require('MD5'); | |
| calculateMD5String = function(path) { | |
| return '-' + md5(fs.readFileSync(path)); | |
| }; | |
| filepath = "app" + calculateMD5String("app.js") + ".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
| Array(21).join('lol'-2)+" Batman" |
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
| main(){ | |
| extrn a,b,c; | |
| putchar(a); putchar(b); putchar(c); putchar('!*n'); | |
| } | |
| a 'hell'; | |
| b 'o, w'; | |
| c 'orld'; | |
| //First appeard in 1972 |
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 config = require('path/to/config'); | |
| var mongoose = require('mongose'); | |
| process.env.NODE_ENV = 'test'; | |
| before(function (done) { | |
| function clearCollections() { | |
| for (var collection in mongoose.connection.collections) { | |
| mongoose.connection.collections[collection].remove(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
| var Range = { | |
| create: function (start, end) { | |
| var results = [], | |
| current = start, | |
| step = start < end ? 1 : -1; | |
| results.push(current); | |
| while (current !== end) { | |
| current += step; |
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 hex (hex){ | |
| if(/^#/.test(hex)){ | |
| hex = hex.slice(1); | |
| } | |
| if(hex.length !== 3 && hex.length !== 6 ){ | |
| throw new Error("Invaild hex String"); | |
| } | |
| var digit = hex.split(""); | |