Skip to content

Instantly share code, notes, and snippets.

View michael-milette's full-sized avatar

Michael Milette michael-milette

View GitHub Profile
OS="$(uname -s)"
case "${OS}" in
Linux*) OS=Linux;;
Darwin*) OS=Mac;;
CYGWIN*) OS=Cygwin;;
MINGW*) OS=MinGw;;
*) if [[ -n "$IS_WSL" || -n "$WSL_DISTRO_NAME" ]]; then
OS="UNKNOWN:${OS}"
else
# WSL2

Git

  • See git cheatsheet.

Copy/Sync Files and Directories

  • rsync -a --delete --compress --omit-dir-times --omit-link-times --no-g --no-perms [user@server:]source [user@server:]target
  • scp -Crqp [user@server:]source [user@server:]target

Terminal

  • ssh username@server
  • tmux (Ctrl+b ":set -g status off" to disable status bar with clock)

Cheatsheet: MySQL vs PostgreSQL commands

Description MySQL PostgreSQL
Connect to database server mysql -u username -p psql -U username
Import a database mysql -u username -p databaseName < data.sql psql -U username databaseName < data.sql
List databases SHOW databases; \l
Use/Connect to datbase with name USE databaseName; \c databaseName
List tables SHOW tables; \dt
List users SELECT user, host FROM mysql.user; \du
@michael-milette
michael-milette / Git Tips and Tricks.md
Last active September 19, 2023 05:24
Cheatsheet: Tips and Tricks for using Git
@michael-milette
michael-milette / update-moodle.sh
Created April 16, 2019 16:32
Update Moodle version
# Script: update-moodle.sh
# From: https://gist.github.com/
# This script will update Moodle within the same major version (example: 3.6.1 to 3.6.3).
# The nice thing about this simple approach is that it won't affect your plugins.
# Assumes you used "git clone" to create and install your instance of Moodle. If you did not, don't use this script!
#
# Copyright TNG Consulting Inc.
# Author: Michael Milette - <www.tngconsulting.ca>
# Release: 1.0 Alpha - 2019-04-16
#
@michael-milette
michael-milette / .htaccess
Last active February 21, 2019 15:29
Useful Apache 2.4 redirection tips and tricks
####################################################
# Force client to use secure HTTPS connections only.
####################################################
RewriteEngine on
# Use HTTP Strict Transport Security to force client to use secure connections only.
RewriteCond %{HTTPS} on
RewriteRule ^ - [ENV=HTTPS:true]
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
@michael-milette
michael-milette / overlay.html
Created February 15, 2019 00:11
Overlay Responsive Image Text
<style>
.banner {
position:relative;
}
.overlay {
position: absolute;
top: 50%;
left: 60%;
width:40%;
transform: translate(-50%, -50%);
@michael-milette
michael-milette / touchsync.ps1
Created December 16, 2018 17:56
Touch / Sync file and/or folder (directory) date and time timestamp between two file paths without copying files or folders.
# Filename: touchsync.ps1
# Purpose: To touch / Sync file and/or folder date and time timestamp between two file paths without copying.
# files or folders. The default is to just touch folders. See comment in code to change this.
# Language: PowerShell for Windows.
# Version: 0.1
# Author: Michael Milette
# Copyright 2018 TNG Consulting Inc.
# License: GNU GPL 3.
# Configuration section. Note: Trailing slash must be included in the following paths. Example: "C:\DEV\":
/**
* Description: This JavaScript enables you to set a launch and/or date and time when
* content will appear as well as when it will be removed from a page.
*
* Usage:
* <div class="AtDate" data-launch="2018-12-01T00:00:01-08:00" data-expire="2018-12-14T23:59:59-08:00">Limite lifespan content.</div>
* <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
* <script src="atdate.js"></script>
*
* Notes:
@michael-milette
michael-milette / moodle-backup.sh
Last active July 7, 2022 04:53
Backup Moodle database, moodle files and moodledata files
# Moodle Site Backup version 1.1
# Copyright 2005-2020 TNG Consulting Inc (www.tngconsulting.ca)
# Author: Michael Milette
# License: GNU GPL 3.0 or later.
# Installation: Place this script in the APPPATH folder.
# Run it as "sudo" or with sufficient permissions.
# -------------------------------------------------------------------------------------
# Configuration section - Assumes Moodle's WEBROOT and DATA are under the APPPATH.
# -------------------------------------------------------------------------------------
TIMEZONE="America/Toronto"