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 / pages.js
Last active January 15, 2016 02:21
Nested list from a flat array
var pages = [{
title: "alice",
depth: 0
},{
title: "bob",
depth: 1
},{
title: "charles",
depth: 1
},{
@frumbert
frumbert / index.html
Created May 19, 2016 05:45
HoverThumb
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>title</title>
</head>
<body>
<p>HoverThumb: mouse over a link to see a full image preview. the href of the hyperlink points to the image.</p>
<p>Adjust as required.</p>
@frumbert
frumbert / sayable.php
Created February 21, 2017 10:41
Sayable Password Generator - for when you want a randomised password that you can remember.
<?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"),
@frumbert
frumbert / Program.cs
Created August 9, 2017 09:15
c# to php encryption handy code snippet
using System;
using System.IO;
using System.Text;
using System.Collections.Generic;
using System.Security.Cryptography;
namespace csharpstuff
{
class MainClass
{
@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
@frumbert
frumbert / Mime.js
Created November 2, 2015 01:30
Find a mime type by supplying an extension (javascript)
var Mime = (function() {
var db = [{"mime":"application/andrew-inset","extn":["ez"]},{"mime":"application/applixware","extn":["aw"]},{"mime":"application/atom+xml","extn":["atom"]},{"mime":"application/atomcat+xml","extn":["atomcat"]},{"mime":"application/atomsvc+xml","extn":["atomsvc"]},{"mime":"application/bdoc","extn":["bdoc"]},{"mime":"application/ccxml+xml","extn":["ccxml"]},{"mime":"application/cdmi-capability","extn":["cdmia"]},{"mime":"application/cdmi-container","extn":["cdmic"]},{"mime":"application/cdmi-domain","extn":["cdmid"]},{"mime":"application/cdmi-object","extn":["cdmio"]},{"mime":"application/cdmi-queue","extn":["cdmiq"]},{"mime":"application/cu-seeme","extn":["cu"]},{"mime":"application/dash+xml","extn":["mdp"]},{"mime":"application/davmount+xml","extn":["davmount"]},{"mime":"application/docbook+xml","extn":["dbk"]},{"mime":"application/dssc+der","extn":["dssc"]},{"mime":"application/dssc+xml","extn":["xdssc"]},{"mime":"application/ecmascript","extn":["ecma"]},{"mime":"application/emma
@frumbert
frumbert / pew-pew.html
Last active October 27, 2017 00:08
a canvas game, based on a tutorial by gamekedo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>game</title>
</head>
<body>
<script>
hiscore = score = 1000;
player = {
@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 / 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 / jQuery.fillRemainingHeight()
Created September 22, 2014 11:32
For when you want an object in a container to fill the remaining height in a container object. Such as when you have a toolbar and want the content adjacent to it to fill the remaining height of the container div.
// e.g. $("#my-child-div").fillRemainingHeight();
(function( $ ){
$.fn.fillRemainingHeight = function( ) {
return this.each(function () {
var $this = $(this),
_h = $this.parent().height(),
_used = 0;
$this.siblings().each(function(){ _used+= $(this).outerHeight(); });
$this.css("height", _h - _used);
});