Skip to content

Instantly share code, notes, and snippets.

View ClaudioVarandas's full-sized avatar

Cláudio Varandas ClaudioVarandas

  • Lisbon Portugal
  • 03:27 (UTC +01:00)
View GitHub Profile
@ClaudioVarandas
ClaudioVarandas / gist:33f5b4588c1d2daa777e
Created December 1, 2014 18:32
Header AUTH Apache to PHP FPM
<VirtualHost *>
ServerName auth.dev
DocumentRoot "/var/www/auth"
ProxyPassMatch ^(/.*\.php)$ fcgi://127.0.0.1:9000/var/www/auth
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</VirtualHost>
@ClaudioVarandas
ClaudioVarandas / gist:5b5251c177abce78e223
Created March 18, 2015 10:40
Generate unique slugs in Laravel 4 (updated)
function generateSlug($value)
{
$slug = \Str::slug($value);
$slugs = $this->whereRaw("slug REGEXP ? ", ["^{$slug}(-[0-9]*)?$"]);
$count = $slugs->count();
if ($count === 0) {
return $slug;
@ClaudioVarandas
ClaudioVarandas / vagrant_apache.yaml
Last active August 29, 2015 14:25
Vagrant configuration apache+factcgi fpm
vagrantfile:
target: local
vm:
box: puphpet/ubuntu1404-x64
box_url: puphpet/ubuntu1404-x64
hostname: xxxxxxxxx
memory: '2048'
cpus: '2'
chosen_provider: parallels
network:
/* Laravel Helpers */
class Helpers
{
public static function setActive($paths = [], $active = 'active')
{
$isActive = false;
foreach ($paths as $path) {
@ClaudioVarandas
ClaudioVarandas / remove_git_files.sh
Created August 23, 2015 17:29
Remove git files from project
find . | grep .git | xargs rm -rf
vagrantfile:
target: local
vm:
box: puphpet/ubuntu1404-x64
box_url: puphpet/ubuntu1404-x64
hostname: cvhomevag
memory: '2048'
cpus: '2'
chosen_provider: virtualbox
network:
@ClaudioVarandas
ClaudioVarandas / ApiController
Last active September 8, 2015 13:51
ApiController - Base api controller
<?php
namespace Api\v1;
use Apilog;
use Config;
use Input;
use League\Fractal;
use League\Fractal\Pagination\Cursor;
use League\Fractal\Resource\Collection;
@ClaudioVarandas
ClaudioVarandas / clean_empty_input_value
Created September 10, 2015 09:35
remove empty value from imput
<?php
$data = array_filter($data, function ($value) {
return $value !== '';
});
@ClaudioVarandas
ClaudioVarandas / CheckSecurity.php
Last active February 6, 2016 12:08
CheckSecurity Command for Laravel 5
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use SensioLabs\Security\SecurityChecker;
class CheckSecurity extends Command
{
/**
#Remove all docker containers with status exited
$ docker rm -v $(docker ps -a -q -f status=exited)