Skip to content

Instantly share code, notes, and snippets.

@joshlevinson
joshlevinson / git-archive.sh
Created June 7, 2016 18:57
Archive git branches
#!/bin/sh -x
# Exit if any error is encountered:
set -o errexit
# git name-rev is fail
# Get the branch name and replace the string from an array of values for instance "feature/" with "archive/"
CURRENT=`git branch | grep '\*' | awk ' {print $2}'`
ARCHIVE=`git branch | grep '\*' | awk ' {print $2}' | sed 's,.*[a-z]/,,g' | sed 's,^,archive/,g'`
#Check if we are on master or develop since we don't want to tag those
if [ $CURRENT = 'master' ]
@joshlevinson
joshlevinson / index.html
Created January 27, 2016 21:29
Google Plus Comments
<script src="https://apis.google.com/js/plusone.js"></script>
<script>
gapi.comments.render('comments', {
href: window.location,
width: '760',
first_party_property: 'BLOGGER',
view_type: 'FILTERED_POSTMOD'
});
</script>
<html>
@joshlevinson
joshlevinson / eight-day-week-filters.php
Created November 6, 2015 15:10
Sample Eight Day Week filters for the Observer
<?php
add_filter( 'Eight_Day_Week\Plugins\Article_Export\xml_outer_elements', function( $elements, $article ) {
$elements['subHeadline'] = get_post_meta( $article->ID, 'nyo_dek', true );
return $elements;
}, 10, 2 );
add_filter( 'Eight_Day_Week\Plugins\Article_Export\xml_outer_elements', function( $elements, $article ) {
if( function_exists( '\Eight_Day_Week\Plugins\Article_Byline\get_article_byline' ) ) {
$elements['byline'] = \Eight_Day_Week\Plugins\Article_Byline\get_article_byline( $article );
@joshlevinson
joshlevinson / query.php
Created November 3, 2015 15:33
Better -1 posts_per_page for WP Query
<?php
$posts_per_page = 100;
$page = 1;
do {
$posts = get_posts( [
'posts_per_page' => $posts_per_page,
'paged' => $page,
] );
@joshlevinson
joshlevinson / WP CLI commands.sh
Last active December 30, 2016 13:54
Create new VVV sites with WP CLI + wildcard hosts
vagrant ssh
cd /srv/www/
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs
wp core download
wp core config --dbname=site-name --dbuser=root --dbpass=root
wp db create
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev
@joshlevinson
joshlevinson / To create a new site
Last active April 14, 2016 17:00
Creating a VVV site with no down time
vagrant ssh
cd /srv/www/
mkdir site-name && cd site-name && mkdir htdocs && cd htdocs
wp core download
wp core config --dbname=site-name --dbuser=root --dbpass=root
# Before you install the site, you'll need to create the DB. I just pull up phpMyAdmin and create it there.
wp core install --url=site-name.dev --title=Site --admin_user=admin --admin_pass=password --admin_email=admin@example.dev
# Create the files "vvv-hosts" and "vvv-nginx.conf"
@joshlevinson
joshlevinson / fixed-block.js
Created September 2, 2015 20:35
Sticky js script found on http://www.9news.com.au/
(function () {
define('redesign/ninemsn/portal/news/stickyElementController',['jquery', 'redesign/ninemsn/portal/news/helper'], function ($, helper) {
var bufferY = 56; // Offset for fixed positioning
var windowTop,
startY,
blockY,
stopY,
offset;
@joshlevinson
joshlevinson / .bash_profile
Last active April 21, 2023 12:04
WP CLI + Xdebug
# Add this to /config/bash_profile
function wpd {
export XDEBUG_CONFIG="idekey=VVVDEBUG remote_connect_back=1"
wp "$@"
unset XDEBUG_CONFIG
};
# Run these commands:
# vagrant ssh
# sudo cp /srv/config/bash_profile /home/vagrant/.bash_profile
# source ~/.bash_profile
/* jshint esnext: true */
import Ember from 'ember';
// When mixed into an Ember.Component class, actions can be explicitly or implicitly delegated to the parent.
// In general this makes the most sense for an app-level component, where actions are not mututated as they bubble
// up to higher levels.
export default Ember.Mixin.create({
// When true, all actions will be implicitly passed on to the parent
@joshlevinson
joshlevinson / ra-export.php
Created October 7, 2014 04:45
Modified Advanced Export for WP & WPMU to Export by Tag
<?php
/*
Plugin Name: Advanced Export
Plugin URI: http://wpmututorials.com/plugins/advanced-export/
Description: Adds an Advanced Export to the Tools menu which allows selective exporting of pages, posts, specific categories and/or post statuses by date.
Version: 2.9
Author: Ron Rennick
Author URI: http://ronandandrea.com/
*/