Skip to content

Instantly share code, notes, and snippets.

View THEtheChad's full-sized avatar

Chad Elliott THEtheChad

View GitHub Profile
@THEtheChad
THEtheChad / parseColor.js
Created October 19, 2011 06:17
Super compact javascript color parsing function
/**!
* @preserve $.parseColor
* Copyright 2011 THEtheChad Elliott
* Released under the MIT and GPL licenses.
*/
// Parse hex/rgb{a} color syntax.
// @input string
// @returns array [r,g,b{,o}]
@THEtheChad
THEtheChad / timeDelta.js
Created October 19, 2011 06:37
Function used to calculate the difference between two dates in human readable format
/**!
* @preserve timeDelta
* Copyright 2011 THEtheChad Elliott
* Released under the MIT and GPL licenses.
*/
function timeDelta( start, end, params, only_totals ) {
var delta = {}
, measurements = {
w: 604800000,
@THEtheChad
THEtheChad / feedproxy.php
Created October 24, 2011 20:21
A simple, multi-purpose PHP feed proxy.
<?php
$session = curl_init($_GET['url']);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($session);
header("Content-Type: text/xml");
echo $xml;
curl_close($session);
?>
@THEtheChad
THEtheChad / .htaccess
Created January 13, 2012 23:26
Access-Control-Allow-Origin for Subdomains
SetEnvIf Origin "^(.*\.example\.com)$" ORIGIN_SUB_DOMAIN=$1
Header set Access-Control-Allow-Origin "%{ORIGIN_SUB_DOMAIN}e" env=ORIGIN_SUB_DOMAIN
@THEtheChad
THEtheChad / gist:1628672
Created January 17, 2012 20:23 — forked from kaievns/gist:996893
Cubic Bezier function emulator
/**
* Cubic Bezier CSS3 transitions emulator
*
* See this post for more details
* http://st-on-it.blogspot.com/2011/05/calculating-cubic-bezier-function.html
*
* Copyright (C) 2011 Nikolay Nemshilov
*/
function Bezier(p1,p2,p3,p4) {
// defining the bezier functions in the polynomial form
@THEtheChad
THEtheChad / universal viewport
Created January 18, 2012 20:46
Cross browser function to identify viewport size
function viewport(){
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0];
// Standards compliant browsers (mozilla/netscape/opera/IE7): window.innerWidth & window.innerHeight
// IE6 in standards compliant mode: documentElement.clientWidth & documentElement.clientHeight
// Older IE6
// document.getElementsByTagName('body')[0].clientWidth &
// document.getElementsByTagName('body')[0].clientHeight
@THEtheChad
THEtheChad / Update.sql
Created January 27, 2012 16:44
SQL used to generate replace statements for all WPdb tables.
SELECT CONCAT(
'UPDATE ', table_name,
' SET ', column_name, ' = ',
'REPLACE(', column_name, ', "oldURL", "newURL");'
)
FROM information_schema.columns
WHERE table_schema = 'wordpressDBname';
@THEtheChad
THEtheChad / normalize.css
Created March 27, 2012 16:24
Minified Normalize CSS Reset
/*! normalize.css 2012-02-07T12:37 UTC - http://github.com/necolas/normalize.css */article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}[hidden]{display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}html,button,input,select,textarea{font-family:sans-serif}body{margin:0}a:focus{outline:thin dotted}a:hover,a:active{outline:0}h1{font-size:2em;margin:.67em 0}h2{font-size:1.5em;margin:.83em 0}h3{font-size:1.17em;margin:1em 0}h4{font-size:1em;margin:1.33em 0}h5{font-size:.83em;margin:1.67em 0}h6{font-size:.75em;margin:2.33em 0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}blockquote{margin:1em 40px}dfn{font-style:italic}mark{background:#ff0;color:#000}p,pre{margin:1em 0}pre,code,kbd,samp{font-family:monospace,serif;_font-family:'courier new',monospace;font-size:1em}pre{white-space:pre;white-space:pre-wrap;word-wrap:break-word
@THEtheChad
THEtheChad / inline_block.css
Created April 2, 2012 19:10
Cross Browser Syntax for inline-block
display: inline-block;
zoom: 1; /* triggers hasLayout for IE */
*display: inline; /* target IE7 only */
@THEtheChad
THEtheChad / menu.html
Created April 4, 2012 16:38
Basic menu styling.
<!doctype html>
<html>
<head>
<style>
.menu,
.submenu
{
list-style: none;
margin: 0;
padding: 0;