Skip to content

Instantly share code, notes, and snippets.

View adrianb93's full-sized avatar
🍝
Somebody touch'ah my spaghet!

Adrian Brown adrianb93

🍝
Somebody touch'ah my spaghet!
View GitHub Profile
@adrianb93
adrianb93 / 1. TestCase.php
Created January 17, 2022 01:04
How I add "private functions" to a pest test file.
<?php
#
# 1. Add the Macroable trait to your base test.
#
namespace Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Support\Traits\Macroable;
@adrianb93
adrianb93 / NativeDateCopyPaste.js
Created June 22, 2020 00:53
Google Chrome's date picker is pretty decent. This gives it the desired UX for copying and pasting in d/m/Y format.
// Google Chrome's date picker is pretty decent. This gives it the desired UX for copying and pasting.
export default function (Vue, options) {
Vue.mixin({
updated() {
Array.from(document.querySelectorAll('input')).filter(input => input.type === 'date').forEach(input => {
input.addEventListener('blur', onBlur);
input.addEventListener('copy', onCopy);
input.addEventListener('paste', onPaste);
});
}
@adrianb93
adrianb93 / tailwind.js
Created November 27, 2019 00:36
Tailwind CSS config with all of Material Design's shades, accents, and contrast colours.
module.exports = {
...
theme: {
...
colors: {
transparent: 'transparent',
black: '#000',
'black-contrast': '#fff',
white: '#fff',
'white-contrast': '#000',
<?php
if (! function_exists('json_validate')) {
/**
* Validate a json string.
*
* @param string $json
* @param boolean $throw
* @return boolean
* @throws \InvalidArgumentException
@adrianb93
adrianb93 / example.html
Created August 8, 2019 22:57
Highlighter CSS Styling
<p>
Did you know that <span class="highlight">all goats</span> like eating their own hats?
</p>

Keybase proof

I hereby claim:

  • I am adrianb93 on github.
  • I am adrianb93 (https://keybase.io/adrianb93) on keybase.
  • I have a public key ASCrdxglElAe3bq9XB6spNbM9hFT-0LrG3-Sft2zNzAZlwo

To claim this, I am signing this object:

@adrianb93
adrianb93 / 1 - helpers.php
Last active November 27, 2018 11:55
Pagination Query Pipeline
<?php
if (! function_exists('pipe')) {
function pipe($passable)
{
return app(\App\Pipeline::class)->send($passable);
}
}
if (! function_exists('paginate')) {
@adrianb93
adrianb93 / RegisterInModelEvents.php
Last active March 18, 2018 04:12
In-Model Event Observers for Laravel Models.
<?php
namespace App\Models\Traits;
use Illuminate\Support\Str;
trait RegisterInModelEvents
{
/**
* Register in-model event observers. This is to avoid creating a seperate
@adrianb93
adrianb93 / title_caps.php
Last active September 1, 2015 10:19
Title capitalisation function. Converts strings to title case.
<?php
// Title capitalisation function
function title_caps($string) {
// Needs work on recognising prepositions
$conjunctions = [ 'an', 'and', 'as', 'at', 'but', 'by', 'else', 'etc', 'for', 'from', 'if', 'in', 'into',
'is', 'nor', 'of', 'off', 'on', 'or', 'per', 'out', 'over', 'so', 'the', 'then', 'to',
'up', 'via', 'vs', 'when', 'with', 'yet' ];
// Uppercase first letter of all words
$string = preg_split('/(\W+)/', strtolower($string), -1, PREG_SPLIT_DELIM_CAPTURE);
@adrianb93
adrianb93 / parallax-bg-example.js
Created August 17, 2015 11:34
Simple parallax background effect.
// Simple parallax background effect by Adrian Brown
//
// Example HTML:
// <div class="parallax fullscreen"
// style="background-image: url(example.jpg);"
// data-img-width="1280"
// data-img-height="800"
// data-difference="100">
// </div>