Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Janetakis nickjj

View GitHub Profile
View Makefile
.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 Feb 16, 2021
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
View 01-setup.sh
# 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 Apr 21, 2021
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.
View cron-sendy-backup
30 0 * * * root /usr/local/bin/sendy-backup > /dev/null 2>&1
@nickjj
nickjj / 01-image-slugs.sh
Last active Jul 16, 2020
List of DigitalOcean slugs for images, sizes and regions.
View 01-image-slugs.sh
# Listed generated on 2020-07-16 at 11: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-6-x32"
"centos-6-x64"
"centos-7-x64"
"centos-8-x64"
@nickjj
nickjj / ansible-role-test.sh
Last active May 19, 2020 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
View ansible-role-test.sh
#!/bin/bash
#
# Ansible role test shim.
#
# Taken from this gist by Jeff Geerling on May 10th 2018:
# https://gist.github.com/geerlingguy/73ef1e5ee45d8694570f334be385e181
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "ubuntu1804")
# - playbook: a playbook in the tests directory (default = "test.yml")
View GitGutter.sublime-settings
// This would go in $sublime_dir/Packages/User/GitGutter.sublime-settings
{
"live_mode": false,
"focus_change_mode": false
}