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 / push-homesick-castles.sh
Created February 5, 2024 12:34
automatically push homes(h)ick castles when they have changes
#!/usr/bin/bash
# crontab -e
# * */2 * * * /home/martin/push-homesick-castles.sh dotfiles > /dev/null 2>&1
if [ $# -eq 0 ]
then
echo "Usage $0 castle1[, castle2, castle3, ...]"
exit 1
fi
for castle in "$@"
do
@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 / CustomHMRHotFile.php
Last active November 8, 2022 10:18
Custom HMR URL
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class CustomHMRHotFile
{
/**
@Mtillmann
Mtillmann / mterser.js
Created December 22, 2021 14:45
Simple glob wrapper for terser, to minify every file in folder, works on windows
/**
* minify all files matched by given glob pattern through terser. Requires `glob` to be installed:
*
* npm i glob --save-dev
*
* Place the scripts in your projects scripts folder, then add it to your package.json's scripts like this
*
* "mterser": "node scripts/mterser.js --glob dist/umd/*.js --compress --mangle --comments false",
*
* and run it by calling `npm run mterser`. A `terser` npm script should also be available, see `--terser-cmd` below.
@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