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 / Install WordPress using Terminal
Last active December 17, 2015 20:10
Install WordPress using Terminal
SSH into your server then navigate to your domain’s web root:
cd /var/www/domain/public/htdocs
Grab the latest WordPress install:
wget http://wordpress.org/latest.tar.gz
Get the files out of the archive:
tar xfz latest.tar.gz
Navigate to the wordpress folder:
@fieldoffice
fieldoffice / Search and replace WordPress Post Content
Last active December 17, 2015 20:18
Search and replace WordPress Post Content
UPDATE wp_posts SET 'post_content'
= REPLACE ('post_content',
'OriginalText',
'ReplacedText');
@fieldoffice
fieldoffice / OSX Menu Bar
Last active December 19, 2015 17:48
Use to prototype menubar icons and dialogues using Xcode
//
// AppDelegate.m
// Menu Bar
//
// Created by Andy Field on 05/07/2013.
// Copyright (c) 2013 Andy Field. All rights reserved.
//
#import "AppDelegate.h"
@fieldoffice
fieldoffice / gist:9137575
Last active August 29, 2015 13:56
SCSS Pixel to REM conversion with px fallback for older browsers
@mixin font-size($size, $base:16) {
font-size: $size + px;
font-size: $size/$base * 1rem;
}
@include font-size(32);
p {
font-size: 32px;
font-size: 2rem;
@fieldoffice
fieldoffice / gist:9137671
Last active August 29, 2015 13:56
SCSS Pixel to REM font-size and line-height conversion with px fallback for older browsers
@mixin font-size($sizeValue: 16, $line: $sizeValue * 1.4) {
font-size: ($sizeValue) + px;
line-height: ($line) + px;
font-size: ($sizeValue / 16) + rem;
line-height: ($line / 16) + rem;
}
@include font-size(32);
p {
@fieldoffice
fieldoffice / Page Me
Last active August 29, 2015 13:56
Display content from another page in WordPress
//Add to functions.php
function page_me($path) {
$post = get_page_by_path($path);
$content = apply_filters('the_content', $post->post_content);
echo $content;
}
//Add to template
@fieldoffice
fieldoffice / WordPress debug.log
Created February 22, 2014 16:27
Create a debug.log file for WordPress installs
//Add to wp-config.php
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
//Writes to wp-content/debug.log
@fieldoffice
fieldoffice / WordPress page content include
Last active August 29, 2015 13:58
WordPress include page content snippet
<?php query_posts('page_id=');
if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php echo the_content(); endwhile; ?>
<?php endif; ?>
@fieldoffice
fieldoffice / randomise
Last active August 29, 2015 14:03
Randomise a group of divs
$(document).ready(function() {
$('.rdm').hide();
var elements = $('.rdm');
var elementCount = elements.size();
var elementsToShow = 5;
var alreadyChoosen = ",";
var i = 0;
while (i < elementsToShow) {
@fieldoffice
fieldoffice / gulpfile.js
Last active August 29, 2015 14:03
Gulp File
// Include Gulp and plugins
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
imagemin = require('gulp-imagemin'),
rename = require('gulp-rename'),
clean = require('gulp-rimraf'),