Skip to content

Instantly share code, notes, and snippets.

View ivuorinen's full-sized avatar

Ismo Vuorinen ivuorinen

View GitHub Profile
@ivuorinen
ivuorinen / minutes-since-midnight.js
Created July 28, 2023 10:26
Minutes since midnight
const minutesSinceMidnight = () => {
const now = new Date();
const midnight = new Date().setHours(0, 0, 0, 0);
return ((now - midnight) / 1000) / 60;
}
@ivuorinen
ivuorinen / every
Created July 27, 2023 07:15 — forked from sorbits/every
Run «command» only every «number» time invoked
#!/usr/bin/env bash
progname=$(basename $0)
version="1.0 (2014-08-17)"
step=2
function create_hash {
openssl dgst -sha1 -binary <<< "$1" | xxd -p
}
@ivuorinen
ivuorinen / 📊 Weekly development breakdown
Last active May 8, 2024 04:09
📊 Weekly development breakdown
JavaScript 1 hr 39 mins ████████▋░░░░░░░░░░░░ 41.4%
Other 45 mins ███▉░░░░░░░░░░░░░░░░░ 18.7%
Markdown 36 mins ███▏░░░░░░░░░░░░░░░░░ 15.2%
JSON 21 mins █▉░░░░░░░░░░░░░░░░░░░ 9.0%
Text 9 mins ▊░░░░░░░░░░░░░░░░░░░░ 4.1%
@ivuorinen
ivuorinen / validate_sha256sum
Created September 30, 2022 13:32 — forked from Hooace/validate_sha256sum
Shell script to validate file sha256 hashes. I use this to check if downloaded binaries are correct in Dockerfiles. This might make updating harder but at least it you see which parts have been updated since the last run.
#!/bin/sh
##
# This script contains helper for sha256 validating your downloads
#
# Source: https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
# Author: Onni Hakala
# License: MIT
##
# Stop program and give error message
@ivuorinen
ivuorinen / clean_vendors.php
Created September 18, 2022 08:33
Remove all vendor and node_modules folders from cli
<?php
system("df -H");
echo "\n\n";
$d = glob(__DIR__ . '/*');
sort($d);
$removable = [
'vendor',
@ivuorinen
ivuorinen / Readme.md
Created September 8, 2021 10:05 — forked from saniaky/Readme.md
Docker + nginx-proxy + let's encrypt + watchtower + fail2ban

Complete solution for websites hosting

This gist contains example of how you can configure nginx reverse-proxy with autmatic container discovery, SSL certificates generation (using Let's Encrypt) and auto updates.

Features:

  • Automatically detect new containers and reconfigure nginx reverse-proxy
  • Automatically generate/update SSL certificates for all specified containers.
  • Watch for new docker images and update them.
  • Ban bots and hackers who are trying to bruteforce your website or do anything suspicious.
@ivuorinen
ivuorinen / E_USER_DEPRECATED_WP.php
Created August 9, 2021 05:05
Skip WordPress E_NOTICE and E_USER_DEPRECATED errors
<?php
// Drop this to the theme functions.php
if ( defined( 'WP_ENV' ) && ! empty( WP_ENV ) && WP_ENV === 'development' ) {
error_reporting( E_ALL & ~E_NOTICE & ~E_USER_DEPRECATED ); // phpcs:ignore
}
@ivuorinen
ivuorinen / wp_generate_posts.sh
Last active July 27, 2020 11:03
wp_generate_posts.sh
#!/usr/bin/env bash
# bash wp_generate_posts.sh [amount, defaults to 25]
# example: bash wp_generate_posts.sh 100 (to generate 100 posts)
_GEN_POSTS_AMOUNT_OF_POSTS=${1:-25}
re='^[0-9]+$'
if ! [[ $_GEN_POSTS_AMOUNT_OF_POSTS =~ $re ]] ; then
echo "error: Amount parameter must be an integer" >&2; exit 1
fi
@ivuorinen
ivuorinen / gitlab-clean-backups.sh
Created March 26, 2020 10:51
Clear old GitLab backups
#!/usr/bin/env bash
# Delete old (over 30 days old) GitLab backups
# CRONTAB: @daily /root/scripts/gitlab-clean-backups.sh
find /var/opt/gitlab/backups/ -type f -name '*.tar' -mtime +30 -exec rm {} \;
@ivuorinen
ivuorinen / release.sh
Created March 23, 2020 11:58
Git-Flow Release Automation with version bumping and changelog generation
#!/usr/bin/env bash
# Git-flow release automation with
# version bumping and changelog generation
#
# Based on many great starting points:
# https://gist.github.com/mareksuscak/1f206fbc3bb9d97dec9c
# https://gist.github.com/pete-otaqui/4188238
# https://gist.github.com/bclinkinbeard/1331790