Skip to content

Instantly share code, notes, and snippets.

View timhunt's full-sized avatar

Tim Hunt timhunt

View GitHub Profile
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CSS test</title>
<style type="text/css">
div {
line-height: 30px;
background: #cfc;
}
<?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
@timhunt
timhunt / Quiz database changes
Last active December 27, 2015 14:39
This is my first take at the sequence of DB design changes necessary to implement https://moodle.org/mod/forum/discuss.php?d=231180 / https://tracker.moodle.org/browse/MDL-40987. Comments welcome. This design came out of a very helpful discussion with Col Chambers and Mahmoud Kassaei. Revised to take into account feedback from Sam Marshal.
I am using BOOL for INT(X) where that is more descriptive.
- line removed
+ line added
* line changed
Unchanged tables omitted from each block.
All columns NOT NULL unless marked NULL.
@timhunt
timhunt / gist:f826e4b7080f2df67707
Created November 4, 2014 17:14
Moodle 2.8 RC1 PHPUnit results Windows 7 + MariaDB 10.0 + Cygwin
tjh238@PCD265396 ~/workspace/moodle_head
$ vendor/phpunit/phpunit/composer/bin/phpunit
Moodle 2.8rc1 (Build: 20141104), mariadb, 6ce4b8ea30ec3c5d843d0d8358c402f8302a2a65
PHPUnit 3.7.38 by Sebastian Bergmann.
Configuration read from C:\Users\tjh238\workspace\moodle_head\phpunit.xml
............................................................. 61 / 3767 ( 1%)
............................................................. 122 / 3767 ( 3%)
............................................................. 183 / 3767 ( 4%)
@timhunt
timhunt / testdocs.php
Created May 16, 2015 08:45
A script to test that all the capabilities in this version of Moodle have a corresponding docs page
<?php
define('NO_OUTPUT_BUFFERING', true);
require_once('config.php');
require_once($CFG->libdir . '/filelib.php');
require_login();
require_capability('moodle/site:config', context_system::instance());
$PAGE->set_context(context_system::instance());
// 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
@timhunt
timhunt / reorder_list.js
Created July 4, 2017 14:07
Simplest possible drag-drop
// 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
@timhunt
timhunt / reorder_list.js
Created July 5, 2017 14:52
Simple drag drop
define(['jquery', 'core/modal_factory', 'core/modal_events', 'theme_osep/drag'],
function($, ModalFactory, ModalEvents, drag) {
/**
* @alias block_dashboardboxes/customise
*/
var t = {
listToOrder: 'ul.sortme',
sectionDraggingStartTime: null,
itemDragging: null,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@timhunt
timhunt / dbmemtest.php
Created August 5, 2019 15:47
Script to explore the memory usage of Moodle's database driver
<?php
require_once(__DIR__ . '/config.php');
raise_memory_limit(MEMORY_HUGE);
$method = 'get_records'; // One of the cases from the switch below.
$numrows = 512 * 1024;
$generatorquery = "
SELECT i AS id, 'A thirty-two char string' || lpad('' || i, 8) AS name
FROM generate_series(1, $numrows) i";