Skip to content

Instantly share code, notes, and snippets.

View paulund's full-sized avatar

Paulund paulund

View GitHub Profile
@paulund
paulund / AuthTestsServiceProvider.php
Last active April 23, 2024 14:05
Laravel Make Auth Tests
<?php
namespace Dappa\AuthTests;
use Illuminate\Support\ServiceProvider;
/**
* Auth test service provider
*/
class AuthTestsServiceProvider extends ServiceProvider
@paulund
paulund / SmokeGuestTest.php
Last active April 12, 2024 15:56
Example of smoke testing guest URLs in a Laravel application
<?php
namespace Tests\Feature\SmokeTests;
use App\Models\Post;
use App\Models\Tutorial;
use Illuminate\Routing\Router;
use Tests\TestCase;
class SmokeGuestTest extends TestCase
@paulund
paulund / example-wp-list-table.php
Last active March 31, 2024 05:40
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@paulund
paulund / laravel-recaptcha-validation.php
Created April 3, 2018 19:14
A Laravel validation rule to verify recaptcha.
<?php
namespace App\Rules;
use GuzzleHttp\Client;
use Illuminate\Contracts\Validation\Rule;
class GoogleRecaptcha implements Rule
{
/**
@paulund
paulund / phpcs.xml
Created August 20, 2017 16:50
PHP PSR-2 CodeSniffer Config for Laravel
<?xml version="1.0"?>
<ruleset name="Laravel Standards">
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
@paulund
paulund / css-purge-webpack-config.js
Last active April 7, 2023 10:02
Using CSS Purge With Laravel Mix. Tutorial on how to use the following can be found https://paulund.co.uk/reduce-css-file-size-with-css-purge reduced a production ready CSS file from 179kb to 7.9kb.
mix.webpackConfig({
plugins: [
new purgeCss({
paths: glob.sync([
path.join(__dirname, 'resources/views/**/*.blade.php'),
path.join(__dirname, 'resources/assets/js/**/*.vue')
]),
extractors: [
{
extractor: class {
@paulund
paulund / AppServiceProvider.php
Last active March 16, 2023 18:10
Laravel Cache Auth::user(). Learn how to cache the logged in user at https://paulund.co.uk/laravel-cache-authuser
<?php
namespace App\Providers;
use App\Models\User;
use App\Observers\UserObserver;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
@paulund
paulund / google-webfont-async.php
Last active January 25, 2023 11:51
Javascript tag to load google web font async
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Roboto' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
@paulund
paulund / add-option-to-dropdown.js
Created June 25, 2013 18:50
Add and Remove Options in Select using jQuery
$("#selectBox").append('<option value="option6">option6</option>');
@paulund
paulund / wordpress-base-custom-data.php
Created September 24, 2013 16:27
A PHP class to handle CRUD functionality in WordPress default tables.
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean