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.
# Create directory for new site | |
cd ~/Sites | |
mkdir {query} | |
cd {query} | |
# Download latest version of WordPress | |
wp core download | |
# Setup wp-config file with WP_DEBUG enabled | |
wp core config --dbname={query} --dbuser=root --dbpass=root --dbprefix={query}wp_ --extra-php <<PHP |
http://www.youtube.com/watch?v=-FRm3VPhseI Google's Clean Code Talks | |
http://blog.gordon-oheim.biz/2011-01-17-Why-Singletons-have-no-use-in-PHP/ | |
http://sebastian-bergmann.de/archives/882-Testing-Code-That-Uses-Singletons.html | |
http://eamann.com/tech/making-singletons-safe-in-php/ | |
http://hakre.wordpress.com/2012/06/10/the-missing-patterns-of-the-php-manual/#p2 | |
http://blogs.msdn.com/b/scottdensmore/archive/2004/05/25/140827.aspx | |
http://www.phptherightway.com/pages/Design-Patterns.html ("You should be wary when using the singleton pattern, as by its very nature it introduces global state into your application, reducing testability.") | |
http://www.practicaldesignpatternsinphp.com/ ("The Singleton Pattern is perhaps the most well known - and most often misused - pattern in all of PHP design pattern development. Its simplicity, combined with its seeming benefits makes it a widely-used (and overused) pattern. The Singleton is not so much a recommended pattern, as a pattern I recommend you shy away from.") | |
http://www.sli |
<?php | |
/** | |
* Callback for saving values from metaboxes. | |
* | |
* @since 1.0.0 | |
* | |
* @param int $post_id The current post ID. | |
* @param object $post The current post object. | |
*/ | |
function tgm_save_meta_boxes( $post_id, $post ) { |
<?php | |
/** | |
* Auto-paginate after 500 words | |
*/ | |
add_action( 'loop_start', function( $query ) { | |
if ( ! is_single() || 'post' != get_post_type() || ! $query->is_main_query() ) | |
return; | |
$content = $query->posts[0]->post_content; |
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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.
// Paste into Firebug or Chrome Dev Tools console | |
// when viewing a page with multiple checkboxes. | |
(function(d) { | |
var input = d.querySelectorAll('input[type="checkbox"]'); | |
var i = input.length; | |
while (i--) { | |
input[i].checked = true; | |
} |
<?php | |
$countries = array | |
( | |
'AF' => 'Afghanistan', | |
'AX' => 'Aland Islands', | |
'AL' => 'Albania', | |
'DZ' => 'Algeria', | |
'AS' => 'American Samoa', | |
'AD' => 'Andorra', |