Skip to content

Instantly share code, notes, and snippets.

🐙
PLING

felipekm felipekm

🐙
PLING
Block or report user

Report or block felipekm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:c1462cd9197c46ebe123f22188bb14d5
sudo ln -s "$(which node)" /usr/bin/node -f
@felipekm
felipekm / pm2-describe.sh
Created Aug 21, 2018
Validates if a PM2 process is running
View pm2-describe.sh
#!/bin/bash
sudo pm2 describe login > /dev/null
RUNNING=$?
if [ "${RUNNING}" -ne 0 ]; then
echo "not running"
else
echo "is running"
fi;
@jsanta
jsanta / mem-monitor.sh
Created Jul 13, 2018
Script to restart PM2 procceses if memory exceeds limit
View mem-monitor.sh
#!/bin/bash
memtotal=$(free | grep Mem | awk '{ print $2 }')
memuse=$(free | grep Mem | awk '{ print $3 }')
let "memusepercent = $memuse * 100 / $memtotal "
let "memtolerance = $memtotal * 0.9 "
echo "MemTotal: $memtotal (Usage tolerance: $memtolerance )"
echo "MemUsed: $memuse ($memusepercent %)"
if [ $memuse -ge $memtolerance ]; then
echo "Memory use over 90%"
View api-cheatsheet-array.md

Array<T>

Legend:

  • ✏️ method changes this.
  • 🔒 method does not change this.

Array<T>.prototype.*:

  • concat(...items: Array<T[] | T>): T[] 🔒 ES3
View pm2-nextjs.txt
# for development
pm2 start npm --name "next" -- run dev
# for production
npm run build
pm2 start npm --name "next" -- start
View Reactive Conf - Thinking metrics on React applications.md

This is a proposal for a lightning talk at the Reactive 2016 conference. If you like this, star the Gist.


Thinking metrics on React applications

In regular websites, it is common to send multiple events to track user clicks. Single Page Applications change the way you look at metrics. This is a talk about a simple pattern we created at Globo.com to manage a metrics layer for http://globoplay.globo.com. The talk will cover how to track user flow using Google Analytics and other services. We solved the challenge of tying metrics and components, keeping information across pages and having global data. Also some React, React Router and React Side Effects concepts like context, higher order components, history state will be covered.

View compile-hook.js
'use strict';
const Module = require('module');
const originalCompile = Module.prototype._compile;
const nohook = function (content, filename, done) {
return done(content);
};
let currentHook = nohook;
@rdsubhas
rdsubhas / generators.js
Last active May 2, 2017
es6-blog-generators.js
View generators.js
var Promise = require('bluebird');
var request = Promise.promisifyAll(require('request'));
var url1='http://httpbin.org/', url2=url1, url3=url1, url4=url1;
function* foo() {
var res1 = yield request.getAsync(url1);
var res2 = yield request.getAsync(url2);
var res3 = yield request.getAsync(url3);
var res4 = yield request.getAsync(url4);
return "whew all done";
View backup-github.sh
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
@getify
getify / gist:7ae82fdc2e86bf66bcba
Last active Jun 27, 2019
List of ES6 books either out or in progress...
View gist:7ae82fdc2e86bf66bcba
You can’t perform that action at this time.