Skip to content

Instantly share code, notes, and snippets.

View heathcliff's full-sized avatar

Heath Beckett heathcliff

View GitHub Profile
@heathcliff
heathcliff / image_cover.js
Last active August 29, 2015 14:19
Image Cover
/*
See JSFiddle for combined HTML/CSS/JS
http://jsfiddle.net/66c43ao1/
*/
$('.cover').each(function() {
var containerHeight = $(this).height(),
containerWidth = $(this).width(),
image = $(this).children('img'),
imageHeight = image.attr('height'),
imageWidth = image.attr('width'),
<?php
header('Content-Type: text/plain');
$file = 'path/to/file.kml';
$array = (array) simplexml_load_file($file);
echo "Title\n";
foreach ($array['Document']->Placemark as $pm) {
@heathcliff
heathcliff / slugify.js
Created April 23, 2014 16:00
slugify jQuery extension
jQuery.extend({
slugify: function(string) {
return $.trim(string)
.toLowerCase()
.replace(/[^\w ]+/g,'')
.replace(/ +/g,'-')
.replace(/\-{2,}/g,'-');
}
});
@heathcliff
heathcliff / cookies.js
Last active December 30, 2015 06:49
cookies.js
var cookies = (function(){
return {
create: function(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
} else {
var expires = "";
}
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
@heathcliff
heathcliff / getHashParam.js
Last active September 16, 2023 14:54
getHashParam(), updateHashParam(), getParam()
function getHashParam(name) {
var regex = new RegExp("(#)("+name+")(\=)([^#]*)"),
matches = [];
matches = regex.exec(window.location.hash);
if (matches !== null && matches.length > 4 && matches[4] !== null) {
return matches[4];
} else {
return false;
}
}
function runFunction(name, arguments) {
var fn = self[name];
if (typeof fn !== 'function') {
return;
}
fn.apply(self, arguments);
}