Skip to content

Instantly share code, notes, and snippets.

View vluzrmos's full-sized avatar
🏠
Working from home

Vagner Luz do Carmo vluzrmos

🏠
Working from home
View GitHub Profile
@vluzrmos
vluzrmos / DatabaseSeeder.php
Last active April 19, 2017 13:08
Laravel - Seeding 100k many rows at 1s
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\User;
class DatabaseSeeder extends Seeder {
/**
* Run the database seeds.
@vluzrmos
vluzrmos / compat_l5.php
Last active November 1, 2022 20:43
Lumen L5 compatibility helpers. That file should be added on root path of your project... and added to your composer.json
<?php
if(!function_exists('config_path'))
{
/**
* Return the path to config files
* @param null $path
* @return string
*/
function config_path($path=null)
@vluzrmos
vluzrmos / command.bat
Last active August 29, 2016 00:59
[en] How to create command to .phar on windows | [pt_BR] Como criar comando de arquivo .phar no windows
@echo Off
php "%~dp0NOMEDOCOMANDO.phar" %*
#REM [en]
#REM %~dp0 is the directory of the actual file (command.bat) , its like the directive __DIR__ on php.
#REM [pt_BR]
#REM %~dp0 é o diretório do arquivo atual, similar a diretiva __DIR__ do php.
@vluzrmos
vluzrmos / phpfmt-settings-user.json
Last active September 11, 2015 10:53
Sublime Text: Preferences > Packages Settings > PHP Code Sniffer > Settings User
{
"php_cs_fixer_on_save": true,
"php_cs_fixer_additional_args": {
"--level": "psr2",
"--fixers": "-psr0"
}
}
@vluzrmos
vluzrmos / helpers.php
Last active August 29, 2015 14:23
Laravel 5.1 Helpers
<?php
if (!function_exists('faker')) {
/**
* Generate or get a faker localized instance
* @param locale $l
* @example
* <code>
@vluzrmos
vluzrmos / ValidatorServiceProvider.php
Last active January 3, 2017 13:45
Laravel - Simple file extension validator
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class ValidatorServiceProvider extends ServiceProvider
{
@vluzrmos
vluzrmos / srt2utf8
Created July 6, 2015 17:20
Command line helper to convert all .srt files into utf-8. The resultant files will have the extension .utf8.srt
#!/usr/bin/env php
<?php
/** @var string local dir */
$cwd = getcwd();
/** @var array local dir subdirectories */
$dirs = glob($cwd."/*", GLOB_ONLYDIR);
/** @var array local dir subtitles */
@vluzrmos
vluzrmos / .php_cs.php
Created July 8, 2015 21:09
phpcs-fixer configuration file to Laravel style. Note: rename this to .php_cs and put on root of your project or package.
<?php
$finder = Symfony\Component\Finder\Finder::create()
->files()
->in(__DIR__)
->exclude('vendor')
->notName("*.txt")
->ignoreDotFiles(true)
->ignoreVCS(true);
@vluzrmos
vluzrmos / App_Http_VideoStream.php
Last active February 14, 2024 22:00
Laravel VideoStream.
<?php
namespace App\Http;
/**
* Description of VideoStream
*
* @author Rana
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069
*/
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";