Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//
@cballou
cballou / wordpress-multi-env-configphp-setup.php
Created August 15, 2011 13:54
Wordpress Multi-Environment wp-config.php Setup
<?php
/**
* This code is intended to be added to your wp-config.php file just below the top comment block.
* It should replace the existing define('DB_*') statements. You can add or remove sections
* depending on the number of environments you intend to setup. You should change all values of
* DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST for each environment, making them all distinct
* for security purposes.
*/
// determine the current environment
@mehlah
mehlah / ArticleControllerTest.php
Created December 18, 2011 11:48 — forked from icambridge/ArticleControllerTest.php
Controller testing lithium
<?php
namespace app\tests\cases\controllers;
use app\tests\mocks\MockArticlesController;
use app\tests\mocks\action\MockControllerRequest as Request; //Mocking the Request
class ArticlesControllerTest extends \lithium\test\Unit {
protected $_controller;
@mehlah
mehlah / li3_errors.php
Created December 18, 2011 17:17
Lithium Error handler
<?php
use lithium\core\ErrorHandler;
use lithium\action\Response;
use lithium\net\http\Media;
use lithium\analysis\Debugger;
use lithium\analysis\Logger;
use lithium\core\Environment;
/**
@mariuskubilius
mariuskubilius / CategoriesController.php
Created December 28, 2011 22:13
Lithium Model and Controller for taxonomies
<?php
namespace app\controllers;
use \app\models\Taxonomies;
use MongoId;
class CategoriesController extends \lithium\action\Controller {
/**
* @var Protected $_type - protected variable which define type of taxonomy,
* Can be omited if there is no need for additional types of taxonomy.
@johnmegahan
johnmegahan / functions.php
Created January 12, 2012 01:50
Extended Walker class for use with the Twitter Bootstrap toolkit Dropdown menus in Wordpress.
<?php
add_action( 'after_setup_theme', 'bootstrap_setup' );
if ( ! function_exists( 'bootstrap_setup' ) ):
function bootstrap_setup(){
add_action( 'init', 'register_menu' );
@ziadoz
ziadoz / awesome-php.md
Last active July 13, 2024 05:29
Awesome PHP — A curated list of amazingly awesome PHP libraries, resources and shiny things.
@zachleat
zachleat / gist:2008932
Created March 9, 2012 21:56
Prevent zoom on focus
// * iOS zooms on form element focus. This script prevents that behavior.
// * <meta name="viewport" content="width=device-width,initial-scale=1">
// If you dynamically add a maximum-scale where no default exists,
// the value persists on the page even after removed from viewport.content.
// So if no maximum-scale is set, adds maximum-scale=10 on blur.
// If maximum-scale is set, reuses that original value.
// * <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=2.0,maximum-scale=1.0">
// second maximum-scale declaration will take precedence.
// * Will respect original maximum-scale, if set.
// * Works with int or float scale values.
@mariuskubilius
mariuskubilius / config\bootstrap\action.php
Created March 18, 2012 17:38
LI3 Change layout depending whether admin continuation route is used or not
use lithium\action\Dispatcher;
//Allow admin continuation routes to be made.
Dispatcher::config(
array(
'rules' => array(
'admin' => array('action' => 'admin_{:action}')
)
)
);
@joseph
joseph / Vagrantfile
Created March 22, 2012 04:14
Various fixes for Vagrant (Lucid64) on Mac OS X Lion
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Preventing kernel panics - VirtualBox 4.1 and Mac OS X Lion 10.7.
#
# This happens on my Macbook Air Mid-2011 Core i7. Every few hours, with
# one or (particularly) more VMs running, you will get a kernel panic.
#
# Some reading:
# https://www.virtualbox.org/ticket/9359