Skip to content

Instantly share code, notes, and snippets.

View arturom's full-sized avatar

Arturo Mejia arturom

  • Nuxeo
  • Florida, USA
View GitHub Profile
<?php
ini_set('memory_limit','512M');
class MessageStructure
{
/**
* @var mixed
*/
public $topic;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<?php
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
static $calls = 0;
echo PHP_EOL, PHP_EOL, $errno, ' ', $errstr, ' ', $errfile, ' ', $errline, PHP_EOL;
$bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
print_r($bt);
// debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
if($calls ++ > 3) {
exit(1);
}
<?php
$fh = STDIN;
while (!feof($fh)) {
$command = json_decode(fgets($fh));
if(!is_object($command)) {
exit;
}
function importLodash() {
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = 'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.1/lodash.min.js';
document.body.appendChild(s);
}
function toURL(id) {
return '/test/reprocess_asset/' + id;
}
<?php
stream_set_blocking(STDIN, 1);
$pattern = '(?<=Request Body \[).+?(?=\] {"file")';
while(($line = fgets(STDIN)) !== false) {
if(preg_match($pattern, $line) === 1) {
echo json_decode($matches[0]), PHP_EOL;
}
}
grep -Pio '(?<=Request Body \[).+?(?=\] {"file")' ./app/tmp/logs/elasticsearch-php.log | tail | php -r 'stream_set_blocking(STDIN, 0); while(($line = fgets(STDIN)) !== false) { echo json_decode($line), PHP_EOL; }'
@arturom
arturom / mysqliFromCake.php
Last active August 29, 2015 14:22
Get raw mysqli from Cake's default config
<?php
// get the raw mysql object
$dataSource = ConnectionManager::getDataSource('default');
$mysqli = $dataSource->connection;
// dump the config
var_dump($dataSource->config);
// query the database
echo -e "\nFile Formats"
ffmpeg -v warning -formats | grep '^\sD[^\.]' | grep -vi '\(audio\|sound\|subtitle\|caption\)' | awk '{print " -", $2}'
echo -e "\nVideo Codecs"
ffmpeg -v warning -codecs | grep '^\sD.A' | awk '{print " -", $2}'
echo -e "\nAudio Codecs"
ffmpeg -v warning -codecs | grep '^\sD.V' | awk '{print " -", $2}'
@arturom
arturom / gist:f29f832acd9e792434af
Created December 8, 2014 21:00
ElasticSearch info paths
GET /_aliases
GET /_cluster/nodes
GET /_cluster/health
GET /_cluster/state
GET /_cluster/state/?filter_nodes=true&filter_metadata=true
GET /_cluster/nodes/process
GET /_cluster/pending_tasks
GET /_nodes/
GET /_nodes/stats