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
martinbean / ExampleTest.php
Created Nov 16, 2017
TestResponse fromJsonString() macro
View ExampleTest.php
<?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 Oct 31, 2017
Install autoconf on macOS
View install-autoconf.sh
#!/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
@martinbean
martinbean / ForceSecure.php
Created Jun 28, 2017
Redirect non-secure requests on Heroku
View ForceSecure.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
class ForceSecure
{
/**
View BladeServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class BladeServiceProvider extends ServiceProvider
{
/**
@martinbean
martinbean / Article.php
Created Jan 3, 2017
Request-driven development
View Article.php
<?php
namespace App\News;
use Illuminate\Database\Eloquent\Model;
class Article extends Model
{
public function publish()
{
@martinbean
martinbean / BladeServiceProvider.php
Last active Oct 26, 2016
Laravel Blade directive for FontAwesome icons.
View BladeServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
class BladeServiceProvider extends ServiceProvider
{
/**
@martinbean
martinbean / ValidationServiceProvider.php
Last active Jul 23, 2018
Sum (of an array) validation in Laravel
View ValidationServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\ServiceProvider;
use InvalidArgumentException;
class ValidationServiceProvider extends ServiceProvider
{
@martinbean
martinbean / macros.php
Created Jul 30, 2016
Laravel Request startsWith and endsWith macros
View macros.php
<?php
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Str;
Request::macro('startsWith', function () {
return Str::startsWith(func_get_args());
});
Request::macro('endsWith', function () {
@martinbean
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
martinbean / VerifySnsMessageCameFromAmazon.php
Created Jul 8, 2016
Laravel 5.x middleware to verify an SNS request came from Amazon.
View VerifySnsMessageCameFromAmazon.php
<?php
namespace App\Http\Middleware;
use Aws\Sns\Message;
use Aws\Sns\MessageValidator;
use Closure;
class VerifySnsMessageCameFromAmazon
{
You can’t perform that action at this time.