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 / 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;
@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 / sync-projects
Created July 30, 2018 09:42 — forked from nathanbrauer/sync-projects
Gitlab: Clone / Pull all projects in a group
#!/usr/bin/env bash
# Documentation
# https://docs.gitlab.com/ce/api/projects.html#list-projects
if [[ `whoami` == "root" ]]; then
echo "DO NOT run this program as root! Quitting."
exit 1
fi
@simonecorsi
simonecorsi / ffmpeg-compress-mp4
Created July 20, 2018 14:09 — forked from lukehedger/ffmpeg-compress-mp4
Compress mp4 using FFMPEG
$ ffmpeg -i input.mp4 -vcodec h264 -acodec mp2 output.mp4
@simonecorsi
simonecorsi / MimeTypes.js
Last active June 27, 2018 12:34
I'm tired.
const MimeTypes = {
documents: [
'application/pdf',
'application/msword',
'application/msword',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'application/vnd.ms-word.document.macroEnabled.12',
'application/vnd.ms-word.template.macroEnabled.12',
'application/vnd.ms-excel',
@simonecorsi
simonecorsi / Caddyfile
Created June 27, 2018 12:30 — forked from electerious/Caddyfile
Most complete list of mime types in the correct format for the Caddy mime directive
mime {
.atom application/atom+xml
.json application/json
.map application/json
.topojson application/json
.jsonld application/ld+json
.rss application/rss+xml
.geojson application/vnd.geo+json
.rdf application/xml
.xml application/xml
{
"ab":{
"name":"Abkhaz",
"nativeName":"аҧсуа"
},
"aa":{
"name":"Afar",
"nativeName":"Afaraf"
},
"af":{
@simonecorsi
simonecorsi / git-create-remote.sh
Last active January 16, 2018 04:59
This function will walk you through the creation of a remote repository on github without wasting your precious time going to the website :)
# This function will walk you through the creation of a remote repository on github
# without wasting your precious time going to the website :)
# how:
# - source it in your (bash|zsh)rc
# - change the alias at the bottom of the script to your needs
# - call it, follow instructions... profit
function createRemoteGitRepository() {
local RED='\033[0;31m'
local NC='\033[0m' # No Color
local GITHUB_USER=''
@simonecorsi
simonecorsi / base64 black GIF.js
Created November 4, 2016 16:58
Plain base64 gif I use in some jsx conditionals src=""
const blackBase64Gif = 'data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output