Skip to content

Instantly share code, notes, and snippets.

// 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;
}
#!/usr/bin/env bash
npm install -g grunt grunt-cli bower yo
@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"
@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 / 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 / install-mongo-centos64-vagrant.sh
Last active December 4, 2019 09:08
Install script for mongodb on a centos64 vagrant box
#!/usr/bin/env bash
cat << 'EOF' >> /etc/yum.repos.d/mongodb.repo
[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1
EOF
@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 / argsloop
Created July 24, 2013 08:36
bash args loop, from $1 to $n
while [ "$1" != "" ]; do
echo $1
shift
done
@neatshell
neatshell / myscript
Last active February 26, 2024 22:50
simple bash template that handles mandatory and optional arguments
#!/bin/bash
script="myscript"
#Declare the number of mandatory args
margs=2
# Common functions - BEGIN
function example {
echo -e "example: $script -m0 VAL -m1 VAL -o1 -o2 VAL"
}