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 / iconslist.php
Created November 19, 2012 04:20 — forked from marinaglancy/iconslist.php
Lists all icons in pix/i, pix/t and mod/*/pix
<?php
require_once('config.php');
echo '<table border=1>';
iconslist('/pix/i/');
iconslist('/pix/t/');
$modlist = get_plugin_list('mod');
foreach ($modlist as $modname => $path) {
iconslist('/mod/'.$modname.'/pix/');

Memcached sessions

Requirements:

  • Locking framwork (MDL-25500)

Goal

Being able to store session data in memcached.

@FMCorz
FMCorz / atto.js
Created September 25, 2013 08:26
// 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
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[Blocker]
- The toolbar should wrap on several lines. Currently, when expanding it, some buttons are opened on the same line, some on the next one. This creates an inconsistent visual experience on Desktop. The buttons should have a constant position so that it makes it easy to find them, and see where they will appear when expanding/collapsing.
- Invert indent/outdent buttons (inconsistent with any other editor).
- The accessibility checker should not report errors when the style is the default one. Eg. On Clean the contract of the links are reported as not compliant with WCAG AA.
- Limit the height of the editor to prevent the toolbar to go off screen.
- A big selection causes the editor to freeze for some seconds.
[Critical]
@FMCorz
FMCorz / css_chunk.php
Last active June 30, 2016 17:28
Chunk CSS into smaller chunks
<?php
function chunk($css, $every = 4095) {
$chunks = array();
$offsets = array();
$offset = 0;
$selectorcount = 0;
$lastvalidoffset = 0;
$lastvalidoffsetselectorcount = 0;
$inrule = 0;
<?php
require('config.php');
require_once($CFG->libdir.'/formslib.php');
class test_form extends moodleform {
function definition() {
$mform =& $this->_form;
// $mform->addElement('static', 'infoeditor', 'Editor limit', 'Max files: Unlimited; Max file size: 1MB; Global limit: 2Mo;');
@FMCorz
FMCorz / renderable.php
Last active June 30, 2016 17:26
Example of a simple renderable implementation
<?php
class \core\renderable\user_post implements renderable {
public function get_properties() {
return array(
'picture': \core\renderable\picture,
'name': \core\renderable\fullname,
'text': RENDERABLE_TYPE_LONGTEXT,
'intro': RENDERABLE_TYPE_SHORTTEXT

(Markdown seems to play tricks on my post, it seems more readable here)

Hi Sam,

thanks for your feedback. I have to say that I do not disagree with your approach, I agree with most of it. the only thing that I dislike is the developer that makes assumptions on how things should be displayed.

If you have a renderable that is called dropdown_renderable, then it is awkward for a designer to overwrite that to display it differently as the name does not make sense any more. For instance if I do not want a dropdown, but a horizontal list of links, or tabs, ...

What I am suggesting is that renderables are containers of information that are not tied to their display. If you look at it from a templating point of view, you would say that the renderables contain the variables to pass to the template, ignoring what the final display would be. This is common to a more stricter MVC model, and I guess we could apply it to Moodle.

@FMCorz
FMCorz / style.less
Created July 2, 2015 10:29
Mixin to set navbar height in Bootstrap 3
// For each media query.
.navbar-height-setup(@navbar-height) {
min-height: @navbar-height;
.navbar-brand {
height: @navbar-height;
}
.navbar-nav {
> li {
> a {
line-height: @navbar-height;