Skip to content

Instantly share code, notes, and snippets.

View MTco's full-sized avatar
😞

Mathew Tyler MTco

😞
View GitHub Profile
@jwage
jwage / SplClassLoader.php
Last active April 9, 2024 21:04
Add MIT license.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@remy
remy / gist:350433
Created March 31, 2010 14:58
Storage 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();
@paulirish
paulirish / gist:366184
Created April 14, 2010 18:59
html5 geolocation with fallback.
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
// doublecheck the ClientLocation results because it may returning null results
;(function(geolocation){
if (geolocation) return;
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.
@tammymakesthings
tammymakesthings / kcurl.sh
Created October 14, 2010 21:32
Download PDFs etc. and send them to your Kindle from the command line.
#!/bin/env bash
##############################################################################
# kcurl: Download one or more files and send them to the Kindle.
# Version 1.1, Tammy Cravit, tammy@tammycravit.com, 10/14/2010
#
# Requires that cURL and mutt be installed. The "home Wi-Fi" detection code
# only works on MacOS X 10.x (probably with x > 4), but I welcome patches.
#
# To use this script, you'll need to configure the Kindle e-mail name and
# home Wi-Fi SSID below.
@rpavlik
rpavlik / fix_homebrew.rb
Created January 6, 2011 20:32 — forked from mxcl/install_homebrew.markdown
Fix permissions on /usr/local for Homebrew
#!/usr/bin/ruby
#
# This script fixes /usr/local only.
#
# 6th January 2010:
# Modified the script to just fix, rather than install. - rpavlik
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
@JoshSchreuder
JoshSchreuder / National Geographic Picture-Of-The-Day Wallpaper Script
Created March 23, 2011 05:28
A BASH script to download National Geographic's picture of the day (http://photography.nationalgeographic.com/photography/photo-of-the-day) saving and setting as wallpaper automatically.
#!/bin/bash
# Copyright (c) 2011 Josh Schreuder
# http://www.postteenageliving.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@hite
hite / decodeURI VS. decodeURIComponent.js
Created April 11, 2011 07:10
decodeURI() VS. decodeURIComponent()
var origin = "&callback=%3Chead%3E%3Cscript%3Ewindow.onload%3Dfunction()%7Bvar%20mailhost%3Dlocation.search.match(%2Fmailhost%3D.%2B(com%7Cnet)%26maildomain%2F)%5B0%5D.split('%3D')%5B1%5D.replace('%26maildomain'%2C'')%3Blocation.href%3D'http%3A%2F%2F'%2Bmailhost%2B'%2Fjy3%2Foptions%2Fforaddrclone.jsp'%2Blocation.search%2B'%26code%3D'%2Bdocument.body.innerHTML%3B%7D%3C%2Fscript%3E%3Chead%3E&rnd=";
//A. decodeURI(origin) = ---------------------------------------------------
var result1 = "&callback=<head><script>window.onload%3Dfunction(){var mailhost%3Dlocation.search.match(%2Fmailhost%3D.%2B(com|net)%26maildomain%2F)[0].split('%3D')[1].replace('%26maildomain'%2C'')%3Blocation.href%3D'http%3A%2F%2F'%2Bmailhost%2B'%2Fjy3%2Foptions%2Fforaddrclone.jsp'%2Blocation.search%2B'%26code%3D'%2Bdocument.body.innerHTML%3B}<%2Fscript><head>&rnd=";
//B. decodeURIComponent(origin) = ---------------------------------------------------
var result2 = "&callback=<head><script>window.onload=function(){var mailhost=location.s
@juliocesar
juliocesar / best-localStorage-polyfill-evar.js
Created April 18, 2011 23:19
This is the best localStorage polyfill in the world
// I mean, seriously, localStorage is supported even by your mum. How about instead of
// casing the feature out, you give users in-memory (stale) storage instead?
// If they close your application, they deserve to lose data anyway.
// if (!('localStorage' in window)) {
if (!Modernizr.localstorage) {
window.localStorage = {
_data : {},
setItem : function(id, val) { return this._data[id] = String(val); },
getItem : function(id) { return this._data.hasOwnProperty(id) ? this._data[id] : undefined; },
@eduardocereto
eduardocereto / cb_addEventListener.js
Created May 4, 2011 17:45
a cross-browser implementation of addEventListener/AttachEvent without external dependencies
/**
* Cross Browser helper to addEventListener.
*
* @param {HTMLElement} obj The Element to attach event to.
* @param {string} evt The event that will trigger the binded function.
* @param {function(event)} fnc The function to bind to the element.
* @return {boolean} true if it was successfuly binded.
*/
var cb_addEventListener = function(obj, evt, fnc) {
// W3C model