Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Chris Barber-Riley ChrisBarberRiley

🚀
View GitHub Profile
View JS Challenge: Longest word.js
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
})
View asyncMiddleware.js
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();
@ChrisBarberRiley
ChrisBarberRiley / WP-SSL-URL-Update.sql
Last active Feb 9, 2018
Update Wordpress Images After SSL Insert
View WP-SSL-URL-Update.sql
UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, 'src="http://www.example.com', 'src="https://www.example.com');