Skip to content

Instantly share code, notes, and snippets.

View fvosberg's full-sized avatar

Frederik Vosberg fvosberg

View GitHub Profile
@fvosberg
fvosberg / main.php
Created October 7, 2014 16:03
Long open connection
apache_setenv('downgrade-1.0','true');
apache_setenv('force-response-1.0','true');
ini_set('output_buffering', 'off');
while( @ob_end_flush() );
ini_set('implicit_flush', true);
flush();
echo "sending";
flush();
<?php
$tempFile = tmpfile();
$tempFileMetaData = stream_get_meta_data( $tempFile );
fwrite($tempFile, $string);
// path of the temp file
$tempFileMetaData['uri'];
// deletes the tmp file
@fvosberg
fvosberg / translate method
Created August 6, 2014 10:12
Translate in Extbase Controller
<?php
protected function translate( $key, $arguments = array()) {
$extensionName = $this->request->getControllerExtensionName();
return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, $extensionName, $arguments);
}
@fvosberg
fvosberg / main.php
Created May 27, 2014 09:46
Shell execute for debugging
<?php
function shelli($command){
$ouput = [];
$return = '';
exec($command, $output, $return);
echo "<hr><hr>\n";
echo "Executing \"$command\" with return value \"$return\".\n";
echo "<hr><pre>\n" . implode($output, "\n") . "</pre><hr><hr>\n";
}
@fvosberg
fvosberg / php
Last active September 25, 2020 09:18
A very lightweight php backtrace
<?php
$debug_backtrace = debug_backtrace();
$output = [];
foreach ($debug_backtrace as $debug) {
if (isset($debug['class'])) {
$o = $debug['class'];
}
$o .= '::' . $debug['function'];