Skip to content

Instantly share code, notes, and snippets.

View nickjj's full-sized avatar

Nick Janetakis nickjj

View GitHub Profile
.PHONY: help
help:
@printf "%s\n" "Useful targets:"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m make %-15s\033[0m %s\n", $$1, $$2}'
.PHONY: db-reset
db-reset: ## Reset the database
docker-compose exec web flask db reset --with-testdb
.PHONY: routes
@nickjj
nickjj / 01-setup.sh
Created February 16, 2021 12:03
A zero dependency Python 3 CLI script to increment file names. This script is explained on video at: https://nickjanetakis.com/blog/a-python-script-to-increment-file-names-starting-at-a-specific-number
# 1. Create the file inc-file-names anywhere on your dev box
touch inc-file-names
# 2. Make it executable
chmod +x inc-file-names
# 3. Copy the script below into the file you just created
# 4. Move it onto your system path
sudo mv inc-file-names /usr/local/bin
@nickjj
nickjj / cron-sendy-backup
Last active December 27, 2023 07:16
An example of creating a database backup and restore script for MySQL, MariaDB and PostgreSQL. It is focused on backing up and restoring a Sendy database (working example from https://www.youtube.com/watch?v=kbCytSYPh0E) but you can apply it for any database with slight modifications.
30 0 * * * root /usr/local/bin/sendy-backup > /dev/null 2>&1
@nickjj
nickjj / 01-image-slugs.sh
Last active July 11, 2023 19:04
List of DigitalOcean slugs for images, sizes and regions.
# Listed generated on 2021-08-07 at 3:45am EST
curl -s -X GET -H "Content-Type: application/json" \
-H "Authorization: Bearer ${DIGITALOCEAN_ACCESS_TOKEN}" \
"https://api.digitalocean.com/v2/images?page=1&per_page=100&type=distribution" \
| jq '.images[].slug' | sort
"centos-7-x64"
"centos-8-x64"
"centos-stream-8-x64"
"debian-10-x64"
@nickjj
nickjj / ansible-role-test.sh
Last active September 9, 2023 11:44 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Taken from this gist by Jeff Geerling on September 9th 2023:
# https://gist.github.com/geerlingguy/73ef1e5ee45d8694570f334be385e181
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "ubuntu2204")
# - playbook: a playbook in the tests directory (default = "test.yml")
// This would go in $sublime_dir/Packages/User/GitGutter.sublime-settings
{
"live_mode": false,
"focus_change_mode": false
}