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 | |
// Get 10mb of data from /dev/zero | |
$infp = fopen('/dev/zero', 'r'); | |
$data = fread($infp, 1024 * 1024 * 10); | |
fclose($infp); | |
write_data($data); | |
echo "Peak memory usage: ", number_format(memory_get_peak_usage()), " bytes\n"; |
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 | |
/** | |
* Calculate Zend Server Web API request signature | |
* | |
* @param string $host Exact value of the 'Host:' HTTP header | |
* @param string $path Request URI | |
* @param integer $timestamp Timestamp used for the 'Date:' HTTP header | |
* @param string $userAgent Exact value of the 'User-Agent:' HTTP header | |
* @param string $apiKey Zend Server API key |
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 | |
/** | |
* Zend Framework | |
* | |
* LICENSE | |
* | |
* This source file is subject to the new BSD license that is bundled | |
* with this package in the file LICENSE.txt. | |
* It is also available through the world-wide-web at this URL: |
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 | |
namespace Zend\Validator; | |
class Uri extends AbstractValidator | |
{ | |
const INVALID = 'uriInvalid'; | |
protected $_messageTemplates = array( | |
self::INVALID => "Provided input is not a valid URL" |
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 | |
/** | |
* Convert single use calls with comma separated list of namespaces into | |
* multiple, stand-alone use calls | |
* | |
* Usage: php cs-fix-use.php <file> | |
* | |
* Will overwrite <file> with new version. If <file> is omitted, stdin / stdout | |
* will be used. |
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
# The following example requires `jq` to parse JSON | |
CLIENT_ID=abcdef12345678s | |
CLIENT_SECRET=0123456789abcdef0123456789abcdef | |
BEARER_TOKEN=$(curl -s -X POST https://api.shoppimon.com/oauth \ | |
-H "Content-Type: application/json" \ | |
-d '{"grant_type":"client_credentials","client_id":"'$CLIENT_ID'","client_secret":"'$CLIENT_SECRET'"}' |\ | |
jq -rM '.access_token') | |
export BEARER_TOKEN | |
echo "Bearer token: $BEARER_TOKEN" |
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 | |
/** | |
* Phing task to generate a Zend Framework style autoloader classmap file | |
* | |
* This task requires ZF 2.x to be in your include_path. You can run phing like | |
* so to enforce this: | |
* | |
* $ export PHP_COMMAND="php -d include_path=.:<path to zf library>:<path to pear>" | |
* $ phing ... |
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
"""same logic as in above, but using a locking context manager | |
""" | |
from app_services import db_session | |
from locking_context import named_lock | |
def single_running_func(): | |
"""this code should never execute in parallel | |
""" | |
with named_lock(db_session, 'my_lock', 5): | |
# Do some stuff that should not run in parallel |
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
# Docker compose for external services, assuming main ckan services are run | |
# outside of Docker | |
version: "3" | |
volumes: | |
pg_data: | |
services: |
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 | |
/** | |
* PHP Built-in Web Server wrapper for ZF apps | |
*/ | |
$reqUri = $_SERVER['REQUEST_URI']; | |
if (strpos($reqUri, '?') !== false) { | |
$reqUri = substr($reqUri, 0, strpos($reqUri, '?')); | |
} |
OlderNewer