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 | |
include ('vendor/autoload.php'); | |
use PhpAmqpLib\Connection\AMQPStreamConnection; | |
use PhpAmqpLib\Message\AMQPMessage; | |
$connection = new AMQPStreamConnection('localhost', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); | |
//Create the queue |
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 | |
include ('vendor/autoload.php'); | |
use prodigyview\media\Video; | |
use prodigyview\util\FileManager; | |
use PhpAmqpLib\Connection\AMQPStreamConnection; | |
//Start RabbitMQ Server | |
$connection = new AMQPStreamConnection('127.0.0.1', 5672, 'guest', 'guest'); | |
$channel = $connection->channel(); |
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
DELETE FROM geoname WHERE (zip, place, state) IN | |
(SELECT DISTINCT ON (zip) zip, place, state FROM geoname WHERE zip IN | |
( '10804', | |
'15129', | |
'15714', | |
'19018', | |
'27539', | |
'28470', |
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
var restify = require('restify') | |
, port = process.env.PORT || 3000 | |
, Phantom = require('phantom') | |
, tmpdir = require('os').tmpdir() | |
, fs = require('fs'); | |
var server = restify.createServer(); | |
function setResponseHeaders(res, filename) { | |
res.header('Content-disposition', 'inline; filename=' + filename); |
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 | |
use Slim\Http\Request; | |
use Slim\Http\Response; | |
use Slim\Http\Stream; | |
$app->get('/stream', function (Request $request, Response $response, array $args) { | |
// a 100mb file | |
$path = '../public/files/document.pdf'; |
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
#!/usr/bin/env php | |
<?php | |
echo "Running tests.. "; | |
exec('vendor/bin/phpunit', $output, $returnCode); | |
if ($returnCode !== 0) { | |
// Show full output | |
echo PHP_EOL . implode($output, PHP_EOL) . PHP_EOL; | |
echo "Cannot push changes untill tests are OK.." . PHP_EOL; | |
exit(1); | |
} |
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
#!/usr/bin/php | |
<?php | |
printf("%sGit pre-commit hook %1\$s", PHP_EOL); | |
$projectName = basename(getcwd()); | |
exec('phpunit --configuration phpunit.xml', $output, $returnCode); // Assuming cwd here | |
if ($returnCode !== 0) { | |
$minimalTestSummary = array_pop($output); | |
printf("Test suite for %s failed: ", $projectName); | |
printf("( %s ) %s%2\$s", $minimalTestSummary, PHP_EOL); | |
return false; // exit(1); |
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
#!/usr/bin/php | |
<?php | |
exec('git diff --name-only --diff-filter=ACM --cached', $files); | |
$status = 0; | |
foreach ($files as $file) { | |
if (pathinfo($file, PATHINFO_EXTENSION) != 'php') continue; | |
$file = escapeshellarg($file); | |
$message = array(); | |
exec("git show :$file | php -l 2>&1", $message, $code); |
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
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to | |
# newer versions of the distribution. | |
deb http://us.archive.ubuntu.com/ubuntu/ bionic main restricted | |
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted | |
## Major bug fix updates produced after the final release of the | |
## distribution. | |
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted | |
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted |
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 | |
// create client | |
$client = new \GuzzleHttp\Client(); | |
$res = $client->request('GET', $someApi, ['http_errors' => false]); | |
// check http status code | |
if ($res->getStatusCode() != 200) { | |
// handle it | |
} |