Skip to content

Instantly share code, notes, and snippets.

@shadyvb
shadyvb / connector
Created September 8, 2014 17:33
Using reflections to add actions/filters from class methods
<?php
class Connector {
protected function __construct() {
$this->add_class_hooks();
}
/**
* Add actions/filters from the methods of this class based on doc blocks
@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
@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 / .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 / 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 / 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 / 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 / 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:6490501
Last active December 22, 2015 15:09
Facebook photo delete, quick console command
document.getElementsByClassName('fbPhotosPhotoActionsItem')[document.getElementsByClassName('fbPhotosPhotoActionsItem').length-1].click(); setTimeout(function(){ document.getElementsByClassName('layerConfirm')[0].click() }, 500);
#!/bin/bash
# Install script for Latest WordPress by Johnathan Williamson - extended by Don Gilbert
# Disclaimer: It might not bloody work
# Disclaimer 2: I'm not responsible for any screwups ... :)
# DB Variables
echo "MySQL Host:"
read mysqlhost
export mysqlhost