Skip to content

Instantly share code, notes, and snippets.

View Olical's full-sized avatar
🧙‍♂️
(magic)

Oliver Caldwell Olical

🧙‍♂️
(magic)
View GitHub Profile
@Olical
Olical / Oliver Caldwell's JavaScript toolbox.md
Created March 24, 2011 15:07
This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

So all you need to do is include the Mappa script which you can download from the repo. The minified version is absolutely tiny.

Then include toolbox.js. Then what do ya know! It just works. Now if you scroll to the bottom of toolbox.js you will see the mappings. It is self explaining documentation. To learn about the functions you will need to go to their respective docs which are linked to from the read me. The read me can be found in the repository.

For example, here is how you dump all of the cookies from the page.

@Olical
Olical / Redirect301Regex.md
Created March 28, 2011 10:12
Turn a table of urls into a list of 301 redirects
@Olical
Olical / Example JavaScript objects.js
Created March 31, 2011 16:27
Blog post: Data normalisation with Mappa
var newsFeed = {
meta: {
foo: 'bar',
etc: 12345
},
results: [
{
t: 'New GCC compiler',
more: {
u: 'http://reddit.com/'
@Olical
Olical / String.trim.js
Created April 1, 2011 09:31
Adds a trim function to strings
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g, '');
};
@Olical
Olical / SparkExample.js
Created April 5, 2011 09:47
Examples for sparkjs.co.uk
// Add an event listener for clicking the button (an input with a class of toggleButton)
Spark('input.toggleButton').event('click', function(e) {
// When it is clicked toggle the li's
// If you wanted them to fade when toggling just pass a string to it containing 'fade'
Spark('li').toggle();
});
@Olical
Olical / Spark.js
Created April 7, 2011 12:48
A pre release of Spark. This is for testing the selector speed.
/**
* @preserve Spark JavaScript Library v3.0.0
* http://sparkjs.co.uk/
*
* Copyright 2011, Oliver Caldwell
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://sparkjs.co.uk/licence.html
*/
(function() {
// Create the object
@Olical
Olical / README.md
Created April 8, 2011 13:36
Turns a list of files into a sitemap and checks that each of the files are good.

Overview

This script takes a list of files out of a file, removes duplicate files and then loops through all those files.

It checks each files headers to see if it has a HTTP status code of 200.

If it is a redirect (301) or not found (404) then it will not add it to the sitemap.

So all good files are added into sitemap.xml at the end.

@Olical
Olical / ie6transparencyfix.css
Created April 14, 2011 11:03
An example transparency fix
div.myDiv {
height: 275px;
width: 960px;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/assets/images/myImage.png', sizingMethod='scale');
}
/**
* Converts any type of colour to rgb
*
* @author Oliver Caldwell (flowdev.co.uk)
* @param {String} color Hex, rgb or name of the colour
* @returns {String} RGB version of the colour
*/
function fixColor(color) {
// Initialise any required variables
var i = null,
@Olical
Olical / spark.min.js
Created April 29, 2011 16:06
Spark 3 pre release (29/04/11)
/*
Spark JavaScript Library v3.0.0
http://sparkjs.co.uk/
Copyright 2011, Oliver Caldwell
Dual licensed under the MIT or GPL Version 2 licenses.
http://sparkjs.co.uk/licence.html
*/
var Spark=function(){function a(){}a.prototype.extend=function(b,c){a.prototype[b]=c;if(typeof c==="object")c.instance=this};a.prototype.clone=function(){return new a};return new a}();if(typeof window.$==="undefined")var $=function(a,b){return Spark.find(a,b)};
Spark.extend("ready",function(a){function b(){c.find(document).data("domReady",!0);a()}var c=this.clone();c.find(document).data("domReady")?a():window.addEventListener?document.addEventListener("DOMContentLoaded",b,!1):function(){var a=document.createElement("document:ready");try{a.doScroll("left"),b()}catch(c){setTimeout(arguments.callee,0)}}()});