Skip to content

Instantly share code, notes, and snippets.

@iainmcampbell
iainmcampbell / wordpress-backup.sh
Last active August 29, 2015 14:13
Web Server Remote Backup
#!/bin/bash
# PRE SETUP: create bkpath dir, ie /user/backups. suggested: put this script there.
name="" # set this to the name of the project
bkpath="/var/backups/" # directory to store backups in locally
# Grab a DB dump from the MySQL server -> $bkpath/db/name_YYYY-MM-DD.sql
MYSQLDUMP="$(which mysqldump)"
/**************************************************************************
Perlin Noise
from https://gist.github.com/banksean/304522, in angular wrapper
**************************************************************************/
(function(window, angular, undefined){ 'use strict';
@iainmcampbell
iainmcampbell / share.html
Created January 14, 2015 19:39
Social Media Share Links
<a href="#" class="facebook" onclick="window.open(
'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),
'facebook-share-dialog','width=626,height=436');return false;">
Facebook
</a>
<a href="#" class="twitter" onclick="window.open(
'http://twitter.com/intent/tweet?url='+encodeURIComponent(location.href),
'twitter-share-dialog','width=626,height=300');return false;">
Twitter
@iainmcampbell
iainmcampbell / extend.js
Last active August 29, 2015 14:13
JS Object Merge
function extend(){
var output = {},
args = arguments,
l = args.length;
for ( var i = 0; i < l; i++ )
for ( var key in args[i] )
if ( args[i].hasOwnProperty(key) )
output[key] = args[i][key];
return output;
@iainmcampbell
iainmcampbell / visibility-change.js
Created February 2, 2015 21:55
Page Visibility API
var hidden
, visibilityChange
// browser prefixes
if (typeof document.hidden !== "undefined") { // Opera 12.10 and Firefox 18 and later support
hidden = "hidden"
visibilityChange = "visibilitychange"
} else if (typeof document.mozHidden !== "undefined") {
hidden = "mozHidden"
visibilityChange = "mozvisibilitychange"
@iainmcampbell
iainmcampbell / spinner.html
Created February 26, 2015 22:08
SVG Loading Spinner
<div class="loader"></div>
<?php
/*
Using WordPress as a REST API endpoint (vs AJAX Admin)
-- with caching using the Transient API --
forked from: Pete Nelson @GunGeekATX
1) Create a page called API in WordPres
2) Create a file called page-api.php in your theme directory
3) Build custom endpoints