Skip to content

Instantly share code, notes, and snippets.

@codecybe
codecybe / ffmpeg.md
Created March 17, 2019 22:53 — forked from steven2358/ffmpeg.md
FFmpeg cheat sheet
@codecybe
codecybe / gist:51ae57e623fd139c8528f433da8d88b6
Created March 17, 2019 06:04 — forked from codler/gist:3906826
Support HTTP Header Range, mp4, php.php/mp4.mp4
<?php
# Nginx don't have PATH_INFO
if (!isset($_SERVER['PATH_INFO'])) {
$_SERVER['PATH_INFO'] = substr($_SERVER["ORIG_SCRIPT_FILENAME"], strlen($_SERVER["SCRIPT_FILENAME"]));
}
$request = substr($_SERVER['PATH_INFO'], 1);
$file = $request;
$fp = @fopen($file, 'rb');
@codecybe
codecybe / remote-file-copy.php
Created March 16, 2019 17:59 — forked from kongondo/remote-file-copy.php
Remote file copying with progress reporting in PHP.
<?php
/*
* Remote File Copy PHP Script 2.0.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
<?php
/**
* Stream or Download big files using php (support multipart and remote url)
* @param $file is the path or remote url
* @param $size is the filesize of the file
*/
function streamDownload($file,$size,$mime='video/mp4') {
header('Content-type: ' . $mime);
header('Content-Disposition: attachment; filename="' . basename($file) . '"');
<?php
/**
* Get the file size of any remote resource (using get_headers()),
* either in bytes or - default - as human-readable formatted string.
*
* @author Stephan Schmitz <eyecatchup@gmail.com>
* @license MIT <http://eyecatchup.mit-license.org/>
* @url <https://gist.github.com/eyecatchup/f26300ffd7e50a92bc4d>
*
* @param string $url Takes the remote object's URL.
@codecybe
codecybe / downloader.php
Created March 16, 2019 17:44 — forked from ARACOOOL/downloader.php
Download remote file with progress bar (PHP, curl)
#!/usr/bin/php
<?php
/**
* Usage:
* php downloader.php http://path.to/remote/file.ext /local/file/path
*
* Output:
* [############################################################################################### ] 96%
*/
@codecybe
codecybe / explode_file.php
Created March 16, 2019 17:42 — forked from ajspadial/explode_file.php
Explode file in smaller chunks, with a max chunk size
<?php
// ---------------------- S C R I P T ---------------------------------------
$chunk_size = $chunk_size_default = 8192 * 1024; // default is 8192 kB
$break_symbol = $break_symbol_default = ";"; // default is semicolon
$filename = "";
process_params();
echo "chunk size: " . $chunk_size . " bytes " . ($chunk_size == $chunk_size_default ? "(default)" : "") . "\n";
@codecybe
codecybe / output-buffer-to-temp.php
Created March 16, 2019 17:41 — forked from hakre/output-buffer-to-temp.php
Output buffer for large output to temporary file on disk (>2MB)
<?php
/*
* Output buffer for large output to temporary file on disk (>2MB)
*
* @link http://stackoverflow.com/questions/5446647/how-can-i-use-var-dump-output-buffering-without-memory-errors/
*/
/**
* Iterate over lines of a stream resource.
*
@codecybe
codecybe / file_chunks.php
Created March 16, 2019 17:38 — forked from unique1984/file_chunks.php
create / merge file chunks using php
<?php
/*****************************************
* App : create / merge file chunks using php
* File : file_chunks.php
* Date : Wed Nov 28 16:40:42 +03 2018
* Version : 1.0.0
* Email : yasinkarabulak@gmail.com
*
* MIT License
* Copyright (c) 2018 Yasin KARABULAK
@codecybe
codecybe / cache.phpi
Created March 16, 2019 17:30 — forked from CAFxX/cache.phpi
PHP remote file/URL cache
<?php
/*
A simple cache for remote files/URLs
2011 Carlo Alberto Ferraris <cafxx@strayorange.com>
===================================================
The cache function allows you to get the contents of a remote URL at
most once every N seconds. It also supports the If-Modified-Since HTTP
header to avoid fetching the resource again if it hasn't changed.