Skip to content

Instantly share code, notes, and snippets.

View fieldoffice's full-sized avatar
🚲
Out cycling

Andy Field fieldoffice

🚲
Out cycling
View GitHub Profile
@fieldoffice
fieldoffice / equaliser
Last active August 29, 2015 14:03
Equal Heights
$.fn.setAllToMaxHeight = function(){
return this.height( Math.max.apply(this, $.map( this , function(e){
if($(e).height()){
return $(e).height();
}
}) ) );
}
$('.equaliser').setAllToMaxHeight();
@fieldoffice
fieldoffice / d3randombarchart
Last active August 29, 2015 14:03
Generate random numbers for d3 barchart
var dataset = [];
for (var i = 0; i < 25; i++) { //Loop 25 times
var newNumber = Math.round(Math.random() * 30); //New random number (0-30)
dataset = dataset.concat(newNumber); //Add new number to array
}
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
@fieldoffice
fieldoffice / mixin-box-shadow
Created July 23, 2014 08:49
Sass Box Shadow Mixin
@mixin box-shadow($top, $left, $blur, $color, $inset:"") {
-webkit-box-shadow:$top $left $blur $color #{$inset};
-moz-box-shadow:$top $left $blur $color #{$inset};
box-shadow:$top $left $blur $color #{$inset};
}
@include box-shadow(inset 0, -12px, 0, rgba(0, 0, 0, 0.06));
@fieldoffice
fieldoffice / mixin-border-radius
Last active August 29, 2015 14:04
Sass Border Radius Mixin
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
@include border-radius(3px 0 0 3px);
@fieldoffice
fieldoffice / mixin-transition
Created July 23, 2014 08:54
Sass Transition Mixin
@mixin transition($args...) {
-webkit-transition: $args;
-moz-transition: $args;
-ms-transition: $args;
transition: $args;
}
a {
color:$color;
@include transition(color .3s ease);
@fieldoffice
fieldoffice / mixin-opacity
Created July 23, 2014 08:57
Sass Opacity Mixin
@mixin opacity($opacity) {
opacity: $opacity;
$opacity-ie: $opacity * 100;
filter: alpha(opacity=$opacity-ie); //IE8
}
.class {
@include opacity(0.6);
}
@fieldoffice
fieldoffice / colours
Created July 28, 2014 11:43
Sass Colour Functions
HEX
$color: #3399cc
$color-alt: #99cc33
RGB
$color: rgb(51, 153, 204)
RGBA
$color: rgba(51,1 53, 204,.5)
@fieldoffice
fieldoffice / box-sizing
Created July 28, 2014 14:20
Sass Box Sizing
@mixin box-sizing($box-model) {
-webkit-box-sizing: $box-model;
-moz-box-sizing: $box-model;
box-sizing: $box-model;
}
*,
*:after,
*:before {
@include box-sizing(border-box);
@fieldoffice
fieldoffice / clearfix
Created September 21, 2014 08:38
Sass Clearfix Mixin
@mixin clearfix() {
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
}
@fieldoffice
fieldoffice / wordpress-date-shortcode
Created September 21, 2014 11:26
WordPress Date Shortcode
function displaydate(){
return date('jS F Y');
}
add_shortcode('date', 'displaydate');