Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
RED="\[\033[0;31m\]" | |
YELLOW="\[\033[0;33m\]" | |
GREEN="\[\033[0;32m\]" | |
BLUE="\[\033[0;34m\]" | |
LIGHT_RED="\[\033[1;31m\]" | |
LIGHT_GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
LIGHT_GRAY="\[\033[0;37m\]" | |
COLOR_NONE="\[\e[0m\]" |
/** | |
* Git Pull | |
* | |
* @author Adam Patterson | |
* http://www.adampatterson.ca/blog/2011/10/diy-simple-staging-server/ | |
* | |
* Use: echo pull(); | |
*/ | |
function pull ( ) |
<?php | |
/** | |
* Here is a non-magic-method version for those that need better auto-complete and faster access times. | |
* It also filters the input to be valid UTF-8 just when needed thanks to phunction. | |
*/ | |
class input | |
{ | |
public static $encoding = 'UTF-8'; | |
public static function server($key, $default = NULL, $control = true) |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
#!/bin/bash | |
########## | |
## Setup: hardcode your mysql user/pass. Yeah, yeah, I know...it's frowned upon. | |
## but for local development, I have no problem with it. | |
## Find and replace: MYSQLUSER / MYSQLPASS | |
## | |
## Usage: This script accepts only one variable, the site name. | |
## | |
######### |
<?php | |
class DocBlock { | |
public $docblock, | |
$description = null, | |
$all_params = array(); | |
/** | |
* Parses a docblock; |
<?php | |
/** | |
* Ranking Library | |
* contains alogrithms for story ranking | |
* Basically a PHP Implementation of reddits algorithms | |
* | |
* @author Lucas Nolte <[email protected]> | |
* @since 0.1 | |
* @package Polska Wiadomosc | |
* @subpackage Libraries |
<?php | |
$date = new DateTime('now'); | |
echo $date->format('d/m/Y').PHP_EOL; // format: day/month/year | |
echo $date->format('m-d-Y').PHP_EOL; // format: month-day-year | |
echo $date->format('Y-m-d').PHP_EOL; // format: year-month-day | |
// add 3 days to current date and output using format year-day-month | |
echo $date->setTimestamp( strtotime('+3 days', $date->getTimestamp()) )->format('Y-d-m'); |
(function() { | |
var CSSCriticalPath = function(w, d, opts) { | |
var opt = opts || {}; | |
var css = {}; | |
var pushCSS = function(r) { | |
if(!!css[r.selectorText] === false) css[r.selectorText] = {}; | |
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/); | |
for(var i = 0; i < styles.length; i++) { | |
if(!!styles[i] === false) continue; | |
var pair = styles[i].split(": "); |
For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.
Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon
with HyperThreading enabled, but it can work without problem on slower machines.
You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.