Skip to content

Instantly share code, notes, and snippets.

View frumbert's full-sized avatar

TIm St.Clair frumbert

  • Repton, Australia
View GitHub Profile
@frumbert
frumbert / survey.html
Created March 19, 2024 03:01
A text parser that turns fairly regular plain text into a series of form elements for use in a survey. There is no concept of numbered questions, only responses. Questions can be grouped by adding a 'page:' identifier, which results in subsequent questions being part of a new fieldset, and are only a visual change (does not appear in results). S…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Survey</title>
<style>
div{margin-block-start: 1rem;}
@frumbert
frumbert / index.html
Created November 14, 2022 22:35
Randomise all-except-last dom input elements with labels
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>sort dom nodes</title>
</head>
<body>
<p>Some typical markup. Input + Label, then a break. Super responsive, super accessible. We want to present them in random order but can't change the source because it is being injected by a black-box process as a template. Vanilla javascript can help us.</p>
@frumbert
frumbert / columns2.mustache
Last active March 15, 2022 03:35
Sample theme template renderer for filter_units (https://github.com/frumbert/filter_units)
{{>theme_mytheme/inc_start}}
<div id="page" class="container-fluid">
{{{ output.full_header }}}
<div id="page-content" class="row">
<div id="region-main-box" class="col-12">
{{#hasregionmainsettingsmenu}}
<div id="region-main-settings-menu" class="d-print-none">
<div> {{{ output.region_main_settings_menu }}} </div>
@frumbert
frumbert / index.html
Created May 4, 2020 04:28
xAPI Example - Send simple Statement to LRS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Send xAPI statement</title>
<script type="text/javascript" src="xAPIWrapper-master/lib/cryptojs_v3.1.2.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/lib/utf8-text-encoding.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/src/activitytypes.js"></script>
<script type="text/javascript" src="xAPIWrapper-master/src/verbs.js"></script>
@frumbert
frumbert / index.php
Created April 13, 2020 04:01
Sort and Link to markdown files in nested sub-folders in PHP (e.g. build documentation)
<?php
/*
You have markdown files in nested folders which comtain
--01.getting-started
| |
| +--02.finalisation
| | |
| | docs.md
| | picture.png
@frumbert
frumbert / zipfolders.php
Created September 2, 2019 04:30
zip each folder in current directory recursively without the top-level folder, and name it after the directory
<?php
header("content-type:text/plain");
$root = realpath(".");
$ar = array_diff(scandir($root), array('.','..'));
foreach ($ar as $fold) {
$rootPath = "{$root}/{$fold}";
if (is_dir($rootPath)) {
$zip = new ZipArchive();
$zip->open("{$rootPath}.zip", ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = new RecursiveIteratorIterator(
@frumbert
frumbert / block.php
Last active September 11, 2020 12:58
Block code for hacking scorm and completion data in Moodle (incomplete file, just the important function bits)
<?php
// there's more to this file than this:
public function get_content()
{
global $CFG, $DB, $USER;
if (!is_siteadmin()) {
return null;
}
@frumbert
frumbert / sample-animation.svg
Created February 20, 2018 02:50
animated svg using smil
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@frumbert
frumbert / tab-title-marquee.html
Created October 27, 2017 00:05
Make a marquee on the browser title
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>argh!</title>
<script type="text/javascript">
message = "The quick brown 🦊 jumps over the lazy 🐶 ";
function step() {
message = message.substr(1) + message.substr(0,1);
document.title = message.substr(0,15);
@frumbert
frumbert / activity.php
Created August 12, 2017 22:08
In moodle, get a list of activities that are available and their index (order from the top down)
<?php
require('../../config.php'); // adjust as needed
require_once($CFG->dirroot.'/course/format/lib.php');
require_once($CFG->libdir.'/modinfolib.php');
$courseid = 26; // the numerical id of the course we are looking in
$index = 1;
$course = get_course($courseId); // in course/format/lib.php
$modinfo = get_fast_modinfo($course); // in lib/modinfolib.php