Skip to content

Instantly share code, notes, and snippets.

View joshuabaker's full-sized avatar
🎭

Joshua Baker joshuabaker

🎭
View GitHub Profile
(function($, undefined)
{
if (window.patatapSequenceIntervals)
{
// Clear
$.each(window.patatapSequenceIntervals, function(index, interval)
{
clearInterval(interval);
});
}
@joshuabaker
joshuabaker / opentableAction.php
Created July 21, 2014 14:14
Referral helper for OpenTable form submissions
<?php
/**
* Referral helper for OpenTable form submissions
*
* The RestaurantReferralID must match the RestaurantID value, however the
* only solution for this is JavaScript. This script copies the
* RestaurantID into the RestaurantReferralID and passes it to the
* OpenTable action endpoint.
*
@joshuabaker
joshuabaker / jquery.canplaytype.js
Created November 18, 2014 17:35
jQuery selector expression to return only sources that can be played
// Selector expression to return only sources that can be played
$.expr[':']['canplaytype'] = function(a)
{
var video = document.createElement('video');
return !!video.canPlayType && video.canPlayType(a.type);
};
// Usage
var playable = $('video source:canplaytype').length;
@joshuabaker
joshuabaker / Spacegray.terminal
Created December 2, 2014 17:06
Terminal theme based on @kkga’s Spacegray.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OVU5TUkdCXE5TQ29sb3JTcGFjZVYkY2xhc3NPECcw
LjEyNTQ5MDE5NjEgMC4xNDExNzY0NzA2IDAuMTc2NDcwNTg4MgAQAYAC0hAREhNaJGNs
YXNzbmFtZVgkY2xhc3Nlc1dOU0NvbG9yohIUWE5TT2JqZWN0XxAPTlNLZXllZEFyY2hp
// Retina media query
// Source: Craft CMS
@retina-media-query: ~'only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min-device-pixel-ratio: 1.5), only screen and (min-resolution: 1.5dppx)';
// Clearfix
// Source: http://nicolasgallagher.com/micro-clearfix-hack/
.clearfix() {
&:before,
&:after {
content: ' ';
// http://meyerweb.com/eric/tools/css/reset/
// v2.0 | 20110126
// License: none (public domain)
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
/**
* jQuery.rgbToHex - Converts an RGB string to a HEX string (forces length 6)
* @author Joshua Baker
* @version 1.0.0
*/
;(function($){
$.extend({
rgbToHex: function(rgbString) {
var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
if ( ! parts) {
@joshuabaker
joshuabaker / modernizr.videoautoplay.js
Created September 16, 2015 13:17
An adjust Modernizr test to check for autoplay support on video elements.
(function() {
var addTest = Modernizr.addTest;
var timeout;
var waitTime = 300;
var elem = document.createElement('video');
var elemStyle = elem.style;
function testAutoplay(arg) {
clearTimeout(timeout);
elem.removeEventListener('playing', testAutoplay, false);
@joshuabaker
joshuabaker / is_mobile.php
Created December 6, 2010 17:12
Detects whether a visitor is using a mobile device. This, although short, caters for all of the mobile device user agents listed on Wikipedia. Please first consider WURFL before using this in production.
function is_mobile()
{
return preg_match('/(ACER\ E101|Android|BlackBerry7230|BlackBerry7730|Blazer|LG\/U8120|LG\/U8130|LG\/U8138|LG\/U8180|LG\/U880|MIDP-2\.|Maemo\ Browser|MobilePhone|NetFront|Obigo|ObigoInternetBrowser|Opera\ Mini|SAMSUNG-SGH-i900|SymbianOS|UP\.Browser|WAP|Windows\ CE\;\ IEMobile|Windows\ CE\;\ PPC|Windows\ Phone|acer_S200|iPhone|iPod|webOS)/i', $_SERVER['HTTP_USER_AGENT']);
}