Skip to content

Instantly share code, notes, and snippets.

View sammarshallou's full-sized avatar

sam marshall sammarshallou

View GitHub Profile
@sammarshallou
sammarshallou / gziptest.php
Created September 30, 2021 14:39
Test for compress/decompress performance
<?php
ini_set('memory_limit', '8G');
$raw = file_get_contents('lib.tar');
$length = strlen($raw);
echo "Loaded file " . $length . " bytes\n";
$chunks = [];
for ($i = 0; $i < $length - 100*1024; $i += 100*1024) {
$chunks[] = substr($raw, $i, 100*1024);
}
echo "Created " . count($chunks) . " 100KB chunks\n";
@sammarshallou
sammarshallou / install.php
Created June 4, 2019 16:39
How to have a Moodle block add itself to the dashboard page for everyone
<?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
@sammarshallou
sammarshallou / mtrace-in-task.php
Created April 12, 2019 09:55
Moodle scheduled task with mtrace convenient for unit tests
class move_to_recycle_bin extends scheduled_task {
/** @var string For unit testing only */
protected $testmtracebuffer = '';
/**
* Outputs a line of text to the cron log.
*
* @param string $line Line of text
*/