Skip to content

Instantly share code, notes, and snippets.

@iainmcampbell
iainmcampbell / Gruntfile.js
Last active August 29, 2015 14:11
grunt-sass
// npm install --save-dev grunt grunt-sass grunt-autoprefixer grunt-contrib-watch load-grunt-tasks
module.exports = function(grunt){
require('load-grunt-tasks')(grunt); // npm install --save-dev load-grunt-tasks
grunt.initConfig({
sass: {
@iainmcampbell
iainmcampbell / gist-backup.py
Last active February 7, 2016 18:51 — forked from joneskoo/gist-backup.py
gist backup
#!/usr/bin/env python
# Git clone all my gists
import json
import urllib
from urllib import urlopen
from subprocess import call
import os
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
};
$.unsubscribe = function() {
o.off.apply(o, arguments);
@iainmcampbell
iainmcampbell / settings.py
Last active August 29, 2015 14:11
Django Settings Stem
"""
Django settings for <project> project.
With Grappelli.
https://docs.djangoproject.com/en/1.7/topics/settings/
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
@iainmcampbell
iainmcampbell / normalize.sass
Last active August 29, 2015 14:12
normalize.sass
*
box-sizing: border-box
h1
font-size: 2em
margin: .67em 0
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary
display: block
audio, canvas, video
@iainmcampbell
iainmcampbell / breakpoint.sass
Last active August 29, 2015 14:12
SASS Snippets
=breakpoint($point)
@if #{$point} == "huge"
@media (min-width: 1200px)
@content
@else if #{$point} == "large"
@media (min-width: 800px)
@content
@else if #{$point} == "medium"
@iainmcampbell
iainmcampbell / smooth-scrolling-anchor-links.js
Created January 5, 2015 16:59
Smooth Scrolling Anchor Links (jQuery)
@iainmcampbell
iainmcampbell / ajax-cached.php
Last active August 29, 2015 14:13
Wordpress Ajax
<?php
add_action('wp_ajax_myajaxfunctionname', 'ajax_myajaxfunctionname');
add_action('wp_ajax_nopriv_myajaxfunctionname', 'ajax_myajaxfunctionname');
function ajax_myajaxfunctionname(){
$var = $_POST['var'];
if( ! isset($var) ) die(1);
@iainmcampbell
iainmcampbell / acf-image.php
Last active August 29, 2015 14:13
Advanced Custom Fields
<?php
$imageID = get_field('image_field_name'); // set this field to return Image ID
$size = 'full'; // thumbnail, medium, large, full
$img = wp_get_attachment_image_src( $imageID, $size );
if( !empty($image) ):
$url = $img[0];
$width = $img[1];
@iainmcampbell
iainmcampbell / safari-ios.css
Created January 7, 2015 22:11
Responsive SVG
/* have to use intrinsic ratio: http://alistapart.com/article/creating-intrinsic-ratios-for-video */
.svg-container {
width: 100%;
display: block;
height: auto;
position: relative;
padding-top: 100%; // ratio: w/h*100
}