Skip to content

Instantly share code, notes, and snippets.

Martin Bean martinbean

Block or report user

Report or block martinbean

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
martinbean / convert-seconds.js
Created Jul 13, 2016
Convert seconds to HH:MM:SS format in JavaScript.
View convert-seconds.js
new Date(seconds * 1000).toISOString().substr(11, 8)
martinbean / pre-commit
Last active May 29, 2019
Pre-commit hook to detect if any .php files contain dd()
View pre-commit
$files = shell_exec('git diff-index --name-only --cached --diff-filter=ACMR HEAD | grep "\.php$"');
$files = explode("\n", trim($files));
$exitCode = 0;
foreach ($files as $file) {
if (empty($file)) {
martinbean / CartPage.php
Created Mar 15, 2019
Laravel Dusk example test
View CartPage.php
namespace Tests\Browser\Pages;
use Laravel\Dusk\Browser;
class CartPage extends Page
* {@inheritDoc}
martinbean / LogNameHandler.php
Last active Mar 15, 2019
Mapping jobs to handler classes in Lumen
View LogNameHandler.php
namespace App\Handlers\Jobs;
use App\Jobs\LogNameJob;
use Illuminate\Support\Facades\Log;
class LogNameHandler
public function __construct()
View styles.css
p:last-of-type::after {
content: "\0020 \220E"
martinbean / component.js
Created Nov 10, 2018
Promise-based Vue.js confirmation dialog mixin
View component.js
import confirm from './confirm';
export default {
mixins: [
methods: {
onDelete() {
this.confirm('Are you sure you wish to delete this item?').then(() => {
// Delete item
martinbean / ValidationServiceProvider.php
Last active Jul 23, 2018
Sum (of an array) validation in Laravel
View ValidationServiceProvider.php
namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
class ValidationServiceProvider extends ServiceProvider
martinbean / Adapter.php
Last active Jul 9, 2018
Basic ORM sketch that uses value objects, data mappers that persists data to a data source, and adapters for data sources.
View Adapter.php
abstract class Adapter
protected $config;
protected $connection;
public function __construct($config)
$this->config = $config;
martinbean / webpack.mix.js
Created May 17, 2018
Vendor library extraction in Laravel Mix
View webpack.mix.js
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 })
martinbean / plugin.ajax_submit.js
Created Apr 1, 2015
jQuery AJAX submit plugin
View plugin.ajax_submit.js
// 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"]');
You can’t perform that action at this time.