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
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.example.com', 'src="https://www.example.com'); |
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 asyncHandler = fn => (req, res, next) => | |
Promise | |
.resolve(fn(req, res, next)) | |
.catch(next); | |
module.exports = asyncHandler; | |
// Implementation (Controller method) | |
exports.someRoute = asyncHandler(async (req, res, next) => { | |
const foo = await Bar.find(); |
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 longestWord(str) { | |
// Match all the words and numbers | |
const wordsArray = str.toLowerCase().match(/[a-z0-9]+/g) | |
// Organise words (longest at the top) | |
const sortedList = wordsArray.sort((a,b) => { | |
return b.length - a.length | |
}) |