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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / README.md
Last active August 29, 2015 14:19
Laravel Lumen CORS Middleware
@vluzrmos
vluzrmos / git_filter_branch.sh
Created March 5, 2015 01:49
Remove file from all commits on all branches
# Remove file from all commits on all branches
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch FILENAMEHERE" --prune-empty --tag-name-filter cat -- --all
# After
git push --all --force
@vluzrmos
vluzrmos / app\views\shared\_listagem.rhtml
Last active August 29, 2015 14:12
configuração do shared listagem
<% @table_buttons.each do |button| %>
<%if button[:block].blank? or button[:block].call %>
<span class="button">
<% _button = button.dup
_button.delete(:block)
confirm = _button.delete(:confirm)
popup = _button.delete(:popup)
name = _button.delete(:name)