hugo
I’m trying Hugo, a static website generator, along with Pages CMS, a web editor.
I’m trying Hugo, a static website generator, along with Pages CMS, a web editor.
An Ansible script that makes multiple machines reservations in a GCP project based on machine type, zone and number of running instances. The script … Creates new reservations if it’s non-existent with count. Update an existing reservation by increasing or decreasing count. Delete a reservation if no instances are present or none are running. Print a summary at end of the script.
If you have a text file with multiple columns, you can use column to align the output vertically. cat output.txt | column -t
Here’s the script that will the dos2unix command recursively in the current directory. It doesn’t have to be dos2unix but can be any command. Run it on all files. find . -type f -exec dos2unix {} + Run it on all shell files only. find . -type f -name "*.sh" -exec dos2unix {} +
Here’s my $0.13 cent cloud bill. Back in the day, my cloud bill was anywhere between $10-20 per month because I was hosting a VM. I converted from WordPress site to Jekyll, a static site generator hosted for free at GitHub. My photo gallery is hosted in AWS S3. I use node.js programs to generate the galleries. My total bill this month is $0.13. It will climb a few cents as I upload more photos.
This is the command to display system memory in GB in Linux. grep -E 'MemTotal|MemAvailable' /proc/meminfo | awk '{printf "%s %.2f GB\n", $1, $2/1024^2}'
Here’s a nice little script that generates a random string. User is asked to match the string. If there’s a match, it continues. If there’s no match, it will exit. confirm() { CHARNUM=6 CHARSET='A-Za-z0-9' # Generate random string RANDOM_STRING=$(LC_ALL=C tr -dc $CHARSET </dev/urandom | head -c $CHARNUM) printf "%s\n" "Please confirm Code to continue: $RANDOM_STRING" read -r -p "Code: " USER_INPUT if [[ "$USER_INPUT" != "$RANDOM_STRING" ]]; then echo "❌ Code does not match! Exiting!" exit 1 fi echo "✅ Code matched!" echo "Shutting down server!" }
Here’s my new git push script. #!/bin/bash comment=$1 if [[ -z $comment ]]; then echo "Usage: $0 'put your comment here'" exit fi git add . git commit -am "$comment" git push To use the script, simply execute ./gitPush.sh ‘put your git comment here’ The script will add, commit and push it to your remote repository.
I run Gitea on my desktop. Recently my desktop IP address changed. I should really set it to a static IP address, but that’s another story. Doing a git pull and a git push no longer works since the remote URL changed. To update to a new remote location, simply run the command below. git remote set-url origin http://192.168.68.105:3000/ulysses/scripts.git If you use SSH, use the SSH remote link instead of HTTP.
Here’s a neat script that will edit crontab without creating duplicates. #!/usr/bin/env bash CRON_ENTRY="0 2 * * * /path/to/script.sh" EXISTING=$(crontab -l 2>/dev/null || true) if ! echo "$EXISTING" | grep -Fxq "$CRON_ENTRY"; then printf "%s\n%s\n" "$EXISTING" "$CRON_ENTRY" | crontab - fi