Skip to content

Instantly share code, notes, and snippets.

@toddsby
toddsby / jsontopost.php
Created April 2, 2014 18:08
JSON to $_POST php
$content_type_args = explode(‘;’, $_SERVER['CONTENT_TYPE']); // parse content_type string
if ($content_type_args[0] == ‘application/json’) {
$_POST = json_decode(file_get_contents(‘php://input’),true); // store decoded json in $_POST object
}
angular.module('ymusica').controller('AlbumSearch', ['$scope', 'Albums', 'Artists', '$q', function($scope, albums, artists, $q) {
$scope.albums = [];
$scope.artists = [];
var terms = new Rx.Subject();
$scope.searchMusic = terms.onNext.bind(terms);
terms.sample(250)
@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);
@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);
};
#! /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 / 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 &&\
@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 / 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');
<?php
if ( ! class_exists( 'Autoload_WP' ) ) {
/**
* Generic autoloader for classes named in WordPress coding style.
*/
class Autoload_WP {
public $dir = __DIR__;

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