Skip to content

Instantly share code, notes, and snippets.

View jeffsrepoaccount's full-sized avatar

Jeff Lambert jeffsrepoaccount

  • Durham, N.C.
View GitHub Profile
@jeffsrepoaccount
jeffsrepoaccount / TemplateProcessor.php
Last active March 15, 2022 06:28
PHPOffice/PHPWord - Injecting AltChunks in word document using placeholders in template file
<?php namespace My\Namespace;
use DOMDocument;
use Parsedown;
use PhpOffice\PhpWord\TemplateProcessor as PhpWordTemplateProcessor;
class TemplateProcessor extends PhpWordTemplateProcessor
{
/**
* Injects a markdown snippet as HTML into the word document.
@jeffsrepoaccount
jeffsrepoaccount / ClientCredentialsGrant.php
Created April 10, 2018 17:56
Sub-class of League\OAuth2\Server\Grant\AbstractGrant that overrides League\OAuth2\Server\Grant\ClientCredentialsGrant so that clients with an assigned user_id using this grant can have that claim inserted into the JWT.
<?php namespace My\Space;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Entities\UserEntityInterface;
use Laravel\Passport\ClientRepository;
use Laravel\Passport\Bridge\User;
use League\OAuth2\Server\RequestEvent;
use League\OAuth2\Server\Exception\OAuthServerException;
use League\OAuth2\Server\Grant\AbstractGrant;
@jeffsrepoaccount
jeffsrepoaccount / post-merge
Last active June 30, 2023 09:42
Git post merge hook for auto-tagging release/hotfix branches based off of branch name
#!/usr/bin/env bash
###############################################################################
#
# Automatically detects a merge on to master from a gitflow-style release
# branch, e.g. release-1.1.1-alpha. If the merged branch matches, the major,
# minor and patch versions are determined and a new release tag is created
# locally. If remote origin exists, this tag will automatically be pushed.
#
# In addition to creating a tag, the release branch will automatically be
# merged into the develop branch. If the branch has already been merged this
@jeffsrepoaccount
jeffsrepoaccount / ListItemByKeyTask.php
Created November 11, 2016 19:25
Retrieves an item from a phing delimited list property by index, or null if index is not set.
<?php
require_once 'phing/Task.php';
/**
* Retrieves and sets a property based on the requested key index
*/
class ListItemByKeyTask extends Task
{
@jeffsrepoaccount
jeffsrepoaccount / ForeachkeyTask.php
Created November 11, 2016 19:23
Allows phing tasks to iterate over a delimited list property and call a target for every item in the list, setting a property for each item as well as the current key index.
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
@jeffsrepoaccount
jeffsrepoaccount / angular.notifications.js
Last active April 10, 2018 18:02
Simple AngularJS service using HTML5 Notifications API
(function() {
'use strict';
var module = angular.module('jrl.notifications', []);
module.service('notify', [
'$q', '$window',
function($q, $window) {
var svc = {
send: function(){},
@jeffsrepoaccount
jeffsrepoaccount / jrl.websockets.js
Last active February 24, 2016 12:54
AngularJS WebSocket Service
(function() {
'use strict';
var app = angular.module('jrl.websockets', [
'jrl.utils'
]);
app.service('websocket', [
'$q', '$timeout', 'common',
function($q, $timeout, common) {
@jeffsrepoaccount
jeffsrepoaccount / Oauth2Middleware.php
Last active October 13, 2015 18:21
Middleware for integrating an OAuth2 Resource Server with an Authorization server built with lucadegasperi/oauth2-server-laravel on Laravel 5
<?php namespace App\Oauth2\Middleware;
use Closure;
use Illuminate\Http\Request;
use App\User;
use League\OAuth2\Server\Exception\AccessDeniedException;
use League\OAuth2\Server\Exception\InvalidRequestException;
use League\OAuth2\Server\ResourceServer;
use Exception;
@jeffsrepoaccount
jeffsrepoaccount / Oauth2ServiceProvider.php
Last active September 6, 2015 12:17
Service Provider for Resource Server
<?php namespace App\Oauth2;
use Illuminate\Support\ServiceProvider;
use League\OAuth2\Server\ResourceServer;
class Oauth2ServiceProvider extends ServiceProvider
{
/**
* Bootstrap application services.
*
@jeffsrepoaccount
jeffsrepoaccount / OauthAccess.php
Created September 6, 2015 12:13
Middleware for validating OAuth requests to the resource server
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use League\OAuth2\Server\Exception\AccessDeniedException;
use League\OAuth2\Server\Exception\InvalidRequestException;
use League\OAuth2\Server\ResourceServer;
use Exception;
class OauthAccess