Skip to content

Instantly share code, notes, and snippets.

View daveaspinall's full-sized avatar

Dave Aspinall daveaspinall

View GitHub Profile
@daveaspinall
daveaspinall / post-embed.php
Last active May 10, 2018 08:32
WordPress Image Embed
public function embedWrapper($html, $url, $attr)
{
$classes = ['post-embed'];
if (strpos($url, 'youtu.be') !== false || strpos($url, 'youtube.com') !== false || strpos($url, 'vimeo') !== false) {
$classes[] = 'post-embed--video';
} else if (strpos($url, 'twitter.com') !== false) {
$classes[] = 'post-embed--twitter';
}
$classes = implode(' ', $classes);
return '<figure class="' . $classes . '">' . $html . '</figure>';
@daveaspinall
daveaspinall / git.migrate
Created December 5, 2016 09:26 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@daveaspinall
daveaspinall / linux-purge-kernels.md
Created November 30, 2016 19:33
Removes all outdated and unused kernels in Ubuntu
dpkg -l linux-* | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e [0-9] | grep -E "(image|headers)" | xargs sudo apt-get -y purge
@daveaspinall
daveaspinall / terminal.md
Last active February 8, 2016 09:00
Useful terminal commands

Useful Terminal Commands

rsync

Sync files between two places (e.g. local and staging)

# single excluded file
rsync -avzh user@server:/var/www/site/dir/ ~/Sites/site/dir/ --exclude 'file.txt'
@daveaspinall
daveaspinall / .htaccess
Last active November 27, 2015 08:40
Redirect all requests to wp-uploads to staging site
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect upload requests to staging site
RewriteRule ^wp-content/uploads/(.*)$ http://staging.domain.com/wp-content/uploads/$1 [L,R=301]
# WP redirects follow...
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
@daveaspinall
daveaspinall / workflow.md
Last active September 4, 2015 07:39
Design Workflow

Design Workflow

I'll try and flesh this out a little further when I get time, but here are links to the general tools and resources I use on a daily basis!

Table of Contents

  1. Apps & Plugins
  2. Inspiration
  3. Colours
  4. Typography
@daveaspinall
daveaspinall / typekit-sync.md
Last active July 17, 2018 09:54
Save Typekit sync fonts to new location

Find the fonts you want to copy:

# Show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles YES

# Location of Typekit Synced fonts
cd /Users/daveaspinall/Library/Application\ Support/Adobe/CoreSync/plugins/livetype/.r
@daveaspinall
daveaspinall / slack.md
Last active August 29, 2015 14:07
Slack themes

Slack themes

Personal brand colours

#282A29,#313533,#00AEEF,#FFFFFF,#3B3F3D,#FFFFFF,#99D04A,#DB6668

Base16 Tomorrow Night

#191A1C,#282A2E,#B6BC68,#FFFFFF,#363B41,#959896,#80A2BE,#C26161

var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var uncss = require('gulp-uncss');
var livereload = require('gulp-livereload');
var notify = require('gulp-notify');
var zip = require('gulp-zip');
var lr = require('tiny-lr');
var server = lr();
var premailer = require('gulp-premailer');