Moodle AMD implementation

Nowadays, Moodle uses Requerjs (RequireJS is a JavaScript file and module loader) loader for managing JS modules. This allows us to conveniently manage JS dependencies between individual scripts, as well as separate the scope of instances.

This documentation provides an excellent description and examples of connecting AMD modules in Moodle Javascript Modules

Below I give examples of connecting JS in all possible ways.

  1. Сonnecting AMD script
// local/plugin/amd/src/main.js 
define([
    'local_plugin/config',                        // Shim config
    'local_plugin/lib',                           // Regular AMD lib
    M.cfg.wwwroot + '/local/plugin/js/lib.js',    // Direct call AMD lib
    'lib'                                         // Not AMD lib
    ], function(config, commonLib, DirectCallLib, ShimLib) {
            console.dir(commonLib);
            console.dir(DirectCallLib); 
            console.dir(ShimLib);

            require([url], callback);


        }
    };
// local/plugin/amd/src/config.js requirejs config file extensions
define([], function() {
    window.requirejs.config({
        paths: {
            "lib": M.cfg.wwwroot + '/local/plugin/js/lib', // Define JS location 
        },
        shim: {
            'lib': {exports: 'count'},                      // Define export variable
        }
    });
});
// local/plugin/amd/src/lib.js  library with full AMD support
(function(name, definition) {
    if (typeof module != 'undefined') module.exports = definition();
    else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
    else this[name] = definition();
}('mod', function() {
    //This is the code you would normally have inside define() or add to module.exports
    return {
        sayHi: function(name) {
            console.log('Hi ' + name + '!');
        }
    };
}));
// local/plugin/js/lib.js  library with full AMD support
(function(name, definition) {
    if (typeof module != 'undefined') module.exports = definition();
    else if (typeof define == 'function' && typeof define.amd == 'object') define(definition);
    else this[name] = definition();
}('mod', function() {
    //This is the code you would normally have inside define() or add to module.exports
    return {
        sayHi: function(name) {
            console.log('Hi ' + name + '!');
        }
    };
}));

Backup DB + data

#!/usr/bin/env bash

# Backup Database Moodle (Morning, After noon into files and MidDay to a backup DB inside MySQL)
01 05 * * *  root mysqldump  -udb_user -pdb_user_password -hlocalhost db_name | gzip  > /backup/db_name-`date +\%Y-\%m-\%d-\%H`.sql.gz

# Keep 10 SQL database backups of economy (last 5 backups of economy)
2 2 * * * root find /backup/* -mtime +5 -exec rm {} \;
# Backup files  (Morning, After noon into files and MidDay to a backup DB inside MySQL)

30 5 * * * root  zip -r /backup/files/moodledata`date +\%Y-\%m-\%d-\%H-\%M-\%S`.zip /var/www/moodledata

# Keep 5 instanse backups of moodledata (last 5 backups of davidson-net)
10 2 * * * root find /backup/wpfiles/* -mtime +5 -exec rm {} \;

Moodle – Upgrade version with Git from 3.3-3.*

First Step: 

 git remote add upstream https://github.com/moodle/moodle.git

Second Step: 

vim update.sh 
#!/bin/bash
git fetch upstream
for BRANCH in MOODLE_{31..37}_STABLE master;
do
git push origin refs/remotes/upstream/$BRANCH:refs/heads/$BRANCH
done

Source: https://docs.moodle.org/dev/Git_for_developers