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
@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);
public function humanizeDateDifference($now,$otherDate=null,$offset=null)
{
if($otherDate != null){
$offset = $now - $otherDate;
}
if ($offset == 0)
{
$otherDate =$otherDate + 1;
$offset = $now - $otherDate;
}
<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.
<?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 / file.php
Created March 31, 2017 08:49
WP Rest API - Retrieve sub page by full slug (URL/Path)
<?php
if (strstr($slug, '/')) {
$segments = explode('/', $slug);
$parent_id = null;
foreach ($segments as $key => $segment) {
$params['slug'] = $segment;
if ($parent_id) {
@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';
/**
# 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'."
# 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'."