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 * permutation (input) { | |
let n = input.length | |
if (n === 0) { | |
yield [] | |
} else { | |
let needle = input.pop() | |
for (let p of permutation(input)) { | |
for (let i = 0; i < n; i++) { | |
let q = p.slice() | |
q.splice(i, 0, needle) |
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
/** | |
* convert `Shared Folders\projects\electron-quick-start` | |
* to `Z:\projects\electron-quick-start` | |
* See https://github.com/electron/electron/issues/6760 | |
* | |
* Copy the source code to your page | |
* or add a script tag with src refering to this module | |
* **BEFORE** any module `require` takes place. | |
* | |
* Now you can `require` modules in HTML script tags as you do in node. |
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
// http://jsbin.com/lamakud/edit?html,output | |
function isValidateDate(datestr) { | |
var ms = Date.parse(datestr) | |
if (isNaN(ms)) return false | |
return ~~(datestr.split(/[^d]/).pop()) === new Date(ms).getDate() | |
} | |
module.exports = isValidateDate |
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 isLeap(year) { | |
var d = new Date(year + '') | |
d.setMonth(1) | |
d.setDate(29) | |
return d.getDate() === 29 | |
} | |
module.exports = isLeap |