Skip to content

Instantly share code, notes, and snippets.

View simonecorsi's full-sized avatar
🦄
Magic unicorn between machine and people

Simone Corsi simonecorsi

🦄
Magic unicorn between machine and people
View GitHub Profile
@simonecorsi
simonecorsi / script.js
Last active December 4, 2018 08:48
MongoDB shell // Invalidate email in collections
db.getCollectionNames().map(function(collection) {
var hasEmailField = db[collection].count({ email: { $exists: true }})
if ( !hasEmailField ) return "no email field in : " + collection
db[collection].find({}).map(function(item) {
db[collection].update(
{ _id: item._id },
{
$set: {
email: item.email.replace(
/@.*\..*/,
@simonecorsi
simonecorsi / blueGreenDeployment.js
Created November 10, 2020 11:31 — forked from brandonros/blueGreenDeployment.js
node.js + nginx + PM2 rolling release/blue green deployments (zero downtime)
const Promise = require('bluebird');
const fs = require('fs');
const execa = require('execa');
class BlueGreenDeployment {
constructor({appName, blueProxyPassPattern, greenProxyPassPattern, nginxConfigFile}) {
this.appName = appName;
this.blueProxyPassPattern = blueProxyPassPattern;
this.greenProxyPassPattern = greenProxyPassPattern;
this.nginxConfigFile = nginxConfigFile;