Skip to content

Instantly share code, notes, and snippets.

View FMCorz's full-sized avatar

Frédéric Massart FMCorz

  • Branch Up Pty Ltd
  • Perth, Australia
View GitHub Profile
@FMCorz
FMCorz / styles.css
Created July 3, 2015 04:10
Styling Moodle's user menu using theme_more
/* Not logged in */
.usermenu .login {
color: red;
}
.usermenu .login a {
color: green;
}
.usermenu .login a:focus,
.usermenu .login a:hover {
color: yellow;
@FMCorz
FMCorz / styles.css
Last active August 29, 2015 14:25
Sticky footer for Moodle with Bootstrap 2
body,
html {
height: 100%;
padding-top: 0; /* Revert default padding for navbar */
}
.wrapper {
min-height: 100%;
margin-bottom: -150px; /* Negative footer minimum height */
}
.wrapper::after {
<?php
/**
* Gets the sort direction for a given field
*
* @param string $field
* @return string ASC or DESC
*/
public function get_field_sort_direction($field) {
$dir = $this->sortdirection || self::DEFAULTSORTDIRECTION;
@FMCorz
FMCorz / mixin.scss
Created September 22, 2015 07:18
Mixin to fix the anchors when a fixed header is causing an offset
.anchor-offset-setup(@offset) {
h2[id]::before,
h3[id]::before,
h4[id]::before,
h5[id]::before,
h6[id]::before {
display: block;
content: "";
padding-top: (@offset + 10);
margin-top: -(@offset + 10);
<?php
// Preparing the query.
$qb = new mod_glossary_entry_query_builder($glossary);
if (!empty($options['includenotapproved']) && has_capability('mod/glossary:approve', $context)) {
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ALL);
} else {
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_SELF);
}
@FMCorz
FMCorz / fetch.py
Last active November 18, 2015 07:56
Using MDK as a module to fetch a branch from the tracker
import logging
import mdk
from mdk.tools import parseBranch
from mdk.moodle import Moodle
from mdk.fetch import FetchTracker
logging.basicConfig(format='%(message)s', level=logging.DEBUG)
M = Moodle('/home/fred/www/repositories/sm/moodle', 'sm')
# mdl = parseBranch(M.currentBranch())['issue']
@FMCorz
FMCorz / PHP.sublime-build
Created November 19, 2015 03:00
Sublime Text PHP Build system
{
"cmd": ["php", "$file"],
"file_regex": "php$",
"selector": "source.php",
"file_regex": "^PHP .+ in (.+) on line ([0-9]+)$",
}
@FMCorz
FMCorz / backup_tool_uploadcourse_plugin.class.php
Created November 26, 2015 08:08
Admin tool backup/restore test using tool_uploadcourse. (Files should be in admin/tool/uploadcourse/backup/moodle/)
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle 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.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@FMCorz
FMCorz / pix_test.mustache
Created December 10, 2015 07:54
Testing Mustache pix helper
{{!
@template core/pix_test
Example context (json):
{
"icon": "t/edit",
"component": "core"
}
}}
<ul>
@FMCorz
FMCorz / prepare-commit-msg
Last active June 30, 2016 17:00
Prepare commit message hook for Moodle
# Add this to .git/hooks/prepare-commit-msg
# Then chmod +x .git/hooks/prepare-commit-msg
#
# /!\ Note, it is assumed that you have the alias `git cb`
# which returns the current branch.
if [ -z "$2" ]; then
branch=`git cb`
mdl=`expr match "$branch" 'MDL-\([0-9]\+\)-.*'`
if [ -n "$mdl" ]; then