Skip to content

Instantly share code, notes, and snippets.

@neatshell
neatshell / install-node-linux.sh
Last active August 29, 2015 13:56
Install script for node.js on linux
#!/bin/bash
cat << 'EOF' >> ~/.npmrc
root = $HOME/.local/lib/node_modules
binroot = $HOME/.local/bin
manroot = $HOME/.local/share/man
EOF
mkdir -p ~/.local
@neatshell
neatshell / bash-customization.sh
Last active August 29, 2015 13:57
A script that adds some customizations to the bash
#!/bin/bash
cat << 'EOF' >> .bash_profile
if [ -n "$SSH_CLIENT" ]; then
PS1='\[\033[01;33m\]\u\033[00m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[00;33m\]\w\[\033[00m\] '
fi
EOF
@neatshell
neatshell / bootstrap-centos64-vagrant.sh
Last active August 29, 2015 13:57
A bootstrap script to initialize a centos64 vagrant box
#!/bin/bash
echo "LC_ALL=C" >> /etc/environment
yum -y install git
@neatshell
neatshell / Vagrantfile-mean-centos64
Last active August 29, 2015 13:57
Vagrantfile that builds up a box with a MEAN stack on a centos64
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos64"
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.5-x86_64-v20140110.box"
config.vm.network :private_network, ip: "192.168.50.2"
#!/usr/bin/env bash
npm install -g grunt grunt-cli bower yo
@neatshell
neatshell / argsloop
Created July 24, 2013 08:36
bash args loop, from $1 to $n
while [ "$1" != "" ]; do
echo $1
shift
done
// Swap keys with values of a javascript object
const swapKV = (object) => {
const ret = {};
for (let key in object) {
if (object.hasOwnProperty(key)) {
ret[object[key]] = key;
}
}
return ret;
}
module.exports = (millis) => {
let seconds = (millis / 1000).toFixed(0);
let minutes = Math.floor(seconds / 60);
let hours = '';
if (minutes > 59) {
hours = Math.floor(minutes / 60);
hours = (hours >= 10) ? hours : '0' + hours;
minutes = minutes - (hours * 60);
minutes = (minutes >= 10) ? minutes : '0' + minutes;
function sleep(milliseconds) {
var start = new Date().getTime();
for (var i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds){
break;
}
}
}
# Retrieve the arguments passed to an npm/yarn script
ARGV=$(echo "console.log(JSON.parse(process.argv[2]).original.splice(1, Infinity).join(' '))" | node - ${npm_config_argv})