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 / function.js
Created August 9, 2017 09:18
blob to dataurl, because I keep forgetting how to do it!
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 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 / 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 / get_activity_url.php
Created August 9, 2017 08:49
Moodle "next" and "previous" activity code
<?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 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 / 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 / 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 / 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 / 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);
});