Skip to content

Instantly share code, notes, and snippets.

@shadyvb
shadyvb / fix-jetpack-gallery-exit-history-back-issue.js
Last active June 10, 2016 14:20
Fix for the Jetpack gallery exit back button returning to gallery instead of moving back in history
@shadyvb
shadyvb / query-loop-simple-generator.php
Created April 19, 2016 12:14
Using a generator function for a simple post query loop
<?php
function get_latest_of_type( $post_type, $number ) {
$args = array(
'post_type' => $post_type,
'posts_per_page' => min( 10, $number ),
'no_found_rows' => true,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) {
@shadyvb
shadyvb / example.php
Created April 2, 2016 17:55 — forked from westonruter/example.php
Some code we're using at XWP to make plugins easier and cleaner to write.
<?php
require_once __DIR__ . '/pluginception.php'
class ShoutPlugin {
use Pluginception;
function __construct() {
/*
* This method comes from the Pluginception trait,
@shadyvb
shadyvb / gist:0f6255196b414650a046
Last active August 29, 2015 14:17
Adding a custom NEW site in VVV
# navigate to VVV/www folder
cd /path/to/vvv/www
# ssh into vagrant
vagrant ssh
# cd to www directory
cd /srv/www
# create a directory for the new site
@shadyvb
shadyvb / gist:df5116bf8634f017ca06
Last active August 29, 2015 14:10
Git+SVN steps/script
# Update from SVN repo
svn up
# Commit the updates into Git repo, using the last revision id of SVN
git add .; git commit -m r`svn info $url | grep 'Last Changed Rev' | awk '{ print $4; }'` -n
# Merge the feature branch, after CR
git merge origin/FEATURE-BRANCH
# Run grunt or any pre-svn-commit steps
@shadyvb
shadyvb / ssh-ngrok.sh
Created November 26, 2014 03:51
Quick SSH help
mkdir /tmp/ngrok; cd /tmp/ngrok; wget "https://api.equinox.io/1/Applications/ap_pJSFC5wQYkAyI0FIVwKYs9h1hW/Updates/Asset/ngrok.zip?os=linux&arch=386&channel=stable"; unzip ngrok.zip; ngrok -proto=tcp 22
@shadyvb
shadyvb / hosts.cmd
Created November 5, 2014 01:19
Batch to block certain websites on Windows
echo "127.0.0.1 facebook.com" >> %Windir%\System32\drivers\etc\hosts
echo "127.0.0.1 myegy.to" >> %Windir%\System32\drivers\etc\hosts
@shadyvb
shadyvb / .gitconfig
Created October 1, 2014 12:12
Git / SVN
# switch to vip git branch
git checkout vip
# pull updates
svn up
# reset working tree
svn revert --recursive .
# try to merge the previous branch ( ie: GNDEV-88 ), but do not auto commit
git merge - --no-commit --no-ff
# see the svn diff, before committing
svn diff | more
@shadyvb
shadyvb / .gitconfig
Created September 26, 2014 16:31
git preview
[alias]
preview ="!f() { git branch -D preview; git fetch; git checkout preview; git merge -; git push; /path/to/wp-vip-preview/bin/deploy-preview.sh > /dev/null 2>&1; git checkout -; }; f"
@shadyvb
shadyvb / deploy.php
Created September 25, 2014 08:20
GitHub Webhook Deployment handler
<?php
header("Content-Type: text/plain");
// Decode the payload
$payload = json_decode( $_POST );
# Include config file if found
@include( __DIR__ . '/deploy-config.php' );
// Ability to choose a custom branch to track / deploy from, in the webhook registered URL