Skip to content

Instantly share code, notes, and snippets.

View martinbean's full-sized avatar

Martin Bean martinbean

View GitHub Profile
@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 / AppServiceProvider.php
Created June 28, 2021 10:53
Caching settings repository
<?php
namespace App\Providers;
use App\Repositories\SettingsRepository;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function register()
### Keybase proof
I hereby claim:
* I am martinbean on github.
* I am martinbean (https://keybase.io/martinbean) on keybase.
* I have a public key ASB2_ZA3DkCT9MjQuO8huSLkj8dOOxr8Cyy_bMrG3HAVJQo
To claim this, I am signing this object:
@martinbean
martinbean / LogNameHandler.php
Last active March 15, 2019 14:42
Mapping jobs to handler classes in Lumen
<?php
namespace App\Handlers\Jobs;
use App\Jobs\LogNameJob;
use Illuminate\Support\Facades\Log;
class LogNameHandler
{
public function __construct()
@martinbean
martinbean / styles.css
Created March 2, 2019 19:38
End mark in HTML
p:last-of-type::after {
content: "\0020 \220E"
}
@martinbean
martinbean / ValidationServiceProvider.php
Last active July 23, 2018 14:23
Sum (of an array) validation in Laravel
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
class ValidationServiceProvider extends ServiceProvider
{
@martinbean
martinbean / Adapter.php
Last active July 9, 2018 08:32
Basic ORM sketch that uses value objects, data mappers that persists data to a data source, and adapters for data sources.
<?php
abstract class Adapter
{
protected $config;
protected $connection;
public function __construct($config)
{
$this->config = $config;
@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();
@martinbean
martinbean / plugin.ajax_submit.js
Created April 1, 2015 11:41
jQuery AJAX submit plugin
// Submit a form via AJAX and return the request object
$.fn.ajaxSubmit = function (options) {
var settings = $.extend({
submittingText: 'Submitting...'
}, options);
var form = $(this);
var url = form.attr('action');
var data = form.serialize();
var type = form.attr('method');
var submitButton = form.find('[type="submit"]');
vendor/bin/phpunit --printer="PHPUnit\TextUI\ResultPrinter"