This file contains 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 | |
// ... | |
protected function getMockedPDO() | |
{ | |
$query = $this->getMock('\PDOStatement'); | |
$query->method('execute')->willReturn(true); | |
$db = $this->getMockBuilder('\PDO') | |
->disableOriginalConstructor() |
This file contains 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
# function to return multiple items (n) from a redis list (q) in an atomic manner | |
# as seen in: http://redis.io/commands/lpop#comment-431677622 | |
def multi_pop(r, q, n): | |
p = r.pipeline() | |
p.multi() | |
p.lrange(q, 0, n - 1) | |
p.ltrim(q, n, -1) | |
return p.execute() |
This file contains 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 | |
// returns True if the given $var is an Array, and it is not empty; | |
// otherwise, False. It does not gives an error if the given $var | |
// is not an Array, however, it returns False. | |
function isNonEmptyArray($var) { | |
return !empty(@reset($var)); | |
} |
NewerOlder