Skip to content

Instantly share code, notes, and snippets.

View gbrock's full-sized avatar

Greg Brock gbrock

View GitHub Profile
@gbrock
gbrock / helper.php
Created May 12, 2023 10:25
Laravel: Gathers all the currently-used routes and return an array
<?php
/*
Gathers all the currently-used routes and returns an array.
*/
function getFirstLevelRoutes() {
return collect(Route::getRoutes()->getRoutes())->pluck('uri')->map(function ($uri) {
return explode('/', $uri)[0];
})->unique()->filter();
@gbrock
gbrock / Extensions\Postmaster.php
Created November 12, 2015 15:32
Laravel 5.1 example of abstracting e-mail sending into its own dedicated class
<?php
namespace App\Extensions;
use Illuminate\Support\Facades\Mail;
class Postmaster {
/**
* Send an e-mail to a specific user. Pass in the User object,
* the name of the view, any data needed by the view, and the subject.
@gbrock
gbrock / 100% CSS custom checkboxes and radios.markdown
Last active September 20, 2015 06:13
100% CSS custom checkboxes and radios

100% CSS custom checkboxes and radios

The HTML structure is very specific. It allows for selecting the based on :checked state. Otherwise it's a fairly standard replacement, except it's very capable of being further styled while reacting to :active, :hover, etc.

Requires Bootstrap.

A Pen by Greg Brock on CodePen.

License.

@gbrock
gbrock / CommaSeparatedList.php
Created August 24, 2015 23:15
Joins an array of strings into a comma-separated string of readable output.
<?php
/**
* Joins an array of strings into a comma-separated string of readable output.
* Array ['John', 'Paul', 'George', 'Ringo'] becomes the string "John, Paul, George, and Ringo".
*
* @param array $items
* @param bool|true $oxfordComma
* @param string $conjunction
* @return string
@gbrock
gbrock / BladeTemplates.md
Last active April 13, 2022 09:11
Starter Blade templates

Starter Blade Templates

A simple starting point for use in Laravel 5.1. Based on Flexible master layout by Sercan Çakır.

Usage

  1. Download html5.blade.php and app.blade.php into your application's resources/views folder.
  2. In your app's custom views, extend app and hook into the yield points to flesh out your pages:
    {{--  myfile.blade.php  --}}

@extends('app', [

<ul class="selector">
<li data-name="red">Red</li>
<li data-name="blue">Blue</li>
</ul>
<ul class="people">
<li class="red">
Ann
<p>Lorem ipsum</p>
</li>
@gbrock
gbrock / parties_import.sql
Last active February 7, 2024 20:58
MySQL setup of a simple Party Model-based address book.
#
# Basic Party Model implementation for MySQL.
# - Parties are either People or Organizations.
# - Party names are tracked separately, including first_used and last_used as dates.
# - Parties can have e-mails addresses, phone numbers, and physical addresses.
# - Parties can have Relationships with one another.
#
#
# Party Model: http://www.tdan.com/view-articles/5014/
# SO answer that helped me get started: http://stackoverflow.com/questions/5466163/same-data-from-different-entities-in-database-best-practice-phone-numbers-ex/5471265#5471265
@gbrock
gbrock / includes.php
Created December 13, 2014 23:09
Includes controller for CodeIgniter (JS and CSS) w/ caching
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Includes for CodeIgniter
*
* @author gBrock
*
* Reads the passed URLs and renders the appropriate CSS and JS files from
* the application's /views/ folder. Hopefully self-explanatory.
*
@gbrock
gbrock / html5.php
Last active August 29, 2015 14:11
A basic HTML5 template for starting CodeIgniter projects
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* HTML5 Template for CodeIgniter
*
* @author gBrock
*
* Sets up a basic HTML5 document with some sensible setup,
* also allowing you to pass arrays of CSS and JS files as
* well as a view from your controller, which will be loaded