View leaks-mocha.js
//Detecting which module is causing a global leak can be cumbersome and boring. But there is a nice little trick to find the little bastard. Add these lines at the very beginning of your tests:
Object.defineProperty(global, "name_of_leaking_property", {
set : function(value) {
throw new Error("Found the leak!");
}
})
// This will print a stacktrace that shows which module caused the leak.
// https://github.com/mochajs/mocha/wiki/Detecting-global-leaks
View re-associate-vagrant.link
View b.js
var browserify = require('browserify');
var async = require('async');
var heapdump = require('heapdump');
var memwatch = require('memwatch');
// memwatch.on('stats', function(stats) { console.log( stats.usage_trend ) });
// memwatch.on('leak', function(info) { console.log( info ) });
var paths = [
'./views/demo1/demo1.js',
'./views/demo2/demo2.js'
View source_dest_scp.sh
# get data from file m.map
# this file has the map sourceName, destName
#i.e:
#/source/A.jpg,/dest/B.jpg
# split with awk and create an array, the use the array to scp
for i in $(cat m.map); do A=($(echo ${i}|awk -F"," '{print $1" "$2}'));scp ${A[0]} 1.1.1.1:${A[1]};done
View gist:21c1cb00bac65a111568
from https://www.howtoforge.com/postgresql-ssl-certificates
This describes how to set up ssl certificates to enable encrypted connections from PgAdmin on some client machine to postgresql on a server machine. The assumption is that postgresql (compiled with ssl support) and openssl are already installed and functional on the server (Linux). PgAdmin is already installed on the client (either Windows or Linux).
On the server, three certificates are required in the data directory. CentOS default is /var/lib/pgsql/data/:
root.crt (trusted root certificate)
server.crt (server certificate)
server.key (private key)
Issue commands as root.
View boot.js
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
View key_to_json
sed ':a;N;$!ba;s/\n/\\n/g' my_key.pem
or in vi
:%s/\n/\\n/
https://tickets.opscode.com/browse/CHEF-3540
View commands.lst
git rm $(git ls-files --deleted)
This will ONLY remove the deleted files from the git.
It could be also be used for adding ONLY modified files also.
git add $(git ls-files --modified)
View install_mod_cloudflare and mod_evasive
#
# based on: http://knowledgevoid.com/blog/2012/01/13/logging-the-correct-ip-address-using-apache-2-2-x-and-amazons-elastic-load-balancer/
# mod_evasive based on
# https://www.linode.com/docs/websites/apache-tips-and-tricks/modevasive-on-apache
# update cloudflare download link
# make sure you're root
sudo -i
View prototypical_inheritance.js
// base
var Padre = function(){
// atributos de la clase padre
this.yo = "soy el padre",
this.nacionalidad = "Argentino",
// metodos de la clase padre
this.saludar = function(){ alert(this.yo) },
this.donde = function(){ alert("soy "+ this.nacionalidad)}
}