Skip to content

Instantly share code, notes, and snippets.

View 4lun's full-sized avatar

Alun Davey 4lun

View GitHub Profile
@4lun
4lun / PageController.php
Created June 1, 2015 15:24
Controller for Laravel 5 that loads views from the filesystem based on the URL
<?php namespace App\Http\Controllers;
class PageController extends Controller
{
/**
* Loads page from the filesystem
* @param String $page
* @return Response
*/
while :; do say "This speech is my recital, I think its very vital. " \
"To rock a rhyme thats right on time. " \
"Its Tricky is the title, here we go. " \
"Its tricky to rock a rhyme, to rock a rhyme thats right on time. " \
"Its tricky, its tricky, tricky. " \
"Tricky, tricky. " \
"Its tricky to rock a rhyme, to rock a rhyme thats right on time. " \
"Its tricky, tr-tr-tricky, tricky. " \
"Tricky. " \
"I met this little girlie, her hair was kinda curly. " \
@4lun
4lun / setup.sh
Last active August 29, 2015 14:25
Initial VM setup for dev work (Ubuntu 14.04). Mainly for Laravel and such
# Run as root, change below variables
export PROJECT_NAME='project'
export DEBIAN_FRONTEND="noninteractive" # Supress mysql-server password dialog (set password during mysql_secure_installation command instead)
apt-get install nginx php5-fpm php5-cli php5-mysql mysql-server nodejs nodejs-legacy npm -y
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
sudo -u www-data -H mkdir -p /var/www/$PROJECT_NAME/public
@4lun
4lun / Model.php
Created September 23, 2015 12:06
Laravel 5.1 Base Model - adds defaults to $casts property on __construct
<?php
namespace App;
use Illuminate\Database\Eloquent\Model as Eloquent;
class Model extends Eloquent
{
/**
* Create a new Eloquent model instance.
@4lun
4lun / HasRoles.php
Created October 6, 2015 16:15
Basic role implementation for Laravel 5
<?php
namespace App\Traits;
use Illuminate\Support\Str;
use App\Role;
/**
* Adds roles to a model
* Note: requires a Role model pivot table {model}_roles and a role table with
@4lun
4lun / index.html
Last active October 13, 2015 22:58
HTML Starting Point
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<title>Project</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">
<script>
(function() {
@4lun
4lun / log_deprecated_method.helpers.php
Created October 16, 2015 10:45
Laravel helper log_deprecated_method
<?php
/**
* Writes to the log that a deprecated method was called, and where it was called from.
*/
function log_deprecated_method()
{
list($x, $current, $caller) = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
$currentMethod = (isset($current['class']) ? $current['class'].'::' : '').$current['function'].'()';
$callerMethod = (isset($caller['class']) ? $caller['class'].'::' : '').$caller['function'].'()';
@4lun
4lun / index.php
Created December 7, 2015 16:28
Simple script to help demo load balancing.
<?php
$id = sha1(getenv('HOSTNAME'));
function rgbcode($id){
return '#'.substr(md5($id), 0, 6);
}
?><html>
<style>
body { padding: 30px; background-color: <?php echo rgbcode($id); ?>; font-family: sans-serif; }
h1 { background: #000; color: #fff; margin: 0; padding: 5px; float: left; }
@4lun
4lun / .bash_profile
Last active December 15, 2015 16:39
OS X .bash_profile
# -------------------------
# Aiases & Functions
# -------------------------
# locations
alias desktop="cd ~/Desktop/"
alias dev="cd ~/Development/"
alias ..="cd ../"
# hosts related
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Generated by: TmTheme-Editor -->
<!-- ============================================ -->
<!-- app: http://tmtheme-editor.herokuapp.com -->
<!-- code: https://github.com/aziz/tmTheme-Editor -->
<plist version="1.0">
<dict>
<key>name</key>
<string>Summerfruit</string>