Skip to content

Instantly share code, notes, and snippets.

View martinbean's full-sized avatar

Martin Bean martinbean

View GitHub Profile
@martinbean
martinbean / styles.css
Created March 2, 2019 19:38
End mark in HTML
p:last-of-type::after {
content: "\0020 \220E"
}
@martinbean
martinbean / component.js
Created November 10, 2018 19:37
Promise-based Vue.js confirmation dialog mixin
import confirm from './confirm';
export default {
mixins: [
confirm
],
methods: {
onDelete() {
this.confirm('Are you sure you wish to delete this item?').then(() => {
// Delete item
@martinbean
martinbean / webpack.mix.js
Created May 17, 2018 14:17
Vendor library extraction in Laravel Mix
let mix = require('laravel-mix');
mix.sass('resources/assets/sass/app.scss', 'public/css')
.js('resources/assets/js/app.js', 'public/js')
.js('resources/assets/js/channel-admin.js', 'public/js')
.js('resources/assets/js/video.js', 'public/js')
.extract(['jquery', 'bootstrap'])
.options({ processCssUrls: false })
.sourceMaps();
vendor/bin/phpunit --printer="PHPUnit\TextUI\ResultPrinter"
@martinbean
martinbean / ArticleController.php
Created March 26, 2018 13:35
Using Laravel’s Responsable interface to create view models
<?php
namespace App\Http\Controllers;
use App\Article;
use App\Http\Views\ArticleIndex;
class ArticleController extends Controller
{
public function index()
@martinbean
martinbean / AppServiceProvider.php
Last active March 1, 2018 11:06
Disable Bugsnag in certain environments
<?php
namespace App\Providers;
use Bugsnag\BugsnagLaravel\Facades\Bugsnag;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
@martinbean
martinbean / test.php
Created February 6, 2018 18:34
Throw a validation exception with a plain array of errors
<?php
use Illuminate\Validation\ValidationException;
if ($coupon->cannotBeRedeemed()) {
throw ValidationException::withMessages([
'coupon' => [
'The coupon code is invalid.',
],
]);
@martinbean
martinbean / confirm.js
Created November 27, 2017 23:22
Vue.js confirm mixin
module.exports = {
methods: {
confirm(message, callback) {
if (window.confirm(message)) {
callback();
}
}
}
};
@martinbean
martinbean / ExampleTest.php
Created November 16, 2017 13:55
TestResponse fromJsonString() macro
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\TestResponse;
use Tests\TestCase;
class ExampleTest extends TestCase
{
public function testExample()
@martinbean
martinbean / install-autoconf.sh
Created October 31, 2017 10:30
Install autoconf on macOS
#!/bin/sh
cd ~/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-latest
./configure --prefix=/usr/local
make
sudo make install