Skip to content

Instantly share code, notes, and snippets.

View joshuabaker's full-sized avatar

Joshua Baker joshuabaker

View GitHub Profile
@joshuabaker
joshuabaker / general.php
Created July 14, 2015 18:44
CloudFlare compatible config for Craft CMS.
<?php
if (isset($_SERVER['HTTPS']) && (strcasecmp($_SERVER['HTTPS'],'on') === 0 || $_SERVER['HTTPS'] == 1))
{
$protocol = 'https://';
}
else if ( ! empty($_SERVER['HTTP_X_FORWARDED_PROTO']))
{
$protocol = $_SERVER['HTTP_X_FORWARDED_PROTO'] . '://';
}
// 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,
@joshuabaker
joshuabaker / gist:179e1a9ff6f727cdc7e5
Created March 30, 2015 10:58
Get a line change count for additions and deletions between two commits — replace ‘commit1’ and ‘commit2’ with commit hashes — optionally by author.
git log --numstat --pretty="%H" commit1..commit2 | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d, -%d\n", plus, minus)}' --author="Your Name"
// 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: ' ';
@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
@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 / html.js
Created July 23, 2014 15:31
Sample script to load a script asynchronously whilst queuing method calls. Inspired by the Google Analytics tracking code.
// Placed into HTML
(function(window, document, tag, src, property, script, before)
{
window['LoaderObject'] = property;
window[property] = window[property] || function()
{
(window[property].q = window[property].q || []).push(arguments);
}
@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.
*
(function($, undefined)
{
if (window.patatapSequenceIntervals)
{
// Clear
$.each(window.patatapSequenceIntervals, function(index, interval)
{
clearInterval(interval);
});
}