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
#!/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/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
<?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
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
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
<?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
<?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
const express = require('express'); | |
const fetch = require('node-fetch'); | |
const redis = require('redis'); | |
const PORT = process.env.PORT || 5000; | |
const REDIS_PORT = process.env.PORT || 6379; | |
const client = redis.createClient(REDIS_PORT); | |
const app = express(); |
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
let | |
# Wrap a nginx server block in an HTTPS site | |
wrapSSL = site: cert: key: block: '' | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name ${site}; | |
location /nginx_status { | |
stub_status on; |