Skip to content

Instantly share code, notes, and snippets.

View Mtillmann's full-sized avatar
👻
bouncing

Martin Tillmann Mtillmann

👻
bouncing
View GitHub Profile
@Mtillmann
Mtillmann / formatBytes.js
Last active December 31, 2022 10:22 — forked from zentala/formatBytes.js
Convert size in bytes to human readable format (JavaScript)
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');
@Mtillmann
Mtillmann / jekyll-install.txt
Last active March 8, 2017 11:05 — forked from Piyush3dB/jekyll-install.txt
Jekyll 3.2.1, Ruby 2.2.3 install on Ubuntu 14.04
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