port already in use
Add following line in app.js or main express server file
if (NODE_ENV !== 'test') {
await app.listen(PORT)
}
# Pre-requisite | |
Should have node >=12 | |
# Install | |
npm i prom-client | |
# Setup |
//https://docs.mongodb.com/v3.2/reference/method/db.collection.bulkWrite | |
db.enemies.bulkWrite( | |
[ | |
{ updateMany : | |
{ | |
"filter" : { "rating" : { $gte : 3} }, | |
"update" : { $inc : { "encounter" : 0.1 } } | |
}, | |
}, |
db.getCollection('panData').aggregate([ | |
{ $match: { createdAt: { $gte: '2020-04-01T18:30:00.000Z' } } }, | |
{ | |
$group: { | |
_id: { partner: '$productCode', project: '$source' }, | |
project: { $sum: { $cond: [{ $eq: ['$cached', true] }, 1, 0] } }, | |
apiHits: { $sum: { $cond: [{ $eq: ['$cached', true] }, 1, 0] } }, | |
dbHits: { $sum: { $cond: [{ $eq: ['$cached', false] }, 1, 0] } }, | |
hits: { $sum: 1 } | |
} |
/* | |
* This is an example of multi stage facet query in MongoDb to cover few possible combinations of query | |
* Facets allows us to write multiple indepent queries to get facet result which is usually used for obtaining stats from DB | |
* or tags for products or blogs with product count, category count from products list with product count etc. | |
*/ | |
db.getCollection('applications').aggregate([ | |
{ | |
$match: { | |
partner: { $in: [ObjectId("5e8ac6806a99770011f2f38b")] }, |
// deepClone.js | |
x = { a: 1, b: 2, z: { c: 3, d: 4, y: { e: 5 } } } | |
const deepClone = (obj) => { | |
if (typeof obj === "object" && obj !== null) { | |
return Object | |
.keys(obj) | |
.map((key) => { | |
return { |
1. brew install postgres | |
2. /usr/local/opt/postgres/bin/createuser -s postgres | |
Step to create default user |
/* | |
This is an example on how I customized the ghostfinder ghost pulgin i.e https://github.com/electronthemes/ghost-finder | |
to show all tags and authors along with custom css for them. | |
*/ | |
/******/ (function(modules) { // webpackBootstrap | |
/******/ // The module cache | |
/******/ var installedModules = {}; |
To remove a submodule you need to:
defmodule Image.Transformer do | |
def transform(original_file, operation \\ "convert") do | |
thumb_path = generate_thumb_file(original_file) | |
System.cmd(operation, operation_commands(original_file_path, thumb_path)) | |
thumb_path | |
end | |
defp generate_thumb_file(original_file) do |