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 (typeof module !== 'undefined' && module.exports) { | |
| module.exports = myModule; | |
| } else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd){ | |
| // AMD. Register as an anonymous module. | |
| define(function () { | |
| return myModule; | |
| }); | |
| } else { | |
| window.myModule = myModule; | |
| } |
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
| DOT = function(obj,prop){ | |
| if(obj.hasOwnProperty(prop)){ | |
| return obj[prop]; | |
| }else if(obj.__proto__){ | |
| return DOT(obj.__proto__,prop) | |
| } | |
| } | |
| DOTCALL = function(obj,props,args){ | |
| var fn = DOT(obj,props); |
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
| import * as _ from 'lodash'; | |
| function objectDiff(prev, now){ | |
| // sanity checks, prev and now must be an object. | |
| if ( ! _.isObject(prev) || ! _.isObject(now) ){ | |
| return new TypeError("Arguments must both be objects",__filename); | |
| } | |
| var changes = {}; | |
| for (var prop in now) { | |
| // if property is new in now i.e unknown, add it too changes |
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(""); | |
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
| 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
| 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
| 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
| 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
| //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'), |