Skip to content

Instantly share code, notes, and snippets.

View bhubbard's full-sized avatar
:octocat:
Hello

Brandon Hubbard bhubbard

:octocat:
Hello
View GitHub Profile
@liuyigh
liuyigh / wp_gdrive_backup_manual.sh
Last active October 23, 2017 05:35
On-demand back up WordPress to Google Drive with Bash Script. Adapted frpm [email protected] for serverpilot server. Removed some scripts for automatic backup, such as old backup deletion, directory checking etc.
#!/usr/bin/env bash
# Source: https://guides.wp-bullet.com
# Author: Mike
#define local path for backups
BACKUPPATH="/srv/users/serverpilot/bak/tmp"
#define remote backup path
BACKUPPATHREM="gBackup"
@bhubbard
bhubbard / pdf_magic.js
Created July 27, 2017 00:48 — forked from mozz100/pdf_magic.js
Zendesk embedded PDF viewer via Google Docs
// add this javascript to your Zendesk Help Center pages
(function($) {
$(function() {
// for all attachment links whose URLs end with .pdf (case sensitive)...
var pdfs = $('.attachments a[href$=".pdf"]');
var eleBody = $('div.article-body');
if (pdfs.length > 0) {
@sushyad
sushyad / gsutil_backup_setup.sh
Last active October 23, 2017 05:19
Google Cloud Storage Setup
#!/bin/bash
#this setup is based on https://scotthelme.co.uk/easy-cheap-and-secure-backup-with-google-cloud-platform
LOG_DIR=~/logs
LOCK_FILE=~/gsutil_backup_cron.lock
#everything under /data (excluding data) will be put into the target gs bucket
SOURCE_DIR=/data
@aliciaiceland
aliciaiceland / functions.php
Created May 29, 2017 11:33
Pre-populate Woocommerce checkout fields
<?php
/**
* Pre-populate Woocommerce checkout fields
*/
add_filter('woocommerce_checkout_get_value', function($input, $field ) {
global $current_user;
switch ($field) :
case 'billing_first_name':
case 'shipping_first_name':
return $current_user->first_name;
@JacopoDaeli
JacopoDaeli / redis-dump-to-gs
Last active October 23, 2017 05:19
Backup Redis to Goolge Cloud Storage
#!/bin/bash
#### BEGIN CONFIGURATION ####
# set dates for backup rotation
NOWDATE=`date +%Y-%m-%d`
# set backup directory variables
SRCDIR='/tmp/gs_backups'
DESTDIR='redis'
@hiddenpearls
hiddenpearls / pe-customize-controls.css
Created February 13, 2017 21:16 — forked from OriginalEXE/pe-customize-controls.css
Extending WordPress Customizer Panels and Sections to allow nesting
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent,
#customize-theme-controls .customize-pane-child.current-section-parent {
-webkit-transform: translateX(-100%);
-ms-transform: translateX(-100%);
transform: translateX(-100%);
}
@mwpastore
mwpastore / 00README.md
Last active September 30, 2024 16:00
Lightning Fast WordPress: Caddy+Varnish+PHP-FPM

README

This gist assumes you are migrating an existing site for www.example.com — ideally WordPress — to a new server — ideally Ubuntu Server 16.04 LTS — and wish to enable HTTP/2 (backwards compatibile with HTTP/1.1) with always-on HTTPS, caching, compression, and more. Although these instructions are geared towards WordPress, they should be trivially extensible to other PHP frameworks, other FastCGI backends, and even non-FastCGI backends (using proxy in lieu of fastcgi in the terminal Caddyfile stanza).

Quickstart: Use your own naked and canonical domain names instead of example.com and www.example.com and customize the Caddyfile and VCL provided in this gist to your preferences!

These instructions target Varnish Cache 4.1, PHP-FPM 7.0, and Caddy 0.10. (I'm using MariaDB 10.1 as well, but that's not relevant to this guide.)

- Setup Google Compute Account
- Create micro-f1 instance
- SSH into instance (Debian/Jessy)
- Install apt-get deps from https://github.com/eugeneware/docker-wordpress-nginx
- install fail2ban (https://www.digitalocean.com/community/tutorials/how-to-protect-an-nginx-server-with-fail2ban-on-ubuntu-14-04)
- create a wordpress rule in jails.local
```
[wordpress]
enabled = true
port = http,https
@kvignos
kvignos / 01-01-outbrain-example-recirc.js
Last active November 28, 2024 02:56
WIRED Day of REST 2016 Conference Presentation - Code Snippets
// Author: Ross Patton (abbreviated by KV)
// Link to WIRED json feed
var apiUrl = 'http://' + location.host + '/wp-json/wp/v2/posts/';
// Fallback if OBR not available
if ( typeof OBR === 'undefined' ) {
$( getAll('poweredByOutbrain') ).remove();
return $.getJSON( apiUrl, function(res) {
@kalenjohnson
kalenjohnson / gist:0e5805894a75bcec0204
Last active June 1, 2016 20:36
Codeship Deploy to WPEngine
REMOTE_REPOSITORY=${REMOTE_REPOSITORY:?'You need to configure the REMOTE_REPOSITORY environment variable!'}
REMOTE_BRANCH=${REMOTE_BRANCH:?'You need to configure the REMOTE_BRANCH environment variable!'}
set -e
git fetch --unshallow || true
git push ${REMOTE_REPOSITORY} ${CI_COMMIT_ID}:${REMOTE_BRANCH}
cd wp-content/themes/<theme>
npm install -g bower gulp
npm install
bower install
gulp --production