Skip to content

Instantly share code, notes, and snippets.

View gregtyler's full-sized avatar

Greg Tyler gregtyler

View GitHub Profile
@gregtyler
gregtyler / openapi-apigateway-mock.yml
Created July 3, 2023 14:43
Setting up AWS API Gateway with a mock integration response
x-amazon-apigateway-integration:
type: "mock"
responses:
default:
statusCode: "200"
responseTemplates:
application/json: "{\"ok\":true}"
@gregtyler
gregtyler / 1-basic-record.sql
Created July 5, 2017 13:23
PLSQL pipelining tests
/**
* Basic usage of types, records and pipelining
*/
CREATE OR REPLACE PACKAGE gt_test AS
TYPE gt_mav IS RECORD(code varchar2(9), year varchar2(7));
TYPE gt_table IS TABLE of gt_mav;
FUNCTION tab_test(i_mod_code VARCHAR) RETURN gt_table PIPELINED;
END;
/
@gregtyler
gregtyler / EventManager.js
Last active May 7, 2016 17:00
A component that can be used by modules to give them simple emit/on event systems
export default function EventManager() {
const events = {};
function emit(event) {
if (typeof events[event] === 'undefined') return false;
for (let i = 0, l = events[event].length; i < l; i++) {
events[event][i].apply(this, Array.prototype.slice.call(arguments, 1));
}
}
@gregtyler
gregtyler / uoe_module.js
Last active August 29, 2015 14:17
Potential definition template for UoE modules
/*** OLD ***/
(function($){
"use strict";
// Define namespace
uoe.namespace_for_this_mod = {};
// Define a function
function exampleFunctionIveCreated() {
alert( 'Please remove the exampleFunctionIveCreated function from your module.' );
## President
- Michael Kutner: https://www.eusa.ed.ac.uk/elections/manifesto/850/
- Faatima Osman: https://www.eusa.ed.ac.uk/elections/manifesto/937/
- Theo Robertson-Bonds: https://www.eusa.ed.ac.uk/elections/manifesto/797/
- Jonny Ross-Tatam: https://www.eusa.ed.ac.uk/elections/manifesto/822/
## Vice President - Academic Affairs
- Chris Edrev: https://www.eusa.ed.ac.uk/elections/manifesto/968/
- Thomas Kerr: https://www.eusa.ed.ac.uk/elections/manifesto/927/
- Calum Mackie: https://www.eusa.ed.ac.uk/elections/manifesto/851/
@gregtyler
gregtyler / find-WebPA-score-range.sql
Created January 3, 2014 15:18
In WebPA, find the score given for each assessment question, and the potential range using a hand-made function.
drop function if exists LOCATE_OFFSET;
DELIMITER //
CREATE FUNCTION LOCATE_OFFSET(substr text, str text, offset int)
RETURNS int
DETERMINISTIC
BEGIN
DECLARE loc INT DEFAULT 1;
DECLARE i INT DEFAULT 0;
WHILE(i<offset) DO
SET loc=LOCATE(substr, str, loc+1);
@gregtyler
gregtyler / locate_offset
Created January 3, 2014 15:15
MySQL function to find the nth occurrence of a substring in a string.
# Drop the function if it's already there
drop function if exists LOCATE_OFFSET;
# Define the function
# @param substr The substring to search for
# @param str The string to search through
# @param offset The nth-occurrence being looked for (1-indexed, using 0 will always return 0)
DELIMITER //
CREATE FUNCTION LOCATE_OFFSET(substr text, str text, offset int)
RETURNS int
@gregtyler
gregtyler / Snippets.js
Last active December 27, 2015 04:29
Some Chrome snippets I like to use.
// jquerify.js
// https://github.com/bgrins/devtools-snippets
// Add jQuery to any page that does not have it already.
(function () {
if ( !window.jQuery ) {
var s = document.createElement('script');
s.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js');
document.body.appendChild(s);
}
})();
@gregtyler
gregtyler / colourer.js
Created September 13, 2013 13:47
A dumb Chrome Snippet to colour every matched DOM element separately, using the Crayola colours. To use, just put in the console: > colourer( selector ) where selector is any selector that can be used in document.querySelectorAll (http://www.w3.org/TR/selectors-api/) Colours from JJ http://jj.isgeek.net/2012/02/crayola-colors-in-json-format/
(function(){
window.colourer = function( sel ) {
var colors = [{"hex":"#EFDECD","name":"Almond","rgb":"(239, 222, 205)"},{"hex":"#CD9575","name":"Antique Brass","rgb":"(205, 149, 117)"},{"hex":"#FDD9B5","name":"Apricot","rgb":"(253, 217, 181)"},{"hex":"#78DBE2","name":"Aquamarine","rgb":"(120, 219, 226)"},{"hex":"#87A96B","name":"Asparagus","rgb":"(135, 169, 107)"},{"hex":"#FFA474","name":"Atomic Tangerine","rgb":"(255, 164, 116)"},{"hex":"#FAE7B5","name":"Banana Mania","rgb":"(250, 231, 181)"},{"hex":"#9F8170","name":"Beaver","rgb":"(159, 129, 112)"},{"hex":"#FD7C6E","name":"Bittersweet","rgb":"(253, 124, 110)"},{"hex":"#000000","name":"Black","rgb":"(0,0,0)"},{"hex":"#ACE5EE","name":"Blizzard Blue","rgb":"(172, 229, 238)"},{"hex":"#1F75FE","name":"Blue","rgb":"(31, 117, 254)"},{"hex":"#A2A2D0","name":"Blue Bell","rgb":"(162, 162, 208)"},{"hex":"#6699CC","name":"Blue Gray","rgb":"(102, 153, 204)"},{"hex":"#0D98BA","name":"Blue Green","rgb":"(13, 152, 186)"},{"hex":"#7366BD","name":"Blue Violet","rgb":"(1
@gregtyler
gregtyler / marc-with-a-c.js
Created August 25, 2013 21:57
Attempt at fixing Marc with a C's little JS problem.
...
$(window).scroll(function() {
$('article').each( function(i){
var bottom_of_object = $(this).position().top;
var bottom_of_window = $(window).scrollTop() + $(window).height();
if( $(window).scrollTop() < 2000 ) {
$('.lax').css('top', ($(window).scrollTop() * 0.25 )+'px').removeClass('active').addClass('show');