Skip to content

Instantly share code, notes, and snippets.

<?php
// I did this simple hack on a private WordPress Multisite blog, to stop it
// sending me emails every time I created a new blog. It's definitely overkill
// to stop all emails, but unfortunately I couldn't find any hooks that let me
// be more specific! (I didn't need any of the other emails - but you shouldn't
// use this code if you do!)
// I put the code in wp-config.php. You could create a plugin instead, or
// putting it in your theme's functions.php might work (I haven't tested it).
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

This guide shows how to set up a PHP and MySQL development environment using OSX's built-in Apache, using Homebrew to install necessary components. With this strategy, you can use different versions of PHP for certain virtual hosts.

VirtualHostX is a convenient way to manage development sites, but not required.

Install PHP and MySQL with Homebrew

brew update
brew install php56
brew install php56-mcrypt
brew install mysql
<?php
if ( ! class_exists( 'Autoload_WP' ) ) {
/**
* Generic autoloader for classes named in WordPress coding style.
*/
class Autoload_WP {
public $dir = __DIR__;
@toddsby
toddsby / backup.php
Last active December 30, 2021 06:01 — forked from menzerath/backup.php
backup.php
<?php
/*
* PHP: Recursively Backup Files & Folders to ZIP-File
* (c) 2012-2014: Marvin Menzerath - http://menzerath.eu
* contribution: Drew Toddsby
*/
// Make sure the script can handle large folders/files
ini_set('max_execution_time', 600);
ini_set('memory_limit','1024M');
@toddsby
toddsby / settings.json
Created August 5, 2014 17:25
Sublime User Settings
{
"file_exclude_patterns":
[
".DS_Store",
"._*",
"*.png",
"*.jpg",
"*.sublime*"
],
"folder_exclude_patterns":
@toddsby
toddsby / Dockerfile
Created July 1, 2014 13:24
Dockerfile discourse docker
# DOCKER-VERSION 0.6.4
FROM phusion/passenger-minimal:0.9.2
MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
RUN apt-get -y update &&\
apt-get -y install python-software-properties &&\
add-apt-repository -y ppa:pitti/postgresql &&\
apt-get -y update &&\
#! /bin/sh
### BEGIN INIT INFO
# Provides: supervisord
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Example initscript
# Description: This file should be used to construct scripts to be
# placed in /etc/init.d.
@toddsby
toddsby / gist:00d05dbd1c509ac1efcc
Created May 31, 2014 15:31
angularjs unsub from events on $scope change
angular
.module('MyApp')
.config(['$provide', function($provide){
$provide.decorator('$rootScope', ['$delegate', function($delegate){
$delegate.constructor.prototype.$onRootScope = function(name, listener){
var unsubscribe = $delegate.$on(name, listener);
this.$on('$destroy', unsubscribe);
};
@toddsby
toddsby / iomode.php
Created May 28, 2014 14:25
IOMode Class PHP STDIN && STDOUT && STDERR
<?php
class IOMode
{
public $stdin;
public $stdout;
public $stderr;
private function getMode(&$dev, $fp)
{
$stat = fstat($fp);