Skip to content

Instantly share code, notes, and snippets.

@fetwar
fetwar / install-docker-and-compose.yaml
Last active August 7, 2023 08:16
Install Docker on Ubuntu - Ansible Playbook
---
- name: Install Docker on Ubuntu
hosts: workstations
become: true
tasks:
- name: Update the apt package index
apt:
update_cache: true
@fetwar
fetwar / remove-if-in-tar.sh
Created April 17, 2023 05:01
Remove files from current folder if they are present in a tarball within the same dir
#!/bin/bash
# Get the current directory path
current_directory=$(pwd)
# Iterate over all tar files in the current directory
for tar_file in "$current_directory"/*.tar; do
# If the tar file exists, process it
if [ -f "${tar_file}" ]; then
# Iterate over all files in the current directory (excluding directories and tar files)
@fetwar
fetwar / bank-balance-burndown.js
Last active October 31, 2023 06:38
Google Apps Script - Create calendar with daily events for your target balance burndown to track spending
function getCalendar(config) {
var calendars = CalendarApp.getCalendarsByName(config.calendarName);
if (calendars.length === 0) {
var calendar = CalendarApp.createCalendar(config.calendarName, config.calendarConfig);
console.log('Created calendar: ' + calendar.getName());
} else {
if (calendars.length > 1) {
console.warn("Non critical error: multiple calendars with applicable name.", calendars)
}
@fetwar
fetwar / print-padded-heading.sh
Last active May 7, 2024 01:23
Print a heading padded with equals signs above and below
#!/usr/bin/env bash
# Usage:
# print-padded-heading Some Heading
#
# Outputs:
# ==============
# Some Heading
# ==============
@fetwar
fetwar / dig-all.sh
Last active October 31, 2023 06:37
Use dig to fetch multiple DNS records of a domain.
#!/usr/bin/env bash
defaultRecordTypes=( A CNAME MX TXT SOA PTR SRV )
# Domain name input
if [ -z $1 ]; then
echo "Error: domain argument expected"
exit 1
fi