This file contains hidden or 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
// Pad string paragraph to a number of characters, and appends ellipsis. | |
// ---------- example------------ | |
// | |
// const String = "Curabitur gravida nisi at nibh. In hac habitasse platea dictumst. Aliquam augue quam, sollicitudin vitae, consectetuer eget, rutrum at, lorem. Integer tincidunt ante vel ipsum. Praesent blandit lacinia erat. Vestibulum sed magna at nunc commodo placerat. nunc purus" | |
// | |
// pad(String, 100) | |
// | |
// returns "'Curabitur gravida nisi at nibh. In hac habitasse platea dictumst. Aliquam augue quam, sollicitudin v...' | |
// |
This file contains hidden or 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
expenseCategories = [ | |
'auto & parking', | |
'bills & utilities', | |
'business services', | |
'cash & cheque', | |
'education', | |
'entertainment', | |
'family', | |
'fees & charges', | |
'finance & investments', |
This file contains hidden or 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
["Acerola – West Indian Cherry","Apple","Apricots","Avocado","Banana","Blackberries","Blackcurrant","Blueberries","Breadfruit","Cantaloupe","Carambola","Cherimoya","Cherries","Clementine","Coconut Meat","Cranberries","Custard-Apple","Date Fruit","Durian","Elderberries","Feijoa","Figs","Gooseberries","Grapefruit","Grapes","Guava","Honeydew Melon","Jackfruit","Java-Plum","Jujube Fruit","Kiwifruit","Kumquat","Lemon","Lime","Longan","Loquat","Lychee","Mandarin","Mango","Mangosteen","Mulberries","Nectarine","Olives","Orange","Papaya","Passion Fruit","Peaches","Pear","Persimmon – Japanese","Pitaya (Dragonfruit)","Pineapple","Pitanga","Plantain","Plums","Pomegranate","Prickly Pear","Prunes","Pummelo","Quince","Raspberries","Rhubarb","Rose-Apple","Sapodilla","Sapote, Mamey","Soursop","Strawberries","Sugar-Apple","Tamarind","Tangerine","Watermelon"] |
This file contains hidden or 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
// config script to connect to MongoDB with MongooseJS | |
const mongoose = require("mongoose"); | |
const connectDB = async () => { | |
const conn = await mongoose.connect(process.env.MONGODB_URL, { | |
useNewUrlParser: true, | |
useCreateIndex: true, | |
useFindAndModify: false, | |
useUnifiedTopology: true, | |
}); |
This file contains hidden or 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
// create a class object to be passed to middleware for Express error handling | |
class errorResponse extends Error { | |
constructor(message, statusCode) { | |
super(message); | |
this.statusCode = statusCode; | |
Error.captureStackTrace(this, this.constructor); | |
} | |
} |
This file contains hidden or 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
// middleware script to handle error for all routes consistently | |
const errorHandler = async (err, req, res, next) => { | |
let error = { ...err }; | |
error.message = err.message; | |
// Log to conosle for dev | |
console.log(err); |
This file contains hidden or 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; |
This file contains hidden or 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 pickOne(arr: any[]) { | |
if (!arr.length) { | |
throw new Error('Param cannot be empty'); | |
} | |
return arr[Math.floor(Math.random() * arr.length)]; | |
} |
This file contains hidden or 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 romanNumerals = { | |
0: "", | |
1: "I", | |
2: "II", | |
3: "III", | |
4: "IV", | |
5: "V", | |
6: "VI", | |
7: "VII", | |
8: "VIII", |
This file contains hidden or 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
$font-weights: (100, 200, 300, 400, 500, 600, 700, 800, 900); | |
@each $weight in $font-weights { | |
.fw-#{$weight} { | |
font-weight: $weight; | |
} | |
} |
OlderNewer