Skip to content

Instantly share code, notes, and snippets.

Working from home

Phellipe Andrade phellipeandrade

Working from home
  • São Paulo - Brazil
View GitHub Profile
phellipeandrade /
Created Nov 6, 2016 — forked from zenorocha/
A template for Github READMEs (Markdown) + Sublime Snippet

Project Name

TODO: Write a project description


TODO: Describe the installation process


View gist:bb2533e8033dc303dd5e6d75f9e47d27
var cacheStatusValues = [];
cacheStatusValues[0] = 'uncached';
cacheStatusValues[1] = 'idle';
cacheStatusValues[2] = 'checking';
cacheStatusValues[3] = 'downloading';
cacheStatusValues[4] = 'updateready';
cacheStatusValues[5] = 'obsolete';
var cache = window.applicationCache;
cache.addEventListener('cached', logEvent, false);
View probability_AB.js
//The sum of 'weights' elements should be equal 1.
let weights = [0.1, 0.9]; // probabilities
//The possible results
let results = [0, 1]; // values to return
function getRandom () {
let num = Math.random(),
s = 0,
lastIndex = weights.length - 1;
phellipeandrade / install_nodejs_ubuntu.txt
Last active Jan 15, 2017
The Best Way to Install Node.js Ubuntu
View install_nodejs_ubuntu.txt
$ sudo apt-get purge nodejs && sudo apt-get autoremove && sudo apt-get autoclean
$ curl -o- | bash
$ nvm list
$ nvm ls-remote
$ nvm install 6.9.4
$ nvm use 6.9.4
$ nvm alias default 6.9.4
$ node -v
phellipeandrade / mongodb_drop_all_databases.txt
Last active Jan 22, 2017
MongoDB drop ALL databases - console
View mongodb_drop_all_databases.txt
mongo --quiet --eval 'db.getMongo().getDBNames().forEach(function(i){db.getSiblingDB(i).dropDatabase()})'
# Fetch the latest branches
git fetch
# Get the repository path
repoPath=$(git config --get remote.origin.url)
# Loop through each branch
phellipeandrade /
Created May 30, 2017 — forked from soheilhy/
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for,, and on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

phellipeandrade /
Created Sep 1, 2017 — forked from sheharyarn/
Mongodump Shell Script for Cronjob
TIMESTAMP=`date +%F-%H%M`
View closest_number_of_array.js
// Based on:
const arr = [360, 375, 414, 768, 1024];
// ES6
const closest = (num, arr) => {
let curr = arr[0];
let diff = Math.abs(num - curr);
for (let i of arr) {
const newDiff = Math.abs(num - i);
View comoNaoDeixarNoVaucoNoWhatsapp.js
Hoje não deixaremos mais ninguém no vácuo no whatsapp
Para utilizar:
- Abra o;
- Abra o console e cole o código que está no gist;
- Aguarde e verá uma mensagem sendo enviada a cada momento que alguém te enviar alguma mensagem.
Confira também como ser chato no whatsapp: