Skip to content

Instantly share code, notes, and snippets.

View jamesmrobinson's full-sized avatar

James Robinson jamesmrobinson

View GitHub Profile
@jamesmrobinson
jamesmrobinson / jquery.ga-event.js
Last active December 14, 2015 20:18
Google Analytics event tracking function. Uses HTML5 data-attributes. Any anchor with the data-event="ga" will fire a Google Analytics event. The event details should also be specified as data-attributes: data-category, data-action, data-label. Requires jQuery > 1.4
eventTracking = function () {
$t = $('[data-event="ga"]');
$t.click(function () {
var gaCat = $(this).data('category') ? $(this).data('category') : '',
gaAct = $(this).data('action') ? $(this).data('action') : '',
gaLab = $(this).data('label') ? $(this).data('label') : '';
try {
_gaq.push(['_trackEvent', gaCat, gaAct, gaLab]);
} catch (e) {
console.log(e);
@jamesmrobinson
jamesmrobinson / form-label-top.css
Created April 12, 2013 23:49
Modified pea.rs form styles (labels on top) with shortened unit values and rems
form fieldset { font-size: 14px; font-size: 1.4rem; margin: 0 0 20px; margin: 0 0 2rem; }
form fieldset.form-actions { margin: 0; }
form fieldset label { display: block; font-weight: 700; margin: 0 0 5px; margin: 0 0 .5rem; }
form fieldset.check label { display: inline; font-weight: normal; }
form fieldset.radio ul li label { display: inline; font-weight: 400; }
form fieldset input.form-text,
form fieldset textarea { background: #f5f5f5; border: 1px solid #ddd; display: block; font-size: 14px; font-size: 1.4rem; padding: 5px; padding: .5rem; -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: inset 0 1px 2px rgba(0,0,0,.05); -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.05); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; width: 50%; }
form fieldset input.form-text:focus { background: #fff; border: 1px solid #ccc; }
form fieldset textarea { height: 150px; height: 15rem; }
form fieldset select { margin: 0; min-width: 25%; }
@jamesmrobinson
jamesmrobinson / mobile-head.md
Last active December 26, 2015 02:18
Web app head markup notes

##Conditional comment for Window Phone 7

<!--[if IEMobile 7 ]>    <html class="no-js iem7" manifest="default.appcache?v=1"...> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"...> <!--<![endif]-->

Conditional comment to add class iem7 for Window Phone 7

##Mobile viewport optimization

<meta name="HandheldFriendly" content="True">
@jamesmrobinson
jamesmrobinson / favicon.md
Last active December 26, 2015 02:19
Notes on favicons

Favicon Sizes

  • 16px: For general use in all browsers, could be displayed in the address bar, tabs or bookmarks views!
  • 24px: Pinned Site in Internet Explorer 9
  • 32px: New tab page in Internet Explorer, taskbar button in Windows 7+ and Safari’s ‘Read Later’ sidebar
  • 57px: non-Retina iPhone, iPod Touch, and Android 2.1+ devices
  • 72px: iPad mini and the first- and second-generation iPad on iOS ≤ 6
  • 76px: iPad mini and the first- and second-generation iPad on iOS ≥ 7
  • 96px: Favicon used by the GoogleTV platform
  • 114px: iPhone with high-resolution Retina display running iOS ≤ 6
@jamesmrobinson
jamesmrobinson / functions.php
Last active May 14, 2017 03:06
WordPress functions.php file with various cleanup, security, performance and helper functions. Obviously requires customisation as per theme needs.
<?php
function im_setup() {
// ++++++++++++++++ REGISTER THEME OBJECTS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //
// Register and enqueue Javascript
function im_js() {
// Modernizr
@media only screen and (-webkit-min-device-pixel-ratio: 1.3),
only screen and (-o-min-device-pixel-ratio: 13/10),
only screen and (min-resolution: 120dpi),
only screen and (min-resolution: 1.3dppx) {
}
@jamesmrobinson
jamesmrobinson / custom-posts.php
Last active March 16, 2017 10:09
A custom post type plugin for WordPress. The plugin will add the custom post type Projects and these posts will also feature a metabox that allows you to toggle whether the post is featured.
<?php
/**
* Plugin Name: Custom Post Types
* Plugin URI: https://gist.github.com/nosquirrelbones/316a29936e5e7d709665
* Description: A simple plugin (template) to register custom post types
* Version: 1.1
* Author: James Robinson
* Author URI: http://jmr.codes/
* License: GPL2
*/
@jamesmrobinson
jamesmrobinson / _social-media-colours.scss
Last active August 29, 2015 14:13
Hex colours for different social media brands
// Social Media Colours
$twitter: #55acee;
$facebook: #385185;
$googleplus: #dd4b39;
$pinterest: #be2026;
$wordpress: #21759b;
$github: #151013;
$myspace: #040707;
$linkedin: #0077b5;
<?php
/**
* Plugin Name: WP Disqus Embed
* Plugin URI: https://imaginarymedia.com.au/2015/02/11/wordpress-plugin-to-embed-disqus/
* Description: A plugin to add Disqus embedding support via shortcode
* Version: 0.1
* Author: Imaginary Media
* Author URI: https://imaginarymedia.com.au/
* License: GPL2
*/
<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=https://simplesharebuttons.com">Facebook</a>
<!-- Twitter -->
<a href="https://twitter.com/share?url=https://simplesharebuttons.com&amp;text=Simple%20Share%20Buttons&amp;hashtags=simplesharebuttons">Twitter</a>
<!-- Google+ -->
<a href="https://plus.google.com/share?url=https://simplesharebuttons.com">Google</a>
<!-- LinkedIn -->