Skip to content

Instantly share code, notes, and snippets.

View baldwicc's full-sized avatar

Chris Baldwin baldwicc

View GitHub Profile
#!/bin/bash
# This script is edited by Brice Dutheil
# See there in french http://blog.arkey.fr/2012/07/30/script-pour-installer-le-jdk-5-sur-macosx-lion/
# Translate button is broken for now, please use Google to translate this website.
#
# 2014/02/10 Updated the script to run on OSX 10.9 Maverick
#
# 2013/05/11 Added a few more guidance when Java Preferences is not available anymore
# Added a simple example of a JDK switch function.
# Short of learning how to actually configure OSX, here's a hacky way to use
# GNU manpages for programs that are GNU ones, and fallback to OSX manpages otherwise
# Borrowed from https://gist.github.com/quickshiftin/9130153
if which brew &> /dev/null; then
if brew list | grep coreutils &> /dev/null; then
alias man='_() { echo $1; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1 1>/dev/null 2>&1; if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1; else man $1; fi }; _'
fi
fi
@baldwicc
baldwicc / gist:f9c28f366d8c8d0eb80e
Last active August 29, 2015 14:02 — forked from remy/gist:350433
sessionStorage and localStorage Polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@baldwicc
baldwicc / xss-test.js
Created June 12, 2014 06:01
XSS Test
alert('script loaded');
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Test for QUT Media Warehouse playback" />
<title>QMW HTML5 Video Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="https://mediawarehouse.qut.edu.au/QMW/css/vendor/bootstrap.css" rel="stylesheet">
@baldwicc
baldwicc / solarized_setup.js
Last active February 9, 2024 15:38
Solarized Light and Solarized Dark for Chrome Secure Shell (nassh), with fonts
/**
* STEP 1: Setup
* - Open Chrome Secure Shell settings
* - Open JS Console (CTRL+SHIFT+J)
* - Copy and paste the following:
*/
var s7d_colours = {
'base03': '#002b36',
'base02': '#073642',
'base01': '#586e75',
@baldwicc
baldwicc / qut-tii-defaults.js
Last active December 25, 2015 16:28
Turnitin Direct - Custom Defaults: Customises the default options when creating Turnitin Direct items.
/* global $$ */
/**
* qut-tii-defaults
* @author Christopher Baldwin [https://staff.qut.edu.au/details?id=baldwicc]
* @license Simplified BSD License
* @source [https://gist.github.com/baldwicc/7005606]
*/
Event.observe(document, 'dom:loaded', function () {
var conf = {
@baldwicc
baldwicc / qut-addscript.js
Created October 16, 2013 10:02
Adds script files <head> with a simple callback once loaded. (Note: Callback fired on 'load' event - not necessarily before / after actual execution)
var _qut = _qut || {};
_qut.addscript = function(src, fn) {
var head = $$("head")[0],
script = new Element('script', {
type: 'text/javascript',
async: true,
defer: true
}),
@baldwicc
baldwicc / qut-clickyicons.html
Created October 16, 2013 08:38
Clickable Content Item Icons: Borrows the hyperlink from the content item title, clones it and wraps it around the content item's icon.
<script type="text/javascript" id="qut-clickyicons">
Event.observe(document,"dom:loaded", function() {
var contentitem_title_hyperlinks = $$('#content_listContainer > li > .item > h3 > a[href^="/webapps"]');
for (var i = 0; i < contentitem_title_hyperlinks.length; i++) {
var thislink = contentitem_title_hyperlinks[i];
var contentitem_icon = thislink.up('.item').previous('img.item_icon');
var newlink = thislink.clone(false);
contentitem_icon.wrap(newlink);
}
});
@baldwicc
baldwicc / detect-ie.js
Last active December 24, 2015 01:19
Quick script to add is-ie, is-ie-8, and not-ie classes to a given list of selectors. Requires Prototype. HTML one-liner version provided that should cope with Bb 9.1sp9's text editor. - Leave VTBE on - Toggle HTML mode - Paste markup - Press submit (don't toggle html mode back off!!)
// <script type="text/javascript">
/**
* configurable options
* @type {object}
* @property {array} selectors array of selectors to add ie classes to
* @property {string} isie_prefix prefix for ie version class
* @property {string} isie class to add when browser is ie
* @property {string} not-ie class to add when browser is not ie
*/