Skip to content

Instantly share code, notes, and snippets.

View joshuabaker's full-sized avatar
🎭

Joshua Baker joshuabaker

🎭
View GitHub Profile
// 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);
});
}
@joshuabaker
joshuabaker / getTweetHTML.js
Last active December 23, 2015 09:09
Switches tweet entities, from a Twitter API response, into anchor links, returning HTML ready for display. Built for use with https://github.com/joshuabaker/twitter-proxy
var getTweetHTML = function(tweet)
{
var i, item, entities = {}, html = tweet.text, target;
for (i in tweet.entities.hashtags)
{
item = tweet.entities.hashtags[i];
entities[item.indices[0]] = [item.indices[1], '<a href="https://twitter.com/search?q=%23' + item.text + '" target="_blank">#' + item.text + '</a>'];
}
@joshuabaker
joshuabaker / gist:6328230
Last active December 21, 2015 15:39
At the time of publishing Digg Reader doesn’t have a simple batch unsubscribe method. This is the source for a bookmarklet that adds a delete button to feed items. Get the bookmarklet here: http://jsbin.com/UdaK/1
(function()
{
var subscriptionDelete = function(item, feedUrl, successCallback, failedCallback)
{
var data =
{
feed_url: feedUrl,
_xsrf: $('[name="_xsrf"]').val(),
traditional: true
};