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/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. |
var LiveCollection = (function (_, Backbone) { | |
var Collection = Backbone.Collection; | |
// Define a Backbone Collection handling the details of running a "live" | |
// collection. Live collections are expected to handle fetching their own | |
// data, rather than being composed from separate models. | |
// They typically add new models instead of resetting the collection. | |
// A custom add comparison makes sure that duplicate models are not | |
// added. End result: only new elements will be added, instead | |
// of redrawing the whole collection. | |
// |
<?php | |
// source: http://cubiq.org/the-perfect-php-clean-url-generator | |
// author: Matteo Spinelli | |
// MIT License / http://creativecommons.org/licenses/by-sa/3.0/ (please re-check at source) | |
setlocale(LC_ALL, 'en_US.UTF8'); | |
function toAscii($str, $replace=array(), $delimiter='-') { | |
if( !empty($replace) ) { | |
$str = str_replace((array)$replace, ' ', $str); | |
} |
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.
<?php | |
abstract class BaseModelManager { | |
protected $em; | |
protected $class; | |
protected $repository; | |
protected $container; | |
/** | |
* Constructor. |
<?php | |
namespace SiteModuleTest; | |
use Zend\Loader\AutoloaderFactory; | |
use ApplicationModuleTest\ServiceManagerTestCase; | |
$basePath = __DIR__ . '/../../../../'; | |
chdir(__DIR__); |
### ENVIRONMENT VARIABLES ### | |
SetEnv PHP_VER 5 | |
SetEnv REGISTER_GLOBALS 0 | |
### MAIN DEFAULTS ### | |
Options All -Indexes | |
DirectoryIndex index.html index.htm index.php | |
AddDefaultCharset UTF-8 | |
### MIME TYPES ### |
dropbox
friendsfeed
function targetBlank() { | |
// remove subdomain of current site's url and setup regex | |
var internal = location.host.replace("www.", ""); | |
internal = new RegExp(internal, "i"); | |
var a = document.getElementsByTagName('a'); // then, grab every link on the page | |
for (var i = 0; i < a.length; i++) { | |
var href = a[i].host; // set the host of each link | |
if( !internal.test(href) ) { // make sure the href doesn't contain current site's host | |
a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes |