Skip to content

Instantly share code, notes, and snippets.

Riccardo Bartoli rbartoli

Block or report user

Report or block rbartoli

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
@rbartoli
rbartoli / install-pm2.sh
Last active Sep 28, 2016
PM2 installation steps
View install-pm2.sh
# Add safe user
useradd -s /bin/bash -m -d /home/safeuser -c "safe user" safeuser
passwd safeuser
usermod -aG sudo safeuser
# Install PM2
sudo npm install -g pm2
cd project
NODE_ENV=production pm2 start server.js
pm2 startup
View Where is that console.log?
['log', 'warn'].forEach(function(method) {
var old = console[method];
console[method] = function() {
var stack = (new Error()).stack.split(/\n/);
// Chrome includes a single "Error" line, FF doesn't.
if (stack[0].indexOf('Error') === 0) {
stack = stack.slice(1);
}
var args = [].slice.apply(arguments).concat([stack[1].trim()]);
return old.apply(console, args);
View Deploy with GIT.md

Deploy your site with GIT

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
    • apache's home directory is /var/www/
@rbartoli
rbartoli / js: sortBy
Last active Aug 29, 2015
JS: Object sort with additional parameters
View js: sortBy
var sort_by;
(function() {
// utility functions
var default_cmp = function(a, b) {
if (a == b) return 0;
return a < b ? -1 : 1;
},
getCmpFunc = function(primer, reverse) {
var dfc = default_cmp, // closer in scope
View GIT tips.md

GIT tips

Fetch a file from another branch to the current one

git checkout branch_name -- filename

Unstage all changes but leave files in the working directory untouched

git reset HEAD

Unstage a file

git reset HEAD

You can’t perform that action at this time.