In this short write-up, I will briefly summarize the types of modeling I have seen and attempted over the years, highlighting some of the advantages and drawbacks of each, ending with a conclusion explaining which one I prefer and why.
Example LESS file:
.layout {
.row();
background: #ddd;
}
.nav {
.col(4);
jQuery plugin to replace checkboxes with <div>
elements for styling.
This plugin makes no assumptions about class-names or the contents of the <div>
element,
it only implements the behavior - it returns the generated <div>
elements for further
operations with jQuery functions, so you can do for example:
$('input[type=checkbox]')
.checkbox() // returns set of <div> elements
.addClass('checkbox') // adds class="checkbox" to every <div> element
.html('✔') // inserts a unicode checkmark into every element
<?php | |
// basic GitHub service hook example | |
$payload = file_get_contents("php://input"); | |
$secret_key = 'secret'; | |
$computed_signature = 'sha1=' . hash_hmac('sha1', $payload, $secret_key, false); |
<?php | |
/** | |
* Map php errors to the built-in ErrorException class. | |
* | |
* Respects the error_reporting() setting and the error-suppression operator. | |
* | |
* @see ErrorException | |
*/ |
<?php | |
namespace Psr\Cache; | |
/** | |
* Cache defines a common driver interface for interacting with a cache back-end. | |
*/ | |
interface Driver | |
{ | |
/** |
I just learned about the proposed cache PSR, and I have to speak up.
I must apologize in advance, as my tone may get harsh or sarcastic, but it really upsets me to see a proposed standard which probably a lot of developers will end up following, to their detriment.
First off, FIG is the "Framework Interop Group" - did you actually look at other frameworks to see what they're doing? ZF2, Laravel, Doctrine, Symfony and Yii, to name a few of the major ones - not a single one of those use an aggregate model for individual cache items. How exactly is this standard supposed to help these frameworks interoperate?
For another, none of the cache providers you're going to be wrapping with this interface use an aggregate model - and for the most part this is probably deliberate, because the operations on a cache are supposed to be very focused and atomic, allowing you to optimize by doing as little work as possible.
This kind of thinking seems
<?php | |
header('Content-type: text/plain'); | |
define('NUM_RUNS', 200); // total number of runs/readings | |
define('NUM_LOOP', 100); // number of iterations per run | |
// benchmark a function using various PHP features to establish | |
// a performance baseline for the PHP version / platform / etc.: |
<?php | |
use RecursiveDirectoryIterator; | |
use RecursiveIteratorIterator; | |
use SplFileInfo; | |
# http://stackoverflow.com/a/3352564/283851 | |
/** | |
* Recursively delete a directory and all of it's contents - e.g.the equivalent of `rm -r` on the command-line. |
// noprotect | |
/** | |
* JavaScript benchmark function | |
* | |
* Usage: console.log(bench(function(){ ... })); | |
*/ | |
bench = (function() { | |
var |