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
module.exports = { | |
postSomething: async (req, res) => { | |
const { title, description, userId } = req.body; | |
const thing = new Field({ | |
title, | |
description, | |
userId, | |
}); | |
try { |
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 toColor(str) { | |
var hash = 0; | |
for (var i = 0; i < str.length; i++) { | |
hash = str.charCodeAt(i) + ((hash << 5) - hash); | |
} | |
var c = (hash & 0x00ffffff).toString(16).toUpperCase(); | |
return "#" + c; | |
} | |
console.log(toColor("cool")) |
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 ucFirstJS(string) | |
{ | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} |
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
//Fastest way to generate random string in JavaScript | |
var x = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15) | |
console.log(x) |