Skip to content

Instantly share code, notes, and snippets.

View JonathanWillitts's full-sized avatar

Jonathan Willitts JonathanWillitts

View GitHub Profile
@JonathanWillitts
JonathanWillitts / download_latest_db.sh
Last active April 12, 2021 18:37
Download latest database backup archive (*.sql file) from a remote server
#!/bin/bash
################################################################################
# Searches remote directory for newest *.sql file and downloads it to current
# directory
#
# Usage: bash download_latest_db.sh <db_dir_name>
#
# Note: requires values for $REMOTE_USER, $REMOTE_HOST and $REMOTE_BACKUP_ROOT
# to be set in corresponding env_variables.conf file
################################################################################
@JonathanWillitts
JonathanWillitts / create_ssh_tunnel_user.sh
Created July 5, 2021 10:53
Creates a new user and configures for SSH tunnel only DB access
#!/bin/bash
################################################################################
# Creates a new user and configures for SSH tunnel only DB access.
#
# Usage: create_ssh_tunnel_user.sh <username_to_create>
#
################################################################################
set -e # on error, exit early
if [[ -z $1 ]]
@JonathanWillitts
JonathanWillitts / last_ssh_login.sh
Created May 12, 2022 12:57
Show the last (accepted, via SSH Key) connection by user
#!/bin/bash
#####
# Shows the last (accepted, via SSH Key) connection for each user.
#
# How? By searching all auth logs (inc gzipped ones), and filtering to show
# most recent accepted connections
#
# Works/tested on: Ubuntu 18.04.6 LTS (bionic)
#
# Usage: [sudo] last_ssh_login.sh
@JonathanWillitts
JonathanWillitts / db_grant_select_access.sh
Last active May 25, 2023 10:08
Assign SELECT-only access for all tables/views (excluding randomization lists and those containint erik) for specified user to specified database
#!/bin/bash
################################################################################
# Grants privileges to specified user on specified database.
#
# Grants/privileges currently defined in: generate_edc_select_grants.sql
# which provide select-only access to all tables in specified database,
# excluding those containing 'rando' or 'erik' in their name.
#
# Usage: db_grant_select_access.sh <user_to_grant_to> <database_to_grant_on>
#
@JonathanWillitts
JonathanWillitts / .vimrc
Last active November 15, 2023 12:30
Basic vim config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Jonathan Willitts - Basic vim config
"
" To download and start using:
" $ cd ~
" $ wget https://gist.github.com/JonathanWillitts/b1636e69f332b79ff52c4a51576efc67/raw/.vimrc
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark
@JonathanWillitts
JonathanWillitts / release_init.sh
Last active February 1, 2024 19:23
Pre-release helper script, to ensure git flow is initialised, and dir initialised for build
#!/bin/bash
echo ""
echo "Running pre-release script for: "
echo "$PWD"
set -e
echo "Checking repo statuses ..."
git checkout main && git pull && \
git checkout develop && git pull
@JonathanWillitts
JonathanWillitts / odbc_on_mac.md
Last active March 10, 2024 08:12 — forked from erikvw/odbc_on_mac.md
mysql, ODBC, STATA 16 on MAC (M1 Silicon and Intel-based)
@JonathanWillitts
JonathanWillitts / README_&_update_edc_code.sh_script.md
Last active March 26, 2024 10:30
Updates EDC dev environment (by pulling all existing repos, cloning new (or missing) clinicedc repos, and installing repos that aren't editable as editable)

Setting up edc_source dev environment

This document describes using the update_edc_code.sh script for both:

  • the initial setup of the edc_source development environment
  • updating the edc_source development environment, to pull down any recent additions/changes

The latest version of the script can be viewed at: https://gist.github.com/JonathanWillitts/13f37c3c169ff71d2488f683e7fbbf53#file-update_edc_code-sh, or downloaded directly from: https://gist.githubusercontent.com/JonathanWillitts/13f37c3c169ff71d2488f683e7fbbf53/raw/update_edc_code.sh