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
String.prototype.mySubstring = function(start, end) { | |
let substr = ''; | |
for (i = (start || 0); i <= ((end || this.length) - 1); i++) { | |
substr += this[i]; | |
} | |
return substr; | |
} | |
console.log("hello world!".mySubstring(1, 5)); // => ello |
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
const captilize = ([fL, ...rest]) => fL.toUpperCase()+rest.join(""); |
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
const formatDate = (datestring) => { | |
const seconds = Math.floor((new Date() - new Date(datestring)) / 1000); | |
let interval = seconds / 31536000; | |
if (interval > 1) return Math.floor(interval) + "Y"; | |
interval = seconds / 2592000; | |
if (interval > 1) return Math.floor(interval) + "M"; | |
interval = seconds / 86400; | |
if (interval > 1) return Math.floor(interval) + "d"; | |
interval = seconds / 3600; | |
if (interval > 1) return Math.floor(interval) + "h"; |
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
var cheerio = require("cheerio"), | |
fs = require("fs"); | |
fs.readFile('bookmarks.html', "utf-8", function read(err, data) { | |
if (err) { | |
throw err; | |
} | |
var $ = cheerio.load(data); | |
$("a").each(function(index, a) { |
OlderNewer