Skip to content

Instantly share code, notes, and snippets.

View paulredmond's full-sized avatar
🏴‍☠️

Paul Redmond paulredmond

🏴‍☠️
View GitHub Profile
@paulredmond
paulredmond / Dockerfile
Last active October 5, 2017 17:36
A simple Dockerfile for Apache + PHP
FROM php:7.1.8-apache
MAINTAINER Paul Redmond
COPY . /srv/app
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN chown -R www-data:www-data /srv/app \
&& a2enmod rewrite
@paulredmond
paulredmond / BladeExtension.php
Last active July 12, 2017 18:15
Example Blade Extension class to group Blade conditionals and directives...
<?php
/**
* This interface would be provided by the framework and properly namespaced
* This is just an example of what an interface might be like...
*/
interface BladeExtension
{
public function getDirectives();
@paulredmond
paulredmond / app.js
Last active September 26, 2020 15:03
Example Vue.js mixins for time
import dateMixin from './mixins/date';
// Globally
Vue.mixin(dateMixin);
@paulredmond
paulredmond / Entry.java
Created June 2, 2017 17:31
Java equivalent example (I think) of the PHP Generics RFC Example
public class Entry<KeyType, ValueType>
{
protected KeyType key;
protected ValueType value;
public Entry(KeyType key, ValueType value) {
key = key;
value = value;
}
@paulredmond
paulredmond / ValidateMailgunWebhook.php
Created April 24, 2017 21:55
Laravel Middleware to Validate a signed Mailgun webhook
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
/**
* Validate Mailgun Webhooks
* @see https://documentation.mailgun.com/user_manual.html#securing-webhooks
@paulredmond
paulredmond / background-process-without-overlap.txt
Last active April 9, 2017 03:49
Documenting different scenarios the Laravel scheduler runs in docker as a bash entrypoint - reference repo https://github.com/bitpressio/laravel-docker
# when you run a 1 minute schedule command that takes more than 1 minute using `withoutOverlapping()`
# Running the scheduler in the background so sleep hits right away...
# # Run the scheduler
# while [ true ]
# do
# php artisan schedule:run --verbose --no-interaction &
# sleep 60
# done
@paulredmond
paulredmond / tinker
Created April 7, 2017 06:07
Artisan Tinker Example Output
>>> $client = app('example.client');
=> GuzzleHttp\Client {#666}
>>> json_decode($client->get('http://guzzle-6-demo.app/example')->getBody()->__toString(), true);
=> [
"authorization" => [
"Signature keyId="key",algorithm="hmac-sha1",signature="HjQHCSOYw9PA4NKK70Y0GX7es3c%3D"",
],
"date" => [
"Fri, 07 Apr 2017 05:58:28 UTC",
],
@paulredmond
paulredmond / web.php
Last active April 7, 2017 06:18
Example Laravel Route that Returns Request Headers for Demonstration Purposes
<?php
Route::get('/example', function () {
return request()->headers->all();
});
@paulredmond
paulredmond / AppServiceProvider.php
Last active April 7, 2017 06:17
Example Laravel AppServiceProvider class that consumes tagged Guzzle 6 middleware
<?php
namespace App\Providers;
use App\HMACRequestHandler;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use Illuminate\Support\ServiceProvider;
@paulredmond
paulredmond / HMACRequestHandler.php
Created April 7, 2017 05:43
Example Guzzle HTTP Middleware for a simple HMAC Authorization
<?php
namespace App;
use Carbon\Carbon;
use Psr\Http\Message\RequestInterface;
class HMACRequestHandler
{
private $key;