Skip to content

Instantly share code, notes, and snippets.

View jdiamond's full-sized avatar

Jason Diamond jdiamond

  • 08:12 (UTC -07:00)
View GitHub Profile
@jdiamond
jdiamond / swap.sh
Created June 2, 2015 17:49
Enable swapfile on Ubuntu
# create the swapfile:
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
# enable it:
swapon /swapfile
sysctl vm.swappiness=10
sysctl vm.vfs_cache_pressure=50
@jdiamond
jdiamond / memory.js
Last active August 29, 2015 14:19
Watch memory and dump heaps in Node.js
function startWatchingMemory() {
if (process.env.MEMWATCH) {
var memwatch = require('memwatch-next');
var heapdump = process.env.HEAPDUMP && require('heapdump');
var hd = null;
memwatch.on('leak', function(info) {
log(info);
@jdiamond
jdiamond / Vagrantfile
Created August 11, 2014 17:39
Yeoman Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
INSTALL_NODE = <<SCRIPT
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y nodejs
var arr1 = [ { name: 'Nikki' }, { name: 'Jason' }, { name: 'Thanh' } ];
var arr2 = [ { name: 'Nikki' }, { name: 'Thanh' } ];
var index = {};
arr1.forEach(function(item) {
index[item.name] = item;
});
console.log(index);