Skip to content

Instantly share code, notes, and snippets.

Michael Milette michael-milette

Block or report user

Report or block michael-milette

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View update-moodle.sh
# 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 Feb 21, 2019
Useful Apache 2.4 redirection tips and tricks
View .htaccess
####################################################
# 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 Feb 15, 2019
Overlay Responsive Image Text
View overlay.html
<style>
.banner {
position:relative;
}
.overlay {
position: absolute;
top: 50%;
left: 60%;
width:40%;
transform: translate(-50%, -50%);
@michael-milette
michael-milette / touchsync.ps1
Created Dec 16, 2018
Touch / Sync file and/or folder (directory) date and time timestamp between two file paths without copying files or folders.
View touchsync.ps1
# 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\":
View atdate.js
/**
* 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 Jul 27, 2018
Backup Moodle database, moodle files and moodledata files
View moodle-backup.sh
# Moodle Site Backup version 1.0
# Copyright 2005-2018 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"
@michael-milette
michael-milette / emailmoodleadmin.php
Last active Jun 25, 2018
Send email message to Moodle Administrators with optional attachments
View emailmoodleadmin.php
<?php
// EmailMoodleAdmin is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// EmailMoodleAdmin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
View Smooth scrolling for in-page links
View scroll-to-class-id-using-jquery-for-yui
/**
* Enables scrolling to a class instead of an ID for applications like Moodle that use YUI.
* YUI often litters your HTML code adding what appears to be random ID's for every element. This means that you can't
* actually use ID's in your HTML, and hence, cannot create in-page links. This solves that problem.
* Usage:
* 1) Add this code to your web page.
* 2) Add a class called goto-WhatEverYouWant such as class="goto-section5" to an element.
* 3) When you load the page, any classes starting with goto- will become an ID for that element.
* This will enable you to create in-page links such as <a href="#section5">Section 5</a>
* Consider combining this with the optional smooth scrolling Gist for a nice touch.
@michael-milette
michael-milette / get-wordpress-roles-array.php
Created Sep 26, 2017
Get a list of all roles in WordPress and return them as an array.
View get-wordpress-roles-array.php
/*
* Get a list of all roles in WordPress and return them as an array.
* @return array of roles.
*/
function getRolesArray() {
global $wp_roles;
foreach($wp_roles->roles as $key => $role) {
$roles[] = $key;
}
return $roles;
You can’t perform that action at this time.