Skip to content

Instantly share code, notes, and snippets.

View matherton's full-sized avatar

Mark Atherton matherton

View GitHub Profile
@matherton
matherton / GA.php
Last active December 23, 2015 19:29
GA E-commerce PHP tracking code
public function getGoogleAnalytics ()
{
$googleid = Config::getConfig()->getPreference('googleAnalyticsCode');
$basketWidget = $this->getWidget('basket');
$clientData = $this->getClientDataForOrderReview($clientID);
$orderData = $this->getOrderData($basketWidget,$clientData);
@matherton
matherton / drag.html
Created September 18, 2013 09:07
Draggable jQuery Div with callback functions (comments included)
<html>
<head>
<title>Dragable Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script src="ui.js"></script>
<style>
.item {
height: 180px;
@matherton
matherton / plugin structure -> DemoPlugin
Created June 28, 2013 09:09
Worpress OO Plugin template
// http://wp.tutsplus.com/tutorials/plugins/two-ways-to-develop-wordpress-plugins-object-oriented-progamming/
class My_Widget extends WP_Widget {
public function __construct() {
// widget actual processes
}
public function form( $instance ) {
// outputs the options form on admin
@matherton
matherton / responsive
Created April 30, 2013 13:54
Responsive Youtube Video
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
@matherton
matherton / responsive-email.html
Created February 17, 2013 13:15
This is a file I created this morning to figure out how media queries work for responsive emails
<style type="text/css">
@media only screen and (max-device-width: 480px) {
/* mobile-specific CSS styles go here - max-devise-width property only works on apple, Amazon Kindle Fire, Android 2.2+, Microsoft Windows Phone 7.5+ mail clients */
table[class=contenttable] {
width: 320px !important;
}
p {
background-color: #000;
}
}
@matherton
matherton / nav.css
Created September 16, 2012 14:24
horizontal sprite navigation with HTML5 tags
#nav {
background:url("images/sprite_nav.png") no-repeat;
width: 962px; /* width of sprite */
height: 73px; /* half height of sprite */
margin: 0;
padding: 0;
}
/* display each list item block with a height of 73px - display block allows re-sizing */
#nav li, #nav a {
@matherton
matherton / insightinternet tweets
Created September 3, 2012 09:33
JavaScript to parse my json twitter feed.
JQTWEET = {
// Set twitter username, number of tweets & id/class to append tweets
user: 'insightinternet',
numTweets: 3,
appendTo: '#jstwitter',
// core function of jqtweet
loadTweets: function() {
$.ajax({
@matherton
matherton / user_controller.rb
Created April 25, 2012 13:35
rails controller using pony gem to send internal email
class UsersController < ApplicationController
before_filter RubyCAS::Filter, :except => :cas_update_user
before_filter :check_user, :except => :cas_update_user
def promote
error = "Please enter your name" if params[:name].blank?
error = "Please enter your telephone number" if params[:telephone].blank?
error = "Please enter a valid email address" unless params[:email].match(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}/)
if error.blank?
@matherton
matherton / The stage directory template
Created April 12, 2012 15:34
Email template using base64 to embed images directly in email
<table width='100%' border='0' cellpadding='4' cellspacing='0'>
<tr>
<td height='50' colspan='4' bgcolor='#000000'><a href='http://www.thestage.co.uk'><img border='0' src='data:image/jpg;base64,R0lGODlhsAAaAPcAAObm5qCgoHJyckpKSujo6LKyssHAwNbW1oyMjNDQ0L29vYKCghoaGhwcHAoK
CjQ0NE5OTn5+fnp6eqampmRkZMjIyEJCQq6urmhoaMrKypSUlMTFxZKSklRVVHR0dA0NDZuamrm5
uZiZmHh4eHx8fIaGhmFiYkZGRhUVFbCwsJ+enqSlpV5eXh4eHlBQUGBgYBISEoSEhFxcXICAgGZm
ZjY2NoqKigQEBGtra0RERDg4OFhYWJCQkI6Pjjw8PCoqKp2dnTo6OiwsLCMjI29vbyIiIr+/vxAQ
ECgoKDAwMFtaWi8uLz4+PlZXVnZ2dsXFxYmJia+urx0dGyAgICYmJlNTUycmJGpqZERDP/T09DMz
M/Pz8zIyMvj4+Pr6+vn5+YeGf8fHx359dk1NSc7OzvX19dra2nRzbampqWFgW7a2tvv7+7W1tfLy
8jo6NtnZ2c3Nze7u7u/v7/z8/IKCgZaWlv39/f7+/rq6uq2trdLS0tTU1DAwLVdWUuDg4KysrOHh
4aurq6qqquvr65eXl8/Pz9vb2/b29t3d3d7e3uXl5djY2PHx8e3t7ff396urqszMzNXV1eLi4ru7
@matherton
matherton / coffee script - relativefixed positioning
Created April 10, 2012 14:56
coffee scrip - relative and fixed positioning dependant on if div is viewable on screen
# code for the advert preview and the "why go premium list" on the create new ad form so that it only adopts fixed positioning when all of it is in view.
$ ->
e = $("div#advert_preview")
jWindow = $(window)
offsetTop = e.offset().top
positionTop = e.position().top
jWindow.scroll ->
if jWindow.scrollTop() > offsetTop
e.css