Skip to content

Instantly share code, notes, and snippets.

View bordoni's full-sized avatar
:shipit:
Working on The Events Calendar

Gustavo Bordoni bordoni

:shipit:
Working on The Events Calendar
View GitHub Profile
@bordoni
bordoni / youtube-regex.php
Created September 15, 2011 22:34
YouTube Regex
<?php
$string = "<iframe width=\"1280\" height=\"720\" src=\"http://www.youtube.com/embed/UoVCqOlWMZg?rel=0&amp;hd=1\" frameborder=\"0\" allowfullscreen></iframe>";
preg_match_all( '~
# Match non-linked youtube URL in the wild. (Rev:20110825)
https?:// # Required scheme. Either http or https.
(?:www\.)? # Optional www subdomain.
(?: # Group host alternatives.
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com followed by
\S* # Allow anything up to VIDEO_ID,
@bordoni
bordoni / gist:1307630
Created October 23, 2011 17:43
Plugins Start Code
<?php
/*
Plugin Name:
Plugin URI:
Version:
Description:
Author:
Author URI:
Text Domain:
Domain Path:
@bordoni
bordoni / input-names-to-obj.js
Created February 15, 2012 19:26
Input Names to Object JS
$.fn.serializeObject = function() {
var _POST = [],
obj = {},
nameList = this.serializeArray(),
build = function ( hierarchy, value ) {
var __t = {}, name = hierarchy.shift();
if( typeof hierarchy[0] != 'undefined' ) {
__t[name] = build( hierarchy, value );
} else {
__t[name] = value;
@bordoni
bordoni / gist:1921488
Created February 27, 2012 04:51
New Server
sudo apt-get update
sudo apt-get install htop binutils cpp flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl m4 libpcre3 libpcre3-dev libssl-dev libpopt-dev lynx make perl perl-modules openssl unzip zip autoconf2.13 gnu-standards automake libtool bison build-essential zlib1g-dev ntp ntpdate autotools-dev g++ bc subversion psmisc libmysqlclient-dev libcurl4-openssl-dev libjpeg62-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev imagemagick build-essential autoconf2.13 libbz2-dev libevent-dev libxml2-dev libcurl4-openssl-dev libjpeg-dev libpng-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libmysqlclient-dev libxslt-dev
sudo mkdir /tmp/nginx && cd /tmp/nginx
sudo wget http://nsudp ginx.org/download/nginx-1.0.12.tar.gz
sudo tar -zxf nginx-1.0.12.tar.gz
sudo cd nginx-1.0.12
#Check http://nginx.org/en/docs/install.html for more information
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=
@bordoni
bordoni / gist:1977499
Created March 5, 2012 08:43
Multi Byte JSON PHP
<?php
function array_map_recursive( $callback, $mixed ) {
if( is_array( $mixed ) || is_object( $mixed ) ) {
$return = is_array( $mixed ) ? array() : new stdClass;
foreach ($mixed as $key => $value){
if( is_array( $mixed ) )
$return[call_user_func( $callback, $key )] = array_map_recursive( $callback, $value );
else
$return->{call_user_func( $callback, $key )} = array_map_recursive( $callback, $value );
}
@bordoni
bordoni / nginx.sh
Created June 26, 2012 22:14
init.d/nginx
#!/bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@bordoni
bordoni / php-fpm.sh
Created July 5, 2012 20:12
init.d/php-fpm
#! /bin/sh
### BEGIN INIT INFO
# Provides: php-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php-fpm
# Description: starts the PHP FastCGI Process Manager daemon
@bordoni
bordoni / php-fpm.conf
Created July 5, 2012 22:12
php-fpm.conf
;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;
; All relative paths in this configuration file are relative to PHP's install
; prefix (/server/php). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.
; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
@bordoni
bordoni / php.ini
Created July 5, 2012 22:31
php.ini
;;;;;;;;;;;;;;;;;;;
; About php.ini ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The following is a summary of its search order:
; 1. SAPI module specific location.
; 2. The PHPRC environment variable. (As of PHP 5.2.0)
@bordoni
bordoni / Makefile
Created July 9, 2012 20:02
Makefile for custom path NGINX
.SILENT:
workplace := $(CURDIR)
clean:
rm -rf server tmp
setup:
echo "Setting up NGINX"
mkdir -p tmp server conf sites