Skip to content

Instantly share code, notes, and snippets.

@mmasko
mmasko / prep-dev-server.sh
Last active September 29, 2025 15:51
To prep a dev server. Includes mounting an EBS volume where you have your code base or working directories.
#!/bin/bash
# Robust user-data / standalone script to install tooling and attach+mount an EBS volume by Name tag on Nitro (NVMe) instances.
set -euo pipefail
IFS=$'\n\t'
# --- System update and package installation ---
dnf update -y
dnf upgrade -y
dnf upgrade --releasever=latest -y
dnf install -y docker git unzip cronie python3-pip
@mmasko
mmasko / stale_activity_checker.sh
Last active September 6, 2025 18:42
check stale activity
#!/bin/bash
# Stale activity checker
# Runs (e.g. via cron every 5 min). Shuts down instance after 30 min of NO file changes under $MONITOR_DIR.
# Improvements:
# - Uses a state file to persist the last observed activity timestamp.
# - Handles empty directories without immediately triggering shutdown.
# - Works off seconds (no integer minute truncation surprises).
# - Prevents race conditions with a lock.
set -euo pipefail
@mmasko
mmasko / port check
Last active October 14, 2025 17:29
port check on linux using raw shell
# Linux
true &>/dev/null </dev/tcp/$HOSTNAMEorIP/$PORT && echo open || echo closed
# Ansible
ansible all -m win_ping -i $IP, --extra-vars "ansible_user=$username ansible_password=$password ansible_port=5986 ansible_connection=winrm ansible_winrm_server_cert_validation=ignore"
# Powershell
$host="<hostname or IP>";$port=<port>;if(Test-NetConnection -ComputerName $host -Port $port -InformationLevel Quiet){Write-Output "open"}else{Write-Output "closed"}
@mmasko
mmasko / UbuntuCFinit.yaml
Last active October 20, 2021 01:41
Configure cfn-hup, cloudformation tools on ubuntu 18. Based on a gist from https://gist.github.com/kixorz/10194688. Written in YAML.
#This script will install the cloudformation helper work on Ubuntu 18.
#Some values are hard coded. Make sure to update where needed, or add to the parameters section.
#This would probably work on other distros, but I have not tested yet. Try it out.
#Just make sure to change things like apt to yum if trying on another OS.
Parameters:
EnvironmentSize:
Type: String
Default: t3.nano
AllowedValues:
- t3.nano