This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apt-get install -y libssl-dev libreadline-dev zlib1g-dev | |
# install missing deps on mark's vagrant basebox to avoid fail at 99% :D | |
cd | |
git clone git://github.com/sstephenson/rbenv.git .rbenv | |
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc | |
echo 'eval "$(rbenv init -)"' >> ~/.bashrc | |
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build | |
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc | |
source ~/.bashrc | |
rbenv install -v 2.2.3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function formatBytes(bytes, decimals = 2, format = 'KB') { | |
if (bytes < 1) { | |
return '0 B'; | |
} | |
const k = format === 'kB' ? 1000 : 1024; | |
const i = Math.floor(Math.log(bytes) / Math.log(k)); | |
const sizes = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; | |
const suffix = [format === 'kB' ? sizes[i].toLowerCase() : sizes[i], 'B']; | |
if (format === 'KiB') { | |
suffix.splice(1, 0, 'i'); |