Skip to content

Instantly share code, notes, and snippets.

TIm St.Clair frumbert

Block or report user

Report or block frumbert

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@frumbert
frumbert / zipfolders.php
Created Sep 2, 2019
zip each folder in current directory recursively without the top-level folder, and name it after the directory
View zipfolders.php
<?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 Feb 28, 2018
Block code for hacking scorm and completion data in Moodle (incomplete file, just the important function bits)
View block.php
<?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 Feb 20, 2018
animated svg using smil
View sample-animation.svg
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 Oct 27, 2017
Make a marquee on the browser title
View tab-title-marquee.html
<!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 Aug 12, 2017
In moodle, get a list of activities that are available and their index (order from the top down)
View activity.php
<?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
@frumbert
frumbert / function.js
Created Aug 9, 2017
blob to dataurl, because I keep forgetting how to do it!
View function.js
function blobToDataURL(blob) {
return new Promise((fulfill, reject) => {
let reader = new FileReader();
reader.onerror = reject;
reader.onload = (e) => fulfill(reader.result);
reader.readAsDataURL(blob);
})
}
@frumbert
frumbert / Program.cs
Created Aug 9, 2017
c# to php encryption handy code snippet
View Program.cs
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace csharpstuff
{
class MainClass
{
@frumbert
frumbert / pew-pew.html
Last active Oct 27, 2017
a canvas game, based on a tutorial by gamekedo
View pew-pew.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>game</title>
</head>
<body>
<script>
hiscore = score = 1000;
player = {
@frumbert
frumbert / get_activity_url.php
Created Aug 9, 2017
Moodle "next" and "previous" activity code
View get_activity_url.php
<?php
// you would probably use this within your theme or block - anywhere inside a course context.
// a moodle function for returning the url adjacent to the current page in a course
// tested in Moodle 3 and higher.
// sourced from within https://moodle.org/plugins/block_navbuttons then refactored a bit to my needs
// lets say you are on http://mymoodle.com/mod/page/view.php?id=302
// and you want to know what the activity immediately after this one is. You'd ask
@frumbert
frumbert / sayable.php
Created Feb 21, 2017
Sayable Password Generator - for when you want a randomised password that you can remember.
View sayable.php
<?php
Class Sayable {
// the different components of words
private $phonetics = array(
"Affricate" => array("ch","dg","j"),
"Alveolar" => array("d","l","n","r","s","t","z"),
"Bilabial" => array("b","m","p"),
"BilabialStop" => array("b","p"),
You can’t perform that action at this time.