Skip to content

Instantly share code, notes, and snippets.

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

Richard Snaver

🏠
Working from home
View GitHub Profile
<Macro VHost $name $domain $db_host $db_name $db_user $db_pw>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
@Snaver
Snaver / gist:7921096
Created December 12, 2013 00:19
PHP functions for removing and adding array key string prefixes
/**
* Remove array key prefixes
*
*/
function remove_prefix($array, $prefix)
{
return array_combine(
array_map(
function($k,$prefix){
return preg_replace("/^$prefix/", '', $k);
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Carbon\Carbon;
@Snaver
Snaver / setup.md
Created March 11, 2017 22:45
LAMP server setup on Linode Ubuntu 14.04.1 LTS
@Snaver
Snaver / instructions.md
Last active January 2, 2018 23:38
Add PHP 7.1 to Ubuntu 14.04 Install (Default setup of mod_php 5.6 & Apache 2.4.7)

Add PHP 7.1 to Ubuntu 14.04 Install (Default setup of mod_php 5.6 & Apache 2.4.7)

https://wiki.apache.org/httpd/PHP-FPM

Steps

  • libapache2-mod-fastcgi isn’t free software so include separate repo
    • add-apt-repository multiverse
  • apt-get update
@Snaver
Snaver / app\Models\Agreement.orig.php
Last active January 30, 2018 23:03
Cleaning up & Simplifying Eloquent Models (using Traits)
<?php
namespace App\Models;
class Agreement extends BaseModel
{
const CREATED_AT = 'CreatedOn';
const UPDATED_AT = 'LastUpdateOn';
/**
@servers(['web' => $user.'@'.$host,'localhost' => '127.0.0.1'])
@setup
// Sanity checks
if (empty($host)) {
exit('ERROR: $host var empty or not defined');
}
if (empty($user)) {
exit('ERROR: $user var empty or not defined');
}
# Bitbucket Pipelines Configuration file
# https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
# options:
# size: 2x
# max-time: 60
pipelines:
default:
- step:
script:
- echo "This script runs on all branches that don't have any specific pipeline assigned in 'branches'."
Route::get('/route-list', function () {
Artisan::call('route:list');
return '<pre>'.Artisan::output();
});
@Snaver
Snaver / App\Geocoder.php
Created May 19, 2020 20:53
geocoder-php / GeocoderLaravel Testing and Mocking Setup
<?php
namespace App;
use Geocoder\Laravel\ProviderAndDumperAggregator as G;
class Geocoder
{
protected $geocoder;