Skip to content

Instantly share code, notes, and snippets.

View joshuadegier's full-sized avatar

Joshua joshuadegier

View GitHub Profile
@joshuadegier
joshuadegier / Vagrantfile
Created January 20, 2017 11:29
Trigger to back-up databases before suspend and/or destroy of Vagrant/Homestead
# -*- mode: ruby -*-
# vi: set ft=ruby :
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.join(Dir.home, ".homestead"))
homesteadYamlPath = confDir + "/Homestead.yaml"
@joshuadegier
joshuadegier / create-backups.sh
Created January 20, 2017 11:25
Create back-ups for homestead/vagrant databases
#!/bin/bash
NOW=$(date +%Y%m%d%H%M)
USER="MYSQL_USERNAME"
PASSWORD="MYSQL_PASSWORD"
FOLDER="/home/vagrant/Projects/_dbdumps/"
cd $FOLDER
mkdir -p $NOW
@joshuadegier
joshuadegier / Vagrantfile
Created October 5, 2016 19:45
Vagrant / Homestead activate GUI
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")
homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"
@joshuadegier
joshuadegier / blade.canone.php
Last active June 16, 2016 12:14
Blade directive to pass one of the given permissions. The code goes in the boot() method of AppServiceProvider
<?php
/**
* Will pass if the logged in user has access to
* one of the given permissions using Gate::allows.
* Usage:
*
*
* @canone('update-company','company-admin')
* <a href="{{ route('admin.companies.edit', [$company->id]) }}" class="btn btn-smal btn-primary">Modify</a>
@joshuadegier
joshuadegier / validator.php
Created June 13, 2016 07:55
Validation rule for Laravel to check existence in database or pass validation if value is 0 or null
/**
* Validate exists_or_null
* This rule validates exactly like the default 'exists' rule, except it passes
* when the value is equal to 0 or null. The function should be added to the
* boot method of the AppServiceProvider. When there's another value than
* 0 or null, the value will be validated against the default exists
* rule.
*/
Validator::extend(
'exists_or_null',